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