summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/chart/converterbase.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source/drawingml/chart/converterbase.cxx')
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx43
1 files changed, 34 insertions, 9 deletions
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index df4d40e952ac..7e601ff016af 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/frame/XModel.hpp>
@@ -78,8 +79,7 @@ struct TitleLayoutInfo
{
typedef Reference< XShape > (*GetShapeFunc)( const Reference< cssc::XChartDocument >& );
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
- mxTitle; /// The API title object.
+ Reference< XTitle > mxTitle; /// The API title object.
ModelRef< LayoutModel > mxLayout; /// The layout model, if existing.
GetShapeFunc mpGetShape; /// Helper function to receive the title shape.
@@ -323,9 +323,9 @@ sal_Int32 lclCalcSize( sal_Int32 nPos, sal_Int32 nChartSize, double fSize, sal_I
sal_Int32 nValue = getLimitedValue< sal_Int32, double >( nChartSize * fSize + 0.5, 0, nChartSize );
switch( nSizeMode )
{
- case XML_factor: // size as factor of chart size
+ case XML_factor: // passed value is width/height
return nValue;
- case XML_edge: // absolute end position as factor of chart size
+ case XML_edge: // passed value is right/bottom position
return nValue - nPos + 1;
};
@@ -333,6 +333,23 @@ sal_Int32 lclCalcSize( sal_Int32 nPos, sal_Int32 nChartSize, double fSize, sal_I
return -1;
}
+/** Returns a relative size value in the chart area. */
+double lclCalcRelSize( double fPos, double fSize, sal_Int32 nSizeMode )
+{
+ switch( nSizeMode )
+ {
+ case XML_factor: // passed value is width/height
+ break;
+ case XML_edge: // passed value is right/bottom position
+ fSize -= fPos;
+ break;
+ default:
+ OSL_ENSURE( false, "lclCalcRelSize - unknown size mode" );
+ fSize = 0.0;
+ };
+ return getLimitedValue< double, double >( fSize, 0.0, 1.0 - fPos );
+}
+
} // namespace
// ----------------------------------------------------------------------------
@@ -369,12 +386,20 @@ bool LayoutConverter::convertFromModel( PropertySet& rPropSet )
(mrModel.mnXMode == XML_edge) && (mrModel.mfX >= 0.0) &&
(mrModel.mnYMode == XML_edge) && (mrModel.mfY >= 0.0) )
{
- RelativePosition aPos;
- aPos.Primary = getLimitedValue< double, double >( mrModel.mfX, 0.0, 1.0 );
- aPos.Secondary = getLimitedValue< double, double >( mrModel.mfY, 0.0, 1.0 );
- aPos.Anchor = ::com::sun::star::drawing::Alignment_TOP_LEFT;
+ RelativePosition aPos(
+ getLimitedValue< double, double >( mrModel.mfX, 0.0, 1.0 ),
+ getLimitedValue< double, double >( mrModel.mfY, 0.0, 1.0 ),
+ Alignment_TOP_LEFT );
rPropSet.setProperty( PROP_RelativePosition, aPos );
- return true;
+
+ RelativeSize aSize(
+ lclCalcRelSize( aPos.Primary, mrModel.mfW, mrModel.mnWMode ),
+ lclCalcRelSize( aPos.Secondary, mrModel.mfH, mrModel.mnHMode ) );
+ if( (aSize.Primary > 0.0) && (aSize.Secondary > 0.0) )
+ {
+ rPropSet.setProperty( PROP_RelativeSize, aSize );
+ return true;
+ }
}
return false;
}