/** A helper structure to store all data related to title objects. Needed for theconversionofmanualtitlepositionsthatneedstheoldChart1API.
*/ struct TitleLayoutInfo
{ typedef Reference< XShape > (*GetShapeFunc)( const Reference< cssc::XChartDocument >& );
Reference< XTitle > mxTitle; /// The API title object.
ModelRef< LayoutModel > mxLayout; /// The layout model, if existing.
GetShapeFunc mpGetShape; /// Helper function to receive the title shape.
try
{ // try to get the title shape
Reference< XShape > xTitleShape = mpGetShape( rxChart1Doc ); if (!xTitleShape)
{
SAL_WARN("oox", "failed to get a TitleShape"); return;
} // get title rotation angle, needed for correction of position of top-left edge double fAngle = 0.0;
PropertySet aTitleProp( mxTitle );
aTitleProp.getProperty( fAngle, PROP_TextRotation ); // convert the position
LayoutModel& rLayout = mxLayout.getOrCreate();
LayoutConverter aLayoutConv( rRoot, rLayout );
aLayoutConv.convertFromModel( xTitleShape, fAngle );
} catch( Exception& )
{
}
}
/* The following local functions implement getting the XShape interface of all supportedtitleobjects(chartandaxes).Thisneedssomeeffortduetothe
design of the old Chart1 API used to access these objects. */
/** A code fragment that returns a shape object from the passed shape supplier
using the specified interface function. Checks a boolean property first. */ #define OOX_FRAGMENT_GETTITLESHAPE( shape_supplier, supplier_func, property_name ) \
PropertySet aPropSet( shape_supplier ); \ if( shape_supplier.is() && aPropSet.getBoolProperty( PROP_##property_name ) ) \ return shape_supplier->supplier_func(); \ return Reference< XShape >(); \
/** Implements a function returning the drawing shape of an axis title, if
existing, using the specified API interface and its function. */ #define OOX_DEFINEFUNC_GETAXISTITLESHAPE( func_name, interface_type, supplier_func, property_name ) \
Reference< XShape > func_name( const Reference< cssc::XChartDocument >& rxChart1Doc ) \
{ \
Reference< cssc::interface_type > xAxisSupp( rxChart1Doc->getDiagram(), UNO_QUERY ); \
OOX_FRAGMENT_GETTITLESHAPE( xAxisSupp, supplier_func, property_name ) \
}
/** Returns the drawing shape of the main title, if existing. */
Reference< XShape > lclGetMainTitleShape( const Reference< cssc::XChartDocument >& rxChart1Doc )
{
OOX_FRAGMENT_GETTITLESHAPE( rxChart1Doc, getTitle, HasMainTitle )
}
/** Returns a position value in the chart area in 1/100 mm. */
sal_Int32 lclCalcPosition( sal_Int32 nChartSize, double fPos, sal_Int32 nPosMode )
{ switch( nPosMode )
{ case XML_edge: // absolute start position as factor of chart size return getLimitedValue< sal_Int32, double >( nChartSize * fPos + 0.5, 0, nChartSize ); case XML_factor: // position relative to object default position
OSL_FAIL( "lclCalcPosition - relative positioning not supported" ); return -1;
};
/** Returns a size value in the chart area in 1/100 mm. */
sal_Int32 lclCalcSize( sal_Int32 nPos, sal_Int32 nChartSize, double fSize, sal_Int32 nSizeMode )
{
sal_Int32 nValue = getLimitedValue< sal_Int32, double >( nChartSize * fSize + 0.5, 0, nChartSize ); switch( nSizeMode )
{ case XML_factor: // passed value is width/height return nValue; case XML_edge: // passed value is right/bottom position return nValue - nPos + 1;
};
bool bPropSet = false; // the call to XShape.getSize() may recalc the chart view
awt::Size aShapeSize = rxShape->getSize(); // rotated shapes need special handling... if( aShapeSize.Height > 0 || aShapeSize.Width > 0 )
{ double fSin = fabs(sin(basegfx::deg2rad(fRotationAngle))); // add part of height to X direction, if title is rotated down if( fRotationAngle > 180.0 )
aShapePos.X += static_cast<sal_Int32>(fSin * aShapeSize.Height + 0.5); // add part of width to Y direction, if title is rotated up elseif( fRotationAngle > 0.0 )
aShapePos.Y += static_cast<sal_Int32>(fSin * aShapeSize.Width + 0.5);
} elseif( fRotationAngle == 90.0 || fRotationAngle == 270.0 )
{
PropertySet aShapeProp( rxShape );
RelativePosition aPos(
getLimitedValue< double, double >(mrModel.mfX, 0.0, 1.0),
getLimitedValue< double, double >(mrModel.mfY, 0.0, 1.0),
fRotationAngle == 90.0 ? Alignment_TOP_RIGHT : Alignment_BOTTOM_LEFT ); // set the resulting position at the shape if( aShapeProp.setProperty(PROP_RelativePosition, aPos) )
bPropSet = true;
} // set the resulting position at the shape if( !bPropSet )
rxShape->setPosition( aShapePos );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.