diff options
author | Björn Milcke <bm@openoffice.org> | 2001-03-27 12:24:46 +0000 |
---|---|---|
committer | Björn Milcke <bm@openoffice.org> | 2001-03-27 12:24:46 +0000 |
commit | 631e07419aa762705497ecd223b23126a194ac3e (patch) | |
tree | 28ad48b6de4c51c1d9d2ee8fd5f053614df598a5 /xmloff/source | |
parent | 933e082de2a5b07be56c5573d6a5f0845b215dea (diff) |
#84521# set position of titles and legend at the end, when object sizes are final
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.cxx | 109 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLChartContext.hxx | 18 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLPlotAreaContext.cxx | 44 | ||||
-rw-r--r-- | xmloff/source/chart/transporttypes.hxx | 5 |
4 files changed, 118 insertions, 58 deletions
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 9b22495e4c5f..36a56c6353e6 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLChartContext.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: bm $ $Date: 2001-03-26 15:37:47 $ + * last change: $Author: bm $ $Date: 2001-03-27 13:22:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,6 +118,10 @@ using namespace com::sun::star; +#define SCH_BUILDCHART(xDoc) if( xDoc->hasControllersLocked() ) {\ + xDoc->unlockControllers();\ + xDoc->lockControllers(); } + enum SchXMLChartType { XML_CHART_CLASS_LINE, @@ -372,6 +376,18 @@ void SchXMLChartContext::EndElement() { DBG_ERROR( "Property String for Title not available" ); } + uno::Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); + if( xShape.is()) + { + // perform build chart with new title string + // so that setting the position works correctly + if( xDoc.is()) + { + xDoc->unlockControllers(); + xDoc->lockControllers(); + } + xShape->setPosition( maMainTitlePos ); + } } } if( maSubTitle.getLength()) @@ -389,6 +405,18 @@ void SchXMLChartContext::EndElement() { DBG_ERROR( "Property String for Title not available" ); } + uno::Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); + if( xShape.is()) + { + // perform build chart with new title string + // so that setting the position works correctly + if( xDoc.is()) + { + xDoc->unlockControllers(); + xDoc->lockControllers(); + } + xShape->setPosition( maSubTitlePos ); + } } } } @@ -477,6 +505,14 @@ void SchXMLChartContext::EndElement() uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); if( xModel.is()) xModel->unlockControllers(); + + // set absolute legend position after (BuildChart!) + if( maLegendPos.X != -1 ) + { + uno::Reference< drawing::XShape > xLegendShape( xDoc->getLegend(), uno::UNO_QUERY ); + if( xLegendShape.is()) + xLegendShape->setPosition( maLegendPos ); + } } SvXMLImportContext* SchXMLChartContext::CreateChildContext( @@ -501,20 +537,15 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext( uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY ); if( xProp.is()) { - sal_Bool bHasControllersLocked = xDoc->hasControllersLocked(); - if( bHasControllersLocked ) - xDoc->unlockControllers(); - uno::Any aTrueBool; aTrueBool <<= (sal_Bool)(sal_True); xProp->setPropertyValue( rtl::OUString::createFromAscii( "HasMainTitle" ), aTrueBool ); - if( bHasControllersLocked ) - xDoc->lockControllers(); + SCH_BUILDCHART( xDoc ); } uno::Reference< drawing::XShape > xTitleShape( xDoc->getTitle(), uno::UNO_QUERY ); pContext = new SchXMLTitleContext( mrImportHelper, GetImport(), - rLocalName, maMainTitle, xTitleShape ); + rLocalName, maMainTitle, xTitleShape, maMainTitlePos ); } break; @@ -524,25 +555,19 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext( uno::Reference< beans::XPropertySet > xProp( xDoc, uno::UNO_QUERY ); if( xProp.is()) { - sal_Bool bHasControllersLocked = xDoc->hasControllersLocked(); - if( bHasControllersLocked ) - xDoc->unlockControllers(); - uno::Any aTrueBool; aTrueBool <<= (sal_Bool)(sal_True); xProp->setPropertyValue( rtl::OUString::createFromAscii( "HasSubTitle" ), aTrueBool ); - - if( bHasControllersLocked ) - xDoc->lockControllers(); + SCH_BUILDCHART( xDoc ); } uno::Reference< drawing::XShape > xTitleShape( xDoc->getSubTitle(), uno::UNO_QUERY ); pContext = new SchXMLTitleContext( mrImportHelper, GetImport(), - rLocalName, maSubTitle, xTitleShape ); + rLocalName, maSubTitle, xTitleShape, maSubTitlePos ); } break; case XML_TOK_CHART_LEGEND: - pContext = new SchXMLLegendContext( mrImportHelper, GetImport(), rLocalName ); + pContext = new SchXMLLegendContext( mrImportHelper, GetImport(), rLocalName, maLegendPos ); break; case XML_TOK_CHART_TABLE: @@ -562,12 +587,14 @@ SvXMLImportContext* SchXMLChartContext::CreateChildContext( SchXMLTitleContext::SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const rtl::OUString& rLocalName, - rtl::OUString& aTitle, - uno::Reference< drawing::XShape >& xTitleShape ) : + rtl::OUString& rTitle, + uno::Reference< drawing::XShape >& xTitleShape, + awt::Point& rPosition ) : SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), mrImportHelper( rImpHelper ), - maTitle( aTitle ), - mxTitleShape( xTitleShape ) + mrTitle( rTitle ), + mxTitleShape( xTitleShape ), + mrPosition( rPosition ) { } @@ -578,12 +605,9 @@ void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttribut { sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; rtl::OUString aValue; - rtl::OUString aServiceName; - rtl::OUString sAutoStyleName; - awt::Point aPosition; if( mxTitleShape.is()) - aPosition = mxTitleShape->getPosition(); + mrPosition = mxTitleShape->getPosition(); for( sal_Int16 i = 0; i < nAttrCount; i++ ) { @@ -595,14 +619,14 @@ void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttribut if( nPrefix == XML_NAMESPACE_SVG ) { if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_x ))) - GetImport().GetMM100UnitConverter().convertMeasure( aPosition.X, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( mrPosition.X, aValue ); else if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_y ))) - GetImport().GetMM100UnitConverter().convertMeasure( aPosition.Y, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( mrPosition.Y, aValue ); } else if( nPrefix == XML_NAMESPACE_CHART ) { if( aLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_style_name ))) - sAutoStyleName = aValue; + msAutoStyleName = aValue; } } @@ -615,13 +639,12 @@ void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttribut if( pStylesCtxt ) { const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - mrImportHelper.GetChartFamilyID(), sAutoStyleName ); + mrImportHelper.GetChartFamilyID(), msAutoStyleName ); if( pStyle && pStyle->ISA( XMLPropStyleContext )) (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp ); } } - mxTitleShape->setPosition( aPosition ); } } @@ -635,7 +658,7 @@ SvXMLImportContext* SchXMLTitleContext::CreateChildContext( if( nPrefix == XML_NAMESPACE_TEXT && rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_p ))) { - pContext = new SchXMLParagraphContext( GetImport(), rLocalName, maTitle ); + pContext = new SchXMLParagraphContext( GetImport(), rLocalName, mrTitle ); } else pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); @@ -646,9 +669,11 @@ SvXMLImportContext* SchXMLTitleContext::CreateChildContext( // ---------------------------------------- SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName ) : + SvXMLImport& rImport, const rtl::OUString& rLocalName, + com::sun::star::awt::Point& rPosition ) : SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ), - mrImportHelper( rImpHelper ) + mrImportHelper( rImpHelper ), + mrPosition( rPosition ) { } @@ -666,14 +691,8 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu aTrueBool <<= (sal_Bool)(sal_True); try { - sal_Bool bHasControllersLocked = xDoc->hasControllersLocked(); - if( bHasControllersLocked ) - xDoc->unlockControllers(); - xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "HasLegend" ), aTrueBool ); - - if( bHasControllersLocked ) - xDoc->lockControllers(); + SCH_BUILDCHART( xDoc ); } catch( beans::UnknownPropertyException ) { @@ -727,10 +746,10 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu break; case XML_TOK_LEGEND_X: - GetImport().GetMM100UnitConverter().convertMeasure( aPosition.X, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( mrPosition.X, aValue ); break; case XML_TOK_LEGEND_Y: - GetImport().GetMM100UnitConverter().convertMeasure( aPosition.Y, aValue ); + GetImport().GetMM100UnitConverter().convertMeasure( mrPosition.Y, aValue ); break; case XML_TOK_LEGEND_STYLE_NAME: sAutoStyleName = aValue; @@ -751,10 +770,6 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp ); } } - - // set absolute position - if( xLegendShape.is()) - xLegendShape->setPosition( aPosition ); } SchXMLLegendContext::~SchXMLLegendContext() diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx index dd5560525e14..389b3b5c8054 100644 --- a/xmloff/source/chart/SchXMLChartContext.hxx +++ b/xmloff/source/chart/SchXMLChartContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLChartContext.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: bm $ $Date: 2000-11-29 12:32:22 $ + * last change: $Author: bm $ $Date: 2001-03-27 13:23:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -98,6 +98,7 @@ private: SchXMLImportHelper& mrImportHelper; rtl::OUString maMainTitle, maSubTitle; + com::sun::star::awt::Point maMainTitlePos, maSubTitlePos, maLegendPos; sal_Bool mbHasOwnTable; com::sun::star::uno::Sequence< com::sun::star::chart::ChartSeriesAddress > maSeriesAddresses; @@ -124,14 +125,17 @@ class SchXMLTitleContext : public SvXMLImportContext { private: SchXMLImportHelper& mrImportHelper; - rtl::OUString& maTitle; + rtl::OUString& mrTitle; com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxTitleShape; + rtl::OUString msAutoStyleName; + com::sun::star::awt::Point& mrPosition; public: SchXMLTitleContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const rtl::OUString& rLocalName, - rtl::OUString& aTitle, - com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xTitleShape ); + rtl::OUString& rTitle, + com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xTitleShape, + com::sun::star::awt::Point& rPosition ); virtual ~SchXMLTitleContext(); virtual void StartElement( const com::sun::star::uno::Reference< @@ -148,10 +152,12 @@ class SchXMLLegendContext : public SvXMLImportContext { private: SchXMLImportHelper& mrImportHelper; + com::sun::star::awt::Point& mrPosition; public: SchXMLLegendContext( SchXMLImportHelper& rImpHelper, - SvXMLImport& rImport, const rtl::OUString& rLocalName ); + SvXMLImport& rImport, const rtl::OUString& rLocalName, + com::sun::star::awt::Point& rPosition ); virtual ~SchXMLLegendContext(); virtual void StartElement( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ); diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index adb6a453e2d8..288b0b541f07 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SchXMLPlotAreaContext.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: bm $ $Date: 2001-03-22 12:31:46 $ + * last change: $Author: bm $ $Date: 2001-03-27 13:24:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -720,6 +720,7 @@ void SchXMLAxisContext::EndElement() uno::Any aTrueBool; aTrueBool <<= (sal_Bool)(sal_True); sal_Bool bHasTitle = ( maCurrentAxis.aTitle.getLength() > 0 ); + uno::Reference< frame::XModel > xDoc( mrImportHelper.GetChartDocument(), uno::UNO_QUERY ); switch( maCurrentAxis.eClass ) { @@ -755,6 +756,18 @@ void SchXMLAxisContext::EndElement() { DBG_ERROR( "Property String for Title not available" ); } + uno::Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); + if( xShape.is()) + { + // perform build chart with new title string + // so that setting the position works correctly + if( xDoc.is()) + { + xDoc->unlockControllers(); + xDoc->lockControllers(); + } + xShape->setPosition( maCurrentAxis.aPosition ); + } } } } @@ -807,6 +820,18 @@ void SchXMLAxisContext::EndElement() { DBG_ERROR( "Property String for Title not available" ); } + uno::Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); + if( xShape.is()) + { + // perform build chart with new title string + // so that setting the position works correctly + if( xDoc.is()) + { + xDoc->unlockControllers(); + xDoc->lockControllers(); + } + xShape->setPosition( maCurrentAxis.aPosition ); + } } } } @@ -858,6 +883,18 @@ void SchXMLAxisContext::EndElement() { DBG_ERROR( "Property String for Title not available" ); } + uno::Reference< drawing::XShape > xShape( xTitleProp, uno::UNO_QUERY ); + if( xShape.is()) + { + // perform build chart with new title string + // so that setting the position works correctly + if( xDoc.is()) + { + xDoc->unlockControllers(); + xDoc->lockControllers(); + } + xShape->setPosition( maCurrentAxis.aPosition ); + } } } } @@ -896,7 +933,8 @@ SvXMLImportContext* SchXMLAxisContext::CreateChildContext( uno::Reference< drawing::XShape > xTitleShape = getTitleShape(); pContext = new SchXMLTitleContext( mrImportHelper, rImport, rLocalName, maCurrentAxis.aTitle, - xTitleShape ); + xTitleShape, + maCurrentAxis.aPosition ); } else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sXML_grid ))) { diff --git a/xmloff/source/chart/transporttypes.hxx b/xmloff/source/chart/transporttypes.hxx index ba6cc0d91ac5..80b822a4241a 100644 --- a/xmloff/source/chart/transporttypes.hxx +++ b/xmloff/source/chart/transporttypes.hxx @@ -2,9 +2,9 @@ * * $RCSfile: transporttypes.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: svesik $ $Date: 2000-11-22 18:00:35 $ + * last change: $Author: bm $ $Date: 2001-03-27 13:24:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -133,6 +133,7 @@ struct SchXMLAxis sal_Int8 nIndexInCategory; rtl::OUString aName; rtl::OUString aTitle; + com::sun::star::awt::Point aPosition; SchXMLAxis() : eClass( SCH_XML_AXIS_UNDEF ), nIndexInCategory( 0 ) {} }; |