merge the formfield patch from ooo-build
[ooovba.git] / svx / source / unodraw / unomod.cxx
blobb514debc7b990453f51102253ba036954ded219b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unomod.cxx,v $
10 * $Revision: 1.23 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #define _SVX_USE_UNOGLOBALS_
35 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
36 #include <com/sun/star/lang/NoSupportException.hpp>
37 #include <com/sun/star/drawing/XShape.hpp>
38 #include <vos/mutex.hxx>
39 #include <vcl/svapp.hxx>
40 #include <tools/list.hxx>
41 #include <svtools/itemprop.hxx>
42 #include <svtools/unoevent.hxx>
43 #include <comphelper/sequence.hxx>
45 #include <cppuhelper/implbase2.hxx>
46 #include <unofill.hxx>
47 #include <unonrule.hxx>
48 #include <svtools/unoimap.hxx>
49 #include <svx/fmdpage.hxx>
50 #include <svx/fmmodel.hxx>
51 #include <svx/fmpage.hxx>
52 #include <sfx2/sfx.hrc>
53 #include <unoapi.hxx>
55 #include <svx/svdmodel.hxx>
56 #include "globl3d.hxx"
57 #include <svx/svdtypes.hxx>
58 #include <svx/unoprov.hxx>
59 #include <svx/unopage.hxx>
60 #include <svx/unofield.hxx>
61 #include <svx/unomod.hxx>
62 #include <svx/unomodel.hxx>
63 #include <svx/svdobj.hxx>
64 #include <svx/svdpage.hxx>
65 #include <svx/unoshape.hxx>
67 extern UHashMapEntry pSdrShapeIdentifierMap[];
69 //-////////////////////////////////////////////////////////////////////
71 using namespace ::rtl;
72 using namespace ::osl;
73 using namespace ::vos;
74 using namespace ::com::sun::star;
76 //-////////////////////////////////////////////////////////////////////
78 #define QUERYINT( xint ) \
79 if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
80 aAny <<= uno::Reference< xint >(this)
82 #define ITYPE( xint ) \
83 ::getCppuType((const uno::Reference< xint >*)0)
85 //-////////////////////////////////////////////////////////////////////
87 #ifndef SVX_LIGHT
89 class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo >
91 private:
92 SvxUnoDrawingModel& mrModel;
94 public:
95 SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw();
96 virtual ~SvxUnoDrawPagesAccess() throw();
98 // XDrawPages
99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
100 virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException);
102 // XIndexAccess
103 virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
104 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);
106 // XElementAccess
107 virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
108 virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
110 // XServiceInfo
111 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
112 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
113 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
115 #endif
116 //-////////////////////////////////////////////////////////////////////
118 #ifndef SVX_LIGHT
119 const SvEventDescription* ImplGetSupportedMacroItems()
121 static const SvEventDescription aMacroDescriptionsImpl[] =
123 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
124 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
125 { 0, NULL }
128 return aMacroDescriptionsImpl;
130 #endif
132 //-////////////////////////////////////////////////////////////////////
134 /** fills the given EventObject from the given SdrHint.
135 @returns
136 true if the SdrHint could be translated to an EventObject<br>
137 false if not
139 sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint* pSdrHint, ::com::sun::star::document::EventObject& aEvent )
141 const SdrObject* pObj = NULL;
142 const SdrPage* pPage = NULL;
144 switch( pSdrHint->GetKind() )
146 // case HINT_LAYERCHG: // Layerdefinition geaendert
147 // case HINT_LAYERORDERCHG: // Layerreihenfolge geaendert (Insert/Remove/ChangePos)
148 // case HINT_LAYERSETCHG: // Layerset geaendert
149 // case HINT_LAYERSETORDERCHG: // Layersetreihenfolge geaendert (Insert/Remove/ChangePos)
151 // #115423#
152 // case HINT_PAGECHG: // Page geaendert
153 // aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageModified" ) );
154 // pPage = pSdrHint->GetPage();
155 // break;
156 case HINT_PAGEORDERCHG: // Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos)
157 aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOrderModified" ) );
158 pPage = pSdrHint->GetPage();
159 break;
160 case HINT_OBJCHG: // Objekt geaendert
161 aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeModified" ) );
162 pObj = pSdrHint->GetObject();
163 break;
164 case HINT_OBJINSERTED: // Neues Zeichenobjekt eingefuegt
165 aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeInserted" ) );
166 pObj = pSdrHint->GetObject();
167 break;
168 case HINT_OBJREMOVED: // Zeichenobjekt aus Liste entfernt
169 aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeRemoved" ) );
170 pObj = pSdrHint->GetObject();
171 break;
172 // HINT_DEFAULTTABCHG, // Default Tabulatorweite geaendert
173 // HINT_DEFFONTHGTCHG, // Default FontHeight geaendert
174 // HINT_SWITCHTOPAGE, // #94278# UNDO/REDO at an object evtl. on another page
175 // HINT_OBJLISTCLEAR // Is called before an SdrObjList will be cleared
176 default:
177 return sal_False;
180 if( pObj )
181 aEvent.Source = const_cast<SdrObject*>(pObj)->getUnoShape();
182 else if( pPage )
183 aEvent.Source = const_cast<SdrPage*>(pPage)->getUnoPage();
184 else
185 aEvent.Source = (const_cast<SdrModel*>(pDoc))->getUnoModel();
187 return sal_True;
190 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& ServiceSpecifier )
191 throw( uno::Exception, uno::RuntimeException )
193 const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") );
195 if( ServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
197 UINT32 nType = aSdrShapeIdentifierMap.getId( ServiceSpecifier );
198 if( nType != UHASHMAP_NOTFOUND )
200 UINT16 nT = (UINT16)(nType & ~E3D_INVENTOR_FLAG);
201 UINT32 nI = (nType & E3D_INVENTOR_FLAG)?E3dInventor:SdrInventor;
203 return uno::Reference< uno::XInterface >( (drawing::XShape*) SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI ) );
207 uno::Reference< uno::XInterface > xRet( createTextField( ServiceSpecifier ) );
208 if( !xRet.is() )
209 throw lang::ServiceNotRegisteredException();
211 return xRet;
214 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
216 uno::Reference< uno::XInterface > xRet;
218 const OUString aTextFieldPrexit( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.textfield.") );
220 // #i93308# up to OOo 3.2 we used this wrong namespace name with the capital T & F. This is
221 // fixed since OOo 3.2 but for compatibility we will still provide support for the wrong notation.
222 const OUString aTextFieldPrexit2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.") );
224 if( (ServiceSpecifier.compareTo( aTextFieldPrexit, aTextFieldPrexit.getLength() ) == 0) ||
225 (ServiceSpecifier.compareTo( aTextFieldPrexit2, aTextFieldPrexit2.getLength() ) == 0) )
227 OUString aFieldType( ServiceSpecifier.copy( aTextFieldPrexit.getLength() ) );
229 sal_Int32 nId = ID_UNKNOWN;
231 if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DateTime") ) )
233 nId = ID_DATEFIELD;
235 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("URL") ) )
237 nId = ID_URLFIELD;
239 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("PageNumber") ) )
241 nId = ID_PAGEFIELD;
243 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("PageCount") ) )
245 nId = ID_PAGESFIELD;
247 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SheetName") ) )
249 nId = ID_TABLEFIELD;
251 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FileName") ) )
253 nId = ID_EXT_FILEFIELD;
255 else if (aFieldType.equalsAsciiL(
256 RTL_CONSTASCII_STRINGPARAM("docinfo.Title") ) ||
257 aFieldType.equalsAsciiL(
258 RTL_CONSTASCII_STRINGPARAM("DocInfo.Title") ) )
260 nId = ID_FILEFIELD;
262 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Author") ) )
264 nId = ID_AUTHORFIELD;
266 else if( aFieldType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Measure") ) )
268 nId = ID_MEASUREFIELD;
271 if( nId != ID_UNKNOWN )
272 xRet = (::cppu::OWeakObject * )new SvxUnoTextField( nId );
275 return xRet;
278 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWithArguments( const OUString&, const uno::Sequence< ::com::sun::star::uno::Any >& )
279 throw( uno::Exception, uno::RuntimeException )
281 throw lang::NoSupportException();
284 uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames()
285 throw( uno::RuntimeException )
287 UHashMapEntry* pMap = pSdrShapeIdentifierMap;
289 UINT32 nCount = 0;
290 while (pMap->aIdentifier.getLength())
292 pMap++;
293 nCount++;
296 uno::Sequence< OUString > aSeq( nCount );
297 OUString* pStrings = aSeq.getArray();
299 pMap = pSdrShapeIdentifierMap;
300 UINT32 nIdx = 0;
301 while(pMap->aIdentifier.getLength())
303 pStrings[nIdx] = pMap->aIdentifier;
304 pMap++;
305 nIdx++;
308 return aSeq;
311 uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw()
313 const sal_Int32 nLen1 = rServices1.getLength();
314 const sal_Int32 nLen2 = rServices2.getLength();
316 uno::Sequence< OUString > aSeq( nLen1+nLen2 );
317 OUString* pStrings = aSeq.getArray();
319 sal_Int32 nIdx;
320 OUString* pStringDst = pStrings;
321 const OUString* pStringSrc = rServices1.getArray();
323 for( nIdx = 0; nIdx < nLen1; nIdx++ )
324 *pStringDst++ = *pStringSrc++;
326 pStringSrc = rServices2.getArray();
328 for( nIdx = 0; nIdx < nLen2; nIdx++ )
329 *pStringDst++ = *pStringSrc++;
331 return aSeq;
335 #ifndef SVX_LIGHT
338 SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw()
339 : mpDoc( pDoc )
343 SvxUnoDrawingModel::~SvxUnoDrawingModel() throw()
347 uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
349 uno::Any aAny;
351 QUERYINT(lang::XServiceInfo);
352 else QUERYINT(lang::XMultiServiceFactory);
353 else QUERYINT(drawing::XDrawPagesSupplier);
354 else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
355 else
356 return SfxBaseModel::queryInterface( rType );
358 return aAny;
361 void SAL_CALL SvxUnoDrawingModel::acquire() throw ( )
363 SfxBaseModel::acquire();
366 void SAL_CALL SvxUnoDrawingModel::release() throw ( )
368 SfxBaseModel::release();
371 // XTypeProvider
372 uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes( ) throw(uno::RuntimeException)
374 if( maTypeSequence.getLength() == 0 )
376 const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
377 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
378 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
380 const sal_Int32 nOwnTypes = 4; // !DANGER! Keep this updated!
382 maTypeSequence.realloc( nBaseTypes + nOwnTypes );
383 uno::Type* pTypes = maTypeSequence.getArray();
385 *pTypes++ = ITYPE(lang::XServiceInfo);
386 *pTypes++ = ITYPE(lang::XMultiServiceFactory);
387 *pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
388 *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
390 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
391 *pTypes++ = *pBaseTypes++;
394 return maTypeSequence;
397 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId( ) throw(uno::RuntimeException)
399 static uno::Sequence< sal_Int8 > aId;
400 if( aId.getLength() == 0 )
402 aId.realloc( 16 );
403 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
405 return aId;
408 void SAL_CALL SvxUnoDrawingModel::lockControllers( )
409 throw(uno::RuntimeException)
411 if( mpDoc )
412 mpDoc->setLock( sal_True );
415 void SAL_CALL SvxUnoDrawingModel::unlockControllers( )
416 throw(uno::RuntimeException)
418 if( mpDoc && mpDoc->isLocked() )
420 mpDoc->setLock( sal_False );
424 sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked( )
425 throw(uno::RuntimeException)
427 return mpDoc && mpDoc->isLocked();
430 // XDrawPagesSupplier
431 uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages()
432 throw(uno::RuntimeException)
434 OGuard aGuard( Application::GetSolarMutex() );
436 uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
438 if( !xDrawPages.is() )
439 mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this);
441 return xDrawPages;
444 // XMultiServiceFactory ( SvxFmMSFactory )
445 uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier )
446 throw(uno::Exception, uno::RuntimeException)
448 OGuard aGuard( Application::GetSolarMutex() );
450 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
452 if( !mxDashTable.is() )
453 mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
454 return mxDashTable;
456 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
458 if( !mxGradientTable.is() )
459 mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
460 return mxGradientTable;
462 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
464 if( !mxHatchTable.is() )
465 mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
466 return mxHatchTable;
468 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
470 if( !mxBitmapTable.is() )
471 mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
472 return mxBitmapTable;
474 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
476 if( !mxTransGradientTable.is() )
477 mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
478 return mxTransGradientTable;
480 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
482 if( !mxMarkerTable.is() )
483 mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
484 return mxMarkerTable;
486 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
488 return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
491 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapRectangleObject") ) )
493 return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
496 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapCircleObject") ) )
498 return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
501 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapPolygonObject") ) )
503 return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
506 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) )
508 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD );
511 uno::Reference< uno::XInterface > xRet;
513 const String aType( aServiceSpecifier );
514 if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
516 SvxShape* pShape = NULL;
518 sal_uInt16 nType = OBJ_TEXT;
519 // create a shape wrapper
520 if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
522 nType = OBJ_TEXT;
524 else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
526 nType = OBJ_TEXT;
528 else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
530 nType = OBJ_TEXT;
532 else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
534 nType = OBJ_GRAF;
536 else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
538 nType = OBJ_PAGE;
540 else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
542 nType = OBJ_OLE2;
544 else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
546 nType = OBJ_OLE2;
548 else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
550 nType = OBJ_OLE2;
552 else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
554 nType = OBJ_OLE2;
556 else if( aType.EqualsAscii( "NotesShape", 26, 10 ) )
558 nType = OBJ_TEXT;
560 else if( aType.EqualsAscii( "HandoutShape", 26, 12 ) )
562 nType = OBJ_PAGE;
564 else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
566 nType = OBJ_TEXT;
568 else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
570 nType = OBJ_TEXT;
572 else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
574 nType = OBJ_TEXT;
576 else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
578 nType = OBJ_TEXT;
580 else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
582 nType = OBJ_TABLE;
584 else
586 throw lang::ServiceNotRegisteredException();
589 // create the API wrapper
590 pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
592 // set shape type
593 if( pShape )
594 pShape->SetShapeType(aServiceSpecifier);
596 xRet = (uno::XWeak*)pShape;
598 else
600 xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
603 return xRet;
606 uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames()
607 throw(uno::RuntimeException)
609 const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
611 uno::Sequence< OUString > aSNS( 21 );
613 sal_uInt16 i = 0;
615 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
616 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
617 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
618 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
619 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
620 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
621 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
622 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject"));
623 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject"));
624 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject"));
626 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
627 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
628 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
629 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
630 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
631 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
632 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
633 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
634 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
635 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
636 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
638 DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
640 return comphelper::concatSequences( aSNS_ORG, aSNS );
643 // lang::XServiceInfo
644 OUString SAL_CALL SvxUnoDrawingModel::getImplementationName()
645 throw(uno::RuntimeException)
647 return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel"));
650 sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName )
651 throw(uno::RuntimeException)
653 return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
656 uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException)
658 OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
659 uno::Sequence< OUString > aSeq( &aSN, 1 );
660 return aSeq;
663 // XAnyCompareFactory
664 uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& )
665 throw(uno::RuntimeException)
667 return SvxCreateNumRuleCompare();
670 //=============================================================================
671 // class SvxUnoDrawPagesAccess
672 //=============================================================================
674 SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw()
675 : mrModel(rMyModel)
679 SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw()
683 // XIndexAccess
684 sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount()
685 throw(uno::RuntimeException)
687 OGuard aGuard( Application::GetSolarMutex() );
689 sal_Int32 nCount = 0;
691 if( mrModel.mpDoc )
692 nCount = mrModel.mpDoc->GetPageCount();
694 return( nCount );
697 uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index )
698 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
700 OGuard aGuard( Application::GetSolarMutex() );
702 uno::Any aAny;
704 if( mrModel.mpDoc )
706 if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) )
707 throw lang::IndexOutOfBoundsException();
709 SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index );
710 if( pPage )
712 uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage );
714 if( !xPage.is() )
716 if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
717 xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage );
718 else
719 xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage );
721 pPage->mxUnoPage = xPage;
724 aAny <<= xPage;
727 return aAny;
730 // XElementAccess
731 uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType()
732 throw(uno::RuntimeException)
734 return ITYPE( drawing::XDrawPage );
737 sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements()
738 throw(uno::RuntimeException)
740 return getCount() > 0;
743 // XDrawPages
745 /******************************************************************************
746 * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
747 * dazugehoerige SdDrawPage zurueck. *
748 ******************************************************************************/
749 uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
750 throw(uno::RuntimeException)
752 OGuard aGuard( Application::GetSolarMutex() );
754 uno::Reference< drawing::XDrawPage > xDrawPage;
756 if( mrModel.mpDoc )
758 SdrPage* pPage;
760 if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
761 pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL);
762 else
763 pPage = new SdrPage(*mrModel.mpDoc);
765 mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex );
766 xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
769 return xDrawPage;
772 void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
773 throw(uno::RuntimeException)
775 OGuard aGuard( Application::GetSolarMutex() );
777 sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount();
778 if( nPageCount > 1 )
780 // pPage von xPage besorgen und dann die Id (nPos )ermitteln
781 SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
782 if( pSvxPage )
784 SdrPage* pPage = pSvxPage->GetSdrPage();
785 if(pPage)
787 sal_uInt16 nPage = pPage->GetPageNum();
788 mrModel.mpDoc->DeletePage( nPage );
794 // XServiceInfo
795 sal_Char pSvxUnoDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
797 OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException)
799 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) );
802 sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
804 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoDrawPagesAccessService ) );
807 uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
809 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) );
810 uno::Sequence< OUString > aSeq( &aService, 1 );
811 return aSeq;
814 #endif