diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-20 15:28:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-20 18:57:10 +0200 |
commit | 3077399b156477963a22c6c89c432ff49583e2c3 (patch) | |
tree | 18e624b4fb9e5fda927d36b34d39c13c29144053 | |
parent | afc9c4454f7bab73087c28ed454d1fd00968e124 (diff) |
no need to store data separately in SvXMLAttrContainerItem
Change-Id: Idea4289c600a81f5c8dbb389343ef57a9623d11d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119251
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | editeng/source/items/xmlcnitm.cxx | 43 | ||||
-rw-r--r-- | include/editeng/xmlcnitm.hxx | 5 | ||||
-rw-r--r-- | include/xmloff/xmlcnimp.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/core/xmlcnimp.cxx | 12 |
4 files changed, 38 insertions, 25 deletions
diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx index 5ee7c47e8d90..1e88121ee576 100644 --- a/editeng/source/items/xmlcnitm.cxx +++ b/editeng/source/items/xmlcnitm.cxx @@ -33,15 +33,14 @@ using namespace ::com::sun::star::xml; SvXMLAttrContainerItem::SvXMLAttrContainerItem( sal_uInt16 _nWhich ) : - SfxPoolItem( _nWhich ), - pImpl( new SvXMLAttrContainerData ) + SfxPoolItem( _nWhich ) { } SvXMLAttrContainerItem::SvXMLAttrContainerItem( const SvXMLAttrContainerItem& rItem ) : SfxPoolItem( rItem ), - pImpl( new SvXMLAttrContainerData( *rItem.pImpl ) ) + maContainerData( rItem.maContainerData ) { } @@ -52,7 +51,7 @@ SvXMLAttrContainerItem::~SvXMLAttrContainerItem() bool SvXMLAttrContainerItem::operator==( const SfxPoolItem& rItem ) const { return SfxPoolItem::operator==(rItem) && - *pImpl == *static_cast<const SvXMLAttrContainerItem&>(rItem).pImpl; + maContainerData == static_cast<const SvXMLAttrContainerItem&>(rItem).maContainerData; } bool SvXMLAttrContainerItem::GetPresentation( @@ -68,7 +67,7 @@ bool SvXMLAttrContainerItem::GetPresentation( bool SvXMLAttrContainerItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const { Reference<XNameContainer> xContainer - = new SvUnoAttributeContainer(std::make_unique<SvXMLAttrContainerData>(*pImpl)); + = new SvUnoAttributeContainer(std::make_unique<SvXMLAttrContainerData>(maContainerData)); rVal <<= xContainer; return true; @@ -84,11 +83,11 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM if( pContainer ) { - pImpl.reset( new SvXMLAttrContainerData( * pContainer->GetContainerImpl() ) ); + maContainerData = *pContainer->GetContainerImpl(); } else { - std::unique_ptr<SvXMLAttrContainerData> pNewImpl(new SvXMLAttrContainerData); + SvXMLAttrContainerData aNewImpl; try { @@ -119,24 +118,24 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM if( pData->Namespace.isEmpty() ) { - if( !pNewImpl->AddAttr( aPrefix, aLName, pData->Value ) ) + if( !aNewImpl.AddAttr( aPrefix, aLName, pData->Value ) ) break; } else { - if( !pNewImpl->AddAttr( aPrefix, pData->Namespace, aLName, pData->Value ) ) + if( !aNewImpl.AddAttr( aPrefix, pData->Namespace, aLName, pData->Value ) ) break; } } else { - if( !pNewImpl->AddAttr( aName, pData->Value ) ) + if( !aNewImpl.AddAttr( aName, pData->Value ) ) break; } } if( nAttr == nCount ) - pImpl = std::move(pNewImpl); + maContainerData = std::move(aNewImpl); else return false; } @@ -152,60 +151,60 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM bool SvXMLAttrContainerItem::AddAttr( const OUString& rLName, const OUString& rValue ) { - return pImpl->AddAttr( rLName, rValue ); + return maContainerData.AddAttr( rLName, rValue ); } bool SvXMLAttrContainerItem::AddAttr( const OUString& rPrefix, const OUString& rNamespace, const OUString& rLName, const OUString& rValue ) { - return pImpl->AddAttr( rPrefix, rNamespace, rLName, rValue ); + return maContainerData.AddAttr( rPrefix, rNamespace, rLName, rValue ); } sal_uInt16 SvXMLAttrContainerItem::GetAttrCount() const { - return static_cast<sal_uInt16>(pImpl->GetAttrCount()); + return static_cast<sal_uInt16>(maContainerData.GetAttrCount()); } OUString SvXMLAttrContainerItem::GetAttrNamespace( sal_uInt16 i ) const { - return pImpl->GetAttrNamespace( i ); + return maContainerData.GetAttrNamespace( i ); } OUString SvXMLAttrContainerItem::GetAttrPrefix( sal_uInt16 i ) const { - return pImpl->GetAttrPrefix( i ); + return maContainerData.GetAttrPrefix( i ); } const OUString& SvXMLAttrContainerItem::GetAttrLName( sal_uInt16 i ) const { - return pImpl->GetAttrLName( i ); + return maContainerData.GetAttrLName( i ); } const OUString& SvXMLAttrContainerItem::GetAttrValue( sal_uInt16 i ) const { - return pImpl->GetAttrValue( i ); + return maContainerData.GetAttrValue( i ); } sal_uInt16 SvXMLAttrContainerItem::GetFirstNamespaceIndex() const { - return pImpl->GetFirstNamespaceIndex(); + return maContainerData.GetFirstNamespaceIndex(); } sal_uInt16 SvXMLAttrContainerItem::GetNextNamespaceIndex( sal_uInt16 nIdx ) const { - return pImpl->GetNextNamespaceIndex( nIdx ); + return maContainerData.GetNextNamespaceIndex( nIdx ); } const OUString& SvXMLAttrContainerItem::GetNamespace( sal_uInt16 i ) const { - return pImpl->GetNamespace( i ); + return maContainerData.GetNamespace( i ); } const OUString& SvXMLAttrContainerItem::GetPrefix( sal_uInt16 i ) const { - return pImpl->GetPrefix( i ); + return maContainerData.GetPrefix( i ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/xmlcnitm.hxx b/include/editeng/xmlcnitm.hxx index b5eb190fb5e2..f3b44e062e00 100644 --- a/include/editeng/xmlcnitm.hxx +++ b/include/editeng/xmlcnitm.hxx @@ -23,13 +23,12 @@ #include <svl/poolitem.hxx> #include <editeng/editengdllapi.h> #include <memory> +#include <xmloff/xmlcnimp.hxx> -class SvXMLAttrContainerData; - class EDITENG_DLLPUBLIC SvXMLAttrContainerItem final : public SfxPoolItem { - std::unique_ptr<SvXMLAttrContainerData> pImpl; + SvXMLAttrContainerData maContainerData; public: diff --git a/include/xmloff/xmlcnimp.hxx b/include/xmloff/xmlcnimp.hxx index c987e9943138..8b09f5ed79cd 100644 --- a/include/xmloff/xmlcnimp.hxx +++ b/include/xmloff/xmlcnimp.hxx @@ -37,6 +37,9 @@ public: SvXMLAttrContainerData(const SvXMLAttrContainerData &rCopy); ~SvXMLAttrContainerData(); + SvXMLAttrContainerData& operator=( const SvXMLAttrContainerData& rCmp ); + SvXMLAttrContainerData& operator=( SvXMLAttrContainerData&& rCmp ); + bool operator ==( const SvXMLAttrContainerData& rCmp ) const; bool AddAttr( const OUString& rLName, const OUString& rValue ); diff --git a/xmloff/source/core/xmlcnimp.cxx b/xmloff/source/core/xmlcnimp.cxx index b38752e2d213..34010568bd19 100644 --- a/xmloff/source/core/xmlcnimp.cxx +++ b/xmloff/source/core/xmlcnimp.cxx @@ -30,6 +30,18 @@ SvXMLAttrContainerData::SvXMLAttrContainerData(const SvXMLAttrContainerData &rCo { } +SvXMLAttrContainerData& SvXMLAttrContainerData::operator=(const SvXMLAttrContainerData &rCopy) +{ + pimpl.reset( new SvXMLAttrCollection( *rCopy.pimpl ) ); + return *this; +} + +SvXMLAttrContainerData& SvXMLAttrContainerData::operator=(SvXMLAttrContainerData&& rCopy) +{ + pimpl = std::move( rCopy.pimpl ); + return *this; +} + // Need destructor defined (despite it being empty) to avoid "checked_delete" // compiler errors. SvXMLAttrContainerData::~SvXMLAttrContainerData() |