summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-25 08:07:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-25 09:23:39 +0200
commit37a5d60df7631cca8ce597905d09748a48ff2a86 (patch)
tree952f0321867527e738f9e25d2abcc64c528e8077 /svx
parentb6e0ae1b1bad5e222e21bbb4b2a158c1fc6f9779 (diff)
SvxUnoXPropertyTable is never passed a null ptr
and make the type of the constructor functions more precise to avoid unnecessary UNO_QUERY at the call site Change-Id: I8164fd3df131720cf86eaf6d49735a3157d3cc97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134914 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/XPropertyTable.hxx14
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx62
-rw-r--r--svx/source/xoutdev/xtabbtmp.cxx3
-rw-r--r--svx/source/xoutdev/xtabcolr.cxx4
-rw-r--r--svx/source/xoutdev/xtabdash.cxx3
-rw-r--r--svx/source/xoutdev/xtabgrdt.cxx4
-rw-r--r--svx/source/xoutdev/xtabhtch.cxx3
-rw-r--r--svx/source/xoutdev/xtablend.cxx3
-rw-r--r--svx/source/xoutdev/xtabptrn.cxx3
9 files changed, 42 insertions, 57 deletions
diff --git a/svx/inc/XPropertyTable.hxx b/svx/inc/XPropertyTable.hxx
index 19da2a0b524a..e9f76965ef36 100644
--- a/svx/inc/XPropertyTable.hxx
+++ b/svx/inc/XPropertyTable.hxx
@@ -19,17 +19,17 @@
#pragma once
-#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
#include <svx/xtable.hxx>
// FIXME: should have a single factory method with an enumeration here [!]
-css::uno::Reference< css::uno::XInterface > SvxUnoXColorTable_createInstance( XPropertyList* pList ) noexcept;
-css::uno::Reference< css::uno::XInterface > SvxUnoXLineEndTable_createInstance( XPropertyList* pList ) noexcept;
-css::uno::Reference< css::uno::XInterface > SvxUnoXDashTable_createInstance( XPropertyList* pList ) noexcept;
-css::uno::Reference< css::uno::XInterface > SvxUnoXHatchTable_createInstance( XPropertyList* pList ) noexcept;
-css::uno::Reference< css::uno::XInterface > SvxUnoXGradientTable_createInstance( XPropertyList* pList ) noexcept;
-css::uno::Reference< css::uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyList* pList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXColorTable_createInstance( XPropertyList& rList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXLineEndTable_createInstance( XPropertyList& rList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXDashTable_createInstance( XPropertyList& rList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXHatchTable_createInstance( XPropertyList& rList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXGradientTable_createInstance( XPropertyList& rList ) noexcept;
+css::uno::Reference< css::container::XNameContainer > SvxUnoXBitmapTable_createInstance( XPropertyList& rList ) noexcept;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx
index 9455f1fe4069..56bb135237f8 100644
--- a/svx/source/unodraw/XPropertyTable.cxx
+++ b/svx/source/unodraw/XPropertyTable.cxx
@@ -46,13 +46,13 @@ namespace {
class SvxUnoXPropertyTable : public WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
{
private:
- XPropertyList* mpList;
+ XPropertyList& mrList;
sal_Int16 mnWhich;
- tools::Long getCount() const { return mpList ? mpList->Count() : 0; }
+ tools::Long getCount() const { return mrList.Count(); }
const XPropertyEntry* get(tools::Long index) const;
public:
- SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) noexcept;
+ SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList& rList ) noexcept;
/// @throws uno::RuntimeException
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const = 0;
@@ -81,17 +81,14 @@ public:
}
-SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) noexcept
-: mpList( pList ), mnWhich( nWhich )
+SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList& rList ) noexcept
+: mrList( rList ), mnWhich( nWhich )
{
}
const XPropertyEntry* SvxUnoXPropertyTable::get(tools::Long index) const
{
- if( mpList )
- return mpList->Get(index);
- else
- return nullptr;
+ return mrList.Get(index);
}
// XServiceInfo
@@ -105,9 +102,6 @@ void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const
{
SolarMutexGuard aGuard;
- if( nullptr == mpList )
- throw lang::IllegalArgumentException();
-
if( hasByName( aName ) )
throw container::ElementExistException();
@@ -117,7 +111,7 @@ void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const
if (!pNewEntry)
throw lang::IllegalArgumentException();
- mpList->Insert(std::move(pNewEntry));
+ mrList.Insert(std::move(pNewEntry));
}
void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
@@ -133,7 +127,7 @@ void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
const XPropertyEntry* pEntry = get(i);
if (pEntry && aInternalName == pEntry->GetName())
{
- mpList->Remove(i);
+ mrList.Remove(i);
return;
}
}
@@ -159,7 +153,7 @@ void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const
if (!pNewEntry)
throw lang::IllegalArgumentException();
- mpList->Replace(std::move(pNewEntry), i);
+ mrList.Replace(std::move(pNewEntry), i);
return;
}
}
@@ -212,7 +206,7 @@ sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
- const tools::Long nCount = mpList?mpList->Count():0;
+ const tools::Long nCount = mrList.Count();
tools::Long i;
for( i = 0; i < nCount; i++ )
{
@@ -237,7 +231,7 @@ namespace {
class SvxUnoXColorTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXColorTable( XPropertyList* pList ) noexcept : SvxUnoXPropertyTable( XATTR_LINECOLOR, pList ) {};
+ explicit SvxUnoXColorTable( XPropertyList& rList ) noexcept : SvxUnoXPropertyTable( XATTR_LINECOLOR, rList ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const noexcept override;
@@ -253,9 +247,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXColorTable_createInstance( XPropertyList* pList ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXColorTable_createInstance( XPropertyList& rList ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXColorTable( pList ));
+ return new SvxUnoXColorTable( rList );
}
// SvxUnoXPropertyTable
@@ -295,7 +289,7 @@ namespace {
class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXLineEndTable( XPropertyList* pTable ) noexcept : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
+ explicit SvxUnoXLineEndTable( XPropertyList& rTable ) noexcept : SvxUnoXPropertyTable( XATTR_LINEEND, rTable ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const noexcept override;
@@ -311,9 +305,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXLineEndTable_createInstance( XPropertyList& rTable ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXLineEndTable( pTable ));
+ return new SvxUnoXLineEndTable( rTable );
}
// SvxUnoXPropertyTable
@@ -363,7 +357,7 @@ namespace {
class SvxUnoXDashTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXDashTable( XPropertyList* pTable ) noexcept : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
+ explicit SvxUnoXDashTable( XPropertyList& rTable ) noexcept : SvxUnoXPropertyTable( XATTR_LINEDASH, rTable ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const noexcept override;
@@ -379,9 +373,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXDashTable_createInstance( XPropertyList* pTable ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXDashTable_createInstance( XPropertyList& rTable ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXDashTable( pTable ));
+ return new SvxUnoXDashTable( rTable );
}
// SvxUnoXPropertyTable
@@ -441,7 +435,7 @@ namespace {
class SvxUnoXHatchTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXHatchTable( XPropertyList* pTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
+ explicit SvxUnoXHatchTable( XPropertyList& rTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLHATCH, rTable ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const noexcept override;
@@ -457,9 +451,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXHatchTable_createInstance( XPropertyList& rTable ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXHatchTable( pTable ));
+ return new SvxUnoXHatchTable( rTable );
}
// SvxUnoXPropertyTable
@@ -514,7 +508,7 @@ namespace {
class SvxUnoXGradientTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXGradientTable( XPropertyList* pTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
+ explicit SvxUnoXGradientTable( XPropertyList& rTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, rTable ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const noexcept override;
@@ -530,9 +524,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXGradientTable_createInstance( XPropertyList& rTable ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXGradientTable( pTable ));
+ return new SvxUnoXGradientTable( rTable );
}
// SvxUnoXPropertyTable
@@ -599,7 +593,7 @@ namespace {
class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
{
public:
- explicit SvxUnoXBitmapTable( XPropertyList* pTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
+ explicit SvxUnoXBitmapTable( XPropertyList& rTable ) noexcept : SvxUnoXPropertyTable( XATTR_FILLBITMAP, rTable ) {};
// SvxUnoXPropertyTable
virtual uno::Any getAny( const XPropertyEntry* pEntry ) const override;
@@ -615,9 +609,9 @@ public:
}
-uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) noexcept
+uno::Reference< container::XNameContainer > SvxUnoXBitmapTable_createInstance( XPropertyList& rTable ) noexcept
{
- return static_cast<OWeakObject*>(new SvxUnoXBitmapTable( pTable ));
+ return new SvxUnoXBitmapTable( rTable );
}
// SvxUnoXPropertyTable
diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx
index fd1b7dfdadb7..178ba8ab2db4 100644
--- a/svx/source/xoutdev/xtabbtmp.cxx
+++ b/svx/source/xoutdev/xtabbtmp.cxx
@@ -35,8 +35,7 @@ XBitmapEntry* XBitmapList::GetBitmap(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XBitmapList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxUnoXBitmapTable_createInstance( *this );
}
bool XBitmapList::Create()
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index 67e963ce92a6..e952d6f8a44f 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -54,9 +54,7 @@ XColorEntry* XColorList::GetColor(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XColorList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXColorTable_createInstance( this ),
- uno::UNO_QUERY );
+ return SvxUnoXColorTable_createInstance( *this );
}
bool XColorList::Create()
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index b0dcced37322..da5ec20a3bdf 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -60,8 +60,7 @@ XDashEntry* XDashList::GetDash(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XDashList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxUnoXDashTable_createInstance( *this );
}
bool XDashList::Create()
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index 94bda61ffa2e..3d2acb574c3c 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -60,9 +60,7 @@ XGradientEntry* XGradientList::GetGradient(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XGradientList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXGradientTable_createInstance( this ),
- uno::UNO_QUERY );
+ return SvxUnoXGradientTable_createInstance( *this );
}
bool XGradientList::Create()
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index 44824cb08289..4fc97727b0cc 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -59,8 +59,7 @@ XHatchEntry* XHatchList::GetHatch(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XHatchList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxUnoXHatchTable_createInstance( *this );
}
bool XHatchList::Create()
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index 50fc240a60ab..fcca059601e5 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -53,8 +53,7 @@ XLineEndEntry* XLineEndList::GetLineEnd(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XLineEndList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxUnoXLineEndTable_createInstance( *this );
}
bool XLineEndList::Create()
diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx
index 8d461167a87a..29697880f07f 100644
--- a/svx/source/xoutdev/xtabptrn.cxx
+++ b/svx/source/xoutdev/xtabptrn.cxx
@@ -37,8 +37,7 @@ XBitmapEntry* XPatternList::GetBitmap(tools::Long nIndex) const
uno::Reference< container::XNameContainer > XPatternList::createInstance()
{
- return uno::Reference< container::XNameContainer >(
- SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxUnoXBitmapTable_createInstance( *this );
}
bool XPatternList::Create()