diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-01-18 21:04:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-19 07:06:40 +0100 |
commit | 65c4b292afda53c1fffd9be3b88d4a5c535149ca (patch) | |
tree | 427bf3175543f79c61f7e1a690e1aa8a863c5042 /chart2 | |
parent | f8a3ce5db8382a3769617c215cb0f7b1da611fe5 (diff) |
use more concrete types in chart2, NameContainer
and simplify the NameContainer class, since it has only one use site
Change-Id: I5b68b8985c22bb5eb37fa559aba1d5314c3d3aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128575
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/inc/ChartModel.hxx | 3 | ||||
-rw-r--r-- | chart2/source/inc/NameContainer.hxx | 12 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 9 | ||||
-rw-r--r-- | chart2/source/tools/NameContainer.cxx | 22 |
4 files changed, 14 insertions, 32 deletions
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx index 9f2c58bdeb78..0a6587d93d74 100644 --- a/chart2/inc/ChartModel.hxx +++ b/chart2/inc/ChartModel.hxx @@ -71,6 +71,7 @@ namespace chart { class Diagram; class ChartTypeManager; +class NameContainer; namespace impl { @@ -168,7 +169,7 @@ private: css::uno::Reference< css::beans::XPropertySet > m_xPageBackground; - css::uno::Reference< css::container::XNameAccess> m_xXMLNamespaceMap; + rtl::Reference< ::chart::NameContainer > m_xXMLNamespaceMap; private: //private methods diff --git a/chart2/source/inc/NameContainer.hxx b/chart2/source/inc/NameContainer.hxx index edebf9b613ec..66d0fde1a70f 100644 --- a/chart2/source/inc/NameContainer.hxx +++ b/chart2/source/inc/NameContainer.hxx @@ -30,9 +30,6 @@ namespace chart { -OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::container::XNameContainer > createNameContainer( - const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName ); - namespace impl { typedef ::cppu::WeakImplHelper< @@ -42,11 +39,12 @@ typedef ::cppu::WeakImplHelper< NameContainer_Base; } +/// Contains the XML namespaces map +/// class NameContainer final : public impl::NameContainer_Base { public: - NameContainer() = delete; - NameContainer( const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName ); + NameContainer(); explicit NameContainer( const NameContainer & rOther ); virtual ~NameContainer() override; @@ -75,12 +73,8 @@ public: virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override; private: //member - const css::uno::Type m_aType; - const OUString m_aServicename; - const OUString m_aImplementationName; typedef std::map< OUString, css::uno::Any > tContentMap; - tContentMap m_aMap; }; diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 6d75a433ebf9..33501965bc48 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -95,8 +95,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) , m_xContext( xContext ) , m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() ) , m_xPageBackground( new PageBackground ) - , m_xXMLNamespaceMap( createNameContainer( ::cppu::UnoType<OUString>::get(), - "com.sun.star.xml.NamespaceMap", "com.sun.star.comp.chart.XMLNameSpaceMap" ) ) + , m_xXMLNamespaceMap( new NameContainer() ) , mnStart(0) , mnEnd(0) { @@ -153,7 +152,7 @@ ChartModel::ChartModel( const ChartModel & rOther ) rtl::Reference< ::chart::Diagram > xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram ); Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< beans::XPropertySet >()( rOther.m_xPageBackground ); rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager; // does not implement XCloneable - Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< container::XNameAccess >()( rOther.m_xXMLNamespaceMap ); + rtl::Reference< ::chart::NameContainer > xXMLNamespaceMap = new NameContainer( *rOther.m_xXMLNamespaceMap ); { MutexGuard aGuard( m_aModelMutex ); @@ -544,7 +543,7 @@ void SAL_CALL ChartModel::dispose() m_xDiagram.clear(); DisposeHelper::DisposeAndClear( m_xTitle ); DisposeHelper::DisposeAndClear( m_xPageBackground ); - DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap ); + m_xXMLNamespaceMap.clear(); m_xStorage.clear(); // just clear, don't dispose - we're not the owner @@ -1146,7 +1145,7 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString } break; case SERVICE_NAMESPACE_MAP: - return Reference< uno::XInterface >( m_xXMLNamespaceMap ); + return static_cast<cppu::OWeakObject*>(m_xXMLNamespaceMap.get()); } } else if(rServiceSpecifier == CHART_VIEW_SERVICE_NAME) diff --git a/chart2/source/tools/NameContainer.cxx b/chart2/source/tools/NameContainer.cxx index 3e485c624948..23e0a2821d1c 100644 --- a/chart2/source/tools/NameContainer.cxx +++ b/chart2/source/tools/NameContainer.cxx @@ -31,25 +31,13 @@ using ::com::sun::star::uno::Any; namespace chart { -uno::Reference< container::XNameContainer > createNameContainer( - const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName ) -{ - return new NameContainer( rType, rServicename, rImplementationName ); -} -NameContainer::NameContainer( const css::uno::Type& rType, const OUString& rServicename, const OUString& rImplementationName ) - : m_aType( rType ) - , m_aServicename( rServicename ) - , m_aImplementationName( rImplementationName ) +NameContainer::NameContainer() { } -NameContainer::NameContainer( - const NameContainer & rOther ) +NameContainer::NameContainer( const NameContainer & rOther ) : impl::NameContainer_Base(rOther) - , m_aType( rOther.m_aType ) - , m_aServicename( rOther.m_aServicename ) - , m_aImplementationName( rOther.m_aImplementationName ) , m_aMap( rOther.m_aMap ) { } @@ -61,7 +49,7 @@ NameContainer::~NameContainer() //XServiceInfo OUString SAL_CALL NameContainer::getImplementationName() { - return m_aImplementationName; + return "com.sun.star.comp.chart.XMLNameSpaceMap"; } sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName ) @@ -71,7 +59,7 @@ sal_Bool SAL_CALL NameContainer::supportsService( const OUString& ServiceName ) Sequence< OUString > SAL_CALL NameContainer::getSupportedServiceNames() { - return { m_aServicename }; + return { "com.sun.star.xml.NamespaceMap" }; } // XNameContainer @@ -126,7 +114,7 @@ sal_Bool SAL_CALL NameContainer::hasElements() uno::Type SAL_CALL NameContainer::getElementType() { - return m_aType; + return ::cppu::UnoType<OUString>::get(); } // XCloneable |