summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-02 14:30:18 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-03 08:29:41 +0100
commitc80be30203b842c7b6d3145200b120cefb452cb8 (patch)
treee9b519886eb1282e33279523b5ac7112d18e65e7 /basic
parent39d5ba2fda01ffe56c8bcc0c5dbbb2b7d1bdf0fe (diff)
coverity#706241 Uncaught exception
we've already checked to see if the element exists, so we know that its not there. Change-Id: I538c0d48a883d478e4c748d222b21958d083c049
Diffstat (limited to 'basic')
-rw-r--r--basic/source/inc/namecont.hxx11
-rw-r--r--basic/source/uno/namecont.cxx29
2 files changed, 31 insertions, 9 deletions
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 6355549bd162..bcbd245dc0ec 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -96,6 +96,17 @@ public:
void setEventSource( ::com::sun::star::uno::XInterface* pxEventSource )
{ mpxEventSource = pxEventSource; }
+ void insertCheck(const OUString& aName, const css::uno::Any& aElement)
+ throw (css::lang::IllegalArgumentException,
+ css::container::ElementExistException,
+ css::lang::WrappedTargetException,
+ css::uno::RuntimeException, std::exception);
+
+ void insertNoCheck(const OUString& aName, const css::uno::Any& aElement)
+ throw (css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException,
+ css::uno::RuntimeException, std::exception);
+
// Methods XElementAccess
virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index de2b91a6b356..ac353509e6c4 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -186,21 +186,25 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement )
}
}
-
-// Methods XNameContainer
-void NameContainer::insertByName( const OUString& aName, const Any& aElement )
+void NameContainer::insertCheck(const OUString& aName, const Any& aElement)
throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
{
+ NameContainerNameMap::iterator aIt = mHashMap.find(aName);
+ if( aIt != mHashMap.end() )
+ {
+ throw ElementExistException();
+ }
+ insertNoCheck(aName, aElement);
+}
+
+void NameContainer::insertNoCheck(const OUString& aName, const Any& aElement)
+ throw(IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
+{
Type aAnyType = aElement.getValueType();
if( mType != aAnyType )
{
throw IllegalArgumentException();
}
- NameContainerNameMap::iterator aIt = mHashMap.find( aName );
- if( aIt != mHashMap.end() )
- {
- throw ElementExistException();
- }
sal_Int32 nCount = mNames.getLength();
mNames.realloc( nCount + 1 );
@@ -236,6 +240,13 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement )
}
}
+// Methods XNameContainer
+void NameContainer::insertByName( const OUString& aName, const Any& aElement )
+ throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception)
+{
+ insertCheck(aName, aElement);
+}
+
void NameContainer::removeByName( const OUString& aName )
throw(NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
{
@@ -2492,7 +2503,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
}
else
{
- pImplLib->maNameContainer.insertByName( aElementName, aAny );
+ pImplLib->maNameContainer.insertNoCheck(aElementName, aAny);
}
}
pImplLib->implSetModified( false );