xref: /AOO41X/main/svx/source/unodraw/unomod.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #define _SVX_USE_UNOGLOBALS_
32 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
33 #include <com/sun/star/lang/NoSupportException.hpp>
34 #include <com/sun/star/drawing/XShape.hpp>
35 #include <vos/mutex.hxx>
36 #include <vcl/svapp.hxx>
37 #include <tools/list.hxx>
38 #include <svl/itemprop.hxx>
39 #include <svtools/unoevent.hxx>
40 #include <comphelper/sequence.hxx>
41 #include <comphelper/serviceinfohelper.hxx>
42 
43 #include <cppuhelper/implbase2.hxx>
44 #include <svx/unofill.hxx>
45 #include <editeng/unonrule.hxx>
46 #include <svtools/unoimap.hxx>
47 #include <svx/fmdpage.hxx>
48 #include <svx/fmmodel.hxx>
49 #include <svx/fmpage.hxx>
50 #include <sfx2/sfx.hrc>
51 #include <svx/unoapi.hxx>
52 
53 #include <svx/svdmodel.hxx>
54 #include "svx/globl3d.hxx"
55 #include <svx/svdtypes.hxx>
56 #include <svx/unoprov.hxx>
57 #include <svx/unopage.hxx>
58 #include <editeng/unofield.hxx>
59 #include <svx/unomod.hxx>
60 #include <svx/unomodel.hxx>
61 #include <svx/svdobj.hxx>
62 #include <svx/svdpage.hxx>
63 #include <svx/unoshape.hxx>
64 
65 extern UHashMapEntry pSdrShapeIdentifierMap[];
66 
67 //-////////////////////////////////////////////////////////////////////
68 
69 using namespace ::rtl;
70 using namespace ::osl;
71 using namespace ::vos;
72 using namespace ::com::sun::star;
73 
74 //-////////////////////////////////////////////////////////////////////
75 
76 #define QUERYINT( xint ) \
77 	if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
78 		aAny <<= uno::Reference< xint >(this)
79 
80 #define ITYPE( xint ) \
81 	::getCppuType((const uno::Reference< xint >*)0)
82 
83 //-////////////////////////////////////////////////////////////////////
84 
85 #ifndef SVX_LIGHT
86 
87 class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo >
88 {
89 private:
90 	SvxUnoDrawingModel&	mrModel;
91 
92 public:
93 	SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw();
94 	virtual ~SvxUnoDrawPagesAccess() throw();
95 
96 	// XDrawPages
97     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException);
99 
100 	// XIndexAccess
101     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
102     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
103 
104 	// XElementAccess
105     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
106     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
107 
108     // XServiceInfo
109     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
110     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
111     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
112 };
113 #endif
114 //-////////////////////////////////////////////////////////////////////
115 
116 #ifndef SVX_LIGHT
117 const SvEventDescription* ImplGetSupportedMacroItems()
118 {
119 	static const SvEventDescription aMacroDescriptionsImpl[] =
120 	{
121 		{ SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
122 		{ SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
123 		{ 0, NULL }
124 	};
125 
126 	return aMacroDescriptionsImpl;
127 }
128 #endif
129 
130 //-////////////////////////////////////////////////////////////////////
131 
132 /** fills the given EventObject from the given SdrHint.
133 	@returns
134 		true	if the SdrHint could be translated to an EventObject<br>
135 		false	if not
136 */
137 sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint* pSdrHint, ::com::sun::star::document::EventObject& aEvent )
138 {
139 	const SdrObject* pObj = NULL;
140 	const SdrPage* pPage = NULL;
141 
142 	switch( pSdrHint->GetKind() )
143 	{
144 //				case HINT_LAYERCHG:				// Layerdefinition geaendert
145 //				case HINT_LAYERORDERCHG:		// Layerreihenfolge geaendert (Insert/Remove/ChangePos)
146 //				case HINT_LAYERSETCHG:			// Layerset geaendert
147 //				case HINT_LAYERSETORDERCHG:		// Layersetreihenfolge geaendert (Insert/Remove/ChangePos)
148 
149 // #115423#
150 //		case HINT_PAGECHG:				// Page geaendert
151 //			aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageModified" ) );
152 //			pPage = pSdrHint->GetPage();
153 //			break;
154 		case HINT_PAGEORDERCHG:			// Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos)
155 			aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOrderModified" ) );
156 			pPage = pSdrHint->GetPage();
157 			break;
158 		case HINT_OBJCHG:				// Objekt geaendert
159 			aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeModified" ) );
160 			pObj = pSdrHint->GetObject();
161 			break;
162 		case HINT_OBJINSERTED:			// Neues Zeichenobjekt eingefuegt
163 			aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeInserted" ) );
164 			pObj = pSdrHint->GetObject();
165 			break;
166 		case HINT_OBJREMOVED:			// Zeichenobjekt aus Liste entfernt
167 			aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeRemoved" ) );
168 			pObj = pSdrHint->GetObject();
169 			break;
170 //				  HINT_DEFAULTTABCHG,   // Default Tabulatorweite geaendert
171 //				  HINT_DEFFONTHGTCHG,   // Default FontHeight geaendert
172 //				  HINT_SWITCHTOPAGE,    // #94278# UNDO/REDO at an object evtl. on another page
173 //				  HINT_OBJLISTCLEAR		// Is called before an SdrObjList will be cleared
174 		default:
175 			return sal_False;
176 	}
177 
178 	if( pObj )
179 		aEvent.Source = const_cast<SdrObject*>(pObj)->getUnoShape();
180 	else if( pPage )
181 		aEvent.Source = const_cast<SdrPage*>(pPage)->getUnoPage();
182 	else
183 		aEvent.Source = (const_cast<SdrModel*>(pDoc))->getUnoModel();
184 
185 	return sal_True;
186 }
187 
188 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& ServiceSpecifier )
189 	throw( uno::Exception, uno::RuntimeException )
190 {
191 	const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") );
192 
193 	if( ServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
194 	{
195 		sal_uInt32 nType = aSdrShapeIdentifierMap.getId( ServiceSpecifier );
196 		if( nType != UHASHMAP_NOTFOUND )
197 		{
198 			sal_uInt16 nT = (sal_uInt16)(nType & ~E3D_INVENTOR_FLAG);
199 			sal_uInt32 nI = (nType & E3D_INVENTOR_FLAG)?E3dInventor:SdrInventor;
200 
201 			return uno::Reference< uno::XInterface >( (drawing::XShape*) SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI ) );
202 		}
203 	}
204 
205 	uno::Reference< uno::XInterface > xRet( createTextField( ServiceSpecifier ) );
206 	if( !xRet.is() )
207 		throw lang::ServiceNotRegisteredException();
208 
209 	return xRet;
210 }
211 
212 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
213 {
214 	return SvxUnoTextCreateTextField( ServiceSpecifier );
215 }
216 
217 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWithArguments( const OUString&, const uno::Sequence< ::com::sun::star::uno::Any >& )
218 	throw( uno::Exception, uno::RuntimeException )
219 {
220 	throw lang::NoSupportException();
221 }
222 
223 uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames()
224 	throw( uno::RuntimeException )
225 {
226 	UHashMapEntry* pMap = pSdrShapeIdentifierMap;
227 
228 	sal_uInt32 nCount = 0;
229 	while (pMap->aIdentifier.getLength())
230 	{
231 		pMap++;
232 		nCount++;
233 	}
234 
235 	uno::Sequence< OUString > aSeq( nCount );
236 	OUString* pStrings = aSeq.getArray();
237 
238 	pMap = pSdrShapeIdentifierMap;
239 	sal_uInt32 nIdx = 0;
240 	while(pMap->aIdentifier.getLength())
241 	{
242 		pStrings[nIdx] = pMap->aIdentifier;
243 		pMap++;
244 		nIdx++;
245 	}
246 
247 	return aSeq;
248 }
249 
250 uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw()
251 {
252 	const sal_Int32 nLen1 = rServices1.getLength();
253 	const sal_Int32 nLen2 = rServices2.getLength();
254 
255 	uno::Sequence< OUString > aSeq( nLen1+nLen2 );
256 	OUString* pStrings = aSeq.getArray();
257 
258 	sal_Int32 nIdx;
259 	OUString* pStringDst = pStrings;
260 	const OUString* pStringSrc = rServices1.getArray();
261 
262 	for( nIdx = 0; nIdx < nLen1; nIdx++ )
263 		*pStringDst++ = *pStringSrc++;
264 
265 	pStringSrc = rServices2.getArray();
266 
267 	for( nIdx = 0; nIdx < nLen2; nIdx++ )
268 		*pStringDst++ = *pStringSrc++;
269 
270 	return aSeq;
271 }
272 
273 
274 #ifndef SVX_LIGHT
275 
276 ///
277 SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw()
278 : mpDoc( pDoc )
279 {
280 }
281 
282 SvxUnoDrawingModel::~SvxUnoDrawingModel() throw()
283 {
284 }
285 
286 uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
287 {
288 	uno::Any aAny;
289 
290 	QUERYINT(lang::XServiceInfo);
291 	else QUERYINT(lang::XMultiServiceFactory);
292 	else QUERYINT(drawing::XDrawPagesSupplier);
293 	else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
294 	else
295 		return SfxBaseModel::queryInterface( rType );
296 
297 	return aAny;
298 }
299 
300 void SAL_CALL SvxUnoDrawingModel::acquire() throw ( )
301 {
302 	SfxBaseModel::acquire();
303 }
304 
305 void SAL_CALL SvxUnoDrawingModel::release() throw ( )
306 {
307 	SfxBaseModel::release();
308 }
309 
310 // XTypeProvider
311 uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes(  ) throw(uno::RuntimeException)
312 {
313 	if( maTypeSequence.getLength() == 0 )
314 	{
315 		const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
316 		const sal_Int32 nBaseTypes = aBaseTypes.getLength();
317 		const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
318 
319 		const sal_Int32 nOwnTypes = 4;		// !DANGER! Keep this updated!
320 
321 		maTypeSequence.realloc(  nBaseTypes + nOwnTypes );
322 		uno::Type* pTypes = maTypeSequence.getArray();
323 
324 		*pTypes++ = ITYPE(lang::XServiceInfo);
325 		*pTypes++ = ITYPE(lang::XMultiServiceFactory);
326 		*pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
327 		*pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
328 
329 		for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
330 			*pTypes++ = *pBaseTypes++;
331 	}
332 
333 	return maTypeSequence;
334 }
335 
336 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId(  ) throw(uno::RuntimeException)
337 {
338 	static uno::Sequence< sal_Int8 > aId;
339 	if( aId.getLength() == 0 )
340 	{
341 		aId.realloc( 16 );
342 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
343 	}
344 	return aId;
345 }
346 
347 void SAL_CALL SvxUnoDrawingModel::lockControllers(  )
348 	throw(uno::RuntimeException)
349 {
350 	if( mpDoc )
351 		mpDoc->setLock( sal_True );
352 }
353 
354 void SAL_CALL SvxUnoDrawingModel::unlockControllers(  )
355 	throw(uno::RuntimeException)
356 {
357 	if( mpDoc && mpDoc->isLocked() )
358 	{
359 		mpDoc->setLock( sal_False );
360 	}
361 }
362 
363 sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked(  )
364 	throw(uno::RuntimeException)
365 {
366 	return mpDoc && mpDoc->isLocked();
367 }
368 
369 // XDrawPagesSupplier
370 uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages()
371 	throw(uno::RuntimeException)
372 {
373 	OGuard aGuard( Application::GetSolarMutex() );
374 
375 	uno::Reference< drawing::XDrawPages >  xDrawPages( mxDrawPagesAccess );
376 
377 	if( !xDrawPages.is() )
378 		mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this);
379 
380 	return xDrawPages;
381 }
382 
383 // XMultiServiceFactory ( SvxFmMSFactory )
384 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier )
385 	throw(uno::Exception, uno::RuntimeException)
386 {
387 	OGuard aGuard( Application::GetSolarMutex() );
388 
389 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
390 	{
391 		if( !mxDashTable.is() )
392 			mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
393 		return mxDashTable;
394 	}
395 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
396 	{
397 		if( !mxGradientTable.is() )
398 			mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
399 		return mxGradientTable;
400 	}
401 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
402 	{
403 		if( !mxHatchTable.is() )
404 			mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
405 		return mxHatchTable;
406 	}
407 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
408 	{
409 		if( !mxBitmapTable.is() )
410 			mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
411 		return mxBitmapTable;
412 	}
413 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
414 	{
415 		if( !mxTransGradientTable.is() )
416 			mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
417 		return mxTransGradientTable;
418 	}
419 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
420 	{
421 		if( !mxMarkerTable.is() )
422 			mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
423 		return mxMarkerTable;
424 	}
425 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
426 	{
427 		return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
428 	}
429 
430 	if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapRectangleObject") ) )
431 	{
432 		return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
433 	}
434 
435 	if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapCircleObject") ) )
436 	{
437 		return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
438 	}
439 
440 	if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapPolygonObject") ) )
441 	{
442 		return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
443 	}
444 
445 	if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) )
446 	{
447 		return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD );
448 	}
449 
450 	uno::Reference< uno::XInterface > xRet;
451 
452 	const String aType( aServiceSpecifier );
453 	if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
454 	{
455 		SvxShape* pShape = NULL;
456 
457 		sal_uInt16 nType = OBJ_TEXT;
458 		// create a shape wrapper
459 		if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
460 		{
461 			nType = OBJ_TEXT;
462 		}
463 		else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
464 		{
465 			nType = OBJ_TEXT;
466 		}
467 		else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
468 		{
469 			nType = OBJ_TEXT;
470 		}
471 		else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
472 		{
473 			nType = OBJ_GRAF;
474 		}
475 		else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
476 		{
477 			nType = OBJ_PAGE;
478 		}
479 		else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
480 		{
481 			nType = OBJ_OLE2;
482 		}
483 		else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
484 		{
485 			nType = OBJ_OLE2;
486 		}
487 		else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
488 		{
489 			nType = OBJ_OLE2;
490 		}
491 		else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
492 		{
493 			nType = OBJ_OLE2;
494 		}
495 		else if( aType.EqualsAscii( "NotesShape", 26, 10 ) )
496 		{
497 			nType = OBJ_TEXT;
498 		}
499 		else if( aType.EqualsAscii( "HandoutShape", 26, 12 ) )
500 		{
501 			nType = OBJ_PAGE;
502 		}
503 		else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
504 		{
505 			nType = OBJ_TEXT;
506 		}
507 		else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
508 		{
509 			nType = OBJ_TEXT;
510 		}
511 		else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
512 		{
513 			nType = OBJ_TEXT;
514 		}
515 		else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
516 		{
517 			nType = OBJ_TEXT;
518 		}
519 		else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
520 		{
521 			nType = OBJ_TABLE;
522 		}
523 		else
524 		{
525 			throw lang::ServiceNotRegisteredException();
526 		}
527 
528 		// create the API wrapper
529 		pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
530 
531 		// set shape type
532 		if( pShape )
533 			pShape->SetShapeType(aServiceSpecifier);
534 
535 		xRet = (uno::XWeak*)pShape;
536 	}
537 	else
538 	{
539 		xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
540 	}
541 
542 	return xRet;
543 }
544 
545 uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames()
546 	throw(uno::RuntimeException)
547 {
548 	const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
549 
550 	uno::Sequence< OUString > aSNS( 21 );
551 
552 	sal_uInt16 i = 0;
553 
554 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
555 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
556 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
557 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
558 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
559 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
560 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
561 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject"));
562 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject"));
563 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject"));
564 
565 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
566 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
567 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
568 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
569 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
570 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
571 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
572 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
573 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
574 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
575 	aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
576 
577 	DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
578 
579 	return comphelper::concatSequences( aSNS_ORG, aSNS );
580 }
581 
582 // lang::XServiceInfo
583 OUString SAL_CALL SvxUnoDrawingModel::getImplementationName()
584 	throw(uno::RuntimeException)
585 {
586 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel"));
587 }
588 
589 sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName )
590 	throw(uno::RuntimeException)
591 {
592 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
593 }
594 
595 uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException)
596 {
597 	OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
598 	uno::Sequence< OUString > aSeq( &aSN, 1 );
599 	return aSeq;
600 }
601 
602 // XAnyCompareFactory
603 uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& )
604 	throw(uno::RuntimeException)
605 {
606 	return SvxCreateNumRuleCompare();
607 }
608 
609 //=============================================================================
610 // class SvxUnoDrawPagesAccess
611 //=============================================================================
612 
613 SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel )  throw()
614 :	mrModel(rMyModel)
615 {
616 }
617 
618 SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw()
619 {
620 }
621 
622 // XIndexAccess
623 sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount()
624 	throw(uno::RuntimeException)
625 {
626 	OGuard aGuard( Application::GetSolarMutex() );
627 
628 	sal_Int32 nCount = 0;
629 
630 	if( mrModel.mpDoc )
631 		nCount = mrModel.mpDoc->GetPageCount();
632 
633 	return( nCount );
634 }
635 
636 uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index )
637 	throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
638 {
639 	OGuard aGuard( Application::GetSolarMutex() );
640 
641 	uno::Any aAny;
642 
643 	if( mrModel.mpDoc )
644 	{
645 		if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) )
646 			throw lang::IndexOutOfBoundsException();
647 
648 		SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index );
649 		if( pPage )
650 		{
651 			uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage );
652 
653 			if( !xPage.is() )
654 			{
655 				if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
656 					xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage );
657 				else
658 					xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage );
659 
660 				pPage->mxUnoPage = xPage;
661 			}
662 
663 			aAny <<= xPage;
664 		}
665 	}
666 	return aAny;
667 }
668 
669 // XElementAccess
670 uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType()
671 	throw(uno::RuntimeException)
672 {
673 	return ITYPE( drawing::XDrawPage );
674 }
675 
676 sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements()
677 	throw(uno::RuntimeException)
678 {
679 	return getCount() > 0;
680 }
681 
682 // XDrawPages
683 
684 /******************************************************************************
685 * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
686 * dazugehoerige SdDrawPage zurueck.                                           *
687 ******************************************************************************/
688 uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
689 	throw(uno::RuntimeException)
690 {
691 	OGuard aGuard( Application::GetSolarMutex() );
692 
693 	uno::Reference< drawing::XDrawPage > xDrawPage;
694 
695 	if( mrModel.mpDoc )
696 	{
697 		SdrPage* pPage;
698 
699 		if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
700 			pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL);
701 		else
702 			pPage = new SdrPage(*mrModel.mpDoc);
703 
704 		mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex );
705 		xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
706 	}
707 
708 	return xDrawPage;
709 }
710 
711 void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
712 		throw(uno::RuntimeException)
713 {
714 	OGuard aGuard( Application::GetSolarMutex() );
715 
716 	sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount();
717 	if( nPageCount > 1 )
718 	{
719 		// pPage von xPage besorgen und dann die Id (nPos )ermitteln
720 		SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
721 		if( pSvxPage )
722 		{
723 			SdrPage* pPage = pSvxPage->GetSdrPage();
724 			if(pPage)
725 			{
726 				sal_uInt16 nPage = pPage->GetPageNum();
727 				mrModel.mpDoc->DeletePage( nPage );
728 			}
729 		}
730 	}
731 }
732 
733 // XServiceInfo
734 sal_Char pSvxUnoDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
735 
736 OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
737 {
738 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) );
739 }
740 
741 sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
742 {
743 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoDrawPagesAccessService ) );
744 }
745 
746 uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
747 {
748 	OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) );
749 	uno::Sequence< OUString > aSeq( &aService, 1 );
750 	return aSeq;
751 }
752 #include <editeng/unonrule.hxx>
753 com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( SdrModel* pModel ) throw()
754 {
755 	SvxNumRule* pDefaultRule = NULL;
756 	if( pModel )
757 	{
758 		SvxNumBulletItem* pItem = (SvxNumBulletItem*) pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
759 		if( pItem )
760 		{
761 			pDefaultRule = pItem->GetNumRule();
762 		}
763 	}
764 
765 	if( pDefaultRule )
766 	{
767 		return SvxCreateNumRule( pDefaultRule );
768 	}
769 	else
770 	{
771 		SvxNumRule aTempRule( 0, 10, false );
772 		return SvxCreateNumRule( &aTempRule );
773 	}
774 }
775 
776 ///////////////////////////////////////////////////////////////////////
777 
778 #endif
779