summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-08-15 09:19:35 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-08-15 07:49:37 +0000
commit2b68e03348b3b4009e8bb2af7979de36bd3450c5 (patch)
treeea337632ae63bc8c19cdb1b72feedbce8302433a /svx
parent3093732c17d14b0e6eb67868c514448f13bc66d0 (diff)
tdf#100782 have XPropertyList hold unique_ptr
Change-Id: I928f297e1be76b965898d83cb3dd2e79b23b7974 Reviewed-on: https://gerrit.libreoffice.org/28095 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/dlgctrl.cxx22
-rw-r--r--svx/source/sidebar/area/AreaPropertyPanelBase.cxx5
-rw-r--r--svx/source/sidebar/line/LinePropertyPanelBase.cxx10
-rw-r--r--svx/source/tbxctrls/SvxPresetListBox.cxx2
-rw-r--r--svx/source/tbxctrls/fillctrl.cxx21
-rw-r--r--svx/source/tbxctrls/linectrl.cxx16
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx82
-rw-r--r--svx/source/unodraw/unoctabl.cxx11
-rw-r--r--svx/source/unodraw/unoshape.cxx10
-rw-r--r--svx/source/xoutdev/xattr.cxx14
-rw-r--r--svx/source/xoutdev/xtabbtmp.cxx5
-rw-r--r--svx/source/xoutdev/xtabcolr.cxx80
-rw-r--r--svx/source/xoutdev/xtabdash.cxx16
-rw-r--r--svx/source/xoutdev/xtabgrdt.cxx22
-rw-r--r--svx/source/xoutdev/xtabhtch.cxx16
-rw-r--r--svx/source/xoutdev/xtable.cxx78
-rw-r--r--svx/source/xoutdev/xtablend.cxx12
-rw-r--r--svx/source/xoutdev/xtabptrn.cxx15
18 files changed, 209 insertions, 228 deletions
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index a864a0a93cc2..17934ed34fde 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1129,7 +1129,7 @@ void ColorLB::Fill( const XColorListRef &pColorTab )
for( long i = 0; i < nCount; i++ )
{
- XColorEntry* pEntry = pColorTab->GetColor( i );
+ const XColorEntry* pEntry = pColorTab->GetColor(i);
InsertEntry( pEntry->GetColor(), pEntry->GetName() );
}
@@ -1181,7 +1181,7 @@ void HatchingLB::Fill( const XHatchListRef &pList )
for( long i = 0; i < nCount; i++ )
{
- XHatchEntry* pEntry = pList->GetHatch( i );
+ const XHatchEntry* pEntry = pList->GetHatch(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
InsertEntry(pEntry->GetName(), Image(aBitmap));
@@ -1230,7 +1230,7 @@ void FillAttrLB::Fill( const XHatchListRef &pList )
for( long i = 0; i < nCount; i++ )
{
- XHatchEntry* pEntry = pList->GetHatch( i );
+ const XHatchEntry* pEntry = pList->GetHatch(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
@@ -1274,7 +1274,7 @@ void GradientLB::Fill( const XGradientListRef &pList )
for( long i = 0; i < nCount; i++ )
{
- XGradientEntry* pEntry = pList->GetGradient( i );
+ const XGradientEntry* pEntry = pList->GetGradient(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
InsertEntry(pEntry->GetName(), Image(aBitmap));
@@ -1318,7 +1318,7 @@ void GradientLB::SelectEntryByList( const XGradientListRef &pList, const OUStrin
const XGradient& rGradient )
{
long nCount = pList.get() ? pList->Count() : 0;
- XGradientEntry* pEntry;
+ const XGradientEntry* pEntry;
bool bFound = false;
OUString aStr;
@@ -1345,7 +1345,7 @@ void FillAttrLB::Fill( const XGradientListRef &pList )
for( long i = 0; i < nCount; i++ )
{
- XGradientEntry* pEntry = pList->GetGradient( i );
+ const XGradientEntry* pEntry = pList->GetGradient(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
ListBox::InsertEntry(pEntry->GetName(), Image(aBitmap));
@@ -1438,7 +1438,7 @@ void BitmapLB::Fill( const XBitmapListRef &pList )
return;
mpList = pList;
- XBitmapEntry* pEntry;
+ const XBitmapEntry* pEntry;
const long nCount(pList->Count());
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
@@ -1498,7 +1498,7 @@ FillAttrLB::FillAttrLB(vcl::Window* pParent, WinBits aWB)
void FillAttrLB::Fill( const XBitmapListRef &pList )
{
const long nCount(pList->Count());
- XBitmapEntry* pEntry;
+ const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
@@ -1519,7 +1519,7 @@ void FillAttrLB::Fill( const XBitmapListRef &pList )
void FillAttrLB::Fill( const XPatternListRef &pList )
{
const long nCount(pList->Count());
- XBitmapEntry* pEntry;
+ const XBitmapEntry* pEntry;
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const Size aSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize());
@@ -1607,7 +1607,7 @@ void LineLB::Fill( const XDashListRef &pList )
for( long i = 0; i < nCount; i++ )
{
- XDashEntry* pEntry = pList->GetDash( i );
+ const XDashEntry* pEntry = pList->GetDash(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
{
@@ -1682,7 +1682,7 @@ void LineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
for( long i = 0; i < nCount; i++ )
{
- XLineEndEntry* pEntry = pList->GetLineEnd( i );
+ const XLineEndEntry* pEntry = pList->GetLineEnd(i);
const Bitmap aBitmap = pList->GetUiBitmap( i );
if( !aBitmap.IsEmpty() )
{
diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
index 46aa13e15b5a..a96ea76afc36 100644
--- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx
@@ -42,6 +42,8 @@
#include <svx/tbcontrl.hxx>
#include "sfx2/opengrf.hxx"
+#include <o3tl/make_unique.hxx>
+
using namespace css;
using namespace css::uno;
@@ -233,8 +235,7 @@ IMPL_LINK_NOARG_TYPED(AreaPropertyPanelBase, ClickImportBitmapHdl, Button*, void
}
}
- XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName );
- pList->Insert(pEntry);
+ pList->Insert(o3tl::make_unique<XBitmapEntry>(aGraphic, aName));
pList->Save();
mpLbFillAttr->Clear();
mpLbFillAttr->Fill(pList);
diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
index 906a4128e458..b433529ac16d 100644
--- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx
@@ -69,7 +69,7 @@ void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLin
for(sal_uInt32 i(0); i < nCount; i++)
{
- XLineEndEntry* pEntry = rList.GetLineEnd(i);
+ const XLineEndEntry* pEntry = rList.GetLineEnd(i);
const Bitmap aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i);
if(!aBitmap.IsEmpty())
@@ -140,7 +140,7 @@ void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList)
for(sal_uInt32 i(0); i < nCount; i++)
{
- XDashEntry* pEntry = rList.GetDash(i);
+ const XDashEntry* pEntry = rList.GetDash(i);
const Bitmap aBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i);
if(!aBitmap.IsEmpty())
@@ -812,7 +812,7 @@ void LinePropertyPanelBase::SelectLineStyle()
const XDash& rDash = mpDashItem->GetDashValue();
for(sal_Int32 a(0);!bSelected && a < mxLineStyleList->Count(); a++)
{
- XDashEntry* pEntry = mxLineStyleList->GetDash(a);
+ const XDashEntry* pEntry = mxLineStyleList->GetDash(a);
const XDash& rEntry = pEntry->GetDash();
if(rDash == rEntry)
{
@@ -848,7 +848,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++)
{
- XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
+ const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
if(rItemPolygon == rEntryPolygon)
{
@@ -877,7 +877,7 @@ void LinePropertyPanelBase::SelectEndStyle(bool bStart)
const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
for(sal_Int32 a(0);!bSelected && a < mxLineEndList->Count(); a++)
{
- XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
+ const XLineEndEntry* pEntry = mxLineEndList->GetLineEnd(a);
const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
if(rItemPolygon == rEntryPolygon)
{
diff --git a/svx/source/tbxctrls/SvxPresetListBox.cxx b/svx/source/tbxctrls/SvxPresetListBox.cxx
index 1f73a4ccaddc..0786d9d9049b 100644
--- a/svx/source/tbxctrls/SvxPresetListBox.cxx
+++ b/svx/source/tbxctrls/SvxPresetListBox.cxx
@@ -102,7 +102,7 @@ void SvxPresetListBox::FillPresetListBoxImpl(ListType & pList, sal_uInt32 nStart
for(long nIndex = 0; nIndex < pList.Count(); nIndex++, nStartIndex++)
{
aBitmap = pList.GetBitmapForPreview(nIndex, aSize);
- EntryType *pItem = static_cast<EntryType*>( pList.Get( nIndex ) );
+ EntryType* pItem = static_cast<EntryType*>( pList.Get(nIndex) );
InsertItem(nStartIndex, Image(aBitmap), pItem->GetName());
}
}
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 9d3bfb067ae1..96f160254285 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -39,6 +39,8 @@
#include <svx/dialmgr.hxx>
#include "helpid.hrc"
#include <memory>
+#include <o3tl/make_unique.hxx>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -376,19 +378,16 @@ void SvxFillToolBoxControl::Update()
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- std::unique_ptr<XGradientEntry> pEntry(new XGradientEntry(mpFillGradientItem->GetGradientValue(), aTmpStr));
XGradientList aGradientList( "", ""/*TODO?*/ );
- aGradientList.Insert( pEntry.get() );
+ aGradientList.Insert(o3tl::make_unique<XGradientEntry>(mpFillGradientItem->GetGradientValue(), aTmpStr));
aGradientList.SetDirty( false );
const Bitmap aBmp = aGradientList.GetUiBitmap( 0 );
if(!aBmp.IsEmpty())
{
- mpLbFillAttr->InsertEntry(pEntry->GetName(), Image(aBmp));
+ mpLbFillAttr->InsertEntry(aGradientList.Get(0)->GetName(), Image(aBmp));
mpLbFillAttr->SelectEntryPos(mpLbFillAttr->GetEntryCount() - 1);
}
-
- aGradientList.Remove( 0 );
}
}
@@ -438,21 +437,17 @@ void SvxFillToolBoxControl::Update()
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr);
XHatchList aHatchList( "", ""/*TODO?*/ );
- aHatchList.Insert( pEntry );
+ aHatchList.Insert(o3tl::make_unique<XHatchEntry>(mpHatchItem->GetHatchValue(), aTmpStr));
aHatchList.SetDirty( false );
const Bitmap aBmp = aHatchList.GetUiBitmap( 0 );
if( !aBmp.IsEmpty() )
{
- mpLbFillAttr->InsertEntry(pEntry->GetName(), Image(aBmp));
+ mpLbFillAttr->InsertEntry(aHatchList.GetHatch(0)->GetName(), Image(aBmp));
mpLbFillAttr->SelectEntryPos( mpLbFillAttr->GetEntryCount() - 1 );
//delete pBmp;
}
-
- aHatchList.Remove( 0 );
- delete pEntry;
}
}
else
@@ -501,16 +496,14 @@ void SvxFillToolBoxControl::Update()
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- std::unique_ptr<XBitmapEntry> pEntry(new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr));
XBitmapListRef xBitmapList =
XPropertyList::AsBitmapList(
XPropertyList::CreatePropertyList(
XBITMAP_LIST, "TmpList", ""/*TODO?*/));
- xBitmapList->Insert( pEntry.get() );
+ xBitmapList->Insert(o3tl::make_unique<XBitmapEntry>(mpBitmapItem->GetGraphicObject(), aTmpStr));
xBitmapList->SetDirty( false );
mpLbFillAttr->Fill( xBitmapList );
mpLbFillAttr->SelectEntryPos(mpLbFillAttr->GetEntryCount() - 1);
- xBitmapList->Remove( 0 );
}
}
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index 54c8a686e69e..9f9b34a37218 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -35,6 +35,7 @@
#include <svx/dialmgr.hxx>
#include <svx/unoapi.hxx>
#include <memory>
+#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
@@ -316,13 +317,13 @@ IMPL_LINK_NOARG_TYPED(SvxLineEndWindow, SelectHdl, ValueSet*, void)
}
else if( nId % 2 ) // beginning of line
{
- XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
- pLineStartItem.reset(new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ));
+ const XLineEndEntry* pEntry = pLineEndList->GetLineEnd( (nId - 1) / 2 - 1 );
+ pLineStartItem.reset(new XLineStartItem(pEntry->GetName(), pEntry->GetLineEnd()));
}
else // end of line
{
- XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
- pLineEndItem.reset(new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ));
+ const XLineEndEntry* pEntry = pLineEndList->GetLineEnd( (nId - 1) / 2 );
+ pLineEndItem.reset(new XLineEndItem(pEntry->GetName(), pEntry->GetLineEnd()));
}
if ( IsInPopupMode() )
@@ -359,7 +360,6 @@ void SvxLineEndWindow::FillValueSet()
{
if( pLineEndList.is() )
{
- XLineEndEntry* pEntry = nullptr;
ScopedVclPtrInstance< VirtualDevice > pVD;
long nCount = pLineEndList->Count();
@@ -367,8 +367,8 @@ void SvxLineEndWindow::FillValueSet()
// First entry: no line end.
// An entry is temporarly added to get the UI bitmap
basegfx::B2DPolyPolygon aNothing;
- pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) );
- pEntry = pLineEndList->GetLineEnd( nCount );
+ pLineEndList->Insert(o3tl::make_unique<XLineEndEntry>(aNothing, SVX_RESSTR(RID_SVXSTR_NONE)));
+ const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nCount);
Bitmap aBmp = pLineEndList->GetUiBitmap( nCount );
OSL_ENSURE( !aBmp.IsEmpty(), "UI bitmap was not created" );
@@ -382,7 +382,7 @@ void SvxLineEndWindow::FillValueSet()
aLineEndSet->InsertItem(1, Image(pVD->GetBitmap(aPt0, aBmpSize)), pEntry->GetName());
aLineEndSet->InsertItem(2, Image(pVD->GetBitmap(aPt1, aBmpSize)), pEntry->GetName());
- delete pLineEndList->Remove( nCount );
+ pLineEndList->Remove(nCount);
for( long i = 0; i < nCount; i++ )
{
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 );
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index d0c445b348c3..c0884bd9c6b2 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -178,7 +178,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
int nIndex;
for( nIndex = 0; nIndex < nCount; nIndex++ )
{
- XPropertyEntry* pEntry = pDefaults->Get(nIndex);
+ const XPropertyEntry* pEntry = pDefaults->Get(nIndex);
if( pEntry )
{
bool bFound = false;
@@ -188,25 +188,25 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
case XATTR_FILLBITMAP:
{
const GraphicObject& rGraphicObjectA(static_cast<const XFillBitmapItem*>(pCheckItem)->GetGraphicObject());
- const GraphicObject& rGraphicObjectB(static_cast<XBitmapEntry*>(pEntry)->GetGraphicObject());
+ const GraphicObject& rGraphicObjectB(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject());
bFound = (rGraphicObjectA == rGraphicObjectB);
break;
}
case XATTR_LINEDASH:
- bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<XDashEntry*>(pEntry)->GetDash();
+ bFound = static_cast<const XLineDashItem*>(pCheckItem)->GetDashValue() == static_cast<const XDashEntry*>(pEntry)->GetDash();
break;
case XATTR_LINESTART:
- bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<XLineEndEntry*>(pEntry)->GetLineEnd();
+ bFound = static_cast<const XLineStartItem*>(pCheckItem)->GetLineStartValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
break;
case XATTR_LINEEND:
- bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<XLineEndEntry*>(pEntry)->GetLineEnd();
+ bFound = static_cast<const XLineEndItem*>(pCheckItem)->GetLineEndValue() == static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd();
break;
case XATTR_FILLGRADIENT:
- bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<XGradientEntry*>(pEntry)->GetGradient();
+ bFound = static_cast<const XFillGradientItem*>(pCheckItem)->GetGradientValue() == static_cast<const XGradientEntry*>(pEntry)->GetGradient();
break;
case XATTR_FILLHATCH:
- bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<XHatchEntry*>(pEntry)->GetHatch();
+ bFound = static_cast<const XFillHatchItem*>(pCheckItem)->GetHatchValue() == static_cast<const XHatchEntry*>(pEntry)->GetHatch();
break;
}
diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx
index e0a280a14e7a..856d52a0f406 100644
--- a/svx/source/xoutdev/xtabbtmp.cxx
+++ b/svx/source/xoutdev/xtabbtmp.cxx
@@ -33,11 +33,6 @@
using namespace com::sun::star;
-XBitmapEntry* XBitmapList::Remove(long nIndex)
-{
- return static_cast<XBitmapEntry*>( XPropertyList::Remove(nIndex) );
-}
-
XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const
{
return static_cast<XBitmapEntry*>( XPropertyList::Get(nIndex) );
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index c0d911bdefe0..3d16c4d26440 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -25,6 +25,8 @@
#include <svx/xtable.hxx>
#include <svx/xpool.hxx>
+#include <o3tl/make_unique.hxx>
+
using namespace com::sun::star;
XColorListRef XColorList::CreateStdColorList()
@@ -40,16 +42,10 @@ XColorListRef XColorList::GetStdColorList()
return aTable;
}
-XColorEntry* XColorList::Replace(long nIndex, XColorEntry* pEntry )
+void XColorList::Replace(long nIndex, std::unique_ptr<XColorEntry> pEntry)
{
- return static_cast<XColorEntry*>(XPropertyList::Replace( pEntry, nIndex ));
+ XPropertyList::Replace(std::move(pEntry), nIndex);
}
-
-XColorEntry* XColorList::Remove(long nIndex)
-{
- return static_cast<XColorEntry*>(XPropertyList::Remove(nIndex));
-}
-
XColorEntry* XColorList::GetColor(long nIndex) const
{
return static_cast<XColorEntry*>( XPropertyList::Get(nIndex) );
@@ -70,18 +66,18 @@ bool XColorList::Create()
// <!-- Gray palette from white to black -->
const OUString aStrGrey( SVX_RESSTR( RID_SVXSTR_COLOR_GREY ) );
- Insert( new XColorEntry( Color( 0xff, 0xff, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_WHITE ) ) );
- Insert( new XColorEntry( Color( 0xee, 0xee, 0xee ), aStrGrey + " 1" ) );
- Insert( new XColorEntry( Color( 0xdd, 0xdd, 0xdd ), aStrGrey + " 2" ) );
- Insert( new XColorEntry( Color( 0xcc, 0xcc, 0xcc ), aStrGrey + " 3" ) );
- Insert( new XColorEntry( Color( 0xb2, 0xb2, 0xb2 ), aStrGrey + " 4" ) );
- Insert( new XColorEntry( Color( 0x99, 0x99, 0x99 ), aStrGrey + " 5" ) );
- Insert( new XColorEntry( Color( 0x80, 0x80, 0x80 ), aStrGrey + " 6" ) );
- Insert( new XColorEntry( Color( 0x66, 0x66, 0x66 ), aStrGrey + " 7" ) );
- Insert( new XColorEntry( Color( 0x33, 0x33, 0x33 ), aStrGrey + " 8" ) );
- Insert( new XColorEntry( Color( 0x1c, 0x1c, 0x1c ), aStrGrey + " 9" ) );
- Insert( new XColorEntry( Color( 0x11, 0x11, 0x11 ), aStrGrey + " 10") );
- Insert( new XColorEntry( Color( 0x00, 0x00, 0x00 ), SVX_RESSTR( RID_SVXSTR_COLOR_BLACK ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0xff, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_WHITE ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xee, 0xee, 0xee ), aStrGrey + " 1" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xdd, 0xdd, 0xdd ), aStrGrey + " 2" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xcc, 0xcc, 0xcc ), aStrGrey + " 3" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xb2, 0xb2, 0xb2 ), aStrGrey + " 4" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x99, 0x99, 0x99 ), aStrGrey + " 5" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x80, 0x80, 0x80 ), aStrGrey + " 6" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x66, 0x66, 0x66 ), aStrGrey + " 7" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x33, 0x33, 0x33 ), aStrGrey + " 8" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x1c, 0x1c, 0x1c ), aStrGrey + " 9" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x11, 0x11, 0x11 ), aStrGrey + " 10") );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x00, 0x00, 0x00 ), SVX_RESSTR( RID_SVXSTR_COLOR_BLACK ) ) );
// <!-- Base colors step 0 to 10 -->
const sal_uInt32 nNumColorsInGroup(12);
@@ -121,37 +117,37 @@ bool XColorList::Create()
for(b = 0; b < nNumColorsInGroup; b++)
{
- Insert( new XColorEntry( aStdCol[nOffset + b], aStrCol[b] + aSuffix ) );
+ Insert( o3tl::make_unique<XColorEntry>( aStdCol[nOffset + b], aStrCol[b] + aSuffix ) );
}
}
// <!-- use some 'nice' colors from original palette -->
- Insert( new XColorEntry( Color( 0xe6, 0xe6, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_BLUEGREY) ) );
- Insert( new XColorEntry( Color( 0xCF, 0xE7, 0xF5 ), SVX_RESSTR( RID_SVXSTR_COLOR_BLUE_CLASSIC ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xe6, 0xe6, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_BLUEGREY) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xCF, 0xE7, 0xF5 ), SVX_RESSTR( RID_SVXSTR_COLOR_BLUE_CLASSIC ) ) );
// <!-- add 'pale' colors from original palette -->
- Insert( new XColorEntry( Color( 0x99, 0x99, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_VIOLET ) ) );
- Insert( new XColorEntry( Color( 0x99, 0x33, 0x66 ), SVX_RESSTR( RID_SVXSTR_COLOR_BORDEAUX ) ) );
- Insert( new XColorEntry( Color( 0xff, 0xff, 0xcc ), SVX_RESSTR( RID_SVXSTR_COLOR_PALE_YELLOW ) ) );
- Insert( new XColorEntry( Color( 0xcc, 0xff, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_PALE_GREEN ) ) );
- Insert( new XColorEntry( Color( 0x66, 0x00, 0x66 ), SVX_RESSTR( RID_SVXSTR_COLOR_DARKVIOLET ) ) );
- Insert( new XColorEntry( Color( 0xff, 0x80, 0x80 ), SVX_RESSTR( RID_SVXSTR_COLOR_SALMON ) ) );
- Insert( new XColorEntry( Color( 0x00, 0x66, 0xcc ), SVX_RESSTR( RID_SVXSTR_COLOR_SEABLUE ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x99, 0x99, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_VIOLET ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x99, 0x33, 0x66 ), SVX_RESSTR( RID_SVXSTR_COLOR_BORDEAUX ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0xff, 0xcc ), SVX_RESSTR( RID_SVXSTR_COLOR_PALE_YELLOW ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xcc, 0xff, 0xff ), SVX_RESSTR( RID_SVXSTR_COLOR_PALE_GREEN ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x66, 0x00, 0x66 ), SVX_RESSTR( RID_SVXSTR_COLOR_DARKVIOLET ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0x80, 0x80 ), SVX_RESSTR( RID_SVXSTR_COLOR_SALMON ) ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x00, 0x66, 0xcc ), SVX_RESSTR( RID_SVXSTR_COLOR_SEABLUE ) ) );
// <!-- add Chart colors from original palette (also 12, coincidence?) -->
const OUString aStrChart( SVX_RESSTR( RID_SVXSTR_COLOR_CHART ) );
- Insert( new XColorEntry( Color( 0x00, 0x45, 0x86 ), aStrChart + " 1" ) );
- Insert( new XColorEntry( Color( 0xff, 0x42, 0x0e ), aStrChart + " 2" ) );
- Insert( new XColorEntry( Color( 0xff, 0xd3, 0x20 ), aStrChart + " 3" ) );
- Insert( new XColorEntry( Color( 0x57, 0x9d, 0x1c ), aStrChart + " 4" ) );
- Insert( new XColorEntry( Color( 0x7e, 0x00, 0x21 ), aStrChart + " 5" ) );
- Insert( new XColorEntry( Color( 0x83, 0xca, 0xff ), aStrChart + " 6" ) );
- Insert( new XColorEntry( Color( 0x31, 0x40, 0x04 ), aStrChart + " 7" ) );
- Insert( new XColorEntry( Color( 0xae, 0xcf, 0x00 ), aStrChart + " 8" ) );
- Insert( new XColorEntry( Color( 0x4b, 0x1f, 0x6f ), aStrChart + " 9" ) );
- Insert( new XColorEntry( Color( 0xff, 0x95, 0x0e ), aStrChart + " 10" ) );
- Insert( new XColorEntry( Color( 0xc5, 0x00, 0x0b ), aStrChart + " 11" ) );
- Insert( new XColorEntry( Color( 0x00, 0x84, 0xd1 ), aStrChart + " 12" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x00, 0x45, 0x86 ), aStrChart + " 1" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0x42, 0x0e ), aStrChart + " 2" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0xd3, 0x20 ), aStrChart + " 3" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x57, 0x9d, 0x1c ), aStrChart + " 4" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x7e, 0x00, 0x21 ), aStrChart + " 5" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x83, 0xca, 0xff ), aStrChart + " 6" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x31, 0x40, 0x04 ), aStrChart + " 7" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xae, 0xcf, 0x00 ), aStrChart + " 8" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x4b, 0x1f, 0x6f ), aStrChart + " 9" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xff, 0x95, 0x0e ), aStrChart + " 10" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0xc5, 0x00, 0x0b ), aStrChart + " 11" ) );
+ Insert( o3tl::make_unique<XColorEntry>( Color( 0x00, 0x84, 0xd1 ), aStrChart + " 12" ) );
return(165 == Count());
}
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index 1dee829d276a..817f115563a8 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -32,6 +32,7 @@
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <memory>
+#include <o3tl/make_unique.hxx>
using namespace com::sun::star;
@@ -47,14 +48,9 @@ XDashList::~XDashList()
{
}
-XDashEntry* XDashList::Replace(XDashEntry* pEntry, long nIndex )
+void XDashList::Replace(std::unique_ptr<XDashEntry> pEntry, long nIndex)
{
- return static_cast<XDashEntry*>( XPropertyList::Replace(pEntry, nIndex) );
-}
-
-XDashEntry* XDashList::Remove(long nIndex)
-{
- return static_cast<XDashEntry*>( XPropertyList::Remove(nIndex) );
+ XPropertyList::Replace(std::move(pEntry), nIndex);
}
XDashEntry* XDashList::GetDash(long nIndex) const
@@ -72,9 +68,9 @@ bool XDashList::Create()
{
const OUString aStr(SVX_RESSTR(RID_SVXSTR_LINESTYLE));
- Insert(new XDashEntry(XDash(css::drawing::DashStyle_RECT,1, 50,1, 50, 50),aStr + " 1"));
- Insert(new XDashEntry(XDash(css::drawing::DashStyle_RECT,1,500,1,500,500),aStr + " 2"));
- Insert(new XDashEntry(XDash(css::drawing::DashStyle_RECT,2, 50,3,250,120),aStr + " 3"));
+ Insert(o3tl::make_unique<XDashEntry>(XDash(css::drawing::DashStyle_RECT,1, 50,1, 50, 50),aStr + " 1"));
+ Insert(o3tl::make_unique<XDashEntry>(XDash(css::drawing::DashStyle_RECT,1,500,1,500,500),aStr + " 2"));
+ Insert(o3tl::make_unique<XDashEntry>(XDash(css::drawing::DashStyle_RECT,2, 50,3,250,120),aStr + " 3"));
return true;
}
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index b8c25e2e9a7a..78c358558e27 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -33,6 +33,7 @@
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <memory>
+#include <o3tl/make_unique.hxx>
using namespace com::sun::star;
@@ -45,14 +46,9 @@ XGradientList::~XGradientList()
{
}
-XGradientEntry* XGradientList::Replace(XGradientEntry* pEntry, long nIndex )
+void XGradientList::Replace(std::unique_ptr<XGradientEntry> pEntry, long nIndex)
{
- return static_cast<XGradientEntry*>( XPropertyList::Replace( pEntry, nIndex ) );
-}
-
-XGradientEntry* XGradientList::Remove(long nIndex)
-{
- return static_cast<XGradientEntry*>( XPropertyList::Remove( nIndex ) );
+ XPropertyList::Replace(std::move(pEntry), nIndex);
}
XGradientEntry* XGradientList::GetGradient(long nIndex) const
@@ -72,17 +68,17 @@ bool XGradientList::Create()
rtl::OUStringBuffer aStr(SVX_RESSTR(RID_SVXSTR_GRADIENT));
aStr.append(" 1");
sal_Int32 nLen = aStr.getLength() - 1;
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLACK ),RGB_Color(COL_WHITE ),css::awt::GradientStyle_LINEAR , 0,10,10, 0,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_BLACK ),RGB_Color(COL_WHITE ),css::awt::GradientStyle_LINEAR , 0,10,10, 0,100,100),aStr.toString()));
aStr[nLen] = '2';
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLUE ),RGB_Color(COL_RED ),css::awt::GradientStyle_AXIAL , 300,20,20,10,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_BLUE ),RGB_Color(COL_RED ),css::awt::GradientStyle_AXIAL , 300,20,20,10,100,100),aStr.toString()));
aStr[nLen] = '3';
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_RED ),RGB_Color(COL_YELLOW ),css::awt::GradientStyle_RADIAL , 600,30,30,20,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_RED ),RGB_Color(COL_YELLOW ),css::awt::GradientStyle_RADIAL , 600,30,30,20,100,100),aStr.toString()));
aStr[nLen] = '4';
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN ),css::awt::GradientStyle_ELLIPTICAL, 900,40,40,30,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN ),css::awt::GradientStyle_ELLIPTICAL, 900,40,40,30,100,100),aStr.toString()));
aStr[nLen] = '5';
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_GREEN ),RGB_Color(COL_MAGENTA),css::awt::GradientStyle_SQUARE , 1200,50,50,40,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_GREEN ),RGB_Color(COL_MAGENTA),css::awt::GradientStyle_SQUARE , 1200,50,50,40,100,100),aStr.toString()));
aStr[nLen] = '6';
- Insert(new XGradientEntry(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),css::awt::GradientStyle_RECT , 1900,60,60,50,100,100),aStr.toString()));
+ Insert(o3tl::make_unique<XGradientEntry>(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),css::awt::GradientStyle_RECT , 1900,60,60,50,100,100),aStr.toString()));
return true;
}
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index 78869c87d5fa..a5227ba7b2b2 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -32,6 +32,7 @@
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <memory>
+#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star;
@@ -44,14 +45,9 @@ XHatchList::~XHatchList()
{
}
-XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex )
+void XHatchList::Replace(std::unique_ptr<XHatchEntry> pEntry, long nIndex)
{
- return static_cast<XHatchEntry*>( XPropertyList::Replace(pEntry, nIndex) );
-}
-
-XHatchEntry* XHatchList::Remove(long nIndex)
-{
- return static_cast<XHatchEntry*>( XPropertyList::Remove(nIndex) );
+ XPropertyList::Replace(std::move(pEntry), nIndex);
}
XHatchEntry* XHatchList::GetHatch(long nIndex) const
@@ -71,11 +67,11 @@ bool XHatchList::Create()
aStr.append(" 1");
sal_Int32 nLen = aStr.getLength() - 1;
- Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),css::drawing::HatchStyle_SINGLE,100, 0),aStr.toString()));
+ Insert(o3tl::make_unique<XHatchEntry>(XHatch(RGB_Color(COL_BLACK),css::drawing::HatchStyle_SINGLE,100, 0),aStr.toString()));
aStr[nLen] = '2';
- Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED ),css::drawing::HatchStyle_DOUBLE, 80,450),aStr.toString()));
+ Insert(o3tl::make_unique<XHatchEntry>(XHatch(RGB_Color(COL_RED ),css::drawing::HatchStyle_DOUBLE, 80,450),aStr.toString()));
aStr[nLen] = '3';
- Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),css::drawing::HatchStyle_TRIPLE,120, 0),aStr.toString()));
+ Insert(o3tl::make_unique<XHatchEntry>(XHatch(RGB_Color(COL_BLUE ),css::drawing::HatchStyle_TRIPLE,120, 0),aStr.toString()));
return true;
}
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
index aebf849ccd74..e8c9d825848a 100644
--- a/svx/source/xoutdev/xtable.cxx
+++ b/svx/source/xoutdev/xtable.cxx
@@ -123,13 +123,14 @@ XPropertyList::XPropertyList(
// fprintf (stderr, "Create type %d count %d\n", (int)meType, count++);
}
-XPropertyList::~XPropertyList()
+bool XPropertyList::isValidIdx(long nIndex) const
{
-// fprintf (stderr, "Destroy type %d count %d\n", (int)meType, --count);
- for(XPropertyEntry* p : maList)
- delete p;
+ return ((size_t)nIndex < maList.size() && nIndex >= 0);
+}
+
- maList.clear();
+XPropertyList::~XPropertyList()
+{
}
long XPropertyList::Count() const
@@ -149,7 +150,10 @@ XPropertyEntry* XPropertyList::Get( long nIndex ) const
if( !const_cast<XPropertyList*>(this)->Load() )
const_cast<XPropertyList*>(this)->Create();
}
- return ( (size_t)nIndex < maList.size() ) ? maList[ nIndex ] : nullptr;
+ if (!isValidIdx(nIndex))
+ return nullptr;
+
+ return maList[nIndex].get();
}
long XPropertyList::GetIndex(const OUString& rName) const
@@ -171,46 +175,60 @@ long XPropertyList::GetIndex(const OUString& rName) const
Bitmap XPropertyList::GetUiBitmap( long nIndex ) const
{
Bitmap aRetval;
- XPropertyEntry* pEntry = ( (size_t)nIndex < maList.size() ) ? maList[ nIndex ] : nullptr;
- if(pEntry)
- {
- aRetval = pEntry->GetUiBitmap();
+ if (!isValidIdx(nIndex))
+ return aRetval;
- if(aRetval.IsEmpty())
- {
- aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
- pEntry->SetUiBitmap(aRetval);
- }
+ XPropertyEntry* pEntry = maList[nIndex].get();
+ aRetval = pEntry->GetUiBitmap();
+
+ if(aRetval.IsEmpty())
+ {
+ aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
+ pEntry->SetUiBitmap(aRetval);
}
return aRetval;
}
-void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
+void XPropertyList::Insert(std::unique_ptr<XPropertyEntry> pEntry, long nIndex)
{
- if ( (size_t)nIndex < maList.size() ) {
- maList.insert( maList.begin() + nIndex, pEntry );
+ if (!pEntry)
+ {
+ assert("empty XPropertyEntry not allowed in XPropertyList");
+ return;
+ }
+
+ if (isValidIdx(nIndex)) {
+ maList.insert( maList.begin()+nIndex, std::move(pEntry) );
} else {
- maList.push_back( pEntry );
+ maList.push_back( std::move(pEntry) );
}
}
-XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
+void XPropertyList::Replace(std::unique_ptr<XPropertyEntry> pEntry, long nIndex)
{
- XPropertyEntry* pOldEntry = (size_t)nIndex < maList.size() ? maList[ nIndex ] : nullptr;
- if ( pOldEntry ) {
- maList[ nIndex ] = pEntry;
+ if (!pEntry)
+ {
+ assert("empty XPropertyEntry not allowed in XPropertyList");
+ return;
}
- return pOldEntry;
+ if (!isValidIdx(nIndex))
+ {
+ assert("trying to replace invalid entry in XPropertyList");
+ return;
+ }
+
+ maList[nIndex] = std::move(pEntry);
}
-XPropertyEntry* XPropertyList::Remove( long nIndex )
+void XPropertyList::Remove(long nIndex)
{
- XPropertyEntry* pEntry = nullptr;
- if ( (size_t)nIndex < maList.size() ) {
- pEntry = maList[ nIndex ];
- maList.erase( maList.begin() + nIndex );
+ if (!isValidIdx(nIndex))
+ {
+ assert("trying to remove invalid entry in XPropertyList");
+ return;
}
- return pEntry;
+
+ maList.erase(maList.begin() + nIndex);
}
void XPropertyList::SetName( const OUString& rString )
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index d27a9c6886c4..988bcb8edfa1 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -32,6 +32,7 @@
#include <drawinglayer/processor2d/processor2dtools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <memory>
+#include <o3tl/make_unique.hxx>
using namespace com::sun::star;
@@ -44,11 +45,6 @@ XLineEndList::~XLineEndList()
{
}
-XLineEndEntry* XLineEndList::Remove(long nIndex)
-{
- return static_cast<XLineEndEntry*>( XPropertyList::Remove(nIndex) );
-}
-
XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
{
return static_cast<XLineEndEntry*>( XPropertyList::Get(nIndex) );
@@ -67,7 +63,7 @@ bool XLineEndList::Create()
aTriangle.append(basegfx::B2DPoint(0.0, 30.0));
aTriangle.append(basegfx::B2DPoint(20.0, 30.0));
aTriangle.setClosed(true);
- Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
+ Insert( o3tl::make_unique<XLineEndEntry>( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
basegfx::B2DPolygon aSquare;
aSquare.append(basegfx::B2DPoint(0.0, 0.0));
@@ -75,10 +71,10 @@ bool XLineEndList::Create()
aSquare.append(basegfx::B2DPoint(10.0, 10.0));
aSquare.append(basegfx::B2DPoint(0.0, 10.0));
aSquare.setClosed(true);
- Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
+ Insert( o3tl::make_unique<XLineEndEntry>( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0));
- Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
+ Insert( o3tl::make_unique<XLineEndEntry>( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
return true;
}
diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx
index aaa343de2a6e..f0c16f0e6909 100644
--- a/svx/source/xoutdev/xtabptrn.cxx
+++ b/svx/source/xoutdev/xtabptrn.cxx
@@ -30,12 +30,9 @@
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-using namespace com::sun::star;
+#include <o3tl/make_unique.hxx>
-XBitmapEntry* XPatternList::Remove(long nIndex)
-{
- return static_cast<XBitmapEntry*>( XPropertyList::Remove(nIndex) );
-}
+using namespace com::sun::star;
XBitmapEntry* XPatternList::GetBitmap(long nIndex) const
{
@@ -60,28 +57,28 @@ bool XPatternList::Create()
// white/white bitmap
aStr.append(" 1");
aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_WHITE), RGB_Color(COL_WHITE));
- Insert(new XBitmapEntry(Graphic(aBitmap), aStr.toString()));
+ Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
// black/white bitmap
aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
aStr[nLen] = '2';
aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
- Insert(new XBitmapEntry(Graphic(aBitmap), aStr.toString()));
+ Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
// lightred/white bitmap
aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
aStr[nLen] = '3';
aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTRED), RGB_Color(COL_WHITE));
- Insert(new XBitmapEntry(Graphic(aBitmap), aStr.toString()));
+ Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
// lightblue/white bitmap
aArray[24] = 1; aArray[25] = 1; aArray[26] = 1;
aArray[29] = 1; aArray[30] = 1; aArray[31] = 1;
aStr[nLen] = '4';
aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTBLUE), RGB_Color(COL_WHITE));
- Insert(new XBitmapEntry(Graphic(aBitmap), aStr.toString()));
+ Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
return true;
}