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/presentation/XPresentation2.hpp>
21 :
22 : #include <com/sun/star/lang/DisposedException.hpp>
23 : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
24 : #include <com/sun/star/lang/Locale.hpp>
25 : #include <com/sun/star/style/XStyle.hpp>
26 : #include <com/sun/star/awt/XDevice.hpp>
27 : #include <com/sun/star/document/IndexedPropertyValues.hpp>
28 :
29 : #include <com/sun/star/embed/Aspects.hpp>
30 :
31 : #include <osl/mutex.hxx>
32 : #include <comphelper/sequence.hxx>
33 : #include <comphelper/servicehelper.hxx>
34 : #include <cppuhelper/supportsservice.hxx>
35 :
36 : #include <editeng/unofield.hxx>
37 : #include <notifydocumentevent.hxx>
38 : #include <unomodel.hxx>
39 : #include <unopool.hxx>
40 : #include <sfx2/dispatch.hxx>
41 : #include <sfx2/bindings.hxx>
42 : #include <vcl/svapp.hxx>
43 : #include <vcl/settings.hxx>
44 :
45 : #include <editeng/UnoForbiddenCharsTable.hxx>
46 : #include <svx/svdoutl.hxx>
47 : #include <editeng/forbiddencharacterstable.hxx>
48 : #include <svx/UnoNamespaceMap.hxx>
49 : #include <svx/svdlayer.hxx>
50 : #include <svx/svdsob.hxx>
51 : #include <svx/unoapi.hxx>
52 : #include <svx/unofill.hxx>
53 : #include <svx/unopool.hxx>
54 : #include <svx/svdorect.hxx>
55 : #include <editeng/flditem.hxx>
56 : #include <editeng/fontitem.hxx>
57 : #include <toolkit/awt/vclxdevice.hxx>
58 : #include <svx/svdpool.hxx>
59 : #include <editeng/unolingu.hxx>
60 : #include <svx/svdpagv.hxx>
61 : #include <svtools/unoimap.hxx>
62 : #include <svx/unoshape.hxx>
63 : #include <editeng/unonrule.hxx>
64 : #include <editeng/eeitem.hxx>
65 :
66 : // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
67 : #include <svx/xmleohlp.hxx>
68 : #include <svx/xmlgrhlp.hxx>
69 : #include "DrawDocShell.hxx"
70 : #include "ViewShellBase.hxx"
71 : #include <UnoDocumentSettings.hxx>
72 :
73 : #include <drawdoc.hxx>
74 : #include <glob.hrc>
75 : #include <sdresid.hxx>
76 : #include <sdpage.hxx>
77 :
78 : #include <strings.hrc>
79 : #include "unohelp.hxx"
80 : #include <unolayer.hxx>
81 : #include <unoprnms.hxx>
82 : #include <unopage.hxx>
83 : #include <unocpres.hxx>
84 : #include <unoobj.hxx>
85 : #include <stlpool.hxx>
86 : #include <unopback.hxx>
87 : #include <unokywds.hxx>
88 : #include "FrameView.hxx"
89 : #include "ClientView.hxx"
90 : #include "DrawViewShell.hxx"
91 : #include "ViewShell.hxx"
92 : #include "app.hrc"
93 : #include <vcl/pdfextoutdevdata.hxx>
94 : #include <com/sun/star/presentation/AnimationEffect.hpp>
95 : #include <com/sun/star/presentation/AnimationSpeed.hpp>
96 : #include <com/sun/star/presentation/ClickAction.hpp>
97 : #include <svx/sdr/contact/viewobjectcontact.hxx>
98 : #include <svx/sdr/contact/viewcontact.hxx>
99 : #include <svx/sdr/contact/displayinfo.hxx>
100 :
101 : #include <com/sun/star/office/XAnnotation.hpp>
102 : #include <com/sun/star/office/XAnnotationAccess.hpp>
103 : #include <com/sun/star/office/XAnnotationEnumeration.hpp>
104 : #include <com/sun/star/geometry/RealPoint2D.hpp>
105 : #include <com/sun/star/util/DateTime.hpp>
106 :
107 : #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
108 :
109 : using namespace ::osl;
110 : using namespace ::cppu;
111 : using namespace ::com::sun::star;
112 : using namespace ::sd;
113 :
114 : class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable,
115 : public SfxListener
116 : {
117 : public:
118 : SdUnoForbiddenCharsTable( SdrModel* pModel );
119 : virtual ~SdUnoForbiddenCharsTable();
120 :
121 : // SfxListener
122 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw () SAL_OVERRIDE;
123 : protected:
124 : virtual void onChange() SAL_OVERRIDE;
125 :
126 : private:
127 : SdrModel* mpModel;
128 : };
129 :
130 50 : SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel )
131 50 : : SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel )
132 : {
133 50 : StartListening( *pModel );
134 50 : }
135 :
136 32 : void SdUnoForbiddenCharsTable::onChange()
137 : {
138 32 : if( mpModel )
139 : {
140 32 : mpModel->ReformatAllTextObjects();
141 : }
142 32 : }
143 :
144 150 : SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable()
145 : {
146 50 : SolarMutexGuard g;
147 :
148 50 : if( mpModel )
149 50 : EndListening( *mpModel );
150 100 : }
151 :
152 0 : void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
153 : {
154 0 : const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>( &rHint );
155 :
156 0 : if( pSdrHint )
157 : {
158 0 : if( HINT_MODELCLEARED == pSdrHint->GetKind() )
159 : {
160 0 : mpModel = NULL;
161 : }
162 : }
163 0 : }
164 :
165 : const sal_Int32 WID_MODEL_LANGUAGE = 1;
166 : const sal_Int32 WID_MODEL_TABSTOP = 2;
167 : const sal_Int32 WID_MODEL_VISAREA = 3;
168 : const sal_Int32 WID_MODEL_MAPUNIT = 4;
169 : const sal_Int32 WID_MODEL_FORBCHARS = 5;
170 : const sal_Int32 WID_MODEL_CONTFOCUS = 6;
171 : const sal_Int32 WID_MODEL_DSGNMODE = 7;
172 : const sal_Int32 WID_MODEL_BASICLIBS = 8;
173 : const sal_Int32 WID_MODEL_RUNTIMEUID = 9;
174 : const sal_Int32 WID_MODEL_BUILDID = 10;
175 : const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11;
176 : const sal_Int32 WID_MODEL_DIALOGLIBS = 12;
177 : const sal_Int32 WID_MODEL_FONTS = 13;
178 : const sal_Int32 WID_MODEL_INTEROPGRABBAG = 14;
179 :
180 438 : const SvxItemPropertySet* ImplGetDrawModelPropertySet()
181 : {
182 : // Attention: the first parameter HAS TO BE sorted!!!
183 : const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] =
184 : {
185 32 : { OUString("BuildId"), WID_MODEL_BUILDID, ::cppu::UnoType<OUString>::get(), 0, 0},
186 32 : { OUString(sUNO_Prop_CharLocale), WID_MODEL_LANGUAGE, ::cppu::UnoType<lang::Locale>::get(), 0, 0},
187 32 : { OUString(sUNO_Prop_TabStop), WID_MODEL_TABSTOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
188 32 : { OUString(sUNO_Prop_VisibleArea), WID_MODEL_VISAREA, ::cppu::UnoType<awt::Rectangle>::get(), 0, 0},
189 32 : { OUString(sUNO_Prop_MapUnit), WID_MODEL_MAPUNIT, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
190 32 : { OUString(sUNO_Prop_ForbiddenCharacters), WID_MODEL_FORBCHARS, cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0},
191 32 : { OUString(sUNO_Prop_AutomContFocus), WID_MODEL_CONTFOCUS, ::getBooleanCppuType(), 0, 0},
192 32 : { OUString(sUNO_Prop_ApplyFrmDsgnMode), WID_MODEL_DSGNMODE, ::getBooleanCppuType(), 0, 0},
193 32 : { OUString("BasicLibraries"), WID_MODEL_BASICLIBS, cppu::UnoType<script::XLibraryContainer>::get(), beans::PropertyAttribute::READONLY, 0},
194 32 : { OUString("DialogLibraries"), WID_MODEL_DIALOGLIBS, cppu::UnoType<script::XLibraryContainer>::get(), beans::PropertyAttribute::READONLY, 0},
195 32 : { OUString(sUNO_Prop_RuntimeUID), WID_MODEL_RUNTIMEUID, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0},
196 32 : { OUString(sUNO_Prop_HasValidSignatures), WID_MODEL_HASVALIDSIGNATURES, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::READONLY, 0},
197 32 : { OUString("Fonts"), WID_MODEL_FONTS, ::getCppuType((uno::Sequence<uno::Any>*)0), beans::PropertyAttribute::READONLY, 0},
198 32 : { OUString(sUNO_Prop_InteropGrabBag), WID_MODEL_INTEROPGRABBAG, ::getCppuType((uno::Sequence< beans::PropertyValue >*)0), 0, 0},
199 : { OUString(), 0, css::uno::Type(), 0, 0 }
200 918 : };
201 438 : static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
202 438 : return &aDrawModelPropertySet_Impl;
203 : }
204 :
205 : // this ctor is used from the DocShell
206 438 : SdXImpressDocument::SdXImpressDocument (::sd::DrawDocShell* pShell, bool bClipBoard ) throw()
207 : : SfxBaseModel( pShell ),
208 : mpDocShell( pShell ),
209 : mpDoc( pShell ? pShell->GetDoc() : NULL ),
210 : mbDisposed(false),
211 438 : mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
212 : mbClipBoard( bClipBoard ),
213 876 : mpPropSet( ImplGetDrawModelPropertySet() )
214 : {
215 438 : if( mpDoc )
216 : {
217 438 : StartListening( *mpDoc );
218 : }
219 : else
220 : {
221 : OSL_FAIL("DocShell is invalid");
222 : }
223 438 : }
224 :
225 0 : SdXImpressDocument::SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard ) throw()
226 : : SfxBaseModel( NULL ),
227 : mpDocShell( NULL ),
228 : mpDoc( pDoc ),
229 : mbDisposed(false),
230 0 : mbImpressDoc( pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
231 : mbClipBoard( bClipBoard ),
232 0 : mpPropSet( ImplGetDrawModelPropertySet() )
233 : {
234 0 : if( mpDoc )
235 : {
236 0 : StartListening( *mpDoc );
237 : }
238 : else
239 : {
240 : OSL_FAIL("SdDrawDocument is invalid");
241 : }
242 0 : }
243 :
244 : /***********************************************************************
245 : * *
246 : ***********************************************************************/
247 860 : SdXImpressDocument::~SdXImpressDocument() throw()
248 : {
249 860 : }
250 :
251 : // XInterface
252 363968 : uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
253 : {
254 363968 : uno::Any aAny;
255 :
256 363968 : if (rType == cppu::UnoType<lang::XServiceInfo>::get())
257 1180 : aAny <<= uno::Reference<lang::XServiceInfo>(this);
258 362788 : else if (rType == cppu::UnoType<beans::XPropertySet>::get())
259 1916 : aAny <<= uno::Reference<beans::XPropertySet>(this);
260 360872 : else if (rType == cppu::UnoType<lang::XMultiServiceFactory>::get())
261 8480 : aAny <<= uno::Reference<lang::XMultiServiceFactory>(this);
262 352392 : else if (rType == cppu::UnoType<drawing::XDrawPageDuplicator>::get())
263 0 : aAny <<= uno::Reference<drawing::XDrawPageDuplicator>(this);
264 352392 : else if (rType == cppu::UnoType<drawing::XLayerSupplier>::get())
265 62 : aAny <<= uno::Reference<drawing::XLayerSupplier>(this);
266 352330 : else if (rType == cppu::UnoType<drawing::XMasterPagesSupplier>::get())
267 448 : aAny <<= uno::Reference<drawing::XMasterPagesSupplier>(this);
268 351882 : else if (rType == cppu::UnoType<drawing::XDrawPagesSupplier>::get())
269 992 : aAny <<= uno::Reference<drawing::XDrawPagesSupplier>(this);
270 350890 : else if (rType == cppu::UnoType<presentation::XHandoutMasterSupplier>::get())
271 86 : aAny <<= uno::Reference<presentation::XHandoutMasterSupplier>(this);
272 350804 : else if (rType == cppu::UnoType<document::XLinkTargetSupplier>::get())
273 2 : aAny <<= uno::Reference<document::XLinkTargetSupplier>(this);
274 350802 : else if (rType == cppu::UnoType<style::XStyleFamiliesSupplier>::get())
275 3336 : aAny <<= uno::Reference<style::XStyleFamiliesSupplier>(this);
276 347466 : else if (rType == cppu::UnoType<css::ucb::XAnyCompareFactory>::get())
277 676 : aAny <<= uno::Reference<css::ucb::XAnyCompareFactory>(this);
278 346790 : else if (rType == cppu::UnoType<view::XRenderable>::get())
279 0 : aAny <<= uno::Reference<view::XRenderable>(this);
280 346790 : else if (mbImpressDoc && rType == cppu::UnoType<presentation::XPresentationSupplier>::get())
281 40 : aAny <<= uno::Reference< presentation::XPresentationSupplier >(this);
282 346750 : else if (mbImpressDoc && rType == cppu::UnoType<presentation::XCustomPresentationSupplier>::get())
283 42 : aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this);
284 : else
285 346708 : return SfxBaseModel::queryInterface(rType);
286 :
287 17260 : return aAny;
288 : }
289 :
290 858579 : void SAL_CALL SdXImpressDocument::acquire() throw ( )
291 : {
292 858579 : SfxBaseModel::acquire();
293 858579 : }
294 :
295 858569 : void SAL_CALL SdXImpressDocument::release() throw ( )
296 : {
297 858569 : if (osl_atomic_decrement( &m_refCount ) == 0)
298 : {
299 : // restore reference count:
300 430 : osl_atomic_increment( &m_refCount );
301 430 : if(!mbDisposed)
302 : {
303 : try
304 : {
305 0 : dispose();
306 : }
307 0 : catch (const uno::RuntimeException& exc)
308 : { // don't break throw ()
309 : OSL_FAIL(
310 : OUStringToOString(
311 : exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
312 : static_cast<void>(exc);
313 : }
314 : }
315 430 : SfxBaseModel::release();
316 : }
317 858569 : }
318 :
319 : namespace
320 : {
321 : class theSdXImpressDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentUnoTunnelId> {};
322 : }
323 :
324 : // XUnoTunnel
325 16796 : const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw()
326 : {
327 16796 : return theSdXImpressDocumentUnoTunnelId::get().getSeq();
328 : }
329 :
330 2082 : SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt )
331 : {
332 2082 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
333 2082 : if( xUT.is() )
334 2082 : return reinterpret_cast<SdXImpressDocument*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( SdXImpressDocument::getUnoTunnelId() )));
335 : else
336 0 : return NULL;
337 : }
338 :
339 14714 : sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception)
340 : {
341 14714 : if( rIdentifier.getLength() == 16 )
342 : {
343 14714 : if( (0 == memcmp( SdXImpressDocument::getUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
344 2082 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
345 :
346 12632 : if( (0 == memcmp( SdrModel::getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
347 0 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc));
348 : }
349 :
350 12632 : return SfxBaseModel::getSomething( rIdentifier );
351 : }
352 :
353 : // XTypeProvider
354 468 : uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) throw(uno::RuntimeException, std::exception)
355 : {
356 468 : ::SolarMutexGuard aGuard;
357 :
358 468 : if( maTypeSequence.getLength() == 0 )
359 : {
360 222 : const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
361 222 : const sal_Int32 nBaseTypes = aBaseTypes.getLength();
362 222 : const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
363 :
364 222 : const sal_Int32 nOwnTypes = mbImpressDoc ? 14 : 11; // !DANGER! Keep this updated!
365 :
366 222 : maTypeSequence.realloc( nBaseTypes + nOwnTypes );
367 222 : uno::Type* pTypes = maTypeSequence.getArray();
368 :
369 222 : *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
370 222 : *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
371 222 : *pTypes++ = cppu::UnoType<lang::XMultiServiceFactory>::get();
372 222 : *pTypes++ = cppu::UnoType<drawing::XDrawPageDuplicator>::get();
373 222 : *pTypes++ = cppu::UnoType<drawing::XLayerSupplier>::get();
374 222 : *pTypes++ = cppu::UnoType<drawing::XMasterPagesSupplier>::get();
375 222 : *pTypes++ = cppu::UnoType<drawing::XDrawPagesSupplier>::get();
376 222 : *pTypes++ = cppu::UnoType<document::XLinkTargetSupplier>::get();
377 222 : *pTypes++ = cppu::UnoType<style::XStyleFamiliesSupplier>::get();
378 222 : *pTypes++ = cppu::UnoType<com::sun::star::ucb::XAnyCompareFactory>::get();
379 222 : *pTypes++ = cppu::UnoType<view::XRenderable>::get();
380 222 : if( mbImpressDoc )
381 : {
382 52 : *pTypes++ = cppu::UnoType<presentation::XPresentationSupplier>::get();
383 52 : *pTypes++ = cppu::UnoType<presentation::XCustomPresentationSupplier>::get();
384 52 : *pTypes++ = cppu::UnoType<presentation::XHandoutMasterSupplier>::get();
385 : }
386 :
387 7770 : for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
388 7770 : *pTypes++ = *pBaseTypes++;
389 : }
390 :
391 468 : return maTypeSequence;
392 : }
393 :
394 0 : uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId( ) throw(uno::RuntimeException, std::exception)
395 : {
396 0 : return css::uno::Sequence<sal_Int8>();
397 : }
398 :
399 : /***********************************************************************
400 : * *
401 : ***********************************************************************/
402 122044 : void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
403 : {
404 122044 : if( mpDoc )
405 : {
406 121706 : const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>( &rHint );
407 :
408 121706 : if( pSdrHint )
409 : {
410 30544 : if( hasEventListeners() )
411 : {
412 12082 : document::EventObject aEvent;
413 12082 : if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) )
414 12078 : notifyEvent( aEvent );
415 : }
416 :
417 30544 : if( pSdrHint->GetKind() == HINT_MODELCLEARED )
418 : {
419 0 : if( mpDoc )
420 0 : EndListening( *mpDoc );
421 0 : mpDoc = NULL;
422 0 : mpDocShell = NULL;
423 : }
424 : }
425 : else
426 : {
427 91162 : const SfxSimpleHint* pSfxHint = dynamic_cast<const SfxSimpleHint*>( &rHint );
428 :
429 : // did our SdDrawDocument just died?
430 91162 : if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING)
431 : {
432 : // yes, so we ask for a new one
433 0 : if( mpDocShell )
434 : {
435 0 : SdDrawDocument *pNewDoc = mpDocShell->GetDoc();
436 :
437 : // is there a new one?
438 0 : if( pNewDoc != mpDoc )
439 : {
440 0 : mpDoc = pNewDoc;
441 0 : if(mpDoc)
442 0 : StartListening( *mpDoc );
443 : }
444 : }
445 : }
446 : }
447 : }
448 122044 : SfxBaseModel::Notify( rBC, rHint );
449 122044 : }
450 :
451 : /******************************************************************************
452 : * *
453 : ******************************************************************************/
454 342 : SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate )
455 : throw (css::uno::RuntimeException, std::exception)
456 : {
457 342 : sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
458 342 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
459 342 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
460 342 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
461 :
462 342 : SdPage* pStandardPage = NULL;
463 :
464 342 : if( 0 == nPageCount )
465 : {
466 : // this is only used for clipboard where we only have one page
467 0 : pStandardPage = mpDoc->AllocSdPage(false);
468 :
469 0 : Size aDefSize(21000, 29700); // A4-Hochformat
470 0 : pStandardPage->SetSize( aDefSize );
471 0 : mpDoc->InsertPage(pStandardPage, 0);
472 : }
473 : else
474 : {
475 : // here we determine the page after which we should insert
476 342 : SdPage* pPreviousStandardPage = mpDoc->GetSdPage( std::min( (sal_uInt16)(nPageCount - 1), nPage ), PK_STANDARD );
477 342 : SetOfByte aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
478 342 : bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd );
479 342 : bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj );
480 :
481 : // AutoLayouts must be ready
482 342 : mpDoc->StopWorkStartupDelay();
483 :
484 : /* First we create a standard page and then a notes page. It is
485 : guaranteed, that after a standard page the corresponding notes page
486 : follows. */
487 :
488 342 : sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
489 342 : SdPage* pPreviousNotesPage = (SdPage*) mpDoc->GetPage( nStandardPageNum - 1 );
490 342 : sal_uInt16 nNotesPageNum = nStandardPageNum + 1;
491 342 : OUString aStandardPageName;
492 684 : OUString aNotesPageName;
493 :
494 : /**************************************************************
495 : * standard page
496 : **************************************************************/
497 342 : if( bDuplicate )
498 0 : pStandardPage = (SdPage*) pPreviousStandardPage->Clone();
499 : else
500 342 : pStandardPage = mpDoc->AllocSdPage(false);
501 :
502 342 : pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
503 342 : pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(),
504 342 : pPreviousStandardPage->GetUppBorder(),
505 342 : pPreviousStandardPage->GetRgtBorder(),
506 1368 : pPreviousStandardPage->GetLwrBorder() );
507 342 : pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() );
508 342 : pStandardPage->SetName(aStandardPageName);
509 :
510 : // insert page after current page
511 342 : mpDoc->InsertPage(pStandardPage, nStandardPageNum);
512 :
513 342 : if( !bDuplicate )
514 : {
515 : // use MasterPage of the current page
516 342 : pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
517 342 : pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
518 342 : pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, true );
519 : }
520 :
521 342 : aBckgrnd = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRND), false);
522 342 : aBckgrndObj = rLayerAdmin.GetLayerID(SD_RESSTR(STR_LAYER_BCKGRNDOBJ), false);
523 342 : aVisibleLayers.Set(aBckgrnd, bIsPageBack);
524 342 : aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
525 342 : pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
526 :
527 : /**************************************************************
528 : * notes page
529 : **************************************************************/
530 342 : SdPage* pNotesPage = NULL;
531 :
532 342 : if( bDuplicate )
533 0 : pNotesPage = (SdPage*) pPreviousNotesPage->Clone();
534 : else
535 342 : pNotesPage = mpDoc->AllocSdPage(false);
536 :
537 342 : pNotesPage->SetSize( pPreviousNotesPage->GetSize() );
538 342 : pNotesPage->SetBorder( pPreviousNotesPage->GetLftBorder(),
539 342 : pPreviousNotesPage->GetUppBorder(),
540 342 : pPreviousNotesPage->GetRgtBorder(),
541 1368 : pPreviousNotesPage->GetLwrBorder() );
542 342 : pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
543 342 : pNotesPage->SetName(aNotesPageName);
544 342 : pNotesPage->SetPageKind(PK_NOTES);
545 :
546 : // insert page after current page
547 342 : mpDoc->InsertPage(pNotesPage, nNotesPageNum);
548 :
549 342 : if( !bDuplicate )
550 : {
551 : // use MasterPage of the current page
552 342 : pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
553 342 : pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
554 342 : pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true );
555 342 : }
556 : }
557 :
558 342 : SetModified();
559 :
560 342 : return( pStandardPage );
561 : }
562 :
563 64544 : void SdXImpressDocument::SetModified( bool bModified /* = sal_True */ ) throw()
564 : {
565 64544 : if( mpDoc )
566 64544 : mpDoc->SetChanged( bModified );
567 64544 : }
568 :
569 : // XModel
570 260 : void SAL_CALL SdXImpressDocument ::lockControllers( )
571 : throw(uno::RuntimeException, std::exception)
572 : {
573 260 : ::SolarMutexGuard aGuard;
574 :
575 260 : if( NULL == mpDoc )
576 0 : throw lang::DisposedException();
577 :
578 260 : mpDoc->setLock(true);
579 260 : }
580 :
581 260 : void SAL_CALL SdXImpressDocument::unlockControllers( )
582 : throw(uno::RuntimeException, std::exception)
583 : {
584 260 : ::SolarMutexGuard aGuard;
585 :
586 260 : if( NULL == mpDoc )
587 0 : throw lang::DisposedException();
588 :
589 260 : if( mpDoc->isLocked() )
590 : {
591 260 : mpDoc->setLock(false);
592 260 : }
593 260 : }
594 :
595 710 : sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked( )
596 : throw(uno::RuntimeException, std::exception)
597 : {
598 710 : ::SolarMutexGuard aGuard;
599 :
600 710 : if( NULL == mpDoc )
601 0 : throw lang::DisposedException();
602 :
603 710 : return mpDoc && mpDoc->isLocked();
604 : }
605 :
606 : #include <comphelper/processfactory.hxx>
607 :
608 498 : uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData() throw( uno::RuntimeException, std::exception )
609 : {
610 498 : ::SolarMutexGuard aGuard;
611 :
612 498 : if( NULL == mpDoc )
613 0 : throw lang::DisposedException();
614 :
615 498 : uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
616 :
617 498 : if( !xRet.is() )
618 : {
619 268 : const std::vector<sd::FrameView*> &rList = mpDoc->GetFrameViewList();
620 :
621 268 : if( !rList.empty() )
622 : {
623 6 : xRet = uno::Reference< container::XIndexAccess >(document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ), uno::UNO_QUERY);
624 :
625 6 : uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
626 : DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" );
627 6 : if( xCont.is() )
628 : {
629 12 : for( sal_uInt32 i = 0, n = rList.size(); i < n; i++ )
630 : {
631 6 : ::sd::FrameView* pFrameView = rList[ i ];
632 :
633 6 : uno::Sequence< beans::PropertyValue > aSeq;
634 6 : pFrameView->WriteUserDataSequence( aSeq );
635 6 : xCont->insertByIndex( i, uno::makeAny( aSeq ) );
636 6 : }
637 6 : }
638 : }
639 : }
640 :
641 498 : return xRet;
642 : }
643 :
644 56 : void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData ) throw(::com::sun::star::uno::RuntimeException, std::exception)
645 : {
646 56 : ::SolarMutexGuard aGuard;
647 :
648 56 : if( NULL == mpDoc )
649 0 : throw lang::DisposedException();
650 :
651 56 : SfxBaseModel::setViewData( xData );
652 56 : if( mpDocShell && (mpDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) && xData.is() )
653 : {
654 28 : const sal_Int32 nCount = xData->getCount();
655 :
656 28 : std::vector<sd::FrameView*>::iterator pIter;
657 28 : std::vector<sd::FrameView*> &rViews = mpDoc->GetFrameViewList();
658 :
659 28 : for ( pIter = rViews.begin(); pIter != rViews.end(); ++pIter )
660 0 : delete *pIter;
661 :
662 28 : rViews.clear();
663 :
664 : ::sd::FrameView* pFrameView;
665 28 : uno::Sequence< beans::PropertyValue > aSeq;
666 56 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
667 : {
668 28 : if( xData->getByIndex( nIndex ) >>= aSeq )
669 : {
670 28 : pFrameView = new ::sd::FrameView( mpDoc );
671 :
672 28 : pFrameView->ReadUserDataSequence( aSeq );
673 28 : rViews.push_back( pFrameView );
674 : }
675 28 : }
676 56 : }
677 56 : }
678 :
679 : // XDrawPageDuplicator
680 0 : uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage )
681 : throw(uno::RuntimeException, std::exception)
682 : {
683 0 : ::SolarMutexGuard aGuard;
684 :
685 0 : if( NULL == mpDoc )
686 0 : throw lang::DisposedException();
687 :
688 : // get pPage from xPage and determine the Id (nPos ) afterwards
689 0 : SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
690 0 : if( pSvxPage )
691 : {
692 0 : SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
693 0 : sal_uInt16 nPos = pPage->GetPageNum();
694 0 : nPos = ( nPos - 1 ) / 2;
695 0 : pPage = InsertSdPage( nPos, true );
696 0 : if( pPage )
697 : {
698 0 : uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
699 0 : return xDrawPage;
700 : }
701 : }
702 :
703 0 : uno::Reference< drawing::XDrawPage > xDrawPage;
704 0 : return xDrawPage;
705 : }
706 :
707 : // XDrawPagesSupplier
708 1184 : uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages()
709 : throw(uno::RuntimeException, std::exception)
710 : {
711 1184 : ::SolarMutexGuard aGuard;
712 :
713 1184 : if( NULL == mpDoc )
714 0 : throw lang::DisposedException();
715 :
716 1184 : uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
717 :
718 1184 : if( !xDrawPages.is() )
719 : {
720 866 : initializeDocument();
721 866 : mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SdDrawPagesAccess(*this);
722 : }
723 :
724 1184 : return xDrawPages;
725 : }
726 :
727 : // XMasterPagesSupplier
728 764 : uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages()
729 : throw(uno::RuntimeException, std::exception)
730 : {
731 764 : ::SolarMutexGuard aGuard;
732 :
733 764 : if( NULL == mpDoc )
734 0 : throw lang::DisposedException();
735 :
736 764 : uno::Reference< drawing::XDrawPages > xMasterPages( mxMasterPagesAccess );
737 :
738 764 : if( !xMasterPages.is() )
739 : {
740 692 : if ( !hasControllersLocked() )
741 48 : initializeDocument();
742 692 : mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this);
743 : }
744 :
745 764 : return xMasterPages;
746 : }
747 :
748 : // XLayerManagerSupplier
749 62 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager( )
750 : throw(uno::RuntimeException, std::exception)
751 : {
752 62 : ::SolarMutexGuard aGuard;
753 :
754 62 : if( NULL == mpDoc )
755 0 : throw lang::DisposedException();
756 :
757 62 : uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
758 :
759 62 : if( !xLayerManager.is() )
760 62 : mxLayerManager = xLayerManager = new SdLayerManager(*this);
761 :
762 62 : return xLayerManager;
763 : }
764 :
765 : // XCustomPresentationSupplier
766 42 : uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations()
767 : throw(uno::RuntimeException, std::exception)
768 : {
769 42 : ::SolarMutexGuard aGuard;
770 :
771 42 : if( NULL == mpDoc )
772 0 : throw lang::DisposedException();
773 :
774 42 : uno::Reference< container::XNameContainer > xCustomPres( mxCustomPresentationAccess );
775 :
776 42 : if( !xCustomPres.is() )
777 42 : mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this);
778 :
779 42 : return xCustomPres;
780 : }
781 :
782 : // XPresentationSupplier
783 40 : uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation()
784 : throw(uno::RuntimeException, std::exception)
785 : {
786 40 : ::SolarMutexGuard aGuard;
787 :
788 40 : if( NULL == mpDoc )
789 0 : throw lang::DisposedException();
790 :
791 40 : return uno::Reference< presentation::XPresentation >( mpDoc->getPresentation().get() );
792 : }
793 :
794 : // XHandoutMasterSupplier
795 86 : uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage()
796 : throw (uno::RuntimeException, std::exception)
797 : {
798 86 : ::SolarMutexGuard aGuard;
799 :
800 86 : if( NULL == mpDoc )
801 0 : throw lang::DisposedException();
802 :
803 86 : uno::Reference< drawing::XDrawPage > xPage;
804 :
805 86 : if( mpDoc )
806 : {
807 86 : initializeDocument();
808 86 : SdPage* pPage = mpDoc->GetMasterSdPage( 0, PK_HANDOUT );
809 86 : if( pPage )
810 86 : xPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
811 : }
812 86 : return xPage;
813 : }
814 :
815 : // XMultiServiceFactory ( SvxFmMSFactory )
816 :
817 7516 : css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create(
818 : OUString const & aServiceSpecifier, OUString const & referer)
819 : {
820 7516 : ::SolarMutexGuard aGuard;
821 :
822 7516 : if( NULL == mpDoc )
823 0 : throw lang::DisposedException();
824 :
825 7516 : if( aServiceSpecifier == "com.sun.star.drawing.DashTable" )
826 : {
827 62 : if( !mxDashTable.is() )
828 54 : mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
829 :
830 62 : return mxDashTable;
831 : }
832 7454 : if( aServiceSpecifier == "com.sun.star.drawing.GradientTable" )
833 : {
834 64 : if( !mxGradientTable.is() )
835 56 : mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
836 :
837 64 : return mxGradientTable;
838 : }
839 7390 : if( aServiceSpecifier == "com.sun.star.drawing.HatchTable" )
840 : {
841 62 : if( !mxHatchTable.is() )
842 54 : mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
843 :
844 62 : return mxHatchTable;
845 : }
846 7328 : if( aServiceSpecifier == "com.sun.star.drawing.BitmapTable" )
847 : {
848 90 : if( !mxBitmapTable.is() )
849 78 : mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
850 :
851 90 : return mxBitmapTable;
852 : }
853 7238 : if( aServiceSpecifier == "com.sun.star.drawing.TransparencyGradientTable" )
854 : {
855 60 : if( !mxTransGradientTable.is() )
856 56 : mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
857 :
858 60 : return mxTransGradientTable;
859 : }
860 7178 : if( aServiceSpecifier == "com.sun.star.drawing.MarkerTable" )
861 : {
862 106 : if( !mxMarkerTable.is() )
863 66 : mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
864 :
865 106 : return mxMarkerTable;
866 : }
867 7072 : if( aServiceSpecifier == "com.sun.star.text.NumberingRules" )
868 : {
869 186 : return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
870 : }
871 6886 : if( aServiceSpecifier == "com.sun.star.drawing.Background" )
872 : {
873 : return uno::Reference< uno::XInterface >(
874 280 : static_cast<uno::XWeak*>(new SdUnoPageBackground( mpDoc )));
875 : }
876 :
877 6606 : if( aServiceSpecifier == "com.sun.star.drawing.Defaults" )
878 : {
879 84 : if( !mxDrawingPool.is() )
880 68 : mxDrawingPool = SdUnoCreatePool( mpDoc );
881 :
882 84 : return mxDrawingPool;
883 :
884 : }
885 :
886 6522 : if ( aServiceSpecifier == sUNO_Service_ImageMapRectangleObject )
887 : {
888 0 : return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
889 : }
890 :
891 6522 : if ( aServiceSpecifier == sUNO_Service_ImageMapCircleObject )
892 : {
893 0 : return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
894 : }
895 :
896 6522 : if ( aServiceSpecifier == sUNO_Service_ImageMapPolygonObject )
897 : {
898 0 : return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
899 : }
900 :
901 19460 : if( aServiceSpecifier == "com.sun.star.document.Settings" ||
902 9756 : ( !mbImpressDoc && ( aServiceSpecifier == "com.sun.star.drawing.DocumentSettings" ) ) ||
903 3288 : ( mbImpressDoc && ( aServiceSpecifier == "com.sun.star.presentation.DocumentSettings" ) ) )
904 : {
905 106 : return sd::DocumentSettings_createInstance( this );
906 : }
907 :
908 12766 : if( aServiceSpecifier == "com.sun.star.text.TextField.DateTime" ||
909 6350 : aServiceSpecifier == "com.sun.star.text.textfield.DateTime" )
910 : {
911 66 : return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::DATE );
912 : }
913 :
914 12634 : if( aServiceSpecifier == "com.sun.star.presentation.TextField.Header" ||
915 6284 : aServiceSpecifier == "com.sun.star.presentation.textfield.Header" )
916 : {
917 66 : return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_HEADER );
918 : }
919 :
920 12472 : if( aServiceSpecifier == "com.sun.star.presentation.TextField.Footer" ||
921 6188 : aServiceSpecifier == "com.sun.star.presentation.textfield.Footer" )
922 : {
923 96 : return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_FOOTER );
924 : }
925 :
926 12280 : if( aServiceSpecifier == "com.sun.star.presentation.TextField.DateTime" ||
927 6092 : aServiceSpecifier == "com.sun.star.presentation.textfield.DateTime" )
928 : {
929 96 : return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_DATE_TIME );
930 : }
931 :
932 6092 : if( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" )
933 : {
934 : static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 };
935 :
936 84 : return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() );
937 : }
938 :
939 : // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
940 6008 : if( aServiceSpecifier == "com.sun.star.document.ExportGraphicObjectResolver" )
941 : {
942 2 : return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE );
943 : }
944 :
945 6006 : if( aServiceSpecifier == "com.sun.star.document.ImportGraphicObjectResolver" )
946 : {
947 110 : return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ );
948 : }
949 :
950 5896 : if( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" )
951 : {
952 2 : ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
953 2 : if( NULL == pPersist )
954 0 : throw lang::DisposedException();
955 :
956 2 : return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE );
957 : }
958 :
959 5894 : if( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" )
960 : {
961 112 : ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
962 112 : if( NULL == pPersist )
963 0 : throw lang::DisposedException();
964 :
965 112 : return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ );
966 : }
967 :
968 11564 : uno::Reference< uno::XInterface > xRet;
969 :
970 5782 : if( aServiceSpecifier.startsWith( "com.sun.star.presentation.") )
971 : {
972 1306 : const OUString aType( aServiceSpecifier.copy(26) );
973 1306 : SvxShape* pShape = NULL;
974 :
975 1306 : sal_uInt16 nType = OBJ_TEXT;
976 : // create a shape wrapper
977 1306 : if( aType.startsWith( "TitleTextShape" ) )
978 : {
979 162 : nType = OBJ_TEXT;
980 : }
981 1144 : else if( aType.startsWith( "OutlinerShape" ) )
982 : {
983 70 : nType = OBJ_TEXT;
984 : }
985 1074 : else if( aType.startsWith( "SubtitleShape" ) )
986 : {
987 90 : nType = OBJ_TEXT;
988 : }
989 984 : else if( aType.startsWith( "GraphicObjectShape" ) )
990 : {
991 4 : nType = OBJ_GRAF;
992 : }
993 980 : else if( aType.startsWith( "PageShape" ) )
994 : {
995 110 : nType = OBJ_PAGE;
996 : }
997 870 : else if( aType.startsWith( "OLE2Shape" ) )
998 : {
999 0 : nType = OBJ_OLE2;
1000 : }
1001 870 : else if( aType.startsWith( "ChartShape" ) )
1002 : {
1003 0 : nType = OBJ_OLE2;
1004 : }
1005 870 : else if( aType.startsWith( "CalcShape" ) )
1006 : {
1007 0 : nType = OBJ_OLE2;
1008 : }
1009 870 : else if( aType.startsWith( "TableShape" ) )
1010 : {
1011 2 : nType = OBJ_TABLE;
1012 : }
1013 868 : else if( aType.startsWith( "OrgChartShape" ) )
1014 : {
1015 0 : nType = OBJ_OLE2;
1016 : }
1017 868 : else if( aType.startsWith( "NotesShape" ) )
1018 : {
1019 108 : nType = OBJ_TEXT;
1020 : }
1021 760 : else if( aType.startsWith( "HandoutShape" ) )
1022 : {
1023 192 : nType = OBJ_PAGE;
1024 : }
1025 568 : else if( aType.startsWith( "FooterShape" ) )
1026 : {
1027 162 : nType = OBJ_TEXT;
1028 : }
1029 406 : else if( aType.startsWith( "HeaderShape" ) )
1030 : {
1031 66 : nType = OBJ_TEXT;
1032 : }
1033 340 : else if( aType.startsWith( "SlideNumberShape" ) )
1034 : {
1035 176 : nType = OBJ_TEXT;
1036 : }
1037 164 : else if( aType.startsWith( "DateTimeShape" ) )
1038 : {
1039 160 : nType = OBJ_TEXT;
1040 : }
1041 4 : else if( aType.startsWith( "MediaShape" ) )
1042 : {
1043 4 : nType = OBJ_MEDIA;
1044 : }
1045 : else
1046 : {
1047 0 : throw lang::ServiceNotRegisteredException();
1048 : }
1049 :
1050 : // create the API wrapper
1051 1306 : pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor, referer );
1052 :
1053 : // set shape type
1054 1306 : if( pShape && !mbClipBoard )
1055 1306 : pShape->SetShapeType(aServiceSpecifier);
1056 :
1057 1306 : xRet = (uno::XWeak*)pShape;
1058 : }
1059 4476 : else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" )
1060 : {
1061 10 : SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor, referer );
1062 10 : if( pShape && !mbClipBoard )
1063 10 : pShape->SetShapeType(aServiceSpecifier);
1064 :
1065 10 : xRet = (uno::XWeak*)pShape;
1066 : }
1067 : else
1068 : {
1069 4466 : xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
1070 : }
1071 :
1072 11544 : uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY );
1073 5772 : SvxShape* pShape = xShape.is() ? SvxShape::getImplementation(xShape) : NULL;
1074 5772 : if (pShape)
1075 : {
1076 5580 : xRet.clear();
1077 5580 : new SdXShape( pShape, (SdXImpressDocument*)this );
1078 5580 : xRet = xShape;
1079 5580 : xShape.clear();
1080 : }
1081 :
1082 13288 : return xRet;
1083 : }
1084 :
1085 7472 : uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
1086 : throw(uno::Exception, uno::RuntimeException, std::exception)
1087 : {
1088 7472 : return create(aServiceSpecifier, "");
1089 : }
1090 :
1091 : css::uno::Reference<css::uno::XInterface>
1092 44 : SdXImpressDocument::createInstanceWithArguments(
1093 : OUString const & ServiceSpecifier,
1094 : css::uno::Sequence<css::uno::Any> const & Arguments)
1095 : throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
1096 : {
1097 44 : OUString arg;
1098 88 : if ((ServiceSpecifier == "com.sun.star.drawing.GraphicObjectShape"
1099 10 : || ServiceSpecifier == "com.sun.star.drawing.MediaShape"
1100 0 : || ServiceSpecifier == "com.sun.star.presentation.MediaShape")
1101 88 : && Arguments.getLength() == 1 && (Arguments[0] >>= arg))
1102 : {
1103 44 : return create(ServiceSpecifier, arg);
1104 : }
1105 : return SvxFmMSFactory::createInstanceWithArguments(
1106 0 : ServiceSpecifier, Arguments);
1107 : }
1108 :
1109 308 : uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames()
1110 : throw(uno::RuntimeException, std::exception)
1111 : {
1112 308 : ::SolarMutexGuard aGuard;
1113 :
1114 308 : if( NULL == mpDoc )
1115 0 : throw lang::DisposedException();
1116 :
1117 616 : const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
1118 :
1119 616 : uno::Sequence< OUString > aSNS( mbImpressDoc ? (36) : (19) );
1120 :
1121 308 : sal_uInt16 i(0);
1122 :
1123 308 : aSNS[i++] = "com.sun.star.drawing.DashTable";
1124 308 : aSNS[i++] = "com.sun.star.drawing.GradientTable";
1125 308 : aSNS[i++] = "com.sun.star.drawing.HatchTable";
1126 308 : aSNS[i++] = "com.sun.star.drawing.BitmapTable";
1127 308 : aSNS[i++] = "com.sun.star.drawing.TransparencyGradientTable";
1128 308 : aSNS[i++] = "com.sun.star.drawing.MarkerTable";
1129 308 : aSNS[i++] = "com.sun.star.text.NumberingRules";
1130 308 : aSNS[i++] = "com.sun.star.drawing.Background";
1131 308 : aSNS[i++] = "com.sun.star.document.Settings";
1132 308 : aSNS[i++] = sUNO_Service_ImageMapRectangleObject;
1133 308 : aSNS[i++] = sUNO_Service_ImageMapCircleObject;
1134 308 : aSNS[i++] = sUNO_Service_ImageMapPolygonObject;
1135 308 : aSNS[i++] = "com.sun.star.xml.NamespaceMap";
1136 :
1137 : // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
1138 308 : aSNS[i++] = "com.sun.star.document.ExportGraphicObjectResolver";
1139 308 : aSNS[i++] = "com.sun.star.document.ImportGraphicObjectResolver";
1140 308 : aSNS[i++] = "com.sun.star.document.ExportEmbeddedObjectResolver";
1141 308 : aSNS[i++] = "com.sun.star.document.ImportEmbeddedObjectResolver";
1142 308 : aSNS[i++] = "com.sun.star.drawing.TableShape";
1143 :
1144 308 : if(mbImpressDoc)
1145 : {
1146 176 : aSNS[i++] = "com.sun.star.presentation.TitleTextShape";
1147 176 : aSNS[i++] = "com.sun.star.presentation.OutlinerShape";
1148 176 : aSNS[i++] = "com.sun.star.presentation.SubtitleShape";
1149 176 : aSNS[i++] = "com.sun.star.presentation.GraphicObjectShape";
1150 176 : aSNS[i++] = "com.sun.star.presentation.ChartShape";
1151 176 : aSNS[i++] = "com.sun.star.presentation.PageShape";
1152 176 : aSNS[i++] = "com.sun.star.presentation.OLE2Shape";
1153 176 : aSNS[i++] = "com.sun.star.presentation.TableShape";
1154 176 : aSNS[i++] = "com.sun.star.presentation.OrgChartShape";
1155 176 : aSNS[i++] = "com.sun.star.presentation.NotesShape";
1156 176 : aSNS[i++] = "com.sun.star.presentation.HandoutShape";
1157 176 : aSNS[i++] = "com.sun.star.presentation.DocumentSettings";
1158 176 : aSNS[i++] = "com.sun.star.presentation.FooterShape";
1159 176 : aSNS[i++] = "com.sun.star.presentation.HeaderShape";
1160 176 : aSNS[i++] = "com.sun.star.presentation.SlideNumberShape";
1161 176 : aSNS[i++] = "com.sun.star.presentation.DateTimeShape";
1162 176 : aSNS[i++] = "com.sun.star.presentation.CalcShape";
1163 176 : aSNS[i++] = "com.sun.star.presentation.MediaShape";
1164 : }
1165 : else
1166 : {
1167 132 : aSNS[i++] = "com.sun.star.drawing.DocumentSettings";
1168 : }
1169 :
1170 : DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
1171 :
1172 616 : return comphelper::concatSequences( aSNS_ORG, aSNS );
1173 : }
1174 :
1175 : // lang::XServiceInfo
1176 0 : OUString SAL_CALL SdXImpressDocument::getImplementationName()
1177 : throw(uno::RuntimeException, std::exception)
1178 : {
1179 0 : return OUString( "SdXImpressDocument" );
1180 : }
1181 :
1182 940 : sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName )
1183 : throw(uno::RuntimeException, std::exception)
1184 : {
1185 940 : return cppu::supportsService(this, ServiceName);
1186 : }
1187 :
1188 1236 : uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
1189 : {
1190 1236 : ::SolarMutexGuard aGuard;
1191 :
1192 1236 : uno::Sequence< OUString > aSeq( 4 );
1193 1236 : OUString* pServices = aSeq.getArray();
1194 :
1195 1236 : *pServices++ = "com.sun.star.document.OfficeDocument";
1196 1236 : *pServices++ = "com.sun.star.drawing.GenericDrawingDocument";
1197 1236 : *pServices++ = "com.sun.star.drawing.DrawingDocumentFactory";
1198 :
1199 1236 : if( mbImpressDoc )
1200 634 : *pServices++ = "com.sun.star.presentation.PresentationDocument";
1201 : else
1202 602 : *pServices++ = "com.sun.star.drawing.DrawingDocument";
1203 :
1204 1236 : return aSeq;
1205 : }
1206 :
1207 : // XPropertySet
1208 278 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo( )
1209 : throw(uno::RuntimeException, std::exception)
1210 : {
1211 278 : ::SolarMutexGuard aGuard;
1212 278 : return mpPropSet->getPropertySetInfo();
1213 : }
1214 :
1215 264 : void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1216 : throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1217 : {
1218 264 : ::SolarMutexGuard aGuard;
1219 :
1220 264 : if( NULL == mpDoc )
1221 0 : throw lang::DisposedException();
1222 :
1223 264 : const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
1224 :
1225 264 : switch( pEntry ? pEntry->nWID : -1 )
1226 : {
1227 : case WID_MODEL_LANGUAGE:
1228 : {
1229 0 : lang::Locale aLocale;
1230 0 : if(!(aValue >>= aLocale))
1231 0 : throw lang::IllegalArgumentException();
1232 :
1233 0 : mpDoc->SetLanguage( LanguageTag::convertToLanguageType(aLocale), EE_CHAR_LANGUAGE );
1234 0 : break;
1235 : }
1236 : case WID_MODEL_TABSTOP:
1237 : {
1238 0 : sal_Int32 nValue = 0;
1239 0 : if(!(aValue >>= nValue) || nValue < 0 )
1240 0 : throw lang::IllegalArgumentException();
1241 :
1242 0 : mpDoc->SetDefaultTabulator((sal_uInt16)nValue);
1243 0 : break;
1244 : }
1245 : case WID_MODEL_VISAREA:
1246 : {
1247 114 : SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1248 114 : if( !pEmbeddedObj )
1249 0 : break;
1250 :
1251 114 : awt::Rectangle aVisArea;
1252 114 : if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) )
1253 0 : throw lang::IllegalArgumentException();
1254 :
1255 114 : pEmbeddedObj->SetVisArea( Rectangle( aVisArea.X, aVisArea.Y, aVisArea.X + aVisArea.Width - 1, aVisArea.Y + aVisArea.Height - 1 ) );
1256 : }
1257 114 : break;
1258 : case WID_MODEL_CONTFOCUS:
1259 : {
1260 8 : bool bFocus = false;
1261 8 : if( !(aValue >>= bFocus ) )
1262 0 : throw lang::IllegalArgumentException();
1263 8 : mpDoc->SetAutoControlFocus( bFocus );
1264 : }
1265 8 : break;
1266 : case WID_MODEL_DSGNMODE:
1267 : {
1268 8 : bool bMode = false;
1269 8 : if( !(aValue >>= bMode ) )
1270 0 : throw lang::IllegalArgumentException();
1271 8 : mpDoc->SetOpenInDesignMode( bMode );
1272 : }
1273 8 : break;
1274 : case WID_MODEL_BUILDID:
1275 36 : aValue >>= maBuildId;
1276 202 : return;
1277 : case WID_MODEL_MAPUNIT:
1278 : case WID_MODEL_BASICLIBS:
1279 : case WID_MODEL_RUNTIMEUID: // is read-only
1280 : case WID_MODEL_DIALOGLIBS:
1281 : case WID_MODEL_FONTS:
1282 0 : throw beans::PropertyVetoException();
1283 : case WID_MODEL_INTEROPGRABBAG:
1284 0 : setGrabBagItem(aValue);
1285 0 : break;
1286 : default:
1287 98 : throw beans::UnknownPropertyException();
1288 : }
1289 :
1290 228 : SetModified();
1291 : }
1292 :
1293 1400 : uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName )
1294 : throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1295 : {
1296 1400 : ::SolarMutexGuard aGuard;
1297 :
1298 2800 : uno::Any aAny;
1299 1400 : if( NULL == mpDoc )
1300 212 : throw lang::DisposedException();
1301 :
1302 1188 : const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
1303 :
1304 1188 : switch( pEntry ? pEntry->nWID : -1 )
1305 : {
1306 : case WID_MODEL_LANGUAGE:
1307 : {
1308 0 : LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE );
1309 0 : aAny <<= LanguageTag::convertToLocale( eLang);
1310 0 : break;
1311 : }
1312 : case WID_MODEL_TABSTOP:
1313 20 : aAny <<= (sal_Int32)mpDoc->GetDefaultTabulator();
1314 20 : break;
1315 : case WID_MODEL_VISAREA:
1316 : {
1317 22 : SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1318 22 : if( !pEmbeddedObj )
1319 0 : break;
1320 :
1321 22 : const Rectangle& aRect = pEmbeddedObj->GetVisArea();
1322 22 : awt::Rectangle aVisArea( aRect.Left(), aRect.Top(), aRect.getWidth(), aRect.getHeight() );
1323 22 : aAny <<= aVisArea;
1324 : }
1325 22 : break;
1326 : case WID_MODEL_MAPUNIT:
1327 : {
1328 0 : SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1329 0 : if( !pEmbeddedObj )
1330 0 : break;
1331 :
1332 0 : sal_Int16 nMeasureUnit = 0;
1333 0 : SvxMapUnitToMeasureUnit( pEmbeddedObj->GetMapUnit(), nMeasureUnit );
1334 0 : aAny <<= (sal_Int16)nMeasureUnit;
1335 : }
1336 0 : break;
1337 : case WID_MODEL_FORBCHARS:
1338 : {
1339 0 : aAny <<= getForbiddenCharsTable();
1340 : }
1341 0 : break;
1342 : case WID_MODEL_CONTFOCUS:
1343 0 : aAny <<= mpDoc->GetAutoControlFocus();
1344 0 : break;
1345 : case WID_MODEL_DSGNMODE:
1346 0 : aAny <<= mpDoc->GetOpenInDesignMode();
1347 0 : break;
1348 : case WID_MODEL_BASICLIBS:
1349 4 : aAny <<= mpDocShell->GetBasicContainer();
1350 4 : break;
1351 : case WID_MODEL_DIALOGLIBS:
1352 0 : aAny <<= mpDocShell->GetDialogContainer();
1353 0 : break;
1354 : case WID_MODEL_RUNTIMEUID:
1355 892 : aAny <<= getRuntimeUID();
1356 892 : break;
1357 : case WID_MODEL_BUILDID:
1358 0 : return uno::Any( maBuildId );
1359 : case WID_MODEL_HASVALIDSIGNATURES:
1360 0 : aAny <<= hasValidSignatures();
1361 0 : break;
1362 : case WID_MODEL_FONTS:
1363 : {
1364 38 : uno::Sequence<uno::Any> aSeq;
1365 38 : int nSeqIndex = 0;
1366 :
1367 : sal_uInt16 aWhichIds[3] = { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK,
1368 38 : EE_CHAR_FONTINFO_CTL };
1369 :
1370 38 : const SfxItemPool& rPool = mpDoc->GetPool();
1371 : const SfxPoolItem* pItem;
1372 :
1373 152 : for( sal_uInt16 i=0; i<3; i++ )
1374 : {
1375 114 : sal_uInt16 nWhichId = aWhichIds[i];
1376 114 : sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
1377 :
1378 114 : aSeq.realloc( aSeq.getLength() + nItems*5 + 5 );
1379 :
1380 264 : for( sal_uInt32 j = 0; j < nItems; ++j )
1381 : {
1382 150 : if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
1383 : {
1384 150 : const SvxFontItem *pFont = (const SvxFontItem *)pItem;
1385 :
1386 150 : aSeq[nSeqIndex++] <<= OUString(pFont->GetFamilyName());
1387 150 : aSeq[nSeqIndex++] <<= OUString(pFont->GetStyleName());
1388 150 : aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetFamily());
1389 150 : aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetPitch());
1390 150 : aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetCharSet());
1391 : }
1392 : }
1393 :
1394 114 : const SvxFontItem& rFont = (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
1395 :
1396 114 : aSeq[nSeqIndex++] <<= OUString(rFont.GetFamilyName());
1397 114 : aSeq[nSeqIndex++] <<= OUString(rFont.GetStyleName());
1398 114 : aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetFamily());
1399 114 : aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetPitch());
1400 114 : aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetCharSet());
1401 :
1402 : }
1403 :
1404 38 : aSeq.realloc( nSeqIndex );
1405 38 : aAny <<= aSeq;
1406 38 : break;
1407 : }
1408 : case WID_MODEL_INTEROPGRABBAG:
1409 0 : getGrabBagItem(aAny);
1410 0 : break;
1411 : default:
1412 212 : throw beans::UnknownPropertyException();
1413 : }
1414 :
1415 2376 : return aAny;
1416 : }
1417 :
1418 0 : void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) {}
1419 0 : void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) {}
1420 0 : void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) {}
1421 0 : void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) {}
1422 :
1423 : // XLinkTargetSupplier
1424 2 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
1425 : throw(uno::RuntimeException, std::exception)
1426 : {
1427 2 : ::SolarMutexGuard aGuard;
1428 :
1429 2 : if( NULL == mpDoc )
1430 0 : throw lang::DisposedException();
1431 :
1432 2 : uno::Reference< container::XNameAccess > xLinks( mxLinks );
1433 2 : if( !xLinks.is() )
1434 2 : mxLinks = xLinks = new SdDocLinkTargets( *this );
1435 2 : return xLinks;
1436 : }
1437 :
1438 : // XStyleFamiliesSupplier
1439 3694 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies( )
1440 : throw(uno::RuntimeException, std::exception)
1441 : {
1442 3694 : ::SolarMutexGuard aGuard;
1443 :
1444 3694 : if( NULL == mpDoc )
1445 0 : throw lang::DisposedException();
1446 :
1447 3694 : uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) );
1448 3694 : return xStyles;
1449 : }
1450 :
1451 : // XAnyCompareFactory
1452 676 : uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& )
1453 : throw (uno::RuntimeException, std::exception)
1454 : {
1455 676 : return SvxCreateNumRuleCompare();
1456 : }
1457 :
1458 : // XRenderable
1459 0 : sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
1460 : const uno::Sequence< beans::PropertyValue >& )
1461 : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
1462 : {
1463 0 : ::SolarMutexGuard aGuard;
1464 0 : sal_Int32 nRet = 0;
1465 :
1466 0 : if( NULL == mpDoc )
1467 0 : throw lang::DisposedException();
1468 :
1469 0 : if( mpDocShell && mpDoc )
1470 : {
1471 0 : uno::Reference< frame::XModel > xModel;
1472 :
1473 0 : rSelection >>= xModel;
1474 :
1475 0 : if( xModel == mpDocShell->GetModel() )
1476 0 : nRet = mpDoc->GetSdPageCount( PK_STANDARD );
1477 : else
1478 : {
1479 0 : uno::Reference< drawing::XShapes > xShapes;
1480 :
1481 0 : rSelection >>= xShapes;
1482 :
1483 0 : if( xShapes.is() && xShapes->getCount() )
1484 0 : nRet = 1;
1485 0 : }
1486 : }
1487 0 : return nRet;
1488 : }
1489 :
1490 0 : uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& ,
1491 : const uno::Sequence< beans::PropertyValue >& rxOptions )
1492 : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
1493 : {
1494 0 : ::SolarMutexGuard aGuard;
1495 :
1496 0 : if( NULL == mpDoc )
1497 0 : throw lang::DisposedException();
1498 :
1499 0 : bool bExportNotesPages = false;
1500 0 : for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1501 : {
1502 0 : if ( rxOptions[ nProperty ].Name == "ExportNotesPages" )
1503 0 : rxOptions[ nProperty].Value >>= bExportNotesPages;
1504 : }
1505 0 : uno::Sequence< beans::PropertyValue > aRenderer;
1506 0 : if( mpDocShell && mpDoc )
1507 : {
1508 0 : awt::Size aPageSize;
1509 0 : if ( bExportNotesPages )
1510 : {
1511 0 : Size aNotesPageSize = mpDoc->GetSdPage( 0, PK_NOTES )->GetSize();
1512 0 : aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
1513 : }
1514 : else
1515 : {
1516 0 : const Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) );
1517 0 : aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() );
1518 : }
1519 0 : aRenderer.realloc( 1 );
1520 :
1521 0 : aRenderer[ 0 ].Name = "PageSize" ;
1522 0 : aRenderer[ 0 ].Value <<= aPageSize;
1523 : }
1524 0 : return aRenderer;
1525 : }
1526 :
1527 : class ImplRenderPaintProc : public ::sdr::contact::ViewObjectContactRedirector
1528 : {
1529 : const SdrLayerAdmin& rLayerAdmin;
1530 : SdrPageView* pSdrPageView;
1531 : vcl::PDFExtOutDevData* pPDFExtOutDevData;
1532 :
1533 : vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject );
1534 :
1535 : public:
1536 : bool IsVisible ( const SdrObject* pObj ) const;
1537 : bool IsPrintable( const SdrObject* pObj ) const;
1538 :
1539 : ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData );
1540 : virtual ~ImplRenderPaintProc();
1541 :
1542 : // all default implementations just call the same methods at the original. To do something
1543 : // different, overload the method and at least do what the method does.
1544 : virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
1545 : const sdr::contact::ViewObjectContact& rOriginal,
1546 : const sdr::contact::DisplayInfo& rDisplayInfo) SAL_OVERRIDE;
1547 : };
1548 :
1549 0 : ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData )
1550 : : ViewObjectContactRedirector(),
1551 : rLayerAdmin ( rLA ),
1552 : pSdrPageView ( pView ),
1553 0 : pPDFExtOutDevData ( pData )
1554 : {
1555 0 : }
1556 :
1557 0 : ImplRenderPaintProc::~ImplRenderPaintProc()
1558 : {
1559 0 : }
1560 :
1561 0 : sal_Int32 ImplPDFGetBookmarkPage( const OUString& rBookmark, SdDrawDocument& rDoc )
1562 : {
1563 0 : sal_Int32 nPage = -1;
1564 :
1565 : OSL_TRACE("GotoBookmark %s",
1566 : OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
1567 :
1568 0 : OUString aBookmark( rBookmark );
1569 :
1570 0 : if( rBookmark.startsWith("#") )
1571 0 : aBookmark = rBookmark.copy( 1 );
1572 :
1573 : // is the bookmark a page ?
1574 : bool bIsMasterPage;
1575 0 : sal_uInt16 nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage );
1576 0 : SdrObject* pObj = NULL;
1577 :
1578 0 : if ( nPgNum == SDRPAGE_NOTFOUND )
1579 : {
1580 : // is the bookmark a object ?
1581 0 : pObj = rDoc.GetObj( aBookmark );
1582 0 : if (pObj)
1583 0 : nPgNum = pObj->GetPage()->GetPageNum();
1584 : }
1585 0 : if ( nPgNum != SDRPAGE_NOTFOUND )
1586 0 : nPage = ( nPgNum - 1 ) / 2;
1587 0 : return nPage;
1588 : }
1589 :
1590 0 : void ImplPDFExportComments( uno::Reference< drawing::XDrawPage > xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData )
1591 : {
1592 : try
1593 : {
1594 0 : uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
1595 0 : uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
1596 :
1597 0 : LanguageType eLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
1598 0 : while( xAnnotationEnumeration->hasMoreElements() )
1599 : {
1600 0 : uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
1601 :
1602 0 : geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
1603 0 : uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
1604 0 : util::DateTime aDateTime( xAnnotation->getDateTime() );
1605 :
1606 0 : Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
1607 0 : ::tools::Time aTime( ::tools::Time::EMPTY );
1608 0 : OUString aStr( SvxDateTimeField::GetFormatted( aDate, aTime, SVXDATEFORMAT_B, *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
1609 :
1610 0 : vcl::PDFNote aNote;
1611 0 : OUString sTitle( xAnnotation->getAuthor() );
1612 0 : sTitle += ", ";
1613 0 : sTitle += aStr;
1614 0 : aNote.Title = sTitle;
1615 0 : aNote.Contents = xText->getString();
1616 0 : rPDFExtOutDevData.CreateNote( Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ),
1617 0 : static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote );
1618 0 : }
1619 : }
1620 0 : catch (const uno::Exception&)
1621 : {
1622 : }
1623 0 : }
1624 :
1625 0 : void ImplPDFExportShapeInteraction( uno::Reference< drawing::XShape > xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData )
1626 : {
1627 0 : const OUString sGroup ( "com.sun.star.drawing.GroupShape");
1628 0 : const OUString sOnClick ( "OnClick" );
1629 0 : const OUString sBookmark( "Bookmark" );
1630 :
1631 0 : if ( xShape->getShapeType().equals( sGroup ) )
1632 : {
1633 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY );
1634 0 : if ( xIndexAccess.is() )
1635 : {
1636 0 : sal_Int32 i, nCount = xIndexAccess->getCount();
1637 0 : for ( i = 0; i < nCount; i++ )
1638 : {
1639 0 : uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
1640 0 : if ( xSubShape.is() )
1641 0 : ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData );
1642 0 : }
1643 0 : }
1644 : }
1645 : else
1646 : {
1647 0 : uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY );
1648 0 : if( xShapePropSet.is() )
1649 : {
1650 0 : Size aPageSize( rDoc.GetSdPage( 0, PK_STANDARD )->GetSize() );
1651 0 : Point aPoint( 0, 0 );
1652 0 : Rectangle aPageRect( aPoint, aPageSize );
1653 :
1654 0 : awt::Point aShapePos( xShape->getPosition() );
1655 0 : awt::Size aShapeSize( xShape->getSize() );
1656 0 : Rectangle aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) );
1657 :
1658 : presentation::ClickAction eCa;
1659 0 : uno::Any aAny( xShapePropSet->getPropertyValue( sOnClick ) );
1660 0 : if ( aAny >>= eCa )
1661 : {
1662 0 : switch ( eCa )
1663 : {
1664 : case presentation::ClickAction_LASTPAGE :
1665 : {
1666 0 : sal_Int32 nCount = rDoc.GetSdPageCount( PK_STANDARD );
1667 0 : sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::FitRectangle );
1668 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1669 0 : rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1670 : }
1671 0 : break;
1672 : case presentation::ClickAction_FIRSTPAGE :
1673 : {
1674 0 : sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::FitRectangle );
1675 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1676 0 : rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1677 : }
1678 0 : break;
1679 : case presentation::ClickAction_PREVPAGE :
1680 : {
1681 0 : sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber();
1682 0 : if ( nDestPage )
1683 0 : nDestPage--;
1684 0 : sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1685 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1686 0 : rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1687 : }
1688 0 : break;
1689 : case presentation::ClickAction_NEXTPAGE :
1690 : {
1691 0 : sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1;
1692 0 : sal_Int32 nLastPage = rDoc.GetSdPageCount( PK_STANDARD ) - 1;
1693 0 : if ( nDestPage > nLastPage )
1694 0 : nDestPage = nLastPage;
1695 0 : sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1696 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1697 0 : rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1698 : }
1699 0 : break;
1700 :
1701 : case presentation::ClickAction_PROGRAM :
1702 : case presentation::ClickAction_BOOKMARK :
1703 : case presentation::ClickAction_DOCUMENT :
1704 : {
1705 0 : OUString aBookmark;
1706 0 : xShapePropSet->getPropertyValue( sBookmark ) >>= aBookmark;
1707 0 : if( !aBookmark.isEmpty() )
1708 : {
1709 0 : switch( eCa )
1710 : {
1711 : case presentation::ClickAction_DOCUMENT :
1712 : case presentation::ClickAction_PROGRAM :
1713 : {
1714 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1715 0 : rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark );
1716 : }
1717 0 : break;
1718 : case presentation::ClickAction_BOOKMARK :
1719 : {
1720 0 : sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc );
1721 0 : if ( nPage != -1 )
1722 : {
1723 0 : sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle );
1724 0 : sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1725 0 : rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1726 : }
1727 : }
1728 0 : break;
1729 : default:
1730 0 : break;
1731 : }
1732 0 : }
1733 : }
1734 0 : break;
1735 :
1736 : case presentation::ClickAction_STOPPRESENTATION :
1737 : case presentation::ClickAction_SOUND :
1738 : case presentation::ClickAction_INVISIBLE :
1739 : case presentation::ClickAction_VERB :
1740 : case presentation::ClickAction_VANISH :
1741 : case presentation::ClickAction_MACRO :
1742 : default :
1743 0 : break;
1744 : }
1745 0 : }
1746 0 : }
1747 0 : }
1748 0 : }
1749 :
1750 0 : vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject )
1751 : {
1752 0 : vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement);
1753 :
1754 0 : if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() )
1755 : {
1756 0 : sal_uInt32 nInventor = rObject.GetObjInventor();
1757 0 : sal_uInt16 nIdentifier = rObject.GetObjIdentifier();
1758 0 : bool bIsTextObj = rObject.ISA( SdrTextObj );
1759 :
1760 0 : if ( nInventor == SdrInventor )
1761 : {
1762 0 : if ( nIdentifier == OBJ_GRUP )
1763 0 : eElement = vcl::PDFWriter::Section;
1764 0 : else if ( nIdentifier == OBJ_TITLETEXT )
1765 0 : eElement = vcl::PDFWriter::Heading;
1766 0 : else if ( nIdentifier == OBJ_OUTLINETEXT )
1767 0 : eElement = vcl::PDFWriter::Division;
1768 0 : else if ( !bIsTextObj || !((SdrTextObj&)rObject).HasText() )
1769 0 : eElement = vcl::PDFWriter::Figure;
1770 : }
1771 : }
1772 :
1773 0 : return eElement;
1774 : }
1775 :
1776 0 : drawinglayer::primitive2d::Primitive2DSequence ImplRenderPaintProc::createRedirectedPrimitive2DSequence(
1777 : const sdr::contact::ViewObjectContact& rOriginal,
1778 : const sdr::contact::DisplayInfo& rDisplayInfo)
1779 : {
1780 0 : SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
1781 :
1782 0 : if(pObject)
1783 : {
1784 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
1785 :
1786 0 : if(pObject->GetPage())
1787 : {
1788 0 : if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
1789 : {
1790 0 : if(IsVisible(pObject) && IsPrintable(pObject))
1791 : {
1792 0 : const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject ));
1793 0 : const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement);
1794 :
1795 0 : xRetval = ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1796 :
1797 0 : if(xRetval.hasElements() && bTagUsed)
1798 : {
1799 : // embed Primitive2DSequence in a structure tag element for
1800 : // exactly this purpose (StructureTagPrimitive2D)
1801 0 : const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::StructureTagPrimitive2D(eElement, xRetval));
1802 0 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
1803 : }
1804 : }
1805 : }
1806 : }
1807 :
1808 0 : return xRetval;
1809 : }
1810 : else
1811 : {
1812 : // not an object, maybe a page
1813 0 : return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1814 : }
1815 : }
1816 :
1817 0 : bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
1818 : {
1819 0 : bool bVisible = true;
1820 0 : SdrLayerID nLayerId = pObj->GetLayer();
1821 0 : if( pSdrPageView )
1822 : {
1823 0 : const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1824 0 : if ( pSdrLayer )
1825 : {
1826 0 : OUString aLayerName = pSdrLayer->GetName();
1827 0 : bVisible = pSdrPageView->IsLayerVisible( aLayerName );
1828 : }
1829 : }
1830 0 : return bVisible;
1831 : }
1832 0 : bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
1833 : {
1834 0 : bool bPrintable = true;
1835 0 : SdrLayerID nLayerId = pObj->GetLayer();
1836 0 : if( pSdrPageView )
1837 : {
1838 0 : const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1839 0 : if ( pSdrLayer )
1840 : {
1841 0 : OUString aLayerName = pSdrLayer->GetName();
1842 0 : bPrintable = pSdrPageView->IsLayerPrintable( aLayerName );
1843 : }
1844 : }
1845 0 : return bPrintable;
1846 :
1847 : }
1848 0 : void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
1849 : const uno::Sequence< beans::PropertyValue >& rxOptions )
1850 : throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
1851 : {
1852 0 : ::SolarMutexGuard aGuard;
1853 :
1854 0 : if( NULL == mpDoc )
1855 0 : throw lang::DisposedException();
1856 :
1857 0 : if( mpDocShell && mpDoc )
1858 : {
1859 0 : uno::Reference< awt::XDevice > xRenderDevice;
1860 0 : const sal_Int32 nPageNumber = nRenderer + 1;
1861 0 : PageKind ePageKind = PK_STANDARD;
1862 0 : bool bExportNotesPages = false;
1863 :
1864 0 : for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1865 : {
1866 0 : if ( rxOptions[ nProperty ].Name == "RenderDevice" )
1867 0 : rxOptions[ nProperty ].Value >>= xRenderDevice;
1868 0 : else if ( rxOptions[ nProperty ].Name == "ExportNotesPages" )
1869 : {
1870 0 : rxOptions[ nProperty].Value >>= bExportNotesPages;
1871 0 : if ( bExportNotesPages )
1872 0 : ePageKind = PK_NOTES;
1873 : }
1874 : }
1875 :
1876 0 : if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) )
1877 : {
1878 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
1879 0 : OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
1880 :
1881 0 : if( pOut )
1882 : {
1883 0 : vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() );
1884 :
1885 0 : if ( !( (mpDoc->GetSdPage((sal_Int16) nPageNumber-1, PK_STANDARD))->IsExcluded() ) ||
1886 0 : (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
1887 : {
1888 0 : ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut, NULL );
1889 0 : Rectangle aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() );
1890 0 : vcl::Region aRegion( aVisArea );
1891 :
1892 0 : ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
1893 0 : ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : NULL;
1894 :
1895 0 : if ( pOldSdView )
1896 0 : pOldSdView->SdrEndTextEdit();
1897 :
1898 0 : pView->SetHlplVisible( false );
1899 0 : pView->SetGridVisible( false );
1900 0 : pView->SetBordVisible( false );
1901 0 : pView->SetPageVisible( false );
1902 0 : pView->SetGlueVisible( false );
1903 :
1904 0 : pOut->SetMapMode( MAP_100TH_MM );
1905 0 : pOut->IntersectClipRegion( aVisArea );
1906 :
1907 0 : uno::Reference< frame::XModel > xModel;
1908 0 : rSelection >>= xModel;
1909 :
1910 0 : if( xModel == mpDocShell->GetModel() )
1911 : {
1912 0 : pView->ShowSdrPage( mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind ));
1913 0 : SdrPageView* pPV = pView->GetSdrPageView();
1914 :
1915 0 : if( pOldSdView )
1916 : {
1917 0 : SdrPageView* pOldPV = pOldSdView->GetSdrPageView();
1918 0 : if( pPV && pOldPV )
1919 : {
1920 0 : pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() );
1921 0 : pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() );
1922 : }
1923 : }
1924 :
1925 0 : ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
1926 0 : pPV, pPDFExtOutDevData );
1927 :
1928 : // background color for outliner :o
1929 0 : SdPage* pPage = pPV ? (SdPage*)pPV->GetPage() : NULL;
1930 0 : if( pPage )
1931 : {
1932 0 : SdrOutliner& rOutl = mpDoc->GetDrawOutliner( NULL );
1933 0 : bool bScreenDisplay(true);
1934 :
1935 0 : if(bScreenDisplay && pOut && OUTDEV_PRINTER == pOut->GetOutDevType())
1936 : {
1937 : // #i75566# printing; suppress AutoColor BackgroundColor generation
1938 : // for visibility reasons by giving GetPageBackgroundColor()
1939 : // the needed hint
1940 0 : bScreenDisplay = false;
1941 : }
1942 :
1943 0 : if(bScreenDisplay && pOut && pOut->GetPDFWriter())
1944 : {
1945 : // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
1946 0 : bScreenDisplay = false;
1947 : }
1948 :
1949 : // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
1950 : // hint value if screen display. Only then the AutoColor mechanisms shall be applied
1951 0 : rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) );
1952 : }
1953 0 : pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc );
1954 :
1955 0 : if ( pPDFExtOutDevData && pPage )
1956 : {
1957 : try
1958 : {
1959 0 : uno::Any aAny;
1960 0 : uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) );
1961 0 : if ( xPage.is() )
1962 : {
1963 0 : if ( pPDFExtOutDevData->GetIsExportNotes() )
1964 0 : ImplPDFExportComments( xPage, *pPDFExtOutDevData );
1965 0 : uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY );
1966 0 : if( xPagePropSet.is() )
1967 : {
1968 : // exporting object interactions to pdf
1969 :
1970 : // if necessary, the master page interactions will be exported first
1971 0 : bool bIsBackgroundObjectsVisible = false; // #i39428# IsBackgroundObjectsVisible not available for Draw
1972 0 : if ( mbImpressDoc && xPagePropSet->getPropertySetInfo()->hasPropertyByName( "IsBackgroundObjectsVisible" ) )
1973 0 : xPagePropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bIsBackgroundObjectsVisible;
1974 0 : if ( bIsBackgroundObjectsVisible && !pPDFExtOutDevData->GetIsExportNotesPages() )
1975 : {
1976 0 : uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY );
1977 0 : if ( xMasterPageTarget.is() )
1978 : {
1979 0 : uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
1980 0 : if ( xMasterPage.is() )
1981 : {
1982 0 : uno::Reference< drawing::XShapes> xShapes( xMasterPage, uno::UNO_QUERY );
1983 0 : sal_Int32 i, nCount = xShapes->getCount();
1984 0 : for ( i = 0; i < nCount; i++ )
1985 : {
1986 0 : aAny = xShapes->getByIndex( i );
1987 0 : uno::Reference< drawing::XShape > xShape;
1988 0 : if ( aAny >>= xShape )
1989 0 : ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
1990 0 : }
1991 0 : }
1992 0 : }
1993 : }
1994 :
1995 : // exporting slide page object interactions
1996 0 : uno::Reference< drawing::XShapes> xShapes( xPage, uno::UNO_QUERY );
1997 0 : sal_Int32 i, nCount = xShapes->getCount();
1998 0 : for ( i = 0; i < nCount; i++ )
1999 : {
2000 0 : aAny = xShapes->getByIndex( i );
2001 0 : uno::Reference< drawing::XShape > xShape;
2002 0 : if ( aAny >>= xShape )
2003 0 : ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
2004 0 : }
2005 :
2006 : // exporting transition effects to pdf
2007 0 : if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && pPDFExtOutDevData->GetIsExportTransitionEffects() )
2008 : {
2009 0 : const OUString sEffect( "Effect" );
2010 0 : const OUString sSpeed ( "Speed" );
2011 0 : sal_Int32 nTime = 800;
2012 : presentation::AnimationSpeed aAs;
2013 0 : if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
2014 : {
2015 0 : aAny = xPagePropSet->getPropertyValue( sSpeed );
2016 0 : if ( aAny >>= aAs )
2017 : {
2018 0 : switch( aAs )
2019 : {
2020 0 : case presentation::AnimationSpeed_SLOW : nTime = 1500; break;
2021 0 : case presentation::AnimationSpeed_FAST : nTime = 300; break;
2022 : default:
2023 0 : case presentation::AnimationSpeed_MEDIUM : nTime = 800;
2024 : }
2025 : }
2026 : }
2027 : presentation::FadeEffect eFe;
2028 0 : vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::Regular;
2029 0 : if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) )
2030 : {
2031 0 : aAny = xPagePropSet->getPropertyValue( sEffect );
2032 0 : if ( aAny >>= eFe )
2033 : {
2034 0 : switch( eFe )
2035 : {
2036 : case presentation::FadeEffect_HORIZONTAL_LINES :
2037 : case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
2038 0 : case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::BlindsHorizontal; break;
2039 :
2040 : case presentation::FadeEffect_VERTICAL_LINES :
2041 : case presentation::FadeEffect_VERTICAL_CHECKERBOARD :
2042 0 : case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::BlindsVertical; break;
2043 :
2044 : case presentation::FadeEffect_UNCOVER_TO_RIGHT :
2045 : case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
2046 : case presentation::FadeEffect_ROLL_FROM_LEFT :
2047 : case presentation::FadeEffect_FADE_FROM_UPPERLEFT :
2048 : case presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
2049 : case presentation::FadeEffect_FADE_FROM_LEFT :
2050 0 : case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::WipeLeftToRight; break;
2051 :
2052 : case presentation::FadeEffect_UNCOVER_TO_BOTTOM :
2053 : case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
2054 : case presentation::FadeEffect_ROLL_FROM_TOP :
2055 : case presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
2056 : case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
2057 : case presentation::FadeEffect_FADE_FROM_TOP :
2058 0 : case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::WipeTopToBottom; break;
2059 :
2060 : case presentation::FadeEffect_UNCOVER_TO_LEFT :
2061 : case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
2062 : case presentation::FadeEffect_ROLL_FROM_RIGHT :
2063 :
2064 : case presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
2065 : case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
2066 : case presentation::FadeEffect_FADE_FROM_RIGHT :
2067 0 : case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::WipeRightToLeft; break;
2068 :
2069 : case presentation::FadeEffect_UNCOVER_TO_TOP :
2070 : case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
2071 : case presentation::FadeEffect_ROLL_FROM_BOTTOM :
2072 : case presentation::FadeEffect_FADE_FROM_LOWERLEFT :
2073 : case presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
2074 : case presentation::FadeEffect_FADE_FROM_BOTTOM :
2075 0 : case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::WipeBottomToTop; break;
2076 :
2077 0 : case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::SplitHorizontalInward; break;
2078 0 : case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::SplitHorizontalOutward; break;
2079 :
2080 0 : case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::SplitVerticalInward; break;
2081 0 : case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::SplitVerticalOutward; break;
2082 :
2083 0 : case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::BoxInward; break;
2084 0 : case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::BoxOutward; break;
2085 :
2086 0 : case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::Regular; break;
2087 :
2088 : case presentation::FadeEffect_RANDOM :
2089 : case presentation::FadeEffect_DISSOLVE :
2090 0 : default: eType = vcl::PDFWriter::Dissolve; break;
2091 : }
2092 : }
2093 : }
2094 :
2095 0 : if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) ||
2096 0 : xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
2097 : {
2098 0 : pPDFExtOutDevData->SetPageTransition( eType, nTime, -1 );
2099 0 : }
2100 0 : }
2101 0 : }
2102 : }
2103 :
2104 0 : Size aPageSize( mpDoc->GetSdPage( 0, PK_STANDARD )->GetSize() );
2105 0 : Point aPoint( 0, 0 );
2106 0 : Rectangle aPageRect( aPoint, aPageSize );
2107 :
2108 : // resolving links found in this page by the method ImpEditEngine::Paint
2109 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
2110 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin();
2111 0 : std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
2112 0 : while ( aIBeg != aIEnd )
2113 : {
2114 0 : sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc );
2115 0 : if ( nPage != -1 )
2116 : {
2117 0 : if ( aIBeg->nLinkId != -1 )
2118 0 : pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ) );
2119 : else
2120 0 : pPDFExtOutDevData->DescribeRegisteredDest( aIBeg->nDestId, aPageRect, nPage, vcl::PDFWriter::FitRectangle );
2121 : }
2122 : else
2123 0 : pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark );
2124 0 : ++aIBeg;
2125 : }
2126 0 : rBookmarks.clear();
2127 : //---> #i56629, #i40318
2128 : //get the page name, will be used as outline element in PDF bookmark pane
2129 0 : OUString aPageName = mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1 , PK_STANDARD )->GetName();
2130 0 : if( !aPageName.isEmpty() )
2131 : {
2132 : // insert the bookmark to this page into the NamedDestinations
2133 0 : if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
2134 0 : pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect, nPageNumber - 1 );
2135 :
2136 : // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
2137 : // issue #i40318.
2138 :
2139 0 : if( pPDFExtOutDevData->GetIsExportBookmarks() )
2140 : {
2141 : // Destination Export
2142 : const sal_Int32 nDestId =
2143 0 : pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 );
2144 :
2145 : // Create a new outline item:
2146 0 : pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
2147 : }
2148 0 : }
2149 : //<--- #i56629, #i40318
2150 : }
2151 0 : catch (const uno::Exception&)
2152 : {
2153 : }
2154 :
2155 0 : }
2156 : }
2157 : else
2158 : {
2159 0 : uno::Reference< drawing::XShapes > xShapes;
2160 0 : rSelection >>= xShapes;
2161 :
2162 0 : if( xShapes.is() && xShapes->getCount() )
2163 : {
2164 0 : SdrPageView* pPV = NULL;
2165 :
2166 0 : ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
2167 0 : pOldSdView ? pOldSdView->GetSdrPageView() : NULL, pPDFExtOutDevData );
2168 :
2169 0 : for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ )
2170 : {
2171 0 : uno::Reference< drawing::XShape > xShape;
2172 0 : xShapes->getByIndex( i ) >>= xShape;
2173 :
2174 0 : if( xShape.is() )
2175 : {
2176 0 : SvxShape* pShape = SvxShape::getImplementation( xShape );
2177 :
2178 0 : if( pShape )
2179 : {
2180 0 : SdrObject* pObj = pShape->GetSdrObject();
2181 0 : if( pObj && pObj->GetPage()
2182 0 : && aImplRenderPaintProc.IsVisible( pObj )
2183 0 : && aImplRenderPaintProc.IsPrintable( pObj ) )
2184 : {
2185 0 : if( !pPV )
2186 0 : pPV = pView->ShowSdrPage( pObj->GetPage() );
2187 :
2188 0 : if( pPV )
2189 0 : pView->MarkObj( pObj, pPV );
2190 : }
2191 : }
2192 : }
2193 0 : }
2194 0 : pView->DrawMarkedObj(*pOut);
2195 0 : }
2196 : }
2197 :
2198 0 : delete pView;
2199 : }
2200 : }
2201 0 : }
2202 0 : }
2203 0 : }
2204 :
2205 0 : DrawViewShell* SdXImpressDocument::GetViewShell()
2206 : {
2207 0 : DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell());
2208 0 : if (!pViewSh)
2209 : {
2210 : SAL_WARN("sd", "DrawViewShell not available!");
2211 0 : return NULL;
2212 : }
2213 0 : return pViewSh;
2214 : }
2215 :
2216 0 : void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
2217 : int nOutputWidth, int nOutputHeight,
2218 : int nTilePosX, int nTilePosY,
2219 : long nTileWidth, long nTileHeight )
2220 : {
2221 0 : DrawViewShell* pViewSh = GetViewShell();
2222 0 : if (!pViewSh)
2223 0 : return;
2224 :
2225 : // Scaling. Must convert from pixels to twips. We know
2226 : // that VirtualDevices use a DPI of 96.
2227 : // We specifically calculate these scales first as we're still
2228 : // in TWIPs, and might as well minimise the number of conversions.
2229 0 : Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
2230 0 : Fraction( nTileWidth);
2231 0 : Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
2232 0 : Fraction( nTileHeight);
2233 :
2234 : // svx seems to be the only component that works natively in
2235 : // 100th mm rather than TWIP. It makes most sense just to
2236 : // convert here and in getDocumentSize, and leave the tiled
2237 : // rendering API working in TWIPs.
2238 0 : nTileWidth = convertTwipToMm100( nTileWidth );
2239 0 : nTileHeight = convertTwipToMm100( nTileHeight );
2240 0 : nTilePosX = convertTwipToMm100( nTilePosX );
2241 0 : nTilePosY = convertTwipToMm100( nTilePosY );
2242 :
2243 0 : MapMode aMapMode = rDevice.GetMapMode();
2244 0 : aMapMode.SetMapUnit( MAP_100TH_MM );
2245 : aMapMode.SetOrigin( Point( -nTilePosX,
2246 0 : -nTilePosY) );
2247 0 : aMapMode.SetScaleX( scaleX );
2248 0 : aMapMode.SetScaleY( scaleY );
2249 :
2250 0 : rDevice.SetMapMode( aMapMode );
2251 :
2252 0 : rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) );
2253 :
2254 0 : Point aPoint(nTilePosX, nTilePosY);
2255 0 : Size aSize(nTileWidth, nTileHeight);
2256 0 : Rectangle aRect(aPoint, aSize);
2257 :
2258 0 : pViewSh->GetView()->CompleteRedraw(&rDevice, vcl::Region(aRect));
2259 : }
2260 :
2261 0 : void SdXImpressDocument::setPart( int nPart )
2262 : {
2263 0 : DrawViewShell* pViewSh = GetViewShell();
2264 0 : if (!pViewSh)
2265 0 : return;
2266 :
2267 : // TODO: have an API to allow selecting between PK_STANDARD (just slide)
2268 : // and PK_NOTES (which shows the combined slide above notes). There is alo
2269 : // a PK_HANDOUT -- that however just shows multiple empty pages (it's also
2270 : // only possible to select page 0 in this mode, I have no idea how you
2271 : // then actually select what is on the handout page, which defaults to
2272 : // a 4x4 grid of empty pages).
2273 0 : pViewSh->SwitchPage( nPart );
2274 : }
2275 :
2276 0 : int SdXImpressDocument::getParts()
2277 : {
2278 : // TODO: master pages?
2279 : // Read: drviews1.cxx
2280 0 : return mpDoc->GetSdPageCount(PK_STANDARD);
2281 : }
2282 :
2283 0 : int SdXImpressDocument::getPart()
2284 : {
2285 0 : DrawViewShell* pViewSh = GetViewShell();
2286 0 : if (!pViewSh)
2287 0 : return 0;
2288 :
2289 : // curPageId seems to start at 1
2290 0 : return pViewSh->GetCurPageId() - 1;
2291 : }
2292 :
2293 0 : OUString SdXImpressDocument::getPartName( int nPart )
2294 : {
2295 0 : SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD );
2296 0 : if (!pPage)
2297 : {
2298 : SAL_WARN("sd", "DrawViewShell not available!");
2299 0 : return OUString();
2300 : }
2301 :
2302 0 : return pPage->GetName();
2303 : }
2304 :
2305 0 : void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
2306 : {
2307 0 : DrawViewShell* pViewSh = GetViewShell();
2308 0 : if (!pViewSh)
2309 0 : return;
2310 :
2311 0 : PageKind aPageKind( PK_STANDARD );
2312 0 : switch ( ePartMode )
2313 : {
2314 : case LOK_PARTMODE_EMBEDDEDOBJ:
2315 : // This will probably be handled higher up, i.e.
2316 : // we probably shouldn't be handling this here.
2317 : // (However we don't offer embedded object-only
2318 : // rendering anywhere yet, so this may be a
2319 : // completely incorrect comment.)
2320 : assert( false );
2321 : // And let's fall through in a normal build.
2322 : case LOK_PARTMODE_DEFAULT:
2323 : case LOK_PARTMODE_SLIDE:
2324 0 : break;
2325 : case LOK_PARTMODE_SLIDENOTES:
2326 0 : aPageKind = PK_NOTES;
2327 0 : break;
2328 : case LOK_PARTMODE_NOTES:
2329 : // TODO: this shows combined slides + notes
2330 0 : aPageKind = PK_NOTES;
2331 0 : break;
2332 : }
2333 0 : pViewSh->SetPageKind( aPageKind );
2334 : }
2335 :
2336 0 : Size SdXImpressDocument::getDocumentSize()
2337 : {
2338 0 : DrawViewShell* pViewSh = GetViewShell();
2339 0 : if (!pViewSh)
2340 0 : return Size();
2341 :
2342 0 : SdrPageView* pCurPageView = pViewSh->GetView()->GetSdrPageView();
2343 :
2344 0 : Size aSize = pCurPageView->GetPageRect().GetSize();
2345 : // Convert the size in 100th mm to TWIP
2346 : // See paintTile above for further info.
2347 0 : return Size(convertMm100ToTwip(aSize.getWidth()), convertMm100ToTwip(aSize.getHeight()));
2348 : }
2349 :
2350 :
2351 50 : uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
2352 : {
2353 50 : uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
2354 :
2355 50 : if( !xForb.is() )
2356 50 : mxForbidenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc );
2357 :
2358 50 : return xForb;
2359 : }
2360 :
2361 1000 : void SdXImpressDocument::initializeDocument()
2362 : {
2363 1000 : if( !mbClipBoard )
2364 : {
2365 1000 : switch( mpDoc->GetPageCount() )
2366 : {
2367 : case 1:
2368 : {
2369 : // nasty hack to detect clipboard document
2370 0 : mbClipBoard = true;
2371 0 : break;
2372 : }
2373 : case 0:
2374 : {
2375 108 : mpDoc->CreateFirstPages();
2376 108 : mpDoc->StopWorkStartupDelay();
2377 108 : break;
2378 : }
2379 : }
2380 : }
2381 1000 : }
2382 :
2383 568 : void SAL_CALL SdXImpressDocument::dispose() throw (::com::sun::star::uno::RuntimeException, std::exception)
2384 : {
2385 568 : if( !mbDisposed )
2386 : {
2387 : {
2388 568 : ::SolarMutexGuard aGuard;
2389 :
2390 568 : if( mpDoc )
2391 : {
2392 438 : EndListening( *mpDoc );
2393 438 : mpDoc = NULL;
2394 : }
2395 :
2396 : // Call the base class dispose() before setting the mbDisposed flag
2397 : // to true. The reason for this is that if close() has not yet been
2398 : // called this is done in SfxBaseModel::dispose(). At the end of
2399 : // that dispose() is called again. It is important to forward this
2400 : // second dispose() to the base class, too.
2401 : // As a consequence the following code has to be able to be run twice.
2402 568 : SfxBaseModel::dispose();
2403 568 : mbDisposed = true;
2404 :
2405 1136 : uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies);
2406 568 : if( xStyles.is() )
2407 : {
2408 0 : uno::Reference< lang::XComponent > xComp( xStyles, uno::UNO_QUERY );
2409 0 : if( xComp.is() )
2410 0 : xComp->dispose();
2411 :
2412 0 : xStyles = 0;
2413 : }
2414 :
2415 1136 : uno::Reference< presentation::XPresentation > xPresentation( mxPresentation );
2416 568 : if( xPresentation.is() )
2417 : {
2418 0 : uno::Reference< ::com::sun::star::presentation::XPresentation2 > xPres( mpDoc->getPresentation().get() );
2419 0 : uno::Reference< lang::XComponent > xPresComp( xPres, uno::UNO_QUERY );
2420 0 : if( xPresComp.is() )
2421 0 : xPresComp->dispose();
2422 : }
2423 :
2424 1136 : uno::Reference< container::XNameAccess > xLinks( mxLinks );
2425 568 : if( xLinks.is() )
2426 : {
2427 2 : uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY );
2428 2 : if( xComp.is() )
2429 2 : xComp->dispose();
2430 :
2431 2 : xLinks = 0;
2432 : }
2433 :
2434 1136 : uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess );
2435 568 : if( xDrawPagesAccess.is() )
2436 : {
2437 138 : uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY );
2438 138 : if( xComp.is() )
2439 138 : xComp->dispose();
2440 :
2441 138 : xDrawPagesAccess = 0;
2442 : }
2443 :
2444 1136 : uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess );
2445 568 : if( xDrawPagesAccess.is() )
2446 : {
2447 0 : uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY );
2448 0 : if( xComp.is() )
2449 0 : xComp->dispose();
2450 :
2451 0 : xDrawPagesAccess = 0;
2452 : }
2453 :
2454 1136 : uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
2455 568 : if( xLayerManager.is() )
2456 : {
2457 4 : uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY );
2458 4 : if( xComp.is() )
2459 4 : xComp->dispose();
2460 :
2461 4 : xLayerManager = 0;
2462 : }
2463 :
2464 1136 : uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess );
2465 568 : if( xCustomPresentationAccess.is() )
2466 : {
2467 4 : uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY );
2468 4 : if( xComp.is() )
2469 0 : xComp->dispose();
2470 :
2471 4 : xCustomPresentationAccess = 0;
2472 : }
2473 :
2474 568 : mxDashTable = 0;
2475 568 : mxGradientTable = 0;
2476 568 : mxHatchTable = 0;
2477 568 : mxBitmapTable = 0;
2478 568 : mxTransGradientTable = 0;
2479 568 : mxMarkerTable = 0;
2480 1136 : mxDrawingPool = 0;
2481 : }
2482 : }
2483 568 : }
2484 :
2485 : // class SdDrawPagesAccess
2486 :
2487 866 : SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel ) throw()
2488 866 : : mpModel( &rMyModel)
2489 : {
2490 866 : }
2491 :
2492 1732 : SdDrawPagesAccess::~SdDrawPagesAccess() throw()
2493 : {
2494 1732 : }
2495 :
2496 : // XIndexAccess
2497 956 : sal_Int32 SAL_CALL SdDrawPagesAccess::getCount()
2498 : throw(uno::RuntimeException, std::exception)
2499 : {
2500 956 : ::SolarMutexGuard aGuard;
2501 :
2502 956 : if( NULL == mpModel )
2503 0 : throw lang::DisposedException();
2504 :
2505 956 : return mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2506 : }
2507 :
2508 1138 : uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index )
2509 : throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2510 : {
2511 1138 : ::SolarMutexGuard aGuard;
2512 :
2513 1138 : if( NULL == mpModel )
2514 0 : throw lang::DisposedException();
2515 :
2516 1138 : uno::Any aAny;
2517 :
2518 1138 : if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PK_STANDARD ) ) )
2519 2 : throw lang::IndexOutOfBoundsException();
2520 :
2521 1136 : SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD );
2522 1136 : if( pPage )
2523 : {
2524 1136 : uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2525 1136 : aAny <<= xDrawPage;
2526 : }
2527 :
2528 1138 : return aAny;
2529 : }
2530 :
2531 : // XNameAccess
2532 0 : uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2533 : {
2534 0 : ::SolarMutexGuard aGuard;
2535 :
2536 0 : if( NULL == mpModel )
2537 0 : throw lang::DisposedException();
2538 :
2539 0 : if( !aName.isEmpty() )
2540 : {
2541 0 : const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2542 : sal_uInt16 nPage;
2543 0 : for( nPage = 0; nPage < nCount; nPage++ )
2544 : {
2545 0 : SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2546 0 : if(NULL == pPage)
2547 0 : continue;
2548 :
2549 0 : if( aName == SdDrawPage::getPageApiName( pPage ) )
2550 : {
2551 0 : uno::Any aAny;
2552 0 : uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2553 0 : aAny <<= xDrawPage;
2554 0 : return aAny;
2555 : }
2556 : }
2557 : }
2558 :
2559 0 : throw container::NoSuchElementException();
2560 : }
2561 :
2562 0 : uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() throw(uno::RuntimeException, std::exception)
2563 : {
2564 0 : ::SolarMutexGuard aGuard;
2565 :
2566 0 : if( NULL == mpModel )
2567 0 : throw lang::DisposedException();
2568 :
2569 0 : const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2570 0 : uno::Sequence< OUString > aNames( nCount );
2571 0 : OUString* pNames = aNames.getArray();
2572 :
2573 : sal_uInt16 nPage;
2574 0 : for( nPage = 0; nPage < nCount; nPage++ )
2575 : {
2576 0 : SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2577 0 : *pNames++ = SdDrawPage::getPageApiName( pPage );
2578 : }
2579 :
2580 0 : return aNames;
2581 : }
2582 :
2583 0 : sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) throw(uno::RuntimeException, std::exception)
2584 : {
2585 0 : ::SolarMutexGuard aGuard;
2586 :
2587 0 : if( NULL == mpModel )
2588 0 : throw lang::DisposedException();
2589 :
2590 0 : const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2591 : sal_uInt16 nPage;
2592 0 : for( nPage = 0; nPage < nCount; nPage++ )
2593 : {
2594 0 : SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2595 0 : if(NULL == pPage)
2596 0 : continue;
2597 :
2598 0 : if( aName == SdDrawPage::getPageApiName( pPage ) )
2599 0 : return sal_True;
2600 : }
2601 :
2602 0 : return sal_False;
2603 : }
2604 :
2605 : // XElementAccess
2606 2 : uno::Type SAL_CALL SdDrawPagesAccess::getElementType()
2607 : throw(uno::RuntimeException, std::exception)
2608 : {
2609 2 : return cppu::UnoType<drawing::XDrawPage>::get();
2610 : }
2611 :
2612 2 : sal_Bool SAL_CALL SdDrawPagesAccess::hasElements()
2613 : throw(uno::RuntimeException, std::exception)
2614 : {
2615 2 : return getCount() > 0;
2616 : }
2617 :
2618 : // XDrawPages
2619 :
2620 : /**
2621 : * Creates a new page with model at the specified position.
2622 : * @returns corresponding SdDrawPage
2623 : */
2624 342 : uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
2625 : throw(uno::RuntimeException, std::exception)
2626 : {
2627 342 : ::SolarMutexGuard aGuard;
2628 :
2629 342 : if( NULL == mpModel )
2630 0 : throw lang::DisposedException();
2631 :
2632 342 : if( mpModel->mpDoc )
2633 : {
2634 342 : SdPage* pPage = mpModel->InsertSdPage( (sal_uInt16)nIndex );
2635 342 : if( pPage )
2636 : {
2637 342 : uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2638 342 : return xDrawPage;
2639 : }
2640 : }
2641 0 : uno::Reference< drawing::XDrawPage > xDrawPage;
2642 342 : return xDrawPage;
2643 : }
2644 :
2645 : /**
2646 : * Removes the specified SdDrawPage from the model and the internal list. It
2647 : * only works, if there is at least one *normal* page in the model after
2648 : * removing this page.
2649 : */
2650 242 : void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2651 : throw(uno::RuntimeException, std::exception)
2652 : {
2653 242 : ::SolarMutexGuard aGuard;
2654 :
2655 242 : if( NULL == mpModel || mpModel->mpDoc == NULL )
2656 0 : throw lang::DisposedException();
2657 :
2658 242 : SdDrawDocument& rDoc = *mpModel->mpDoc;
2659 :
2660 242 : sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD );
2661 242 : if( nPageCount > 1 )
2662 : {
2663 : // get pPage from xPage and determine the Id (nPos ) afterwards
2664 242 : SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage );
2665 242 : if( pSvxPage )
2666 : {
2667 242 : SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
2668 242 : if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) )
2669 : {
2670 242 : sal_uInt16 nPage = pPage->GetPageNum();
2671 :
2672 242 : SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
2673 :
2674 242 : bool bUndo = rDoc.IsUndoEnabled();
2675 242 : if( bUndo )
2676 : {
2677 : // Add undo actions and delete the pages. The order of adding
2678 : // the undo actions is important.
2679 242 : rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2680 242 : rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2681 242 : rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2682 : }
2683 :
2684 242 : rDoc.RemovePage( nPage ); // the page
2685 242 : rDoc.RemovePage( nPage ); // the notes page
2686 :
2687 242 : if( bUndo )
2688 : {
2689 242 : rDoc.EndUndo();
2690 : }
2691 : else
2692 : {
2693 0 : delete pNotesPage;
2694 0 : delete pPage;
2695 : }
2696 : }
2697 : }
2698 : }
2699 :
2700 242 : mpModel->SetModified();
2701 242 : }
2702 :
2703 : // XServiceInfo
2704 : const char pSdDrawPagesAccessService[] = "com.sun.star.drawing.DrawPages";
2705 :
2706 0 : OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException, std::exception)
2707 : {
2708 0 : return OUString( "SdDrawPagesAccess" );
2709 : }
2710 :
2711 0 : sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException, std::exception)
2712 : {
2713 0 : return cppu::supportsService(this, ServiceName);
2714 : }
2715 :
2716 0 : uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
2717 : {
2718 0 : OUString aService( pSdDrawPagesAccessService );
2719 0 : uno::Sequence< OUString > aSeq( &aService, 1 );
2720 0 : return aSeq;
2721 : }
2722 :
2723 : // XComponent
2724 138 : void SAL_CALL SdDrawPagesAccess::dispose( ) throw (uno::RuntimeException, std::exception)
2725 : {
2726 138 : mpModel = NULL;
2727 138 : }
2728 :
2729 0 : void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
2730 : {
2731 : OSL_FAIL( "not implemented!" );
2732 0 : }
2733 :
2734 0 : void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
2735 : {
2736 : OSL_FAIL( "not implemented!" );
2737 0 : }
2738 :
2739 : // class SdMasterPagesAccess
2740 :
2741 692 : SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw()
2742 692 : : mpModel(&rMyModel)
2743 : {
2744 692 : }
2745 :
2746 1384 : SdMasterPagesAccess::~SdMasterPagesAccess() throw()
2747 : {
2748 1384 : }
2749 :
2750 : // XComponent
2751 0 : void SAL_CALL SdMasterPagesAccess::dispose( ) throw (uno::RuntimeException, std::exception)
2752 : {
2753 0 : mpModel = NULL;
2754 0 : }
2755 :
2756 0 : void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
2757 : {
2758 : OSL_FAIL( "not implemented!" );
2759 0 : }
2760 :
2761 0 : void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
2762 : {
2763 : OSL_FAIL( "not implemented!" );
2764 0 : }
2765 :
2766 : // XIndexAccess
2767 424 : sal_Int32 SAL_CALL SdMasterPagesAccess::getCount()
2768 : throw(uno::RuntimeException, std::exception)
2769 : {
2770 424 : ::SolarMutexGuard aGuard;
2771 :
2772 424 : if( NULL == mpModel->mpDoc )
2773 0 : throw lang::DisposedException();
2774 :
2775 424 : return mpModel->mpDoc->GetMasterSdPageCount(PK_STANDARD);
2776 : }
2777 :
2778 : /**
2779 : * Provides a drawing::XDrawPage interface for accessing the Masterpage at the
2780 : * specified position in the model.
2781 : */
2782 560 : uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index )
2783 : throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
2784 : {
2785 560 : ::SolarMutexGuard aGuard;
2786 :
2787 560 : if( NULL == mpModel )
2788 0 : throw lang::DisposedException();
2789 :
2790 560 : uno::Any aAny;
2791 :
2792 560 : if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PK_STANDARD ) ) )
2793 2 : throw lang::IndexOutOfBoundsException();
2794 :
2795 558 : SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD );
2796 558 : if( pPage )
2797 : {
2798 558 : uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2799 558 : aAny <<= xDrawPage;
2800 : }
2801 :
2802 560 : return aAny;
2803 : }
2804 :
2805 : // XElementAccess
2806 2 : uno::Type SAL_CALL SdMasterPagesAccess::getElementType()
2807 : throw(uno::RuntimeException, std::exception)
2808 : {
2809 2 : return cppu::UnoType<drawing::XDrawPage>::get();
2810 : }
2811 :
2812 2 : sal_Bool SAL_CALL SdMasterPagesAccess::hasElements()
2813 : throw(uno::RuntimeException, std::exception)
2814 : {
2815 2 : return getCount() > 0;
2816 : }
2817 :
2818 : // XDrawPages
2819 32 : uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos )
2820 : throw(uno::RuntimeException, std::exception)
2821 : {
2822 32 : ::SolarMutexGuard aGuard;
2823 :
2824 32 : if( NULL == mpModel )
2825 0 : throw lang::DisposedException();
2826 :
2827 32 : uno::Reference< drawing::XDrawPage > xDrawPage;
2828 :
2829 32 : SdDrawDocument* mpDoc = mpModel->mpDoc;
2830 32 : if( mpDoc )
2831 : {
2832 : // calculate internal index and check for range errors
2833 32 : const sal_Int32 nMPageCount = mpDoc->GetMasterPageCount();
2834 32 : nInsertPos = nInsertPos * 2 + 1;
2835 32 : if( nInsertPos < 0 || nInsertPos > nMPageCount )
2836 0 : nInsertPos = nMPageCount;
2837 :
2838 : // now generate a unique name for the new masterpage
2839 32 : const OUString aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) );
2840 64 : OUString aPrefix( aStdPrefix );
2841 :
2842 32 : bool bUnique = true;
2843 32 : sal_Int32 i = 0;
2844 70 : do
2845 : {
2846 70 : bUnique = true;
2847 190 : for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ )
2848 : {
2849 158 : SdPage* pPage = (SdPage*)mpDoc->GetMasterPage((sal_uInt16)nMaster);
2850 158 : if( pPage && pPage->GetName() == aPrefix )
2851 : {
2852 38 : bUnique = false;
2853 38 : break;
2854 : }
2855 : }
2856 :
2857 70 : if( !bUnique )
2858 : {
2859 38 : i++;
2860 38 : aPrefix = aStdPrefix + " " + OUString::number( i );
2861 : }
2862 :
2863 70 : } while( !bUnique );
2864 :
2865 64 : OUString aLayoutName( aPrefix );
2866 32 : aLayoutName += SD_LT_SEPARATOR;
2867 32 : aLayoutName += SD_RESSTR(STR_LAYOUT_OUTLINE);
2868 :
2869 : // create styles
2870 32 : ((SdStyleSheetPool*)mpDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix );
2871 :
2872 : // get the first page for initial size and border settings
2873 32 : SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD );
2874 32 : SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_NOTES);
2875 :
2876 : // create and instert new draw masterpage
2877 32 : SdPage* pMPage = mpModel->mpDoc->AllocSdPage(true);
2878 32 : pMPage->SetSize( pPage->GetSize() );
2879 32 : pMPage->SetBorder( pPage->GetLftBorder(),
2880 32 : pPage->GetUppBorder(),
2881 32 : pPage->GetRgtBorder(),
2882 128 : pPage->GetLwrBorder() );
2883 32 : pMPage->SetLayoutName( aLayoutName );
2884 32 : mpDoc->InsertMasterPage(pMPage, (sal_uInt16)nInsertPos);
2885 :
2886 : {
2887 : // ensure default MasterPage fill
2888 32 : pMPage->EnsureMasterPageDefaultBackground();
2889 : }
2890 :
2891 32 : xDrawPage = uno::Reference< drawing::XDrawPage >::query( pMPage->getUnoPage() );
2892 :
2893 : // create and instert new notes masterpage
2894 32 : SdPage* pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
2895 32 : pMNotesPage->SetSize( pRefNotesPage->GetSize() );
2896 32 : pMNotesPage->SetPageKind(PK_NOTES);
2897 32 : pMNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
2898 32 : pRefNotesPage->GetUppBorder(),
2899 32 : pRefNotesPage->GetRgtBorder(),
2900 128 : pRefNotesPage->GetLwrBorder() );
2901 32 : pMNotesPage->SetLayoutName( aLayoutName );
2902 32 : mpDoc->InsertMasterPage(pMNotesPage, (sal_uInt16)nInsertPos + 1);
2903 32 : pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
2904 64 : mpModel->SetModified();
2905 : }
2906 :
2907 32 : return( xDrawPage );
2908 : }
2909 :
2910 : /**
2911 : * Removes the specified SdMasterPage from the model and the internal list. It
2912 : * only works, if there is no *normal* page using this page as MasterPage in
2913 : * the model.
2914 : */
2915 2 : void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2916 : throw(uno::RuntimeException, std::exception)
2917 : {
2918 2 : ::SolarMutexGuard aGuard;
2919 :
2920 2 : if( NULL == mpModel || mpModel->mpDoc == NULL )
2921 0 : throw lang::DisposedException();
2922 :
2923 2 : SdDrawDocument& rDoc = *mpModel->mpDoc;
2924 :
2925 2 : SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage );
2926 2 : if(pSdPage == NULL)
2927 0 : return;
2928 :
2929 2 : SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage());
2930 :
2931 : DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?");
2932 :
2933 2 : if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0))
2934 0 : return; //Todo: this should be excepted
2935 :
2936 : // only standard pages can be removed directly
2937 2 : if( pPage->GetPageKind() == PK_STANDARD )
2938 : {
2939 2 : sal_uInt16 nPage = pPage->GetPageNum();
2940 :
2941 2 : SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
2942 :
2943 2 : bool bUndo = rDoc.IsUndoEnabled();
2944 2 : if( bUndo )
2945 : {
2946 : // Add undo actions and delete the pages. The order of adding
2947 : // the undo actions is important.
2948 2 : rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2949 2 : rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2950 2 : rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2951 : }
2952 :
2953 : // remove both pages
2954 2 : rDoc.RemoveMasterPage( nPage );
2955 2 : rDoc.RemoveMasterPage( nPage );
2956 :
2957 2 : if( bUndo )
2958 : {
2959 2 : rDoc.EndUndo();
2960 : }
2961 : else
2962 : {
2963 0 : delete pNotesPage;
2964 0 : delete pPage;
2965 : }
2966 2 : }
2967 : }
2968 :
2969 : // XServiceInfo
2970 : const char pSdMasterPagesAccessService[] = "com.sun.star.drawing.MasterPages";
2971 :
2972 0 : OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) throw(uno::RuntimeException, std::exception)
2973 : {
2974 0 : return OUString( "SdMasterPagesAccess" );
2975 : }
2976 :
2977 0 : sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException, std::exception)
2978 : {
2979 0 : return cppu::supportsService(this, ServiceName);
2980 : }
2981 :
2982 0 : uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
2983 : {
2984 0 : OUString aService( pSdMasterPagesAccessService );
2985 0 : uno::Sequence< OUString > aSeq( &aService, 1 );
2986 0 : return aSeq;
2987 : }
2988 :
2989 : // class SdDocLinkTargets
2990 :
2991 2 : SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw()
2992 2 : : mpModel( &rMyModel )
2993 : {
2994 2 : }
2995 :
2996 4 : SdDocLinkTargets::~SdDocLinkTargets() throw()
2997 : {
2998 4 : }
2999 :
3000 : // XComponent
3001 2 : void SAL_CALL SdDocLinkTargets::dispose( ) throw (uno::RuntimeException, std::exception)
3002 : {
3003 2 : mpModel = NULL;
3004 2 : }
3005 :
3006 0 : void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
3007 : {
3008 : OSL_FAIL( "not implemented!" );
3009 0 : }
3010 :
3011 0 : void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException, std::exception)
3012 : {
3013 : OSL_FAIL( "not implemented!" );
3014 0 : }
3015 :
3016 : // XNameAccess
3017 4 : uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName )
3018 : throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
3019 : {
3020 4 : ::SolarMutexGuard aGuard;
3021 :
3022 4 : if( NULL == mpModel )
3023 0 : throw lang::DisposedException();
3024 :
3025 4 : SdPage* pPage = FindPage( aName );
3026 :
3027 4 : if( pPage == NULL )
3028 2 : throw container::NoSuchElementException();
3029 :
3030 2 : uno::Any aAny;
3031 :
3032 4 : uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY );
3033 2 : if( xProps.is() )
3034 2 : aAny <<= xProps;
3035 :
3036 6 : return aAny;
3037 : }
3038 :
3039 2 : uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames()
3040 : throw(uno::RuntimeException, std::exception)
3041 : {
3042 2 : ::SolarMutexGuard aGuard;
3043 :
3044 2 : if( NULL == mpModel )
3045 0 : throw lang::DisposedException();
3046 :
3047 2 : SdDrawDocument* mpDoc = mpModel->GetDoc();
3048 2 : if( mpDoc == NULL )
3049 : {
3050 0 : uno::Sequence< OUString > aSeq;
3051 0 : return aSeq;
3052 : }
3053 :
3054 2 : if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW )
3055 : {
3056 2 : const sal_uInt16 nMaxPages = mpDoc->GetSdPageCount( PK_STANDARD );
3057 2 : const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterSdPageCount( PK_STANDARD );
3058 :
3059 2 : uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
3060 2 : OUString* pStr = aSeq.getArray();
3061 :
3062 : sal_uInt16 nPage;
3063 : // standard pages
3064 4 : for( nPage = 0; nPage < nMaxPages; nPage++ )
3065 2 : *pStr++ = mpDoc->GetSdPage( nPage, PK_STANDARD )->GetName();
3066 :
3067 : // master pages
3068 4 : for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
3069 2 : *pStr++ = mpDoc->GetMasterSdPage( nPage, PK_STANDARD )->GetName();
3070 2 : return aSeq;
3071 : }
3072 : else
3073 : {
3074 0 : const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
3075 0 : const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
3076 :
3077 0 : uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
3078 0 : OUString* pStr = aSeq.getArray();
3079 :
3080 : sal_uInt16 nPage;
3081 : // standard pages
3082 0 : for( nPage = 0; nPage < nMaxPages; nPage++ )
3083 0 : *pStr++ = ((SdPage*)mpDoc->GetPage( nPage ))->GetName();
3084 :
3085 : // master pages
3086 0 : for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
3087 0 : *pStr++ = ((SdPage*)mpDoc->GetMasterPage( nPage ))->GetName();
3088 0 : return aSeq;
3089 2 : }
3090 : }
3091 :
3092 4 : sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName )
3093 : throw(uno::RuntimeException, std::exception)
3094 : {
3095 4 : ::SolarMutexGuard aGuard;
3096 :
3097 4 : if( NULL == mpModel )
3098 0 : throw lang::DisposedException();
3099 :
3100 4 : return FindPage( aName ) != NULL;
3101 : }
3102 :
3103 : // container::XElementAccess
3104 2 : uno::Type SAL_CALL SdDocLinkTargets::getElementType()
3105 : throw(uno::RuntimeException, std::exception)
3106 : {
3107 2 : return cppu::UnoType<beans::XPropertySet>::get();
3108 : }
3109 :
3110 2 : sal_Bool SAL_CALL SdDocLinkTargets::hasElements()
3111 : throw(uno::RuntimeException, std::exception)
3112 : {
3113 2 : ::SolarMutexGuard aGuard;
3114 :
3115 2 : if( NULL == mpModel )
3116 0 : throw lang::DisposedException();
3117 :
3118 2 : return mpModel->GetDoc() != NULL;
3119 : }
3120 :
3121 8 : SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw()
3122 : {
3123 8 : SdDrawDocument* mpDoc = mpModel->GetDoc();
3124 8 : if( mpDoc == NULL )
3125 0 : return NULL;
3126 :
3127 8 : const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
3128 8 : const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
3129 :
3130 : sal_uInt16 nPage;
3131 : SdPage* pPage;
3132 :
3133 8 : const OUString aName( rName );
3134 :
3135 8 : const bool bDraw = mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW;
3136 :
3137 : // standard pages
3138 24 : for( nPage = 0; nPage < nMaxPages; nPage++ )
3139 : {
3140 20 : pPage = (SdPage*)mpDoc->GetPage( nPage );
3141 20 : if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
3142 4 : return pPage;
3143 : }
3144 :
3145 : // master pages
3146 16 : for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
3147 : {
3148 12 : pPage = (SdPage*)mpDoc->GetMasterPage( nPage );
3149 12 : if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
3150 0 : return pPage;
3151 : }
3152 :
3153 4 : return NULL;
3154 : }
3155 :
3156 : // XServiceInfo
3157 0 : OUString SAL_CALL SdDocLinkTargets::getImplementationName()
3158 : throw(uno::RuntimeException, std::exception)
3159 : {
3160 0 : return OUString( "SdDocLinkTargets" );
3161 : }
3162 :
3163 0 : sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName )
3164 : throw(uno::RuntimeException, std::exception)
3165 : {
3166 0 : return cppu::supportsService( this, ServiceName );
3167 : }
3168 :
3169 0 : uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames()
3170 : throw(uno::RuntimeException, std::exception)
3171 : {
3172 0 : const OUString aSN( "com.sun.star.document.LinkTargets" );
3173 0 : uno::Sequence< OUString > aSeq( &aSN, 1 );
3174 0 : return aSeq;
3175 : }
3176 :
3177 0 : rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument* pDocument )
3178 : {
3179 0 : rtl::Reference< SdXImpressDocument > xRet;
3180 0 : if( pDocument )
3181 : {
3182 0 : ::sd::DrawDocShell* pDocShell = pDocument->GetDocSh();
3183 0 : if( pDocShell )
3184 : {
3185 0 : uno::Reference<frame::XModel> xModel(pDocShell->GetModel());
3186 :
3187 0 : xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) );
3188 : }
3189 : }
3190 :
3191 0 : return xRet;
3192 : }
3193 :
3194 0 : void NotifyDocumentEvent( SdDrawDocument* pDocument, const OUString& rEventName )
3195 : {
3196 0 : rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3197 :
3198 0 : if( xModel.is() )
3199 : {
3200 0 : uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) );
3201 0 : ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3202 0 : xModel->notifyEvent(aEvent );
3203 0 : }
3204 0 : }
3205 :
3206 0 : void NotifyDocumentEvent( SdDrawDocument* pDocument, const OUString& rEventName, const uno::Reference< uno::XInterface >& xSource )
3207 : {
3208 0 : rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3209 :
3210 0 : if( xModel.is() )
3211 : {
3212 0 : ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3213 0 : xModel->notifyEvent(aEvent );
3214 0 : }
3215 114 : }
3216 :
3217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|