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