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