diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-11-09 10:52:14 +0100 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-11-09 10:52:14 +0100 |
commit | 32bb320ed0e4c52a7adf84d13a8066877adceb54 (patch) | |
tree | 4b191cf382c6603b1dfb3a71e12622b7b3e8b562 /oox/source/helper | |
parent | bf9cd246dc431e20181cfec8107e3b7c59866281 (diff) |
dr77: more cleanup: remove RecordInputStream, cleanup ContainerHelper
Diffstat (limited to 'oox/source/helper')
-rw-r--r-- | oox/source/helper/containerhelper.cxx | 58 | ||||
-rw-r--r-- | oox/source/helper/modelobjecthelper.cxx | 60 | ||||
-rw-r--r-- | oox/source/helper/recordinputstream.cxx | 72 |
3 files changed, 60 insertions, 130 deletions
diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx index 4d41d9924326..e7f322ff10e3 100644 --- a/oox/source/helper/containerhelper.cxx +++ b/oox/source/helper/containerhelper.cxx @@ -160,62 +160,4 @@ 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 diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx index f9b6b066230a..7fdbe4b38134 100644 --- a/oox/source/helper/modelobjecthelper.cxx +++ b/oox/source/helper/modelobjecthelper.cxx @@ -28,9 +28,11 @@ #include "oox/helper/modelobjecthelper.hxx" #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include "oox/helper/containerhelper.hxx" #include "oox/helper/helper.hxx" namespace oox { @@ -46,6 +48,64 @@ using ::rtl::OUString; // ============================================================================ +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" ); +} + +// ============================================================================ + ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxModelFactory ) : maMarkerContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ), maDashContainer( rxModelFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ), diff --git a/oox/source/helper/recordinputstream.cxx b/oox/source/helper/recordinputstream.cxx deleted file mode 100644 index a746eef47d73..000000000000 --- a/oox/source/helper/recordinputstream.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/helper/recordinputstream.hxx" - -#include <vector> - -namespace oox { - -// ============================================================================ - -using ::rtl::OUString; - -// ============================================================================ - -RecordInputStream::RecordInputStream( const StreamDataSequence& rData ) : - SequenceInputStream( rData ) -{ -} - -OUString RecordInputStream::readString( bool b32BitLen ) -{ - OUString aString; - if( !isEof() ) - { - sal_Int32 nCharCount = b32BitLen ? readValue< sal_Int32 >() : readValue< sal_Int16 >(); - // string length -1 is often used to indicate a missing string - OSL_ENSURE( !isEof() && (nCharCount >= -1), "RecordInputStream::readString - invalid string length" ); - if( !isEof() && (nCharCount > 0) ) - { - ::std::vector< sal_Unicode > aBuffer; - aBuffer.reserve( getLimitedValue< size_t, sal_Int32 >( nCharCount + 1, 0, 0xFFFF ) ); - for( sal_Int32 nCharIdx = 0; !isEof() && (nCharIdx < nCharCount); ++nCharIdx ) - { - sal_uInt16 nChar; - readValue( nChar ); - aBuffer.push_back( static_cast< sal_Unicode >( nChar ) ); - } - aBuffer.push_back( 0 ); - aString = OUString( &aBuffer.front() ); - } - } - return aString; -} - -// ============================================================================ - -} // namespace oox |