diff options
Diffstat (limited to 'svx/source/unodraw')
-rw-r--r-- | svx/source/unodraw/XPropertyTable.cxx | 82 | ||||
-rw-r--r-- | svx/source/unodraw/unoctabl.cxx | 11 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 10 |
3 files changed, 50 insertions, 53 deletions
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx index d1016614b92b..031063730b58 100644 --- a/svx/source/unodraw/XPropertyTable.cxx +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -26,6 +26,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <o3tl/any.hxx> +#include <o3tl/make_unique.hxx> #include <osl/mutex.hxx> #include <vcl/svapp.hxx> @@ -48,14 +49,14 @@ private: sal_Int16 mnWhich; long getCount() const { return mpList ? mpList->Count() : 0; } - XPropertyEntry* get( long index ) const; + const XPropertyEntry* get(long index) const; public: SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw(); virtual ~SvxUnoXPropertyTable() throw(); virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(uno::RuntimeException) = 0; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException, lang::IllegalArgumentException) = 0; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw(uno::RuntimeException, lang::IllegalArgumentException) = 0; // XServiceInfo virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception) override; @@ -85,7 +86,7 @@ SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw() { } -XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const +const XPropertyEntry* SvxUnoXPropertyTable::get(long index) const { if( mpList ) return mpList->Get(index); @@ -114,12 +115,11 @@ void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName); - XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement ); - if( nullptr == pNewEntry ) + std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement)); + if (!pNewEntry) throw lang::IllegalArgumentException(); - if( mpList ) - mpList->Insert( pNewEntry ); + mpList->Insert(std::move(pNewEntry)); } void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name ) @@ -133,11 +133,10 @@ void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name ) long i; for( i = 0; i < nCount; i++ ) { - XPropertyEntry* pEntry = get( i ); + const XPropertyEntry* pEntry = get(i); if (pEntry && aInternalName.equals(pEntry->GetName())) { - if( mpList ) - delete mpList->Remove( i ); + mpList->Remove(i); return; } } @@ -157,15 +156,14 @@ void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const long i; for( i = 0; i < nCount; i++ ) { - XPropertyEntry* pEntry = get( i ); + const XPropertyEntry* pEntry = get(i); if (pEntry && aInternalName.equals(pEntry->GetName())) { - XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement ); - if( nullptr == pNewEntry ) + std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement)); + if (!pNewEntry) throw lang::IllegalArgumentException(); - if( mpList ) - delete mpList->Replace( pNewEntry, i ); + mpList->Replace(std::move(pNewEntry), i); return; } } @@ -185,7 +183,7 @@ uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName ) long i; for( i = 0; i < nCount; i++ ) { - XPropertyEntry* pEntry = get( i ); + const XPropertyEntry* pEntry = get(i); if (pEntry && aInternalName.equals(pEntry->GetName())) return getAny( pEntry ); @@ -205,7 +203,7 @@ uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames() long i; for( i = 0; i < nCount; i++ ) { - XPropertyEntry* pEntry = get( i ); + const XPropertyEntry* pEntry = get(i); if (pEntry) *pNames++ = SvxUnogetApiNameForItem(mnWhich, pEntry->GetName()); @@ -225,7 +223,7 @@ sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName ) long i; for( i = 0; i < nCount; i++ ) { - XPropertyEntry* pEntry = get( i ); + const XPropertyEntry* pEntry = get(i); if (pEntry && aInternalName.equals(pEntry->GetName())) return true; } @@ -250,7 +248,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw() override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -271,14 +269,14 @@ uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw() return uno::Any( (sal_Int32)static_cast<const XColorEntry*>(pEntry)->GetColor().GetColor() ); } -XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +std::unique_ptr<XPropertyEntry> SvxUnoXColorTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw() { sal_Int32 nColor = 0; if( !(rAny >>= nColor) ) - return nullptr; + return std::unique_ptr<XPropertyEntry>(); const Color aColor( (ColorData)nColor ); - return new XColorEntry( aColor, rName ); + return o3tl::make_unique<XColorEntry>(aColor, rName); } // XElementAccess @@ -309,7 +307,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(lang::IllegalArgumentException) override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw(lang::IllegalArgumentException) override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -333,11 +331,11 @@ uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw return uno::Any(aBezier); } -XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw(lang::IllegalArgumentException) +std::unique_ptr<XPropertyEntry> SvxUnoXLineEndTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw(lang::IllegalArgumentException) { auto pCoords = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rAny); if( !pCoords ) - return nullptr; + return std::unique_ptr<XLineEndEntry>(); basegfx::B2DPolyPolygon aPolyPolygon; if( pCoords->Coordinates.getLength() > 0 ) @@ -346,7 +344,7 @@ XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno: // #86265# make sure polygon is closed aPolyPolygon.setClosed(true); - return new XLineEndEntry( aPolyPolygon, rName ); + return o3tl::make_unique<XLineEndEntry>(aPolyPolygon, rName); } // XElementAccess @@ -377,7 +375,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw() override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -409,11 +407,11 @@ uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw() return uno::Any(aLineDash); } -XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +std::unique_ptr<XPropertyEntry> SvxUnoXDashTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw() { drawing::LineDash aLineDash; if(!(rAny >>= aLineDash)) - return nullptr; + return std::unique_ptr<XDashEntry>(); XDash aXDash; @@ -424,7 +422,7 @@ XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::An aXDash.SetDashLen(aLineDash.DashLen); aXDash.SetDistance(aLineDash.Distance); - return new XDashEntry( aXDash, rName ); + return o3tl::make_unique<XDashEntry>(aXDash, rName); } // XElementAccess @@ -455,7 +453,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw() override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -485,11 +483,11 @@ uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw() return uno::Any(aUnoHatch); } -XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +std::unique_ptr<XPropertyEntry> SvxUnoXHatchTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw() { drawing::Hatch aUnoHatch; if(!(rAny >>= aUnoHatch)) - return nullptr; + return std::unique_ptr<XHatchEntry>(); XHatch aXHatch; aXHatch.SetHatchStyle( (css::drawing::HatchStyle)aUnoHatch.Style ); @@ -497,7 +495,7 @@ XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::A aXHatch.SetDistance( aUnoHatch.Distance ); aXHatch.SetAngle( aUnoHatch.Angle ); - return new XHatchEntry( aXHatch, rName ); + return o3tl::make_unique<XHatchEntry>(aXHatch, rName); } // XElementAccess @@ -528,7 +526,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw() override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -563,11 +561,11 @@ uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const thro return uno::Any(aGradient); } -XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw() +std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw() { awt::Gradient aGradient; if(!(rAny >>= aGradient)) - return nullptr; + return std::unique_ptr<XPropertyEntry>(); XGradient aXGradient; @@ -582,7 +580,7 @@ XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno aXGradient.SetEndIntens( aGradient.EndIntensity ); aXGradient.SetSteps( aGradient.StepCount ); - return new XGradientEntry( aXGradient, rName ); + return o3tl::make_unique<XGradientEntry>(aXGradient, rName); } // XElementAccess @@ -613,7 +611,7 @@ public: // SvxUnoXPropertyTable virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw(uno::RuntimeException) override; - virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException) override; + virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const throw(uno::RuntimeException) override; // XElementAccess virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException, std::exception ) override; @@ -638,15 +636,15 @@ uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw( return uno::Any(aURL); } -XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw(uno::RuntimeException) +std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString& rName, const uno::Any& rAny) const throw(uno::RuntimeException) { OUString aURL; if(!(rAny >>= aURL)) - return nullptr; + return std::unique_ptr<XPropertyEntry>(); const GraphicObject aGrafObj(GraphicObject::CreateGraphicObjectFromURL(aURL)); - return new XBitmapEntry(aGrafObj, rName); + return o3tl::make_unique<XBitmapEntry>(aGrafObj, rName); } // XElementAccess diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx index bda46f67def5..55f01081a6fe 100644 --- a/svx/source/unodraw/unoctabl.cxx +++ b/svx/source/unodraw/unoctabl.cxx @@ -25,6 +25,7 @@ #include <cppuhelper/supportsservice.hxx> #include <rtl/ref.hxx> #include <svx/xtable.hxx> +#include <o3tl/make_unique.hxx> using namespace ::com::sun::star; @@ -99,8 +100,7 @@ void SAL_CALL SvxUnoColorTable::insertByName( const OUString& aName, const uno:: if( pList.is() ) { - XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); - pList->Insert( pEntry, pList->Count() ); + pList->Insert(o3tl::make_unique<XColorEntry>(Color((ColorData)nColor), aName)); } } @@ -126,8 +126,7 @@ void SAL_CALL SvxUnoColorTable::replaceByName( const OUString& aName, const uno: if( nIndex == -1 ) throw container::NoSuchElementException(); - XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); - delete pList->Replace( nIndex, pEntry ); + pList->Replace(nIndex, o3tl::make_unique<XColorEntry>(Color((ColorData)nColor), aName )); } // XNameAccess @@ -138,7 +137,7 @@ uno::Any SAL_CALL SvxUnoColorTable::getByName( const OUString& aName ) if( nIndex == -1 ) throw container::NoSuchElementException(); - XColorEntry* pEntry = pList->GetColor( nIndex ); + const XColorEntry* pEntry = pList->GetColor(nIndex); return uno::Any( (sal_Int32) pEntry->GetColor().GetRGBColor() ); } @@ -152,7 +151,7 @@ uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getElementNames() for( long nIndex = 0; nIndex < nCount; nIndex++ ) { - XColorEntry* pEntry = pList->GetColor( (long)nIndex ); + const XColorEntry* pEntry = pList->GetColor(nIndex); pStrings[nIndex] = pEntry->GetName(); } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 8f04d60ed142..a239ee34bc68 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -1436,7 +1436,7 @@ bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, if( nPos == -1 ) return false; - XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos ); + const XBitmapEntry* pEntry = pBitmapList->GetBitmap(nPos); XFillBitmapItem aBmpItem; aBmpItem.SetWhich( XATTR_FILLBITMAP ); aBmpItem.SetName( rName ); @@ -1455,7 +1455,7 @@ bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, if( nPos == -1 ) return false; - XGradientEntry* pEntry = pGradientList->GetGradient( nPos ); + const XGradientEntry* pEntry = pGradientList->GetGradient(nPos); XFillGradientItem aGrdItem; aGrdItem.SetWhich( XATTR_FILLGRADIENT ); aGrdItem.SetName( rName ); @@ -1474,7 +1474,7 @@ bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, if( nPos == -1 ) return false; - XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); + const XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); XFillHatchItem aHatchItem; aHatchItem.SetWhich( XATTR_FILLHATCH ); aHatchItem.SetName( rName ); @@ -1494,7 +1494,7 @@ bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, if( nPos == -1 ) return false; - XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); if( XATTR_LINEEND == nWID ) { XLineEndItem aLEItem; @@ -1525,7 +1525,7 @@ bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, if( nPos == -1 ) return false; - XDashEntry* pEntry = pDashList->GetDash( nPos ); + const XDashEntry* pEntry = pDashList->GetDash(nPos); XLineDashItem aDashItem; aDashItem.SetWhich( XATTR_LINEDASH ); aDashItem.SetName( rName ); |