summaryrefslogtreecommitdiff
path: root/oox/source/drawingml/chart
diff options
context:
space:
mode:
authorDaniel Rentz <daniel.rentz@sun.com>2009-12-02 16:32:36 +0100
committerDaniel Rentz <daniel.rentz@sun.com>2009-12-02 16:32:36 +0100
commit0cd4e15a401ccefb853cdce12a0e80ef94bb674b (patch)
tree41f554f5926f6ee6dfa114b73e0e3bef689b39b1 /oox/source/drawingml/chart
parente9e59fc57083f5056a64d3c6c33867b6466af3c8 (diff)
chartpositioning: #i86609# set manual position for legend, title, axis titles
Diffstat (limited to 'oox/source/drawingml/chart')
-rw-r--r--oox/source/drawingml/chart/axisconverter.cxx3
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx19
-rw-r--r--oox/source/drawingml/chart/titleconverter.cxx84
3 files changed, 62 insertions, 44 deletions
diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx
index 1fd8dbd61f31..36a18117fd04 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -305,7 +305,8 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo
// axis title ---------------------------------------------------------
- if( mrModel.mxTitle.is() )
+ // in radar charts, title objects may exist, but are not shown
+ if( mrModel.mxTitle.is() && (rTypeGroup.getTypeInfo().meTypeCategory != TYPECATEGORY_RADAR) )
{
Reference< XTitled > xTitled( xAxis, UNO_QUERY_THROW );
TitleConverter aTitleConv( *this, *mrModel.mxTitle );
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index 369b71fc6b48..22b359ab0866 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -35,6 +35,8 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include "properties.hxx"
#include "oox/core/xmlfilterbase.hxx"
#include "oox/drawingml/theme.hxx"
@@ -48,6 +50,7 @@ using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::frame::XModel;
using ::com::sun::star::awt::Rectangle;
using ::com::sun::star::awt::Size;
+using ::com::sun::star::chart2::RelativePosition;
using ::com::sun::star::chart2::XChartDocument;
using ::oox::core::XmlFilterBase;
@@ -224,7 +227,7 @@ LayoutConverter::~LayoutConverter()
{
}
-bool LayoutConverter::calcAbsRectangle( Rectangle& orRect )
+bool LayoutConverter::calcAbsRectangle( Rectangle& orRect ) const
{
if( !mrModel.mbAutoLayout )
{
@@ -241,6 +244,20 @@ bool LayoutConverter::calcAbsRectangle( Rectangle& orRect )
return false;
}
+bool LayoutConverter::convertFromModel( PropertySet& rPropSet )
+{
+ if( !mrModel.mbAutoLayout && (mrModel.mfX >= 0.0) && (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;
+ rPropSet.setProperty( PROP_RelativePosition, aPos );
+ return true;
+ }
+ return false;
+}
+
// ============================================================================
} // namespace chart
diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx
index 4d7d1d29f423..fdb8cdc7793e 100644
--- a/oox/source/drawingml/chart/titleconverter.cxx
+++ b/oox/source/drawingml/chart/titleconverter.cxx
@@ -32,7 +32,6 @@
#include "oox/drawingml/chart/titleconverter.hxx"
#include <com/sun/star/chart2/LegendExpansion.hpp>
#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/chart2/XFormattedString.hpp>
#include <com/sun/star/chart2/XLegend.hpp>
@@ -181,6 +180,10 @@ void TitleConverter::convertFromModel( const Reference< XTitled >& rxTitled, con
OSL_ENSURE( !mrModel.mxTextProp || !rText.mxTextBody, "TitleConverter::convertFromModel - multiple text properties" );
ModelRef< TextBody > xTextProp = mrModel.mxTextProp.is() ? mrModel.mxTextProp : rText.mxTextBody;
getFormatter().convertTextRotation( aPropSet, xTextProp, true );
+
+ // frame position
+ LayoutConverter aLayoutConv( *this, mrModel.mxLayout.getOrCreate() );
+ aLayoutConv.convertFromModel( aPropSet );
}
catch( Exception& )
{
@@ -211,59 +214,56 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram )
PropertySet aPropSet( xLegend );
aPropSet.setProperty( PROP_Show, true );
- // legend position and expansion
+ // legend formatting
+ getFormatter().convertFormatting( aPropSet, mrModel.mxShapeProp, mrModel.mxTextProp, OBJECTTYPE_LEGEND );
+
+ // predefined legend position and expansion
+ cssc2::LegendPosition eLegendPos = cssc2::LegendPosition_CUSTOM;
+ cssc2::LegendExpansion eLegendExpand = cssc2::LegendExpansion_HIGH;
+ switch( mrModel.mnPosition )
+ {
+ case XML_l:
+ eLegendPos = cssc2::LegendPosition_LINE_START;
+ eLegendExpand = cssc2::LegendExpansion_HIGH;
+ break;
+ case XML_r:
+ eLegendPos = cssc2::LegendPosition_LINE_END;
+ eLegendExpand = cssc2::LegendExpansion_HIGH;
+ break;
+ case XML_t:
+ eLegendPos = cssc2::LegendPosition_PAGE_START;
+ eLegendExpand = cssc2::LegendExpansion_WIDE;
+ break;
+ case XML_b:
+ eLegendPos = cssc2::LegendPosition_PAGE_END;
+ eLegendExpand = cssc2::LegendExpansion_WIDE;
+ break;
+ case XML_tr:
+ eLegendPos = cssc2::LegendPosition_LINE_END; // top-right not supported
+ eLegendExpand = cssc2::LegendExpansion_HIGH;
+ break;
+ }
+
+ // manual positioning
LayoutModel& rLayout = mrModel.mxLayout.getOrCreate();
LayoutConverter aLayoutConv( *this, rLayout );
+ aLayoutConv.convertFromModel( aPropSet );
Rectangle aLegendRect;
- bool bManualLayout = aLayoutConv.calcAbsRectangle( aLegendRect );
- if( bManualLayout )
+ if( aLayoutConv.calcAbsRectangle( aLegendRect ) )
{
- // relative position
- cssc2::RelativePosition aRelPos;
- aRelPos.Primary = getLimitedValue< double, double >( rLayout.mfX, 0.0, 1.0 );
- aRelPos.Secondary = getLimitedValue< double, double >( rLayout.mfY, 0.0, 1.0 );
- aRelPos.Anchor = ::com::sun::star::drawing::Alignment_TOP_LEFT;
- aPropSet.setProperty( PROP_AnchorPosition, cssc2::LegendPosition_CUSTOM );
- aPropSet.setProperty( PROP_RelativePosition, aRelPos );
-
// #i71697# it is not possible to set the size directly, do some magic here
- cssc2::LegendExpansion eLegendExpand = cssc2::LegendExpansion_BALANCED;
double fRatio = static_cast< double >( aLegendRect.Width ) / aLegendRect.Height;
if( fRatio > 1.5 )
eLegendExpand = cssc2::LegendExpansion_WIDE;
else if( fRatio < 0.75 )
eLegendExpand = cssc2::LegendExpansion_HIGH;
- aPropSet.setProperty( PROP_Expansion, eLegendExpand );
- }
- else // automatic layout
- {
- cssc2::LegendPosition eLegendPos = cssc2::LegendPosition_LINE_END;
- cssc2::LegendExpansion eLegendExpand = cssc2::LegendExpansion_HIGH;
- switch( mrModel.mnPosition )
- {
- case XML_l:
- eLegendPos = cssc2::LegendPosition_LINE_START;
- eLegendExpand = cssc2::LegendExpansion_HIGH;
- break;
- case XML_r:
- eLegendPos = cssc2::LegendPosition_LINE_END;
- eLegendExpand = cssc2::LegendExpansion_HIGH;
- break;
- case XML_t:
- eLegendPos = cssc2::LegendPosition_PAGE_START;
- eLegendExpand = cssc2::LegendExpansion_WIDE;
- break;
- case XML_b:
- eLegendPos = cssc2::LegendPosition_PAGE_END;
- eLegendExpand = cssc2::LegendExpansion_WIDE;
- break;
- }
- aPropSet.setProperty( PROP_AnchorPosition, eLegendPos );
- aPropSet.setProperty( PROP_Expansion, eLegendExpand );
+ else
+ eLegendExpand = cssc2::LegendExpansion_BALANCED;
}
- // legend formatting
- getFormatter().convertFormatting( aPropSet, mrModel.mxShapeProp, mrModel.mxTextProp, OBJECTTYPE_LEGEND );
+ // set position and expansion properties
+ aPropSet.setProperty( PROP_AnchorPosition, eLegendPos );
+ aPropSet.setProperty( PROP_Expansion, eLegendExpand );
}
catch( Exception& )
{