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