diff options
-rw-r--r-- | svx/source/unodraw/UnoNameItemTable.cxx | 367 | ||||
-rw-r--r-- | svx/source/unodraw/UnoNameItemTable.hxx | 124 | ||||
-rw-r--r-- | svx/source/unodraw/makefile.mk | 6 | ||||
-rw-r--r-- | svx/source/unodraw/unobtabl.cxx | 201 | ||||
-rw-r--r-- | svx/source/unodraw/unodtabl.cxx | 224 | ||||
-rw-r--r-- | svx/source/unodraw/unogtabl.cxx | 208 | ||||
-rw-r--r-- | svx/source/unodraw/unohtabl.cxx | 190 | ||||
-rw-r--r-- | svx/source/unodraw/unomtabl.cxx | 299 | ||||
-rw-r--r-- | svx/source/unodraw/unottabl.cxx | 179 |
9 files changed, 753 insertions, 1045 deletions
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx new file mode 100644 index 000000000000..f68f3f492b5b --- /dev/null +++ b/svx/source/unodraw/UnoNameItemTable.cxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * $RCSfile: UnoNameItemTable.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SFXITEMPOOL_HXX +#include <svtools/itempool.hxx> +#endif + +#ifndef _SFXITEMSET_HXX //autogen +#include <svtools/itemset.hxx> +#endif + +#ifndef _SFXSTYLE_HXX +#include <svtools/style.hxx> +#endif + +#include "svdmodel.hxx" + +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" +#endif + +using namespace ::com::sun::star; +using namespace ::rtl; +using namespace ::cppu; + +SvxUnoNameItemTable::SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich ) throw() +: mpModel( pModel ), + mpModelPool( pModel ? &pModel->GetItemPool() : NULL ), + mpStylePool( pModel ? &pModel->GetStyleSheetPool()->GetPool() : NULL ), + mnWhich( nWhich ) +{ +} + +SvxUnoNameItemTable::~SvxUnoNameItemTable() throw() +{ + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + while( aIter != aEnd ) + { + delete (*aIter).first; + delete (*aIter++).second; + } +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) +{ + uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); + const OUString * pArray = aSNL.getConstArray(); + + for( INT32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return TRUE; + + return FALSE; +} + +// XNameContainer +void SAL_CALL SvxUnoNameItemTable::insertByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) +{ + if( hasByName( aName ) ) + throw container::ElementExistException(); + + SfxItemSet* mpInSet1 = new SfxItemSet( *mpModelPool, mnWhich, mnWhich ); + SfxItemSet* mpInSet2 = new SfxItemSet( *mpStylePool, mnWhich, mnWhich ); + maItemSetVector.push_back( std::pair< SfxItemSet*, SfxItemSet*>( mpInSet1, mpInSet2 ) ); + + NameOrIndex* pNewItem = createItem(); + pNewItem->SetName( String( aName ) ); + pNewItem->PutValue( aElement ); + + mpInSet1->Put( *pNewItem, mnWhich ); + mpInSet2->Put( *pNewItem, mnWhich ); + delete pNewItem; +} + + + +void SAL_CALL SvxUnoNameItemTable::removeByName( const OUString& Name ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( Name ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter).first->Get( mnWhich ) ); + if( pItem->GetName() == aSearchName ) + { + delete (*aIter).first; + delete (*aIter).second; + maItemSetVector.erase( aIter ); + return; + } + aIter++; + } + + if( !hasByName( Name ) ) + throw container::NoSuchElementException(); +} + +// XNameReplace +void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aName, const uno::Any& aElement ) + throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +{ + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( aName ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter).first->Get( mnWhich ) ); + if( pItem->GetName() == aSearchName ) + { + NameOrIndex* pNewItem = createItem(); + pNewItem->SetName( aSearchName ); + if( !pNewItem->PutValue( aElement, 0 ) ) + throw lang::IllegalArgumentException(); + + (*aIter).first->Put( *pNewItem ); + (*aIter).second->Put( *pNewItem ); + return; + } + aIter++; + } + + if( !hasByName( aName ) ) + throw container::NoSuchElementException(); +} + +// XNameAccess +uno::Any SAL_CALL SvxUnoNameItemTable::getByName( const OUString& aName ) + throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any aAny; + + if( mpModelPool && mpStylePool && aName.getLength() != 0 ) + { + const String aSearchName( aName ); + NameOrIndex *pItem; + sal_Int32 nSurrogate; + + sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName() == aSearchName ) + { + pItem->QueryValue( aAny, 0 ); + return aAny; + } + } + + nSurrogateCount = mpStylePool ? (sal_Int32)mpStylePool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpStylePool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName() == aSearchName ) + { + pItem->QueryValue( aAny, 0 ); + return aAny; + } + } + } + + throw container::NoSuchElementException(); + return aAny; +} + +uno::Sequence< OUString > SAL_CALL SvxUnoNameItemTable::getElementNames( ) + throw( uno::RuntimeException ) +{ + const sal_Int32 nSurrogateCount1 = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + const sal_Int32 nSurrogateCount2 = mpStylePool ? (sal_Int32)mpStylePool->GetItemCount( mnWhich ) : 0; + + sal_Int32 nCount = 0; + + uno::Sequence< OUString > aSeq( nSurrogateCount1 + nSurrogateCount2 ); + OUString* pStrings = aSeq.getArray(); + sal_Int32 nSurrogate; + + NameOrIndex *pItem; + + for( nSurrogate = 0; nSurrogate < nSurrogateCount1; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem == NULL || pItem->GetName().Len() == 0 ) + continue; + + // check if there is already an item with this name + const OUString aSearchName( pItem->GetName() ); + OUString* pStartNames = aSeq.getArray(); + sal_Bool bFound = sal_False; + for( sal_Int32 i = 0; i < nCount; i++ ) + { + if( *pStartNames++ == aSearchName ) + { + bFound = sal_True; + break; + } + } + + if( !bFound ) + { + nCount++; + + *pStrings++ = pItem->GetName(); + } + } + + for( nSurrogate = 0; nSurrogate < nSurrogateCount2; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpStylePool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem == NULL || pItem->GetName().Len() == 0 ) + continue; + + // check if there is already an item with this name + const OUString aSearchName( pItem->GetName() ); + OUString* pStartNames = aSeq.getArray(); + sal_Bool bFound = sal_False; + for( sal_Int32 i = 0; i < nCount; i++ ) + { + if( *pStartNames++ == aSearchName ) + { + bFound = sal_True; + break; + } + } + + if( !bFound ) + { + nCount++; + + *pStrings++ = pItem->GetName(); + } + } + + if( nCount < aSeq.getLength() ) + aSeq.realloc( nCount ); + + return aSeq; +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::hasByName( const OUString& aName ) + throw( uno::RuntimeException ) +{ + if( aName.getLength() == 0 ) + return sal_False; + + const String aSearchName( aName ); + USHORT nSurrogate; + + const NameOrIndex *pItem; + + USHORT nCount = mpModelPool ? mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, nSurrogate ); + if( pItem && pItem->GetName() == aSearchName ) + return sal_True; + } + + nCount = mpStylePool ? mpStylePool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpStylePool->GetItem( mnWhich, nSurrogate ); + if( pItem && pItem->GetName() == aSearchName ) + return sal_True; + } + + return sal_False; +} + +sal_Bool SAL_CALL SvxUnoNameItemTable::hasElements( ) + throw( uno::RuntimeException ) +{ + const NameOrIndex *pItem; + + sal_Int32 nSurrogate; + sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + nSurrogateCount = mpStylePool ? (sal_Int32)mpStylePool->GetItemCount( mnWhich ) : 0; + for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpStylePool->GetItem( mnWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + return sal_False; +} diff --git a/svx/source/unodraw/UnoNameItemTable.hxx b/svx/source/unodraw/UnoNameItemTable.hxx new file mode 100644 index 000000000000..da4bd794331f --- /dev/null +++ b/svx/source/unodraw/UnoNameItemTable.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * $RCSfile: UnoNameItemTable.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#define _SVX_UNONAMEITEMTABLE_HXX_ + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif + +#include <cppuhelper/implbase2.hxx> + +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + +#ifndef _SVX_XIT_HXX +#include "xit.hxx" +#endif + +#include "xdef.hxx" + +class SdrModel; +class SfxItemPool; +class SfxItemSet; + +typedef std::vector< std::pair< SfxItemSet*, SfxItemSet*> > ItemPoolVector; +class SvxUnoNameItemTable : public cppu::WeakImplHelper2< com::sun::star::container::XNameContainer, com::sun::star::lang::XServiceInfo > +{ +private: + SdrModel* mpModel; + SfxItemPool* mpModelPool; + SfxItemPool* mpStylePool; + USHORT mnWhich; + + ItemPoolVector maItemSetVector; + +public: + SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich ) throw(); + virtual ~SvxUnoNameItemTable() throw(); + + virtual NameOrIndex* createItem() const throw() = 0; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( com::sun::star::uno::RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByName( const rtl::OUString& Name ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + + // XNameReplace + virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + + // XNameAccess + virtual com::sun::star::uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw( com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements( ) throw( com::sun::star::uno::RuntimeException); +}; + +#endif // _SVX_UNONAMEITEMTABLE_HXX_
\ No newline at end of file diff --git a/svx/source/unodraw/makefile.mk b/svx/source/unodraw/makefile.mk index 6446cf04be74..49d7a772147c 100644 --- a/svx/source/unodraw/makefile.mk +++ b/svx/source/unodraw/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.4 $ +# $Revision: 1.5 $ # -# last change: $Author: cl $ $Date: 2000-12-01 16:52:32 $ +# last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -76,6 +76,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- CXXFILES = \ + UnoNameItemTable.cxx \ unoipset.cxx \ unoshape.cxx \ unoshap2.cxx \ @@ -98,6 +99,7 @@ CXXFILES = \ gluepts.cxx SLOFILES = \ + $(SLO)$/UnoNameItemTable.obj \ $(SLO)$/unoshape.obj \ $(SLO)$/unoipset.obj \ $(SLO)$/unoctabl.obj \ diff --git a/svx/source/unodraw/unobtabl.cxx b/svx/source/unodraw/unobtabl.cxx index 9835cf2d20c3..b44e8b7d858c 100644 --- a/svx/source/unodraw/unobtabl.cxx +++ b/svx/source/unodraw/unobtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unobtabl.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: ka $ $Date: 2000-12-14 10:23:58 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,6 @@ * ************************************************************************/ -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_XBITMAP_HPP_ -#include <com/sun/star/awt/XBitmap.hpp> -#endif - -#include <cppuhelper/implbase2.hxx> - #ifndef _SFXITEMPOOL_HXX #include <svtools/itempool.hxx> #endif @@ -89,90 +77,45 @@ #include <sfx2/docfile.hxx> #endif +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" +#endif + #include "xbtmpit.hxx" #include "svdmodel.hxx" -#include "xdef.hxx" #include "xflhtit.hxx" #include "unoapi.hxx" #include "impgrf.hxx" #include "unomid.hxx" #include "unoprnms.hxx" -#ifndef _LIST_HXX -#include<tools/list.hxx> -#endif - using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) - -class SvxUnoBitmapTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoBitmapTable : public SvxUnoNameItemTable { -private: - SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; - - void CreateName( OUString& rStrName ); - public: SvxUnoBitmapTable( SdrModel* pModel ) throw(); virtual ~SvxUnoBitmapTable() throw(); + virtual NameOrIndex* createItem() const throw(); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoBitmapTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - - // XNameContainer - virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); - virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); - // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); }; SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw() -: mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP ) { } SvxUnoBitmapTable::~SvxUnoBitmapTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); -} - -sal_Bool SAL_CALL SvxUnoBitmapTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) -{ - uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); - const OUString * pArray = aSNL.getConstArray(); - - for( INT32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return TRUE; - - return FALSE; } OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException ) @@ -183,114 +126,14 @@ OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::Runtime uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoBitmapTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" )); return aSNS; } -// XNameContainer -void SAL_CALL SvxUnoBitmapTable::insertByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) -{ - if( hasByName( aName ) ) - throw container::ElementExistException(); - - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_FILLBITMAP, XATTR_FILLBITMAP ); - aItemSetArray.Insert( mpInSet );//, aItemSetArray.Count() ); - - XFillBitmapItem aBitmap; - aBitmap.SetName( String( aName ) ); - - if(!aBitmap.PutValue( aElement, MID_GRAFURL )) - throw lang::IllegalArgumentException(); - - mpInSet->Put( aBitmap, XATTR_FILLBITMAP ); -} - -void SAL_CALL SvxUnoBitmapTable::removeByName( const OUString& Name ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ -} - -// XNameReplace -void SAL_CALL SvxUnoBitmapTable::replaceByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) -{ -} - -// XNameAccess -uno::Any SAL_CALL SvxUnoBitmapTable::getByName( const OUString& aName ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - if( mpPool ) - { - const String aSearchName( aName ); - const USHORT nCount = mpPool->GetItemCount( XATTR_FILLBITMAP ); - const XFillBitmapItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillBitmapItem*)mpPool->GetItem( XATTR_FILLBITMAP, nSurrogate ); - - if( pItem && ( pItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pItem->QueryValue( aAny, MID_GRAFURL ); - return aAny; - } - } - } - throw container::NoSuchElementException(); -} - -uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getElementNames( ) - throw( uno::RuntimeException ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount( XATTR_FILLBITMAP ) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - XFillBitmapItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillBitmapItem*)mpPool->GetItem( XATTR_FILLBITMAP, nSurrogate ); - - if( pItem ) - { - if( pItem->GetName().Len() == 0 ) - pItem->SetName( pItem->CreateStandardName( mpPool, XATTR_FILLBITMAP ) ); - - pStrings[nSurrogate] = pItem->GetName(); - - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XFillBitmapItem in pool should have a name !"); - } - } - - return aSeq; -} - -sal_Bool SAL_CALL SvxUnoBitmapTable::hasByName( const OUString& aName ) - throw( uno::RuntimeException ) +NameOrIndex* SvxUnoBitmapTable::createItem() const throw() { - const String aSearchName( aName ); - const USHORT nCount = mpPool ? mpPool->GetItemCount( XATTR_FILLBITMAP ) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - const XFillBitmapItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillBitmapItem*)mpPool->GetItem( XATTR_FILLBITMAP, nSurrogate ); - if( pItem && pItem->GetName() == aSearchName ) - return sal_True; - } - - return sal_False; + return new XFillBitmapItem(); } // XElementAccess @@ -300,26 +143,6 @@ uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( ) return ::getCppuType( (const ::rtl::OUString*)0 ); } - -sal_Bool SAL_CALL SvxUnoBitmapTable::hasElements( ) - throw( uno::RuntimeException ) -{ - return mpPool && mpPool->GetItemCount( XATTR_FILLBITMAP ) != 0; -} - -void SvxUnoBitmapTable::CreateName( OUString& rStrName) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLGRADIENT) : 0; - sal_Bool bFound = sal_True; - - for( sal_Int32 nPostfix = 1; nPostfix<= nCount && bFound; nPostfix++ ) - { - rStrName = OUString::createFromAscii( "Standard " ); - rStrName += OUString::valueOf( nPostfix ); - bFound = hasByName( rStrName ); - } -} - /** * Create a bitmaptable */ diff --git a/svx/source/unodraw/unodtabl.cxx b/svx/source/unodraw/unodtabl.cxx index 88d360803e49..6d25c7cb4cd8 100644 --- a/svx/source/unodraw/unodtabl.cxx +++ b/svx/source/unodraw/unodtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unodtabl.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: cl $ $Date: 2000-11-28 12:03:51 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,10 @@ * ************************************************************************/ -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif #ifndef _COM_SUN_STAR_DRAWING_LINEDASH_HPP_ #include <com/sun/star/drawing/LineDash.hpp> #endif -#include <cppuhelper/implbase2.hxx> - #ifndef _SFXITEMPOOL_HXX #include <svtools/itempool.hxx> #endif @@ -79,88 +71,48 @@ #include <svtools/itemset.hxx> #endif -#ifndef _LIST_HXX -#include<tools/list.hxx> +#ifndef __SGI_STL_VECTOR +#include <stl/vector> +#endif + +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" +#endif + +#ifndef _SVX_XLNDSIT_HXX +#include "xlndsit.hxx" #endif #include "xdash.hxx" #include "svdmodel.hxx" -#include "xdef.hxx" -#include "xlndsit.hxx" -//#include "xflgrit.hxx" using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) - -class SvxUnoDashTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoDashTable : public SvxUnoNameItemTable { -private: - SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; - - void CreateName( OUString& rStrName); - public: SvxUnoDashTable( SdrModel* pModel ) throw(); virtual ~SvxUnoDashTable() throw(); + virtual NameOrIndex* createItem() const throw(); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoDashTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - - - // XNameContainer - virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); - virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); - // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); }; SvxUnoDashTable::SvxUnoDashTable( SdrModel* pModel ) throw() -: mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +: SvxUnoNameItemTable( pModel, XATTR_LINEDASH ) { } SvxUnoDashTable::~SvxUnoDashTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); -} - -sal_Bool SAL_CALL SvxUnoDashTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) -{ - uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); - const OUString * pArray = aSNL.getConstArray(); - - for( INT32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return TRUE; - - return FALSE; } OUString SAL_CALL SvxUnoDashTable::getImplementationName() throw( uno::RuntimeException ) @@ -171,133 +123,16 @@ OUString SAL_CALL SvxUnoDashTable::getImplementationName() throw( uno::RuntimeEx uno::Sequence< OUString > SAL_CALL SvxUnoDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoDashTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable" )); return aSNS; } - -// XNameContainer -void SAL_CALL SvxUnoDashTable::insertByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) +NameOrIndex* SvxUnoDashTable::createItem() const throw() { - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_LINEDASH, XATTR_LINEDASH ); - aItemSetArray.Insert( mpInSet );//, aItemSetArray.Count() ); - - XLineDashItem aLineDash; - aLineDash.SetName( String( aName ) ); - aLineDash.PutValue( aElement ); - aLineDash.SetWhich( XATTR_FILLGRADIENT ); // set which id for pooling - - mpInSet->Put( aLineDash, XATTR_LINEDASH ); -} - - - -void SAL_CALL SvxUnoDashTable::removeByName( const OUString& Name ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - /* Currently, don't know how to do this ? - long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( Name ) : -1; - if( nIndex == -1 ) - throw container::NoSuchElementException(); - - pTable->Remove( nIndex ); - */ -} - -// XNameReplace -void SAL_CALL SvxUnoDashTable::replaceByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) -{ - /* Currently, don't know how to do this ? - INT32 nColor; - if( aElement >>= nColor ) - throw lang::IllegalArgumentException(); - - long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1; - if( nIndex == -1 ) - throw container::NoSuchElementException(); - - XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); - delete pTable->Replace( nIndex, pEntry ); - */ -} - -// XNameAccess -uno::Any SAL_CALL SvxUnoDashTable::getByName( const OUString& aName ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - if( mpPool ) - { - const String aSearchName( aName ); - const USHORT nCount = mpPool->GetItemCount(XATTR_LINEDASH); - const XLineDashItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XLineDashItem*)mpPool->GetItem(XATTR_LINEDASH, nSurrogate); - - if( pItem && ( pItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pItem->QueryValue( aAny ); - return aAny; - } - } - } - - throw container::NoSuchElementException(); -} - -uno::Sequence< OUString > SAL_CALL SvxUnoDashTable::getElementNames( ) - throw( uno::RuntimeException ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_LINEDASH) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - XLineDashItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XLineDashItem*)mpPool->GetItem(XATTR_LINEDASH, nSurrogate); - - if( pItem ) - { - if( pItem->GetName().Len() == 0 ) - pItem->SetName( pItem->CreateStandardName( mpPool, XATTR_LINEDASH ) ); - - pStrings[nSurrogate] = pItem->GetName(); - - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XLineDashItem in pool should have a name !"); - } - } - - return aSeq; -} - -sal_Bool SAL_CALL SvxUnoDashTable::hasByName( const OUString& aName ) - throw( uno::RuntimeException ) -{ - const String aSearchName( aName ); - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_LINEDASH) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - const XLineDashItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XLineDashItem*)mpPool->GetItem(XATTR_LINEDASH, nSurrogate); - if( pItem && pItem->GetName() == aSearchName ) - return sal_True; - } - - return sal_False; + XLineDashItem* pNewItem = new XLineDashItem(); + pNewItem->SetWhich( XATTR_LINEDASH ); // set which id for pooling + return pNewItem; } // XElementAccess @@ -307,25 +142,6 @@ uno::Type SAL_CALL SvxUnoDashTable::getElementType( ) return ::getCppuType((const struct drawing::LineDash*)0); } -sal_Bool SAL_CALL SvxUnoDashTable::hasElements( ) - throw( uno::RuntimeException ) -{ - return mpPool && mpPool->GetItemCount(XATTR_LINEDASH) != 0; -} - -void SvxUnoDashTable::CreateName( OUString& rStrName) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_LINEDASH) : 0; - sal_Bool bFound = sal_True; - - for( sal_Int32 nPostfix = 1; nPostfix<= nCount && bFound; nPostfix++ ) - { - rStrName = OUString::createFromAscii( "Standard " ); - rStrName += OUString::valueOf( nPostfix ); - bFound = hasByName( rStrName ); - } -} - /** * Create a gradienttable */ diff --git a/svx/source/unodraw/unogtabl.cxx b/svx/source/unodraw/unogtabl.cxx index 35cf66af5c89..2c53bda543d7 100644 --- a/svx/source/unodraw/unogtabl.cxx +++ b/svx/source/unodraw/unogtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unogtabl.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: cl $ $Date: 2000-11-12 15:51:48 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,10 @@ * ************************************************************************/ -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif #ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_ #include <com/sun/star/awt/Gradient.hpp> #endif -#include <cppuhelper/implbase2.hxx> - #ifndef _SFXITEMPOOL_HXX #include <svtools/itempool.hxx> #endif @@ -79,8 +71,8 @@ #include <svtools/itemset.hxx> #endif -#ifndef _LIST_HXX -#include<tools/list.hxx> +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" #endif #include "xgrad.hxx" @@ -92,74 +84,29 @@ using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) - -class SvxUnoGradientTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoGradientTable : public SvxUnoNameItemTable { -private: - SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; - - void CreateName( OUString& rStrName); - public: SvxUnoGradientTable( SdrModel* pModel ) throw(); virtual ~SvxUnoGradientTable() throw(); + virtual NameOrIndex* createItem() const throw(); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoGradientTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - - - // XNameContainer - virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); - virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); - // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); }; SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel ) throw() -: mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +: SvxUnoNameItemTable( pModel, XATTR_FILLGRADIENT ) { } SvxUnoGradientTable::~SvxUnoGradientTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); -} - -sal_Bool SAL_CALL SvxUnoGradientTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) -{ - uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); - const OUString * pArray = aSNL.getConstArray(); - - for( INT32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return TRUE; - - return FALSE; } OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::RuntimeException ) @@ -170,11 +117,6 @@ OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::Runti uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoGradientTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable" )); return aSNS; @@ -182,120 +124,9 @@ uno::Sequence< OUString > SvxUnoGradientTable::getSupportedServiceNames_Static(v // XNameContainer -void SAL_CALL SvxUnoGradientTable::insertByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) -{ - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_FILLGRADIENT, XATTR_FILLGRADIENT ); - aItemSetArray.Insert( mpInSet );//, aItemSetArray.Count() ); - - XFillGradientItem aGradient; - aGradient.SetName( String( aName ) ); - aGradient.PutValue( aElement ); - - mpInSet->Put( aGradient, XATTR_FILLGRADIENT ); -} - - - -void SAL_CALL SvxUnoGradientTable::removeByName( const OUString& Name ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - /* Currently, don't know how to do this ? - long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( Name ) : -1; - if( nIndex == -1 ) - throw container::NoSuchElementException(); - - pTable->Remove( nIndex ); - */ -} - -// XNameReplace -void SAL_CALL SvxUnoGradientTable::replaceByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) -{ - /* Currently, don't know how to do this ? - INT32 nColor; - if( aElement >>= nColor ) - throw lang::IllegalArgumentException(); - - long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1; - if( nIndex == -1 ) - throw container::NoSuchElementException(); - - XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName ); - delete pTable->Replace( nIndex, pEntry ); - */ -} - -// XNameAccess -uno::Any SAL_CALL SvxUnoGradientTable::getByName( const OUString& aName ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - if( mpPool ) - { - const String aSearchName( aName ); - const USHORT nCount = mpPool->GetItemCount(XATTR_FILLGRADIENT); - const XFillGradientItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillGradientItem*)mpPool->GetItem(XATTR_FILLGRADIENT, nSurrogate); - - if( pItem && ( pItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pItem->QueryValue( aAny ); - return aAny; - } - } - } - - throw container::NoSuchElementException(); -} - -uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getElementNames( ) - throw( uno::RuntimeException ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLGRADIENT) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - XFillGradientItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillGradientItem*)mpPool->GetItem(XATTR_FILLGRADIENT, nSurrogate); - - if( pItem ) - { - if( pItem->GetName().Len() == 0 ) - pItem->SetName( pItem->CreateStandardName( mpPool, XATTR_FILLGRADIENT ) ); - - pStrings[nSurrogate] = pItem->GetName(); - - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XFillGradientItem in pool should have a name !"); - } - } - - return aSeq; -} - -sal_Bool SAL_CALL SvxUnoGradientTable::hasByName( const OUString& aName ) - throw( uno::RuntimeException ) +NameOrIndex* SvxUnoGradientTable::createItem() const throw() { - const String aSearchName( aName ); - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLGRADIENT) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - const XFillGradientItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillGradientItem*)mpPool->GetItem(XATTR_FILLGRADIENT, nSurrogate); - if( pItem && pItem->GetName() == aSearchName ) - return sal_True; - } - - return sal_False; + return new XFillGradientItem(); } // XElementAccess @@ -305,25 +136,6 @@ uno::Type SAL_CALL SvxUnoGradientTable::getElementType( ) return ::getCppuType((const struct awt::Gradient*)0); } -sal_Bool SAL_CALL SvxUnoGradientTable::hasElements( ) - throw( uno::RuntimeException ) -{ - return mpPool && mpPool->GetItemCount(XATTR_FILLGRADIENT) != 0; -} - -void SvxUnoGradientTable::CreateName( OUString& rStrName) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLGRADIENT) : 0; - sal_Bool bFound = sal_True; - - for( sal_Int32 nPostfix = 1; nPostfix<= nCount && bFound; nPostfix++ ) - { - rStrName = OUString::createFromAscii( "Standard " ); - rStrName += OUString::valueOf( nPostfix ); - bFound = hasByName( rStrName ); - } -} - /** * Create a gradienttable */ diff --git a/svx/source/unodraw/unohtabl.cxx b/svx/source/unodraw/unohtabl.cxx index 39c8843d7caa..4094a8018b3c 100644 --- a/svx/source/unodraw/unohtabl.cxx +++ b/svx/source/unodraw/unohtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unohtabl.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: cl $ $Date: 2000-11-12 15:51:48 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,10 @@ * ************************************************************************/ -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif #ifndef _COM_SUN_STAR_DRAWING_HATCH_HPP_ #include <com/sun/star/drawing/Hatch.hpp> #endif -#include <cppuhelper/implbase2.hxx> - #ifndef _SFXITEMPOOL_HXX #include <svtools/itempool.hxx> #endif @@ -79,8 +71,8 @@ #include <svtools/itemset.hxx> #endif -#ifndef _LIST_HXX -#include<tools/list.hxx> +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" #endif #include "xhatch.hxx" @@ -92,73 +84,29 @@ using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) - -class SvxUnoHatchTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoHatchTable : public SvxUnoNameItemTable { -private: - SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; - - void CreateName( OUString& rStrName); - public: SvxUnoHatchTable( SdrModel* pModel ) throw(); virtual ~SvxUnoHatchTable() throw(); + virtual NameOrIndex* createItem() const throw(); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoHatchTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - - // XNameContainer - virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); - virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); - // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); }; SvxUnoHatchTable::SvxUnoHatchTable( SdrModel* pModel ) throw() -: mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +: SvxUnoNameItemTable( pModel, XATTR_FILLHATCH ) { } SvxUnoHatchTable::~SvxUnoHatchTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); -} - -sal_Bool SAL_CALL SvxUnoHatchTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) -{ - uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); - const OUString * pArray = aSNL.getConstArray(); - - for( INT32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return TRUE; - - return FALSE; } OUString SAL_CALL SvxUnoHatchTable::getImplementationName() throw( uno::RuntimeException ) @@ -169,126 +117,14 @@ OUString SAL_CALL SvxUnoHatchTable::getImplementationName() throw( uno::RuntimeE uno::Sequence< OUString > SAL_CALL SvxUnoHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoHatchTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable" )); return aSNS; } -// XNameContainer -void SAL_CALL SvxUnoHatchTable::insertByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) -{ - if( hasByName( aName ) ) - throw container::ElementExistException(); - - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_FILLHATCH, XATTR_FILLHATCH ); - aItemSetArray.Insert( mpInSet );//, aItemSetArray.Count() ); - - XFillHatchItem aHatch; - aHatch.SetName( String( aName ) ); - aHatch.PutValue( aElement ); - - mpInSet->Put( aHatch, XATTR_FILLHATCH ); -} - -void SAL_CALL SvxUnoHatchTable::removeByName( const OUString& Name ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ -} - -// XNameReplace -void SAL_CALL SvxUnoHatchTable::replaceByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +NameOrIndex* SvxUnoHatchTable::createItem() const throw() { -} - -// XNameAccess -uno::Any SAL_CALL SvxUnoHatchTable::getByName( const OUString& aName ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - if( mpPool ) - { - const String aSearchName( aName ); - const USHORT nCount = mpPool->GetItemCount(XATTR_FILLHATCH); - const XFillHatchItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillHatchItem*)mpPool->GetItem(XATTR_FILLHATCH, nSurrogate); - - if( pItem && ( pItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pItem->QueryValue( aAny ); - return aAny; - } - } - } - - throw container::NoSuchElementException(); -} - -uno::Sequence< OUString > SAL_CALL SvxUnoHatchTable::getElementNames( ) - throw( uno::RuntimeException ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLHATCH) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - XFillHatchItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillHatchItem*)mpPool->GetItem(XATTR_FILLHATCH, nSurrogate); - - if( pItem ) - { - if( pItem->GetName().Len() == 0 ) - pItem->SetName( pItem->CreateStandardName( mpPool, XATTR_FILLHATCH ) ); - - pStrings[nSurrogate] = pItem->GetName(); - - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XFillHatchItem in pool should have a name !"); - } - } - - return aSeq; -} - -sal_Bool SAL_CALL SvxUnoHatchTable::hasByName( const OUString& aName ) - throw( uno::RuntimeException ) -{ - const String aSearchName( aName ); - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLHATCH) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - const XFillHatchItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillHatchItem*)mpPool->GetItem(XATTR_FILLHATCH, nSurrogate); - if( pItem && pItem->GetName() == aSearchName ) - return sal_True; - } - - return sal_False; -} - -void SvxUnoHatchTable::CreateName( OUString& rStrName ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLGRADIENT) : 0; - sal_Bool bFound = sal_True; - - for( sal_Int32 nPostfix = 1; nPostfix<= nCount && bFound; nPostfix++ ) - { - rStrName = OUString::createFromAscii( "Standard " ); - rStrName += OUString::valueOf( nPostfix ); - bFound = hasByName( rStrName ); - } + return new XFillHatchItem(); } // XElementAccess @@ -298,12 +134,6 @@ uno::Type SAL_CALL SvxUnoHatchTable::getElementType( ) return ::getCppuType((const struct drawing::Hatch*)0); } -sal_Bool SAL_CALL SvxUnoHatchTable::hasElements( ) - throw( uno::RuntimeException ) -{ - return mpPool && mpPool->GetItemCount(XATTR_FILLHATCH) != 0; -} - /** * Create a hatchtable */ diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx index 7301e58ff68e..e3774c863f00 100644 --- a/svx/source/unodraw/unomtabl.cxx +++ b/svx/source/unodraw/unomtabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unomtabl.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: cl $ $Date: 2001-01-16 20:17:25 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,10 @@ #include <com/sun/star/drawing/PointSequence.hpp> #endif +#ifndef _SFXSTYLE_HXX +#include <svtools/style.hxx> +#endif + #include <cppuhelper/implbase2.hxx> #ifndef _SFXITEMPOOL_HXX @@ -89,25 +93,24 @@ #include "xdef.hxx" #include "xflhtit.hxx" -#ifndef _LIST_HXX -#include<tools/list.hxx> +#ifndef __SGI_STL_VECTOR +#include <stl/vector> #endif using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) +typedef std::vector< std::pair< SfxItemSet*, SfxItemSet*> > ItemPoolVector; class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > { private: SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; + SfxItemPool* mpModelPool; + SfxItemPool* mpStylePool; - void CreateName( OUString& rStrName ); + ItemPoolVector maItemSetVector; public: SvxUnoMarkerTable( SdrModel* pModel ) throw(); @@ -118,13 +121,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoMarkerTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - // XNameContainer virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); @@ -144,14 +140,21 @@ public: SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw() : mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) + mpStylePool( pModel ? &pModel->GetStyleSheetPool()->GetPool() : NULL ), + mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) { } SvxUnoMarkerTable::~SvxUnoMarkerTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + while( aIter != aEnd ) + { + delete (*aIter).first; + delete (*aIter++).second; + } } sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) @@ -174,11 +177,6 @@ OUString SAL_CALL SvxUnoMarkerTable::getImplementationName() throw( uno::Runtime uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoMarkerTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable" )); return aSNS; @@ -191,113 +189,198 @@ void SAL_CALL SvxUnoMarkerTable::insertByName( const OUString& aName, const uno: if( hasByName( aName ) ) throw container::ElementExistException(); - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_LINESTART, XATTR_LINEEND ); - aItemSetArray.Insert( mpInSet );//, aItemSetArray.Count() ); + SfxItemSet* mpInSet1 = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND ); + SfxItemSet* mpInSet2 = new SfxItemSet( *mpStylePool, XATTR_LINESTART, XATTR_LINEEND ); + maItemSetVector.push_back( std::pair< SfxItemSet*, SfxItemSet*>( mpInSet1, mpInSet2 ) ); XLineEndItem aEndMarker; aEndMarker.SetName( String( aName ) ); aEndMarker.PutValue( aElement ); - mpInSet->Put( aEndMarker, XATTR_LINEEND ); + mpInSet1->Put( aEndMarker, XATTR_LINEEND ); + mpInSet2->Put( aEndMarker, XATTR_LINEEND ); XLineStartItem aStartMarker; aStartMarker.SetName( String( aName ) ); aStartMarker.PutValue( aElement ); - mpInSet->Put( aStartMarker, XATTR_LINESTART ); + mpInSet1->Put( aStartMarker, XATTR_LINESTART ); + mpInSet2->Put( aStartMarker, XATTR_LINESTART ); } void SAL_CALL SvxUnoMarkerTable::removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( Name ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter).first->Get( XATTR_LINEEND ) ); + if( pItem->GetName() == aSearchName ) + { + delete (*aIter).first; + delete (*aIter).second; + maItemSetVector.erase( aIter ); + return; + } + aIter++; + } + + if( !hasByName( Name ) ) + throw container::NoSuchElementException(); } // XNameReplace void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) { + ItemPoolVector::iterator aIter = maItemSetVector.begin(); + const ItemPoolVector::iterator aEnd = maItemSetVector.end(); + + NameOrIndex *pItem; + const String aSearchName( aName ); + + while( aIter != aEnd ) + { + pItem = (NameOrIndex *)&((*aIter).first->Get( XATTR_LINEEND ) ); + if( pItem->GetName() == aSearchName ) + { + XLineEndItem aEndMarker; + aEndMarker.SetName( aSearchName ); + if( !aEndMarker.PutValue( aElement ) ) + throw lang::IllegalArgumentException(); + + (*aIter).first->Put( aEndMarker, XATTR_LINEEND ); + (*aIter).second->Put( aEndMarker, XATTR_LINEEND ); + + XLineStartItem aStartMarker; + aStartMarker.SetName( aSearchName ); + aStartMarker.PutValue( aElement ); + + (*aIter).first->Put( aStartMarker, XATTR_LINESTART ); + (*aIter).second->Put( aStartMarker, XATTR_LINESTART ); + return; + } + aIter++; + } + + if( !hasByName( aName ) ) + throw container::NoSuchElementException(); +} + +static sal_Bool getByNameFromPool( const String& rSearchName, SfxItemPool* pPool, USHORT nWhich, uno::Any& rAny ) +{ + NameOrIndex *pItem; + const sal_Int32 nSurrogateCount = pPool ? (sal_Int32)pPool->GetItemCount( nWhich ) : 0; + for( sal_Int32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate ); + + if( pItem && pItem->GetName() == rSearchName ) + { + pItem->QueryValue( rAny, 0 ); + return sal_True; + } + } + + return sal_False; } // XNameAccess uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { - if( mpPool ) - { - const String aSearchName( aName ); - USHORT nCount = mpPool->GetItemCount( XATTR_LINEEND ); - const XLineEndItem *pEndItem; + uno::Any aAny; - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) + if( mpModelPool && mpStylePool && aName.getLength() != 0 ) + { + do { - pEndItem = (XLineEndItem*)mpPool->GetItem( XATTR_LINEEND, nSurrogate ); + const String aSearchName( aName ); + if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINESTART, aAny ) ) + break; - if( pEndItem && ( pEndItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pEndItem->QueryValue( aAny ); - return aAny; - } - - } + if( getByNameFromPool( aSearchName, mpStylePool, XATTR_LINESTART, aAny ) ) + break; - const XLineStartItem *pStartItem; - nCount = mpPool->GetItemCount( XATTR_LINESTART ); + if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINEEND, aAny ) ) + break; - for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pStartItem = (XLineStartItem*)mpPool->GetItem( XATTR_LINESTART, nSurrogate ); + if( getByNameFromPool( aSearchName, mpStylePool, XATTR_LINEEND, aAny ) ) + break; - if( pStartItem && ( pStartItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pStartItem->QueryValue( aAny ); - return aAny; - } + throw container::NoSuchElementException(); } + while(0); } - throw container::NoSuchElementException(); + return aAny; } -uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames( ) - throw( uno::RuntimeException ) +static void createNamesForPool( SfxItemPool* pPool, USHORT nWhich, sal_Int32 nSuroCount, uno::Sequence< OUString >& rSeq, OUString*& rpWritePos, sal_Int32& rCount ) { - const USHORT nEndCount = mpPool ? mpPool->GetItemCount( XATTR_LINEEND ) : 0; - const USHORT nStartCount = mpPool ? mpPool->GetItemCount( XATTR_LINESTART ) : 0; - uno::Sequence< OUString > aSeq( nEndCount+nStartCount ); - OUString* pStrings = aSeq.getArray(); - - XLineEndItem *pEndItem; - for( USHORT nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) + NameOrIndex *pItem; + for( sal_Int32 nSurrogate = 0; nSurrogate < nSuroCount; nSurrogate++ ) { - pEndItem = (XLineEndItem*)mpPool->GetItem( XATTR_LINEEND, nSurrogate); + pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate ); - if( pEndItem ) - { - if( pEndItem->GetName().Len() == 0 ) - pEndItem->SetName( pEndItem->CreateStandardName( mpPool, XATTR_LINEEND ) ); + if( pItem == NULL || pItem->GetName().Len() == 0 ) + continue; - pStrings[nSurrogate] = pEndItem->GetName(); + // check if there is already a line start with this name + const OUString aSearchName( pItem->GetName() ); + OUString* pStartNames = rSeq.getArray(); + sal_Bool bFound = sal_False; + for( sal_Int32 i = 0; i < rCount; i++ ) + { + if( *pStartNames++ == aSearchName ) + { + bFound = sal_True; + break; + } + } - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XLineEndItem in pool should have a name !"); + if( !bFound ) + { + rCount++; + *rpWritePos++ = aSearchName; } } +} - XLineStartItem *pStartItem; - for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) +uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames( ) + throw( uno::RuntimeException ) +{ + const sal_Int32 nStartCount1 = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; + const sal_Int32 nStartCount2 = mpStylePool ? (sal_Int32)mpStylePool->GetItemCount( XATTR_LINESTART ) : 0; + const sal_Int32 nEndCount1 = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( XATTR_LINEEND ) : 0; + const sal_Int32 nEndCount2 = mpStylePool ? (sal_Int32)mpStylePool->GetItemCount( XATTR_LINEEND ) : 0; + sal_Int32 nCount = 0; + + uno::Sequence< OUString > aSeq( nStartCount1 + nEndCount1 + nStartCount2 + nEndCount2 ); + if( aSeq.getLength() ) { - pStartItem = (XLineStartItem*)mpPool->GetItem( XATTR_LINESTART, nSurrogate); + OUString* pStrings = aSeq.getArray(); - if( pStartItem ) - { - if( pStartItem->GetName().Len() == 0 ) - pStartItem->SetName( pStartItem->CreateStandardName( mpPool, XATTR_LINESTART ) ); + // search model pool for line starts + createNamesForPool( mpModelPool, XATTR_LINESTART, nStartCount1, aSeq, pStrings, nCount ); - pStrings[nSurrogate+nEndCount] = pStartItem->GetName(); + // search style pool for line starts + createNamesForPool( mpStylePool, XATTR_LINESTART, nStartCount2, aSeq, pStrings, nCount ); - DBG_ASSERT( pStrings[nSurrogate+nEndCount].getLength(), "XLineStartItem in pool should have a name !"); - } + // search model pool for line ends + createNamesForPool( mpModelPool, XATTR_LINEEND, nEndCount1, aSeq, pStrings, nCount ); + + // search style pool for line ends + createNamesForPool( mpStylePool, XATTR_LINEEND, nEndCount2, aSeq, pStrings, nCount ); + + DBG_ASSERT( nCount <= aSeq.getLength(), "SvxUnoMarkerTable Overflow!" ); + if( nCount < aSeq.getLength() ) + aSeq.realloc( nCount ); } return aSeq; @@ -306,44 +389,32 @@ uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames( ) sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName ) throw( uno::RuntimeException ) { + if( aName.getLength() == 0 ) + return sal_False; + const String aSearchName( aName ); - const USHORT nStartCount = mpPool ? mpPool->GetItemCount( XATTR_LINESTART ) : 0; - const USHORT nEndCount = mpPool ? mpPool->GetItemCount( XATTR_LINEEND ) : 0; - const XLineEndItem *pEndItem; - const XLineStartItem *pStartItem; + NameOrIndex *pItem; + + const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; for( USHORT nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) { - pStartItem = (XLineStartItem*)mpPool->GetItem( XATTR_LINESTART, nSurrogate); - if( pStartItem && pStartItem->GetName() == aSearchName ) + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) return sal_True; } + const USHORT nEndCount = mpStylePool ? mpStylePool->GetItemCount( XATTR_LINEEND ) : 0; for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) { - pEndItem = (XLineEndItem*)mpPool->GetItem( XATTR_LINEEND, nSurrogate); - if( pEndItem && pEndItem->GetName() == aSearchName ) + pItem = (NameOrIndex*)mpStylePool->GetItem( XATTR_LINEEND, nSurrogate); + if( pItem && pItem->GetName() == aSearchName ) return sal_True; } return sal_False; } -void SvxUnoMarkerTable::CreateName( OUString& rStrName ) -{ - const USHORT nStartCount = mpPool ? mpPool->GetItemCount(XATTR_LINESTART) : 0; - const USHORT nEndCount = mpPool ? mpPool->GetItemCount(XATTR_LINEEND) : 0; - const USHORT nCount = nStartCount > nEndCount ? nStartCount : nEndCount; - sal_Bool bFound = sal_True; - - for( sal_Int32 nPostfix = 1; nPostfix<= nCount && bFound; nPostfix++ ) - { - rStrName = OUString::createFromAscii( "Standard " ); - rStrName += OUString::valueOf( nPostfix ); - bFound = hasByName( rStrName ); - } -} - // XElementAccess uno::Type SAL_CALL SvxUnoMarkerTable::getElementType( ) throw( uno::RuntimeException ) @@ -354,7 +425,25 @@ uno::Type SAL_CALL SvxUnoMarkerTable::getElementType( ) sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements( ) throw( uno::RuntimeException ) { - return mpPool && mpPool->GetItemCount(XATTR_LINEEND) != 0; + NameOrIndex *pItem; + + const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0; + for( USHORT nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate); + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + const USHORT nEndCount = mpStylePool ? mpStylePool->GetItemCount( XATTR_LINEEND ) : 0; + for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ ) + { + pItem = (NameOrIndex*)mpStylePool->GetItem( XATTR_LINEEND, nSurrogate); + if( pItem && pItem->GetName().Len() != 0 ) + return sal_True; + } + + return sal_False; } /** diff --git a/svx/source/unodraw/unottabl.cxx b/svx/source/unodraw/unottabl.cxx index 4991dca08504..53a06088ab05 100644 --- a/svx/source/unodraw/unottabl.cxx +++ b/svx/source/unodraw/unottabl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unottabl.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: cl $ $Date: 2000-11-12 15:51:48 $ + * last change: $Author: cl $ $Date: 2001-01-28 16:24:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,18 +59,10 @@ * ************************************************************************/ -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ -#include <com/sun/star/container/XNameContainer.hpp> -#endif #ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_ #include <com/sun/star/awt/Gradient.hpp> #endif -#include <cppuhelper/implbase2.hxx> - #ifndef _SFXITEMPOOL_HXX #include <svtools/itempool.hxx> #endif @@ -87,82 +79,39 @@ #endif #include "svdmodel.hxx" -#include "xdef.hxx" #include "xflhtit.hxx" -#ifndef _LIST_HXX -#include<tools/list.hxx> +#ifndef _SVX_UNONAMEITEMTABLE_HXX_ +#include "UnoNameItemTable.hxx" #endif using namespace ::com::sun::star; using namespace ::rtl; using namespace ::cppu; -DECLARE_LIST( ItemSetArray_Impl, SfxItemSet* ) - -class SvxUnoTransGradientTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > +class SvxUnoTransGradientTable : public SvxUnoNameItemTable { -private: - SdrModel* mpModel; - SfxItemPool* mpPool; - - ItemSetArray_Impl aItemSetArray; - public: SvxUnoTransGradientTable( SdrModel* pModel ) throw(); virtual ~SvxUnoTransGradientTable() throw(); + virtual NameOrIndex* createItem() const throw(); + // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException); virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException); - static OUString getImplementationName_Static() throw() - { - return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoTransGradientTable")); - } - - static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw(); - - // XNameContainer - virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException); - virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameReplace - virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - - // XNameAccess - virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException); - virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException); - // XElementAccess virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException); }; SvxUnoTransGradientTable::SvxUnoTransGradientTable( SdrModel* pModel ) throw() -: mpModel( pModel ), - mpPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL ) +: SvxUnoNameItemTable( pModel, XATTR_FILLFLOATTRANSPARENCE ) { } SvxUnoTransGradientTable::~SvxUnoTransGradientTable() throw() { - for( int i = 0; i<aItemSetArray.Count(); i++ ) - delete (SfxItemSet*)aItemSetArray.GetObject( i ); -} - -sal_Bool SAL_CALL SvxUnoTransGradientTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) -{ - uno::Sequence< OUString > aSNL( getSupportedServiceNames() ); - const OUString * pArray = aSNL.getConstArray(); - - for( INT32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return TRUE; - - return FALSE; } OUString SAL_CALL SvxUnoTransGradientTable::getImplementationName() throw( uno::RuntimeException ) @@ -173,114 +122,16 @@ OUString SAL_CALL SvxUnoTransGradientTable::getImplementationName() throw( uno:: uno::Sequence< OUString > SAL_CALL SvxUnoTransGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException ) { - return getSupportedServiceNames_Static(); -} - -uno::Sequence< OUString > SvxUnoTransGradientTable::getSupportedServiceNames_Static(void) throw() -{ uno::Sequence< OUString > aSNS( 1 ); aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable" )); return aSNS; } -// XNameContainer -void SAL_CALL SvxUnoTransGradientTable::insertByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException ) -{ - if( hasByName( aName ) ) - throw container::ElementExistException(); - - SfxItemSet* mpInSet = new SfxItemSet( *mpPool, XATTR_FILLFLOATTRANSPARENCE, XATTR_FILLFLOATTRANSPARENCE ); - aItemSetArray.Insert( mpInSet ); - - XFillFloatTransparenceItem aTransGradient; - aTransGradient.SetName( String( aName ) ); - aTransGradient.PutValue( aElement ); - aTransGradient.SetEnabled( TRUE ); - - mpInSet->Put( aTransGradient, XATTR_FILLFLOATTRANSPARENCE ); -} - -void SAL_CALL SvxUnoTransGradientTable::removeByName( const OUString& Name ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ -} - -// XNameReplace -void SAL_CALL SvxUnoTransGradientTable::replaceByName( const OUString& aName, const uno::Any& aElement ) - throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +NameOrIndex* SvxUnoTransGradientTable::createItem() const throw() { -} - -// XNameAccess -uno::Any SAL_CALL SvxUnoTransGradientTable::getByName( const OUString& aName ) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) -{ - if( mpPool ) - { - const String aSearchName( aName ); - const USHORT nCount = mpPool->GetItemCount(XATTR_FILLFLOATTRANSPARENCE); - const XFillFloatTransparenceItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillFloatTransparenceItem*)mpPool->GetItem(XATTR_FILLFLOATTRANSPARENCE, nSurrogate); - - if( pItem && ( pItem->GetName() == aSearchName ) ) - { - uno::Any aAny; - pItem->QueryValue( aAny ); - return aAny; - } - } - } - - throw container::NoSuchElementException(); -} - -uno::Sequence< OUString > SAL_CALL SvxUnoTransGradientTable::getElementNames( ) - throw( uno::RuntimeException ) -{ - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLFLOATTRANSPARENCE) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - XFillFloatTransparenceItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillFloatTransparenceItem*)mpPool->GetItem(XATTR_FILLFLOATTRANSPARENCE, nSurrogate); - - if( pItem ) - { - if( pItem->GetName().Len() == 0 ) - pItem->SetName( pItem->CreateStandardName( mpPool, XATTR_FILLFLOATTRANSPARENCE ) ); - - pStrings[nSurrogate] = pItem->GetName(); - DBG_ASSERT( pStrings[nSurrogate].getLength(), "XFillFloatTransparenceItem in pool should have a name !"); - } - } - - return aSeq; -} - -sal_Bool SAL_CALL SvxUnoTransGradientTable::hasByName( const OUString& aName ) - throw( uno::RuntimeException ) -{ - const String aSearchName( aName ); - const USHORT nCount = mpPool ? mpPool->GetItemCount(XATTR_FILLFLOATTRANSPARENCE) : 0; - uno::Sequence< OUString > aSeq( nCount ); - OUString* pStrings = aSeq.getArray(); - const XFillFloatTransparenceItem *pItem; - - for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) - { - pItem = (XFillFloatTransparenceItem*)mpPool->GetItem(XATTR_FILLFLOATTRANSPARENCE, nSurrogate); - - if( pItem && pItem->GetName() == aSearchName ) - return sal_True; - } - - return sal_False; + XFillFloatTransparenceItem* pNewItem = new XFillFloatTransparenceItem(); + pNewItem->SetEnabled( TRUE ); + return pNewItem; } // XElementAccess @@ -290,12 +141,6 @@ uno::Type SAL_CALL SvxUnoTransGradientTable::getElementType( ) return ::getCppuType((const struct awt::Gradient*)0); } -sal_Bool SAL_CALL SvxUnoTransGradientTable::hasElements( ) - throw( uno::RuntimeException ) -{ - return mpPool && mpPool->GetItemCount(XATTR_FILLFLOATTRANSPARENCE) != 0; -} - /** * Create a hatchtable */ |