summaryrefslogtreecommitdiff
path: root/oox/source/helper
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2008-07-22 13:00:42 +0000
committerOliver Bolte <obo@openoffice.org>2008-07-22 13:00:42 +0000
commit64a05deaa91e0ccbf6c1f2ee56dab2ae13713b9e (patch)
tree1db540e2de31ade93ee3a5066689eebd1e7cd91f /oox/source/helper
parent7242a67ed6b7b9142b584da105c6fcf77ba5a44d (diff)
INTEGRATION: CWS xmlfilter06 (1.3.8); FILE MERGED
2008/06/26 14:16:00 dr 1.3.8.2: handle drawing object tables separated for chart import, extended line formatting with own property name sets 2008/06/09 15:16:13 dr 1.3.8.1: more chart line formatting, add line dashs to chart dash container
Diffstat (limited to 'oox/source/helper')
-rw-r--r--oox/source/helper/containerhelper.cxx72
1 files changed, 67 insertions, 5 deletions
diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx
index 2f4f32a24b77..9d4327e12d31 100644
--- a/oox/source/helper/containerhelper.cxx
+++ b/oox/source/helper/containerhelper.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: containerhelper.cxx,v $
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
* This file is part of OpenOffice.org.
*
@@ -115,13 +115,16 @@ OUString ContainerHelper::getUnusedName(
bool ContainerHelper::insertByName(
const Reference< XNameContainer >& rxNameContainer,
- const OUString& rName, const Any& rObject )
+ const OUString& rName, const Any& rObject, bool bReplaceOldExisting )
{
OSL_ENSURE( rxNameContainer.is(), "ContainerHelper::insertByName - missing XNameContainer interface" );
bool bRet = false;
try
{
- rxNameContainer->insertByName( rName, rObject );
+ if( bReplaceOldExisting && rxNameContainer->hasByName( rName ) )
+ rxNameContainer->replaceByName( rName, rObject );
+ else
+ rxNameContainer->insertByName( rName, rObject );
bRet = true;
}
catch( Exception& )
@@ -132,8 +135,9 @@ bool ContainerHelper::insertByName(
}
OUString ContainerHelper::insertByUnusedName(
- const Reference< XNameContainer >& rxNameContainer, const Any& rObject,
- const OUString& rSuggestedName, sal_Unicode cSeparator, bool bRenameOldExisting )
+ const Reference< XNameContainer >& rxNameContainer,
+ const OUString& rSuggestedName, sal_Unicode cSeparator,
+ const Any& rObject, bool bRenameOldExisting )
{
OSL_ENSURE( rxNameContainer.is(), "ContainerHelper::insertByUnusedName - missing XNameContainer interface" );
@@ -164,5 +168,63 @@ OUString ContainerHelper::insertByUnusedName(
// ============================================================================
+ObjectContainer::ObjectContainer( const Reference< XMultiServiceFactory >& rxFactory, const OUString& rServiceName ) :
+ mxFactory( rxFactory ),
+ maServiceName( rServiceName ),
+ mnIndex( 0 )
+{
+ OSL_ENSURE( mxFactory.is(), "ObjectContainer::ObjectContainer - missing service factory" );
+}
+
+ObjectContainer::~ObjectContainer()
+{
+}
+
+bool ObjectContainer::hasObject( const OUString& rObjName ) const
+{
+ createContainer();
+ return mxContainer.is() && mxContainer->hasByName( rObjName );
+}
+
+Any ObjectContainer::getObject( const OUString& rObjName ) const
+{
+ createContainer();
+ if( mxContainer.is() ) try
+ {
+ return mxContainer->getByName( rObjName );
+ }
+ catch( Exception& )
+ {
+ }
+ return Any();
+}
+
+OUString ObjectContainer::insertObject( const OUString& rObjName, const Any& rObj, bool bInsertByUnusedName )
+{
+ createContainer();
+ if( mxContainer.is() )
+ {
+ if( bInsertByUnusedName )
+ return ContainerHelper::insertByUnusedName( mxContainer, rObjName + OUString::valueOf( ++mnIndex ), ' ', rObj );
+ if( ContainerHelper::insertByName( mxContainer, rObjName, rObj ) )
+ return rObjName;
+ }
+ return OUString();
+}
+
+void ObjectContainer::createContainer() const
+{
+ if( !mxContainer.is() && mxFactory.is() ) try
+ {
+ mxContainer.set( mxFactory->createInstance( maServiceName ), UNO_QUERY_THROW );
+ }
+ catch( Exception& )
+ {
+ }
+ OSL_ENSURE( mxContainer.is(), "ObjectContainer::createContainer - container not found" );
+}
+
+// ============================================================================
+
} // namespace oox