include/xmloff/SchXMLImportHelper.hxx | 3 ++ xmloff/source/chart/SchXMLAxisContext.cxx | 28 ++++++------------------ xmloff/source/chart/SchXMLChartContext.cxx | 30 +++----------------------- xmloff/source/chart/SchXMLImport.cxx | 18 ++++++++++++++- xmloff/source/chart/SchXMLLegendContext.cxx | 10 -------- xmloff/source/chart/SchXMLPlotAreaContext.cxx | 27 ++--------------------- 6 files changed, 35 insertions(+), 81 deletions(-)
New commits: commit 4d1118e5cc9f2a4dc20ea73fba4cb09d9e2a3ce5 Author: Jan Holesovsky <ke...@collabora.com> Date: Thu Jun 23 10:22:34 2016 +0200 Simplify dynamic_cast followed by a static_cast. Change-Id: Ia8b1145d43828a40611e5f59651d9dc6ff7d5360 diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx index 652e223..41fad4d7 100644 --- a/xmloff/source/chart/SchXMLAxisContext.cxx +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -465,17 +465,13 @@ void SchXMLAxisContext::CreateAxis() if( !m_aAutoStyleName.isEmpty()) { const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) + if (pStylesCtxt) { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - SchXMLImportHelper::GetChartFamilyID(), m_aAutoStyleName ); + SvXMLStyleContext* pStyle = const_cast<SvXMLStyleContext*>(pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(), m_aAutoStyleName)); - if( pStyle && dynamic_cast<const XMLPropStyleContext*>( pStyle) != nullptr) + if (XMLPropStyleContext * pPropStyleContext = dynamic_cast<XMLPropStyleContext*>(pStyle)) { - // note: SvXMLStyleContext::FillPropertySet is not const - XMLPropStyleContext * pPropStyleContext = const_cast< XMLPropStyleContext * >( dynamic_cast< const XMLPropStyleContext * >( pStyle )); - if( pPropStyleContext ) - pPropStyleContext->FillPropertySet( m_xAxisProps ); + pPropStyleContext->FillPropertySet(m_xAxisProps); if( m_bAdaptWrongPercentScaleValues && m_aCurrentAxis.eDimension==SCH_XML_AXIS_Y ) { @@ -498,7 +494,7 @@ void SchXMLAxisContext::CreateAxis() if( xAxisSuppl.is() ) { Reference< beans::XPropertySet > xXAxisProp( xAxisSuppl->getAxis(0), uno::UNO_QUERY ); - const_cast<XMLPropStyleContext*>( static_cast< const XMLPropStyleContext* >( pStyle ))->FillPropertySet( xXAxisProp ); + pPropStyleContext->FillPropertySet(xXAxisProp); } //set scale data of added x axis back to default commit a07a69850acddae631d6bd9496ace0c35accdda5 Author: Jan Holesovsky <ke...@collabora.com> Date: Thu Jun 23 10:18:35 2016 +0200 Introduce FillAutoStyle() method to reduce copy'n'paste. Change-Id: Ibdb6ae15790cc117d3d8c41c57924f9b22e85cba diff --git a/include/xmloff/SchXMLImportHelper.hxx b/include/xmloff/SchXMLImportHelper.hxx index 415a9a0..765a960 100644 --- a/include/xmloff/SchXMLImportHelper.hxx +++ b/include/xmloff/SchXMLImportHelper.hxx @@ -100,6 +100,9 @@ public: void SetAutoStylesContext( SvXMLStylesContext* pAutoStyles ) { mpAutoStyles = pAutoStyles; } SvXMLStylesContext* GetAutoStylesContext() const { return mpAutoStyles; } + /// Fill in the autostyle. + void FillAutoStyle(const OUString& rAutoStyleName, const css::uno::Reference<css::beans::XPropertySet>& rProp); + const css::uno::Reference< css::chart::XChartDocument >& GetChartDocument() { return mxChartDoc; } diff --git a/xmloff/source/chart/SchXMLAxisContext.cxx b/xmloff/source/chart/SchXMLAxisContext.cxx index 9feded2..652e223 100644 --- a/xmloff/source/chart/SchXMLAxisContext.cxx +++ b/xmloff/source/chart/SchXMLAxisContext.cxx @@ -219,18 +219,8 @@ void SchXMLAxisContext::CreateGrid( const OUString& sAutoStyleName, bool bIsMajo // the line color is black as default, in the model it is a light gray xGridProp->setPropertyValue("LineColor", uno::makeAny( COL_BLACK )); - if( !sAutoStyleName.isEmpty()) - { - const SvXMLStylesContext* pStylesCtxt = m_rImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName ); - - if( pStyle && dynamic_cast<const XMLPropStyleContext*>( pStyle) != nullptr) - const_cast<XMLPropStyleContext*>( static_cast< const XMLPropStyleContext* >( pStyle ))->FillPropertySet( xGridProp ); - } - } + if (!sAutoStyleName.isEmpty()) + m_rImportHelper.FillAutoStyle(sAutoStyleName, xGridProp); } } diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 5cc699f..f9e2dab 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -364,19 +364,8 @@ void SchXMLChartContext::StartElement( const uno::Reference< xml::sax::XAttribut } // set auto-styles for Area - uno::Reference< beans::XPropertySet > xProp( mrImportHelper.GetChartDocument()->getArea(), uno::UNO_QUERY ); - if( xProp.is()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName ); - - if( pStyle && dynamic_cast< const XMLPropStyleContext*>(pStyle) != nullptr) - const_cast<XMLPropStyleContext*>( static_cast< const XMLPropStyleContext* >( pStyle ) )->FillPropertySet( xProp ); - } - } + uno::Reference<beans::XPropertySet> xProp(mrImportHelper.GetChartDocument()->getArea(), uno::UNO_QUERY); + mrImportHelper.FillAutoStyle(sAutoStyleName, xProp); } namespace @@ -1183,19 +1172,8 @@ void SchXMLTitleContext::StartElement( const uno::Reference< xml::sax::XAttribut if( bHasXPosition && bHasYPosition ) mxTitleShape->setPosition( aPosition ); - uno::Reference< beans::XPropertySet > xProp( mxTitleShape, uno::UNO_QUERY ); - if( xProp.is()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - SchXMLImportHelper::GetChartFamilyID(), msAutoStyleName ); - - if( pStyle && dynamic_cast< const XMLPropStyleContext*>(pStyle) != nullptr) - const_cast<XMLPropStyleContext*>( static_cast< const XMLPropStyleContext* >( pStyle ) )->FillPropertySet( xProp ); - } - } + uno::Reference<beans::XPropertySet> xProp(mxTitleShape, uno::UNO_QUERY); + mrImportHelper.FillAutoStyle(msAutoStyleName, xProp); } } diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 3b903be..17645c9 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -26,10 +26,11 @@ #include <rtl/ustrbuf.hxx> #include <comphelper/processfactory.hxx> +#include <xmloff/nmspmap.hxx> +#include <xmloff/prstylei.hxx> #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> -#include <xmloff/nmspmap.hxx> #include <xmloff/xmlictxt.hxx> #include <xmloff/xmlstyle.hxx> #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> @@ -140,6 +141,21 @@ SvXMLImportContext* SchXMLImportHelper::CreateChartContext( return pContext; } +void SchXMLImportHelper::FillAutoStyle(const OUString& rAutoStyleName, const uno::Reference<beans::XPropertySet>& rProp) +{ + if (!rProp.is()) + return; + + const SvXMLStylesContext* pStylesCtxt = GetAutoStylesContext(); + if (pStylesCtxt) + { + SvXMLStyleContext* pStyle = const_cast<SvXMLStyleContext*>(pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(), rAutoStyleName)); + + if (XMLPropStyleContext* pPropStyle = dynamic_cast<XMLPropStyleContext*>(pStyle)) + pPropStyle->FillPropertySet(rProp); + } +} + // get various token maps const SvXMLTokenMap& SchXMLImportHelper::GetDocElemTokenMap() diff --git a/xmloff/source/chart/SchXMLLegendContext.cxx b/xmloff/source/chart/SchXMLLegendContext.cxx index 04d06c0..600b6b9 100644 --- a/xmloff/source/chart/SchXMLLegendContext.cxx +++ b/xmloff/source/chart/SchXMLLegendContext.cxx @@ -198,15 +198,7 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu xLegendProps->setPropertyValue("FillStyle", uno::makeAny( drawing::FillStyle_NONE )); // set auto-styles for Legend - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if( pStylesCtxt ) - { - const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext( - SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName ); - - if( pStyle && dynamic_cast< const XMLPropStyleContext*>(pStyle) != nullptr) - const_cast<XMLPropStyleContext*>( static_cast<const XMLPropStyleContext*>( pStyle ) )->FillPropertySet( xLegendProps ); - } + mrImportHelper.FillAutoStyle(sAutoStyleName, xLegendProps); } SchXMLLegendContext::~SchXMLLegendContext() diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index 65ddc9a..a0d2e09 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -798,20 +798,9 @@ void SchXMLWallFloorContext::StartElement( const uno::Reference< xml::sax::XAttr ? mxWallFloorSupplier->getWall() : mxWallFloorSupplier->getFloor(), uno::UNO_QUERY ); - if (xProp.is()) - { - if (!sAutoStyleName.isEmpty()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if (pStylesCtxt) - { - SvXMLStyleContext* pStyle = const_cast<SvXMLStyleContext*>(pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName)); - if (XMLPropStyleContext* pPropStyle = dynamic_cast<XMLPropStyleContext*>(pStyle)) - pPropStyle->FillPropertySet(xProp); - } - } - } + if (!sAutoStyleName.isEmpty()) + mrImportHelper.FillAutoStyle(sAutoStyleName, xProp); } } @@ -870,17 +859,7 @@ void SchXMLStockContext::StartElement( const uno::Reference< xml::sax::XAttribut break; } - if (xProp.is()) - { - const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext(); - if (pStylesCtxt) - { - SvXMLStyleContext* pStyle = const_cast<SvXMLStyleContext*>(pStylesCtxt->FindStyleChildContext(SchXMLImportHelper::GetChartFamilyID(), sAutoStyleName)); - - if (XMLPropStyleContext* pPropStyle = dynamic_cast<XMLPropStyleContext*>(pStyle)) - pPropStyle->FillPropertySet(xProp); - } - } + mrImportHelper.FillAutoStyle(sAutoStyleName, xProp); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits