xref: /trunk/main/svx/source/unodraw/unomtabl.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <set>
28cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
32cdf0e10cSrcweir #include <svl/style.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
35cdf0e10cSrcweir #include <svl/itempool.hxx>
36cdf0e10cSrcweir #include <svl/itemset.hxx>
37cdf0e10cSrcweir #include <svl/lstner.hxx>
38cdf0e10cSrcweir #include <svx/xlnedit.hxx>
39cdf0e10cSrcweir #include <svx/xlnstit.hxx>
40cdf0e10cSrcweir #include <svx/svdmodel.hxx>
41cdf0e10cSrcweir #include <svx/xdef.hxx>
42cdf0e10cSrcweir #include <svx/xflhtit.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <vector>
45cdf0e10cSrcweir #include <vos/mutex.hxx>
46cdf0e10cSrcweir #include <vcl/svapp.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include "svx/unofill.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include "svx/unoapi.hxx"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace ::com::sun::star;
54cdf0e10cSrcweir using namespace ::rtl;
55cdf0e10cSrcweir using namespace ::cppu;
56cdf0e10cSrcweir using namespace ::vos;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir typedef std::vector< SfxItemSet* > ItemPoolVector;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >,
61cdf0e10cSrcweir 						  public SfxListener
62cdf0e10cSrcweir {
63cdf0e10cSrcweir private:
64cdf0e10cSrcweir 	SdrModel*		mpModel;
65cdf0e10cSrcweir 	SfxItemPool*	mpModelPool;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	ItemPoolVector maItemSetVector;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir public:
70cdf0e10cSrcweir 	SvxUnoMarkerTable( SdrModel* pModel ) throw();
71cdf0e10cSrcweir 	virtual	~SvxUnoMarkerTable() throw();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	void dispose();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	// SfxListener
76cdf0e10cSrcweir 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	void SAL_CALL ImplInsertByName( const OUString& aName, const uno::Any& aElement );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     // XServiceInfo
81cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName(  ) throw( uno::RuntimeException );
82cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const  OUString& ServiceName ) throw( uno::RuntimeException);
83cdf0e10cSrcweir     virtual uno::Sequence<  OUString > SAL_CALL getSupportedServiceNames(  ) throw( uno::RuntimeException);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	// XNameContainer
86cdf0e10cSrcweir 	virtual void SAL_CALL insertByName( const  OUString& aName, const  uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
87cdf0e10cSrcweir 	virtual void SAL_CALL removeByName( const  OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	// XNameReplace
90cdf0e10cSrcweir     virtual void SAL_CALL replaceByName( const  OUString& aName, const  uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	// XNameAccess
93cdf0e10cSrcweir     virtual uno::Any SAL_CALL getByName( const  OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
94cdf0e10cSrcweir     virtual uno::Sequence<  OUString > SAL_CALL getElementNames(  ) throw( uno::RuntimeException);
95cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasByName( const  OUString& aName ) throw( uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	// XElementAccess
98cdf0e10cSrcweir     virtual uno::Type SAL_CALL getElementType(  ) throw( uno::RuntimeException);
99cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements(  ) throw( uno::RuntimeException);
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
SvxUnoMarkerTable(SdrModel * pModel)102cdf0e10cSrcweir SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw()
103cdf0e10cSrcweir : mpModel( pModel ),
104cdf0e10cSrcweir   mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	if( pModel )
107cdf0e10cSrcweir 		StartListening( *pModel );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
~SvxUnoMarkerTable()110cdf0e10cSrcweir SvxUnoMarkerTable::~SvxUnoMarkerTable() throw()
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	if( mpModel )
113cdf0e10cSrcweir 		EndListening( *mpModel );
114cdf0e10cSrcweir 	dispose();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
dispose()117cdf0e10cSrcweir void SvxUnoMarkerTable::dispose()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	ItemPoolVector::iterator aIter = maItemSetVector.begin();
120cdf0e10cSrcweir 	const ItemPoolVector::iterator aEnd = maItemSetVector.end();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	while( aIter != aEnd )
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 		delete (*aIter++);
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	maItemSetVector.clear();
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // SfxListener
Notify(SfxBroadcaster &,const SfxHint & rHint)131cdf0e10cSrcweir void SvxUnoMarkerTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() )
136cdf0e10cSrcweir 		dispose();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
supportsService(const OUString & ServiceName)139cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const  OUString& ServiceName ) throw(uno::RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
142cdf0e10cSrcweir     const OUString * pArray = aSNL.getConstArray();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
145cdf0e10cSrcweir         if( pArray[i] == ServiceName )
146cdf0e10cSrcweir             return sal_True;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     return sal_False;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
getImplementationName()151cdf0e10cSrcweir OUString SAL_CALL SvxUnoMarkerTable::getImplementationName() throw( uno::RuntimeException )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoMarkerTable") );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
getSupportedServiceNames()156cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getSupportedServiceNames(  )
157cdf0e10cSrcweir 	throw( uno::RuntimeException )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     uno::Sequence< OUString > aSNS( 1 );
160cdf0e10cSrcweir     aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable" ));
161cdf0e10cSrcweir     return aSNS;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
ImplInsertByName(const OUString & aName,const uno::Any & aElement)164cdf0e10cSrcweir void SAL_CALL SvxUnoMarkerTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND );
167cdf0e10cSrcweir 	maItemSetVector.push_back( mpInSet );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	XLineEndItem aEndMarker;
170cdf0e10cSrcweir 	aEndMarker.SetName( String( aName ) );
171cdf0e10cSrcweir 	aEndMarker.PutValue( aElement );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	mpInSet->Put( aEndMarker, XATTR_LINEEND );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	XLineStartItem aStartMarker;
176cdf0e10cSrcweir 	aStartMarker.SetName( String( aName ) );
177cdf0e10cSrcweir 	aStartMarker.PutValue( aElement );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	mpInSet->Put( aStartMarker, XATTR_LINESTART );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir // XNameContainer
insertByName(const OUString & aApiName,const uno::Any & aElement)183cdf0e10cSrcweir void SAL_CALL SvxUnoMarkerTable::insertByName( const OUString& aApiName, const uno::Any& aElement )
184cdf0e10cSrcweir 	throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	if( hasByName( aApiName ) )
189cdf0e10cSrcweir 		throw container::ElementExistException();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	String aName;
192cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	ImplInsertByName( aName, aElement );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
removeByName(const OUString & aApiName)197cdf0e10cSrcweir void SAL_CALL SvxUnoMarkerTable::removeByName( const OUString& aApiName )
198cdf0e10cSrcweir 	throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	// a little quickfix for 2.0 to let applications clear api
203cdf0e10cSrcweir 	// created items that are not used
204cdf0e10cSrcweir 	if( aApiName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("~clear~") ) )
205cdf0e10cSrcweir 	{
206cdf0e10cSrcweir 		dispose();
207cdf0e10cSrcweir 		return;
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	String Name;
211cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, Name );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	ItemPoolVector::iterator aIter = maItemSetVector.begin();
214cdf0e10cSrcweir 	const ItemPoolVector::iterator aEnd = maItemSetVector.end();
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	NameOrIndex *pItem;
217cdf0e10cSrcweir 	const String aSearchName( Name );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	while( aIter != aEnd )
220cdf0e10cSrcweir 	{
221cdf0e10cSrcweir 		pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
222cdf0e10cSrcweir 		if( pItem->GetName() == aSearchName )
223cdf0e10cSrcweir 		{
224cdf0e10cSrcweir 			delete (*aIter);
225cdf0e10cSrcweir 			maItemSetVector.erase( aIter );
226cdf0e10cSrcweir 			return;
227cdf0e10cSrcweir 		}
228cdf0e10cSrcweir 		aIter++;
229cdf0e10cSrcweir 	}
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	if( !hasByName( Name ) )
232cdf0e10cSrcweir 		throw container::NoSuchElementException();
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir // XNameReplace
replaceByName(const OUString & aApiName,const uno::Any & aElement)236cdf0e10cSrcweir void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const uno::Any& aElement )
237cdf0e10cSrcweir 	throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	String aName;
242cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	ItemPoolVector::iterator aIter = maItemSetVector.begin();
245cdf0e10cSrcweir 	const ItemPoolVector::iterator aEnd = maItemSetVector.end();
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	NameOrIndex *pItem;
248cdf0e10cSrcweir 	const String aSearchName( aName );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	while( aIter != aEnd )
251cdf0e10cSrcweir 	{
252cdf0e10cSrcweir 		pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
253cdf0e10cSrcweir 		if( pItem->GetName() == aSearchName )
254cdf0e10cSrcweir 		{
255cdf0e10cSrcweir 			XLineEndItem aEndMarker;
256cdf0e10cSrcweir 			aEndMarker.SetName( aSearchName );
257cdf0e10cSrcweir 			if( !aEndMarker.PutValue( aElement ) )
258cdf0e10cSrcweir 				throw lang::IllegalArgumentException();
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 			(*aIter)->Put( aEndMarker, XATTR_LINEEND );
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 			XLineStartItem aStartMarker;
263cdf0e10cSrcweir 			aStartMarker.SetName( aSearchName );
264cdf0e10cSrcweir 			aStartMarker.PutValue( aElement );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 			(*aIter)->Put( aStartMarker, XATTR_LINESTART );
267cdf0e10cSrcweir 			return;
268cdf0e10cSrcweir 		}
269cdf0e10cSrcweir 		aIter++;
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	// if it is not in our own sets, modify the pool!
273cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	sal_uInt32 nSurrogate;
276cdf0e10cSrcweir 	const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
277cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
280cdf0e10cSrcweir 		if( pItem && pItem->GetName() == aSearchName )
281cdf0e10cSrcweir 		{
282cdf0e10cSrcweir 			pItem->PutValue( aElement );
283cdf0e10cSrcweir 			bFound = sal_True;
284cdf0e10cSrcweir 			break;
285cdf0e10cSrcweir 		}
286cdf0e10cSrcweir 	}
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
289cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
292cdf0e10cSrcweir 		if( pItem && pItem->GetName() == aSearchName )
293cdf0e10cSrcweir 		{
294cdf0e10cSrcweir 			pItem->PutValue( aElement );
295cdf0e10cSrcweir 			bFound = sal_True;
296cdf0e10cSrcweir 			break;
297cdf0e10cSrcweir 		}
298cdf0e10cSrcweir 	}
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	if( bFound )
301cdf0e10cSrcweir 		ImplInsertByName( aName, aElement );
302cdf0e10cSrcweir 	else
303cdf0e10cSrcweir 		throw container::NoSuchElementException();
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
getByNameFromPool(const String & rSearchName,SfxItemPool * pPool,sal_uInt16 nWhich,uno::Any & rAny)306cdf0e10cSrcweir static sal_Bool getByNameFromPool( const String& rSearchName, SfxItemPool* pPool, sal_uInt16 nWhich, uno::Any& rAny )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	NameOrIndex *pItem;
309cdf0e10cSrcweir 	const sal_uInt32 nSurrogateCount = pPool ? pPool->GetItemCount2( nWhich ) : 0;
310cdf0e10cSrcweir 	for( sal_uInt32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
311cdf0e10cSrcweir 	{
312cdf0e10cSrcweir 		pItem = (NameOrIndex*)pPool->GetItem2( nWhich, nSurrogate );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 		if( pItem && pItem->GetName() == rSearchName )
315cdf0e10cSrcweir 		{
316cdf0e10cSrcweir 			pItem->QueryValue( rAny, 0 );
317cdf0e10cSrcweir 			return sal_True;
318cdf0e10cSrcweir 		}
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	return sal_False;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir // XNameAccess
getByName(const OUString & aApiName)325cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aApiName )
326cdf0e10cSrcweir 	throw( container::NoSuchElementException,  lang::WrappedTargetException, uno::RuntimeException)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	String aName;
331cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 	uno::Any aAny;
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	if( mpModelPool && aName.Len() != 0 )
336cdf0e10cSrcweir 	{
337cdf0e10cSrcweir 		do
338cdf0e10cSrcweir 		{
339cdf0e10cSrcweir 			const String aSearchName( aName );
340cdf0e10cSrcweir 			if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINESTART, aAny ) )
341cdf0e10cSrcweir 				break;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 			if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINEEND, aAny ) )
344cdf0e10cSrcweir 				break;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 			throw container::NoSuchElementException();
347cdf0e10cSrcweir 		}
348cdf0e10cSrcweir 		while(0);
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	return aAny;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
createNamesForPool(SfxItemPool * pPool,sal_uInt16 nWhich,std::set<OUString,comphelper::UStringLess> & rNameSet)354cdf0e10cSrcweir static void createNamesForPool( SfxItemPool* pPool, sal_uInt16 nWhich, std::set< OUString, comphelper::UStringLess >& rNameSet )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir 	const sal_uInt32 nSuroCount = pPool->GetItemCount2( nWhich );
357cdf0e10cSrcweir 	sal_uInt32 nSurrogate;
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	NameOrIndex* pItem;
360cdf0e10cSrcweir 	OUString aName;
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nSuroCount; nSurrogate++ )
363cdf0e10cSrcweir 	{
364cdf0e10cSrcweir 		pItem = (NameOrIndex*)pPool->GetItem2( nWhich, nSurrogate );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		if( pItem == NULL || pItem->GetName().Len() == 0 )
367cdf0e10cSrcweir 			continue;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 		SvxUnogetApiNameForItem( XATTR_LINEEND, pItem->GetName(), aName );
370cdf0e10cSrcweir 		rNameSet.insert( aName );
371cdf0e10cSrcweir 	}
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
getElementNames()374cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames()
375cdf0e10cSrcweir 	throw( uno::RuntimeException )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 	std::set< OUString, comphelper::UStringLess > aNameSet;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	// search model pool for line starts
382cdf0e10cSrcweir 	createNamesForPool( mpModelPool, XATTR_LINESTART, aNameSet );
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 	// search model pool for line ends
385cdf0e10cSrcweir 	createNamesForPool( mpModelPool, XATTR_LINEEND, aNameSet );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	uno::Sequence< OUString > aSeq( aNameSet.size() );
388cdf0e10cSrcweir 	OUString* pNames = aSeq.getArray();
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() );
391cdf0e10cSrcweir 	const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 	while( aIter != aEnd )
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		*pNames++ = *aIter++;
396cdf0e10cSrcweir 	}
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 	return aSeq;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
hasByName(const OUString & aName)401cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName )
402cdf0e10cSrcweir 	throw( uno::RuntimeException )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	if( aName.getLength() == 0 )
407cdf0e10cSrcweir 		return sal_False;
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 	String aSearchName;
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	NameOrIndex *pItem;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINESTART, aName, aSearchName );
414cdf0e10cSrcweir 	sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
415cdf0e10cSrcweir 	sal_uInt32 nSurrogate;
416cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
417cdf0e10cSrcweir 	{
418cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
419cdf0e10cSrcweir 		if( pItem && pItem->GetName() == aSearchName )
420cdf0e10cSrcweir 			return sal_True;
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	SvxUnogetInternalNameForItem( XATTR_LINEEND, aName, aSearchName );
424cdf0e10cSrcweir 	sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
425cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
426cdf0e10cSrcweir 	{
427cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
428cdf0e10cSrcweir 		if( pItem && pItem->GetName() == aSearchName )
429cdf0e10cSrcweir 			return sal_True;
430cdf0e10cSrcweir 	}
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 	return sal_False;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir // XElementAccess
getElementType()436cdf0e10cSrcweir uno::Type SAL_CALL SvxUnoMarkerTable::getElementType(  )
437cdf0e10cSrcweir 	throw( uno::RuntimeException )
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	return ::getCppuType((const drawing::PointSequence*)0);
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
hasElements()442cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements(  )
443cdf0e10cSrcweir 	throw( uno::RuntimeException )
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	OGuard aGuard( Application::GetSolarMutex() );
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	NameOrIndex *pItem;
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 	const sal_uInt32 nStartCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINESTART ) : 0;
450cdf0e10cSrcweir 	sal_uInt32 nSurrogate;
451cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
452cdf0e10cSrcweir 	{
453cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINESTART, nSurrogate);
454cdf0e10cSrcweir 		if( pItem && pItem->GetName().Len() != 0 )
455cdf0e10cSrcweir 			return sal_True;
456cdf0e10cSrcweir 	}
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 	const sal_uInt32 nEndCount = mpModelPool ? mpModelPool->GetItemCount2( XATTR_LINEEND ) : 0;
459cdf0e10cSrcweir 	for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
460cdf0e10cSrcweir 	{
461cdf0e10cSrcweir 		pItem = (NameOrIndex*)mpModelPool->GetItem2( XATTR_LINEEND, nSurrogate);
462cdf0e10cSrcweir 		if( pItem && pItem->GetName().Len() != 0 )
463cdf0e10cSrcweir 			return sal_True;
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	return sal_False;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir /**
470cdf0e10cSrcweir  * Create a hatchtable
471cdf0e10cSrcweir  */
SvxUnoMarkerTable_createInstance(SdrModel * pModel)472cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SvxUnoMarkerTable_createInstance( SdrModel* pModel )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	return *new SvxUnoMarkerTable(pModel);
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 
479