merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / unomodel.cxx
blob0d96cbfcc24396205d63ebfc5b9185a327b89df4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unomodel.cxx,v $
10 * $Revision: 1.114 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include <com/sun/star/presentation/XPresentation2.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
38 #include <com/sun/star/lang/Locale.hpp>
39 #include <com/sun/star/style/XStyle.hpp>
40 #include <com/sun/star/awt/XDevice.hpp>
42 #include <com/sun/star/embed/Aspects.hpp>
43 #include <com/sun/star/presentation/XPresentation2.hpp>
45 #include <osl/mutex.hxx>
47 #ifndef _UTL_SEQUENCE_HXX_
48 #include <comphelper/sequence.hxx>
49 #endif
51 #include <rtl/uuid.h>
52 #include <rtl/memory.h>
53 #include <svx/unofield.hxx>
54 #include <unomodel.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <sfx2/bindings.hxx>
57 #include <vcl/svapp.hxx>
58 #include <svx/UnoForbiddenCharsTable.hxx>
59 #include <svx/svdoutl.hxx>
60 #include <svx/forbiddencharacterstable.hxx>
61 #include <svx/UnoNamespaceMap.hxx>
62 #include <svx/svdlayer.hxx>
63 #include <svx/svdsob.hxx>
64 #include <svx/unoapi.hxx>
65 #include <svx/unofill.hxx>
66 #include <svx/unopool.hxx>
67 #include <svx/svdorect.hxx>
68 #include <vos/mutex.hxx>
69 #include <toolkit/awt/vclxdevice.hxx>
71 #include <svtools/unoimap.hxx>
72 #include <svx/unolingu.hxx>
73 #include <svx/svdpagv.hxx>
75 #include <svx/unoshape.hxx>
76 #include <svx/unonrule.hxx>
77 #include <svx/eeitem.hxx>
79 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
80 #include <svx/xmleohlp.hxx>
81 #include <svx/xmlgrhlp.hxx>
82 #include "DrawDocShell.hxx"
83 #include "ViewShellBase.hxx"
84 #include <UnoDocumentSettings.hxx>
86 #include <drawdoc.hxx>
87 #include <glob.hrc>
88 #include <sdresid.hxx>
89 #include <sdpage.hxx>
91 #include <strings.hrc>
92 #include "unohelp.hxx"
93 #include <unolayer.hxx>
94 #include <unoprnms.hxx>
95 #include <unopage.hxx>
96 #include <unocpres.hxx>
97 #include <unoobj.hxx>
98 #include <stlpool.hxx>
99 #include <unopback.hxx>
100 #include <unokywds.hxx>
101 #include "FrameView.hxx"
102 #include "ClientView.hxx"
103 #include "ViewShell.hxx"
104 #include "app.hrc"
105 #include <vcl/pdfextoutdevdata.hxx>
106 #include <com/sun/star/presentation/AnimationEffect.hpp>
107 #include <com/sun/star/presentation/AnimationSpeed.hpp>
108 #include <com/sun/star/presentation/ClickAction.hpp>
109 #include <tools/urlobj.hxx>
110 #include <svx/sdr/contact/viewobjectcontact.hxx>
111 #include <svx/sdr/contact/viewcontact.hxx>
112 #include <svx/sdr/contact/displayinfo.hxx>
114 using ::rtl::OUString;
116 #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
118 using namespace ::osl;
119 using namespace ::vos;
120 using namespace ::cppu;
121 using namespace ::com::sun::star;
123 extern uno::Reference< uno::XInterface > SdUnoCreatePool( SdDrawDocument* pDrawModel );
125 ///////////////////////////////////////////////////////////////////////
127 class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable,
128 public SfxListener
130 public:
131 SdUnoForbiddenCharsTable( SdrModel* pModel );
132 ~SdUnoForbiddenCharsTable();
134 // SfxListener
135 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
136 protected:
137 virtual void onChange();
139 private:
140 SdrModel* mpModel;
143 SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel )
144 : SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel )
146 StartListening( *pModel );
149 void SdUnoForbiddenCharsTable::onChange()
151 if( mpModel )
153 mpModel->ReformatAllTextObjects();
157 SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable()
159 if( mpModel )
160 EndListening( *mpModel );
163 void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
165 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
167 if( pSdrHint )
169 if( HINT_MODELCLEARED == pSdrHint->GetKind() )
171 mpModel = NULL;
176 ///////////////////////////////////////////////////////////////////////
178 const sal_Int32 WID_MODEL_LANGUAGE = 1;
179 const sal_Int32 WID_MODEL_TABSTOP = 2;
180 const sal_Int32 WID_MODEL_VISAREA = 3;
181 const sal_Int32 WID_MODEL_MAPUNIT = 4;
182 const sal_Int32 WID_MODEL_FORBCHARS= 5;
183 const sal_Int32 WID_MODEL_CONTFOCUS = 6;
184 const sal_Int32 WID_MODEL_DSGNMODE = 7;
185 const sal_Int32 WID_MODEL_BASICLIBS = 8;
186 const sal_Int32 WID_MODEL_RUNTIMEUID = 9;
187 const sal_Int32 WID_MODEL_BUILDID = 10;
188 const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11;
189 const sal_Int32 WID_MODEL_DIALOGLIBS = 12;
191 const SvxItemPropertySet* ImplGetDrawModelPropertySet()
193 // Achtung: Der erste Parameter MUSS sortiert vorliegen !!!
194 const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] =
196 { MAP_CHAR_LEN("BuildId"), WID_MODEL_BUILDID, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
197 { MAP_CHAR_LEN(sUNO_Prop_CharLocale), WID_MODEL_LANGUAGE, &::getCppuType((const lang::Locale*)0), 0, 0},
198 { MAP_CHAR_LEN(sUNO_Prop_TabStop), WID_MODEL_TABSTOP, &::getCppuType((const sal_Int32*)0), 0, 0},
199 { MAP_CHAR_LEN(sUNO_Prop_VisibleArea), WID_MODEL_VISAREA, &::getCppuType((const awt::Rectangle*)0), 0, 0},
200 { MAP_CHAR_LEN(sUNO_Prop_MapUnit), WID_MODEL_MAPUNIT, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
201 { MAP_CHAR_LEN(sUNO_Prop_ForbiddenCharacters), WID_MODEL_FORBCHARS,&::getCppuType((const uno::Reference< i18n::XForbiddenCharacters > *)0), beans::PropertyAttribute::READONLY, 0 },
202 { MAP_CHAR_LEN(sUNO_Prop_AutomContFocus ), WID_MODEL_CONTFOCUS, &::getBooleanCppuType(), 0, 0},
203 { MAP_CHAR_LEN(sUNO_Prop_ApplyFrmDsgnMode), WID_MODEL_DSGNMODE, &::getBooleanCppuType(), 0, 0},
204 { MAP_CHAR_LEN("BasicLibraries"), WID_MODEL_BASICLIBS,&::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 },
205 { MAP_CHAR_LEN("DialogLibraries"), WID_MODEL_DIALOGLIBS, &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 },
206 { MAP_CHAR_LEN(sUNO_Prop_RuntimeUID), WID_MODEL_RUNTIMEUID, &::getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0 },
207 { MAP_CHAR_LEN(sUNO_Prop_HasValidSignatures), WID_MODEL_HASVALIDSIGNATURES, &::getCppuType(static_cast< const sal_Bool * >(0)), beans::PropertyAttribute::READONLY, 0 },
208 { 0,0,0,0,0,0 }
210 static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl );
211 return &aDrawModelPropertySet_Impl;
214 // this ctor is used from the DocShell
215 SdXImpressDocument::SdXImpressDocument (::sd::DrawDocShell* pShell, bool bClipBoard ) throw()
216 : SfxBaseModel( pShell ),
217 mpDocShell( pShell ),
218 mpDoc( pShell ? pShell->GetDoc() : NULL ),
219 mbDisposed(false),
220 mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
221 mbClipBoard( bClipBoard ),
222 mpPropSet( ImplGetDrawModelPropertySet() )
224 if( mpDoc )
226 StartListening( *mpDoc );
228 else
230 DBG_ERROR("DocShell is invalid");
234 SdXImpressDocument::SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard ) throw()
235 : SfxBaseModel( NULL ),
236 mpDocShell( NULL ),
237 mpDoc( pDoc ),
238 mbDisposed(false),
239 mbImpressDoc( pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
240 mbClipBoard( bClipBoard ),
241 mpPropSet( ImplGetDrawModelPropertySet() )
243 if( mpDoc )
245 StartListening( *mpDoc );
247 else
249 DBG_ERROR("SdDrawDocument is invalid");
253 /***********************************************************************
255 ***********************************************************************/
256 SdXImpressDocument::~SdXImpressDocument() throw()
260 // uno helper
263 /******************************************************************************
264 * Erzeugt anhand der uebergebennen SdPage eine SdDrawPage. Wurde fuer diese *
265 * SdPage bereits eine SdDrawPage erzeugt, wird keine neue SdDrawPage erzeug. *
266 ******************************************************************************/
268 uno::Reference< drawing::XDrawPage > SdXImpressDocument::CreateXDrawPage( SdPage* pPage ) throw()
270 DBG_ASSERT(pPage,"SdXImpressDocument::CreateXDrawPage( NULL? )");
272 uno::Reference< drawing::XDrawPage > xDrawPage;
274 if(pPage)
276 xDrawPage = SvxDrawPage::GetPageForSdrPage(pPage);
278 if(!xDrawPage.is())
280 if(pPage->IsMasterPage())
282 xDrawPage = (presentation::XPresentationPage*)new SdMasterPage( this, pPage );
284 else
286 xDrawPage = (SvxDrawPage*)new SdDrawPage( this, pPage );
291 return xDrawPage;
295 // XInterface
296 uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
298 uno::Any aAny;
300 QUERYINT(lang::XServiceInfo);
301 else QUERYINT(beans::XPropertySet);
302 else QUERYINT(lang::XMultiServiceFactory);
303 else QUERYINT(drawing::XDrawPageDuplicator);
304 else QUERYINT(drawing::XLayerSupplier);
305 else QUERYINT(drawing::XMasterPagesSupplier);
306 else QUERYINT(drawing::XDrawPagesSupplier);
307 else QUERYINT(presentation::XHandoutMasterSupplier);
308 else QUERYINT(document::XLinkTargetSupplier);
309 else QUERYINT(style::XStyleFamiliesSupplier);
310 else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
311 else QUERYINT(view::XRenderable);
312 else if( mbImpressDoc && rType == ITYPE(presentation::XPresentationSupplier) )
313 aAny <<= uno::Reference< presentation::XPresentationSupplier >(this);
314 else if( mbImpressDoc && rType == ITYPE(presentation::XCustomPresentationSupplier) )
315 aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this);
316 else
317 return SfxBaseModel::queryInterface( rType );
319 return aAny;
322 void SAL_CALL SdXImpressDocument::acquire() throw ( )
324 SfxBaseModel::acquire();
327 void SAL_CALL SdXImpressDocument::release() throw ( )
329 if (osl_decrementInterlockedCount( &m_refCount ) == 0)
331 // restore reference count:
332 osl_incrementInterlockedCount( &m_refCount );
333 if(!mbDisposed)
337 dispose();
339 catch (uno::RuntimeException const& exc)
340 { // don't break throw ()
341 OSL_ENSURE(
342 false, OUStringToOString(
343 exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
344 static_cast<void>(exc);
347 SfxBaseModel::release();
351 // XUnoTunnel
352 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw()
354 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
355 if( !pSeq )
357 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
358 if( !pSeq )
360 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
361 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
362 pSeq = &aSeq;
365 return *pSeq;
368 SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt )
370 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
371 if( xUT.is() )
372 return reinterpret_cast<SdXImpressDocument*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( SdXImpressDocument::getUnoTunnelId() )));
373 else
374 return NULL;
377 sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException)
379 if( rIdentifier.getLength() == 16 )
381 if( (0 == rtl_compareMemory( SdXImpressDocument::getUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
382 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
384 if( (0 == rtl_compareMemory( SdrModel::getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
385 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc));
388 return SfxBaseModel::getSomething( rIdentifier );
391 // XTypeProvider
392 uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) throw(uno::RuntimeException)
394 OGuard aGuard( Application::GetSolarMutex() );
396 if( maTypeSequence.getLength() == 0 )
398 const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
399 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
400 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
402 const sal_Int32 nOwnTypes = mbImpressDoc ? 14 : 11; // !DANGER! Keep this updated!
404 maTypeSequence.realloc( nBaseTypes + nOwnTypes );
405 uno::Type* pTypes = maTypeSequence.getArray();
407 *pTypes++ = ITYPE(beans::XPropertySet);
408 *pTypes++ = ITYPE(lang::XServiceInfo);
409 *pTypes++ = ITYPE(lang::XMultiServiceFactory);
410 *pTypes++ = ITYPE(drawing::XDrawPageDuplicator);
411 *pTypes++ = ITYPE(drawing::XLayerSupplier);
412 *pTypes++ = ITYPE(drawing::XMasterPagesSupplier);
413 *pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
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 )
420 *pTypes++ = ITYPE(presentation::XPresentationSupplier);
421 *pTypes++ = ITYPE(presentation::XCustomPresentationSupplier);
422 *pTypes++ = ITYPE(presentation::XHandoutMasterSupplier);
425 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
426 *pTypes++ = *pBaseTypes++;
429 return maTypeSequence;
432 uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId( ) throw(uno::RuntimeException)
434 OGuard aGuard( Application::GetSolarMutex() );
436 static uno::Sequence< sal_Int8 > aId;
437 if( aId.getLength() == 0 )
439 aId.realloc( 16 );
440 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
442 return aId;
445 /***********************************************************************
447 ***********************************************************************/
448 void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
450 if( mpDoc )
452 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
454 if( pSdrHint )
456 if( hasEventListeners() )
459 bool bBackgroundShape = false;
461 // the background shape itself has no api representation, so filter all notifies for it
462 const SdrObject* pSdrObj = pSdrHint->GetObject();
463 if( pSdrObj && (pSdrObj->GetObjInventor() == SdrInventor) && (pSdrObj->GetObjIdentifier() == OBJ_RECT) )
465 SdPage* pPage = (SdPage*)pSdrObj->GetPage();
466 bBackgroundShape = pPage && (pPage->GetPresObjKind(const_cast<SdrObject*>(pSdrObj)) == PRESOBJ_BACKGROUND);
469 if( !bBackgroundShape )
471 document::EventObject aEvent;
472 if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) )
473 notifyEvent( aEvent );
477 if( pSdrHint->GetKind() == HINT_MODELCLEARED )
479 if( mpDoc )
480 EndListening( *mpDoc );
481 mpDoc = NULL;
482 mpDocShell = NULL;
485 else
487 const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint );
489 // ist unser SdDrawDocument gerade gestorben?
490 if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING)
492 // yup, also schnell ein neues erfragen
493 if( mpDocShell )
495 SdDrawDocument *pNewDoc = mpDocShell->GetDoc();
497 // ist ueberhaupt ein neues da?
498 if( pNewDoc != mpDoc )
500 mpDoc = pNewDoc;
501 if(mpDoc)
502 StartListening( *mpDoc );
508 SfxBaseModel::Notify( rBC, rHint );
511 /******************************************************************************
513 ******************************************************************************/
514 SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, sal_Bool bDuplicate ) throw()
516 sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
517 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
518 BYTE aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
519 BYTE aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
521 SdPage* pStandardPage = NULL;
523 if( 0 == nPageCount )
525 // this is only used for clipboard where we only have one page
526 pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False);
528 Size aDefSize(21000, 29700); // A4-Hochformat
529 pStandardPage->SetSize( aDefSize );
530 mpDoc->InsertPage(pStandardPage, 0);
532 else
534 // Hier wird die Seite ermittelt, hinter der eingefuegt werden soll
535 SdPage* pPreviousStandardPage = mpDoc->GetSdPage( Min( (sal_uInt16)(nPageCount - 1), nPage ), PK_STANDARD );
536 SetOfByte aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
537 sal_Bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd );
538 sal_Bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj );
540 // AutoLayouts muessen fertig sein
541 mpDoc->StopWorkStartupDelay();
543 /**************************************************************
544 * Es wird stets zuerst eine Standardseite und dann eine
545 * Notizseite erzeugt. Es ist sichergestellt, dass auf eine
546 * Standardseite stets die zugehoerige Notizseite folgt.
547 **************************************************************/
549 sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
550 SdPage* pPreviousNotesPage = (SdPage*) mpDoc->GetPage( nStandardPageNum - 1 );
551 sal_uInt16 nNotesPageNum = nStandardPageNum + 1;
552 String aStandardPageName;
553 String aNotesPageName;
555 /**************************************************************
556 * Standardseite
557 **************************************************************/
558 if( bDuplicate )
559 pStandardPage = (SdPage*) pPreviousStandardPage->Clone();
560 else
561 pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False);
563 pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
564 pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(),
565 pPreviousStandardPage->GetUppBorder(),
566 pPreviousStandardPage->GetRgtBorder(),
567 pPreviousStandardPage->GetLwrBorder() );
568 pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() );
569 pStandardPage->SetName(aStandardPageName);
571 // Seite hinter aktueller Seite einfuegen
572 mpDoc->InsertPage(pStandardPage, nStandardPageNum);
574 if( !bDuplicate )
576 // MasterPage der aktuellen Seite verwenden
577 pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
578 pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
579 pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, sal_True );
582 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
583 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
584 aVisibleLayers.Set(aBckgrnd, bIsPageBack);
585 aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
586 pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
588 /**************************************************************
589 * Notizseite
590 **************************************************************/
591 SdPage* pNotesPage = NULL;
593 if( bDuplicate )
594 pNotesPage = (SdPage*) pPreviousNotesPage->Clone();
595 else
596 pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
598 pNotesPage->SetSize( pPreviousNotesPage->GetSize() );
599 pNotesPage->SetBorder( pPreviousNotesPage->GetLftBorder(),
600 pPreviousNotesPage->GetUppBorder(),
601 pPreviousNotesPage->GetRgtBorder(),
602 pPreviousNotesPage->GetLwrBorder() );
603 pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
604 pNotesPage->SetName(aNotesPageName);
605 pNotesPage->SetPageKind(PK_NOTES);
607 // Seite hinter aktueller Seite einfuegen
608 mpDoc->InsertPage(pNotesPage, nNotesPageNum);
610 if( !bDuplicate )
612 // MasterPage der aktuellen Seite verwenden
613 pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
614 pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
615 pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True );
619 SetModified();
621 return( pStandardPage );
624 void SdXImpressDocument::SetModified( sal_Bool bModified /* = sal_True */ ) throw()
626 if( mpDoc )
627 mpDoc->SetChanged( bModified );
630 // XModel
631 void SAL_CALL SdXImpressDocument ::lockControllers( )
632 throw(uno::RuntimeException)
634 OGuard aGuard( Application::GetSolarMutex() );
636 if( NULL == mpDoc )
637 throw lang::DisposedException();
639 mpDoc->setLock( sal_True );
642 void SAL_CALL SdXImpressDocument::unlockControllers( )
643 throw(uno::RuntimeException)
645 OGuard aGuard( Application::GetSolarMutex() );
647 if( NULL == mpDoc )
648 throw lang::DisposedException();
650 if( mpDoc->isLocked() )
652 mpDoc->setLock( sal_False );
656 sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked( )
657 throw(uno::RuntimeException)
659 OGuard aGuard( Application::GetSolarMutex() );
661 if( NULL == mpDoc )
662 throw lang::DisposedException();
664 return mpDoc && mpDoc->isLocked();
667 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
668 #include <comphelper/processfactory.hxx>
669 #endif
671 uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData() throw( uno::RuntimeException )
673 OGuard aGuard( Application::GetSolarMutex() );
675 if( NULL == mpDoc )
676 throw lang::DisposedException();
678 uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
680 if( !xRet.is() )
682 List* pFrameViewList = mpDoc->GetFrameViewList();
684 if( pFrameViewList && pFrameViewList->Count() )
686 xRet = uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues"))));
689 uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
690 DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" );
691 if( xCont.is() )
693 sal_uInt32 i;
694 for( i = 0; i < pFrameViewList->Count(); i++ )
696 ::sd::FrameView* pFrameView =
697 static_cast< ::sd::FrameView*>(
698 pFrameViewList->GetObject(i));
700 if(pFrameView)
702 uno::Sequence< beans::PropertyValue > aSeq;
703 pFrameView->WriteUserDataSequence( aSeq );
704 xCont->insertByIndex( i, uno::makeAny( aSeq ) );
711 return xRet;
714 void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData ) throw(::com::sun::star::uno::RuntimeException)
716 OGuard aGuard( Application::GetSolarMutex() );
718 if( NULL == mpDoc )
719 throw lang::DisposedException();
721 SfxBaseModel::setViewData( xData );
722 if( mpDocShell && (mpDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) && xData.is() )
724 const sal_Int32 nCount = xData->getCount();
726 List* pFrameViewList = mpDoc->GetFrameViewList();
728 DBG_ASSERT( pFrameViewList, "No FrameViewList?" );
729 if( pFrameViewList )
731 ::sd::FrameView* pFrameView;
733 sal_uInt32 i;
734 for ( i = 0; i < pFrameViewList->Count(); i++)
736 // Ggf. FrameViews loeschen
737 pFrameView = static_cast< ::sd::FrameView*>(
738 pFrameViewList->GetObject(i));
740 if (pFrameView)
741 delete pFrameView;
744 pFrameViewList->Clear();
746 uno::Sequence< beans::PropertyValue > aSeq;
747 sal_Int32 nIndex;
748 for( nIndex = 0; nIndex < nCount; nIndex++ )
750 if( xData->getByIndex( nIndex ) >>= aSeq )
752 pFrameView = new ::sd::FrameView( mpDoc );
753 pFrameView->ReadUserDataSequence( aSeq );
754 pFrameViewList->Insert( pFrameView );
761 // XDrawPageDuplicator
762 uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage )
763 throw(uno::RuntimeException)
765 OGuard aGuard( Application::GetSolarMutex() );
767 if( NULL == mpDoc )
768 throw lang::DisposedException();
770 // pPage von xPage besorgen und dann die Id (nPos )ermitteln
771 SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
772 if( pSvxPage )
774 SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
775 sal_uInt16 nPos = pPage->GetPageNum();
776 nPos = ( nPos - 1 ) / 2;
777 pPage = InsertSdPage( nPos, sal_True );
778 if( pPage )
780 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
781 return xDrawPage;
785 uno::Reference< drawing::XDrawPage > xDrawPage;
786 return xDrawPage;
790 // XDrawPagesSupplier
791 uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages()
792 throw(uno::RuntimeException)
794 OGuard aGuard( Application::GetSolarMutex() );
796 if( NULL == mpDoc )
797 throw lang::DisposedException();
799 uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
801 if( !xDrawPages.is() )
803 initializeDocument();
804 mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SdDrawPagesAccess(*this);
807 return xDrawPages;
810 // XMasterPagesSupplier
811 uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages()
812 throw(uno::RuntimeException)
814 OGuard aGuard( Application::GetSolarMutex() );
816 if( NULL == mpDoc )
817 throw lang::DisposedException();
819 uno::Reference< drawing::XDrawPages > xMasterPages( mxMasterPagesAccess );
821 if( !xMasterPages.is() )
823 initializeDocument();
824 mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this);
827 return xMasterPages;
830 // XLayerManagerSupplier
831 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager( )
832 throw(uno::RuntimeException)
834 OGuard aGuard( Application::GetSolarMutex() );
836 if( NULL == mpDoc )
837 throw lang::DisposedException();
839 uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
841 if( !xLayerManager.is() )
842 mxLayerManager = xLayerManager = new SdLayerManager(*this);
844 return xLayerManager;
847 // XCustomPresentationSupplier
848 uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations()
849 throw(uno::RuntimeException)
851 OGuard aGuard( Application::GetSolarMutex() );
853 if( NULL == mpDoc )
854 throw lang::DisposedException();
856 uno::Reference< container::XNameContainer > xCustomPres( mxCustomPresentationAccess );
858 if( !xCustomPres.is() )
859 mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this);
861 return xCustomPres;
864 extern uno::Reference< presentation::XPresentation > createPresentation( SdXImpressDocument& rModel );
866 // XPresentationSupplier
867 uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation()
868 throw(uno::RuntimeException)
870 OGuard aGuard( Application::GetSolarMutex() );
872 if( NULL == mpDoc )
873 throw lang::DisposedException();
875 return uno::Reference< presentation::XPresentation >( mpDoc->getPresentation().get() );
878 // XHandoutMasterSupplier
879 uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage()
880 throw (uno::RuntimeException)
882 OGuard aGuard( Application::GetSolarMutex() );
884 if( NULL == mpDoc )
885 throw lang::DisposedException();
887 uno::Reference< drawing::XDrawPage > xPage;
889 if( mpDoc )
891 initializeDocument();
892 SdPage* pPage = mpDoc->GetMasterSdPage( 0, PK_HANDOUT );
893 if( pPage )
894 xPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
896 return xPage;
899 // XMultiServiceFactory ( SvxFmMSFactory )
900 uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
901 throw(uno::Exception, uno::RuntimeException)
903 OGuard aGuard( Application::GetSolarMutex() );
905 if( NULL == mpDoc )
906 throw lang::DisposedException();
908 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
910 if( !mxDashTable.is() )
911 mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
913 return mxDashTable;
915 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
917 if( !mxGradientTable.is() )
918 mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
920 return mxGradientTable;
922 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
924 if( !mxHatchTable.is() )
925 mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
927 return mxHatchTable;
929 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
931 if( !mxBitmapTable.is() )
932 mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
934 return mxBitmapTable;
936 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
938 if( !mxTransGradientTable.is() )
939 mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
941 return mxTransGradientTable;
943 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
945 if( !mxMarkerTable.is() )
946 mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
948 return mxMarkerTable;
950 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
952 return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
954 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Background" ) ) )
956 return uno::Reference< uno::XInterface >(
957 static_cast<uno::XWeak*>(new SdUnoPageBackground( mpDoc )));
960 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) )
962 if( !mxDrawingPool.is() )
963 mxDrawingPool = SdUnoCreatePool( mpDoc );
965 return mxDrawingPool;
969 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapRectangleObject) ) )
971 return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
974 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapCircleObject) ) )
976 return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
979 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapPolygonObject) ) )
981 return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
984 if( ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) ) ||
985 ( !mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DocumentSettings") ) ) ) ||
986 ( mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.DocumentSettings") ) ) ) )
988 return sd::DocumentSettings_createInstance( this );
991 if( ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) ) ||
992 ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.textfield.DateTime") ) ) )
994 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD );
997 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.Header"))) ||
998 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.Header"))) )
1000 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_HEADERFIELD );
1003 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.Footer"))) ||
1004 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.Footer"))) )
1006 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_FOOTERFIELD );
1009 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.DateTime"))) ||
1010 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.DateTime"))) )
1012 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_DATETIMEFIELD );
1015 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.xml.NamespaceMap") ) )
1017 static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 };
1019 return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() );
1022 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
1023 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver") ) )
1025 return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE );
1028 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver") ) )
1030 return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ );
1033 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver") ) )
1035 ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
1036 if( NULL == pPersist )
1037 throw lang::DisposedException();
1039 return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE );
1042 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) )
1044 ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
1045 if( NULL == pPersist )
1046 throw lang::DisposedException();
1048 return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ );
1051 uno::Reference< uno::XInterface > xRet;
1053 const String aType( aServiceSpecifier );
1054 if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
1056 SvxShape* pShape = NULL;
1058 sal_uInt16 nType = OBJ_TEXT;
1059 // create a shape wrapper
1060 if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
1062 nType = OBJ_TEXT;
1064 else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
1066 nType = OBJ_TEXT;
1068 else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
1070 nType = OBJ_TEXT;
1072 else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
1074 nType = OBJ_GRAF;
1076 else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
1078 nType = OBJ_PAGE;
1080 else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
1082 nType = OBJ_OLE2;
1084 else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
1086 nType = OBJ_OLE2;
1088 else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
1090 nType = OBJ_OLE2;
1092 else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
1094 nType = OBJ_OLE2;
1096 else if( aType.EqualsAscii( "NotesShape", 26, 13 ) )
1098 nType = OBJ_TEXT;
1100 else if( aType.EqualsAscii( "HandoutShape", 26, 13 ) )
1102 nType = OBJ_PAGE;
1104 else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
1106 nType = OBJ_TEXT;
1108 else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
1110 nType = OBJ_TEXT;
1112 else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
1114 nType = OBJ_TEXT;
1116 else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
1118 nType = OBJ_TEXT;
1120 else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
1122 nType = OBJ_TABLE;
1124 else
1126 throw lang::ServiceNotRegisteredException();
1129 // create the API wrapper
1130 pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
1132 // set shape type
1133 if( pShape && !mbClipBoard )
1134 pShape->SetShapeType(aServiceSpecifier);
1136 xRet = (uno::XWeak*)pShape;
1138 else if( aServiceSpecifier.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape") ) )
1140 SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor );
1141 if( pShape && !mbClipBoard )
1142 pShape->SetShapeType(aServiceSpecifier);
1144 xRet = (uno::XWeak*)pShape;
1146 else
1148 xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
1151 uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY );
1152 if( xShape.is() )
1154 xRet.clear();
1155 new SdXShape( SvxShape::getImplementation( xShape ), (SdXImpressDocument*)this );
1156 xRet = xShape;
1157 xShape.clear();
1160 return xRet;
1163 uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames()
1164 throw(uno::RuntimeException)
1166 OGuard aGuard( Application::GetSolarMutex() );
1168 if( NULL == mpDoc )
1169 throw lang::DisposedException();
1171 const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
1173 uno::Sequence< OUString > aSNS( mbImpressDoc ? (34) : (19) );
1175 sal_uInt16 i(0);
1177 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
1178 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
1179 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
1180 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
1181 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
1182 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
1183 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
1184 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Background"));
1185 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings"));
1186 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapRectangleObject));
1187 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapCircleObject));
1188 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapPolygonObject));
1189 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.NamespaceMap"));
1191 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
1192 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver"));
1193 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver"));
1194 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver"));
1195 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver"));
1196 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TableShape"));
1198 if(mbImpressDoc)
1200 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
1201 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
1202 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
1203 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
1204 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
1205 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
1206 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
1207 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
1208 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
1209 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
1210 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
1211 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.DocumentSettings"));
1212 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.FooterShape"));
1213 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HeaderShape"));
1214 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideNumberShape"));
1215 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.DateTimeShape"));
1217 else
1219 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DocumentSettings"));
1222 DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
1224 return comphelper::concatSequences( aSNS_ORG, aSNS );
1227 // lang::XServiceInfo
1228 OUString SAL_CALL SdXImpressDocument::getImplementationName()
1229 throw(uno::RuntimeException)
1231 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXImpressDocument"));
1234 sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName )
1235 throw(uno::RuntimeException)
1237 OGuard aGuard( Application::GetSolarMutex() );
1239 if (
1240 (ServiceName.equalsAscii("com.sun.star.document.OfficeDocument" )) ||
1241 (ServiceName.equalsAscii("com.sun.star.drawing.GenericDrawingDocument")) ||
1242 (ServiceName.equalsAscii("com.sun.star.drawing.DrawingDocumentFactory"))
1245 return sal_True;
1248 return (
1249 ( mbImpressDoc && ServiceName.equalsAscii("com.sun.star.presentation.PresentationDocument")) ||
1250 (!mbImpressDoc && ServiceName.equalsAscii("com.sun.star.drawing.DrawingDocument" ))
1254 uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException)
1256 OGuard aGuard( Application::GetSolarMutex() );
1258 uno::Sequence< OUString > aSeq( 4 );
1259 OUString* pServices = aSeq.getArray();
1261 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OfficeDocument"));
1262 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GenericDrawingDocument"));
1263 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentFactory"));
1265 if( mbImpressDoc )
1266 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"));
1267 else
1268 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
1270 return aSeq;
1273 // XPropertySet
1274 uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo( )
1275 throw(uno::RuntimeException)
1277 OGuard aGuard( Application::GetSolarMutex() );
1278 return mpPropSet->getPropertySetInfo();
1281 void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1282 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1284 OGuard aGuard( Application::GetSolarMutex() );
1286 if( NULL == mpDoc )
1287 throw lang::DisposedException();
1289 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
1291 switch( pEntry ? pEntry->nWID : -1 )
1293 case WID_MODEL_LANGUAGE:
1295 lang::Locale aLocale;
1296 if(!(aValue >>= aLocale))
1297 throw lang::IllegalArgumentException();
1299 mpDoc->SetLanguage( SvxLocaleToLanguage(aLocale), EE_CHAR_LANGUAGE );
1300 break;
1302 case WID_MODEL_TABSTOP:
1304 sal_Int32 nValue = 0;
1305 if(!(aValue >>= nValue) || nValue < 0 )
1306 throw lang::IllegalArgumentException();
1308 mpDoc->SetDefaultTabulator((sal_uInt16)nValue);
1309 break;
1311 case WID_MODEL_VISAREA:
1313 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1314 if( !pEmbeddedObj )
1315 break;
1317 awt::Rectangle aVisArea;
1318 if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) )
1319 throw lang::IllegalArgumentException();
1321 pEmbeddedObj->SetVisArea( Rectangle( aVisArea.X, aVisArea.Y, aVisArea.X + aVisArea.Width - 1, aVisArea.Y + aVisArea.Height - 1 ) );
1323 break;
1324 case WID_MODEL_CONTFOCUS:
1326 sal_Bool bFocus = sal_False;
1327 if( !(aValue >>= bFocus ) )
1328 throw lang::IllegalArgumentException();
1329 mpDoc->SetAutoControlFocus( bFocus );
1331 break;
1332 case WID_MODEL_DSGNMODE:
1334 sal_Bool bMode = sal_False;
1335 if( !(aValue >>= bMode ) )
1336 throw lang::IllegalArgumentException();
1337 mpDoc->SetOpenInDesignMode( bMode );
1339 break;
1340 case WID_MODEL_BUILDID:
1341 aValue >>= maBuildId;
1342 return;
1343 case WID_MODEL_MAPUNIT:
1344 case WID_MODEL_BASICLIBS:
1345 case WID_MODEL_RUNTIMEUID: // is read-only
1346 case WID_MODEL_DIALOGLIBS:
1347 throw beans::PropertyVetoException();
1348 default:
1349 throw beans::UnknownPropertyException();
1352 SetModified();
1355 uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName )
1356 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1358 OGuard aGuard( Application::GetSolarMutex() );
1360 uno::Any aAny;
1361 if( NULL == mpDoc )
1362 throw lang::DisposedException();
1364 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
1366 switch( pEntry ? pEntry->nWID : -1 )
1368 case WID_MODEL_LANGUAGE:
1370 LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE );
1371 lang::Locale aLocale;
1372 SvxLanguageToLocale( aLocale, eLang );
1373 aAny <<= aLocale;
1374 break;
1376 case WID_MODEL_TABSTOP:
1377 aAny <<= (sal_Int32)mpDoc->GetDefaultTabulator();
1378 break;
1379 case WID_MODEL_VISAREA:
1381 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1382 if( !pEmbeddedObj )
1383 break;
1385 const Rectangle& aRect = pEmbeddedObj->GetVisArea();
1386 awt::Rectangle aVisArea( aRect.nLeft, aRect.nTop, aRect.getWidth(), aRect.getHeight() );
1387 aAny <<= aVisArea;
1389 break;
1390 case WID_MODEL_MAPUNIT:
1392 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
1393 if( !pEmbeddedObj )
1394 break;
1396 sal_Int16 nMeasureUnit = 0;
1397 SvxMapUnitToMeasureUnit( (const short)pEmbeddedObj->GetMapUnit(), nMeasureUnit );
1398 aAny <<= (sal_Int16)nMeasureUnit;
1400 break;
1401 case WID_MODEL_FORBCHARS:
1403 aAny <<= getForbiddenCharsTable();
1405 break;
1406 case WID_MODEL_CONTFOCUS:
1407 aAny <<= (sal_Bool)mpDoc->GetAutoControlFocus();
1408 break;
1409 case WID_MODEL_DSGNMODE:
1410 aAny <<= mpDoc->GetOpenInDesignMode();
1411 break;
1412 case WID_MODEL_BASICLIBS:
1413 aAny <<= mpDocShell->GetBasicContainer();
1414 break;
1415 case WID_MODEL_DIALOGLIBS:
1416 aAny <<= mpDocShell->GetDialogContainer();
1417 break;
1418 case WID_MODEL_RUNTIMEUID:
1419 aAny <<= getRuntimeUID();
1420 break;
1421 case WID_MODEL_BUILDID:
1422 return uno::Any( maBuildId );
1423 case WID_MODEL_HASVALIDSIGNATURES:
1424 aAny <<= hasValidSignatures();
1425 break;
1426 default:
1427 throw beans::UnknownPropertyException();
1430 return aAny;
1433 void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1434 void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1435 void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1436 void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1438 // XLinkTargetSupplier
1439 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
1440 throw(uno::RuntimeException)
1442 OGuard aGuard( Application::GetSolarMutex() );
1444 if( NULL == mpDoc )
1445 throw lang::DisposedException();
1447 uno::Reference< container::XNameAccess > xLinks( mxLinks );
1448 if( !xLinks.is() )
1449 mxLinks = xLinks = new SdDocLinkTargets( *this );
1450 return xLinks;
1453 // XStyleFamiliesSupplier
1454 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies( )
1455 throw(uno::RuntimeException)
1457 OGuard aGuard( Application::GetSolarMutex() );
1459 if( NULL == mpDoc )
1460 throw lang::DisposedException();
1462 uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) );
1463 return xStyles;
1466 // XAnyCompareFactory
1467 uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& )
1468 throw (uno::RuntimeException)
1470 return SvxCreateNumRuleCompare();
1473 // XRenderable
1474 sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
1475 const uno::Sequence< beans::PropertyValue >& )
1476 throw (lang::IllegalArgumentException, uno::RuntimeException)
1478 OGuard aGuard( Application::GetSolarMutex() );
1479 sal_Int32 nRet = 0;
1481 if( NULL == mpDoc )
1482 throw lang::DisposedException();
1484 uno::Sequence< beans::PropertyValue > aRenderer;
1486 if( mpDocShell && mpDoc )
1488 uno::Reference< frame::XModel > xModel;
1490 rSelection >>= xModel;
1492 if( xModel == mpDocShell->GetModel() )
1493 nRet = mpDoc->GetSdPageCount( PK_STANDARD );
1494 else
1496 uno::Reference< drawing::XShapes > xShapes;
1498 rSelection >>= xShapes;
1500 if( xShapes.is() && xShapes->getCount() )
1501 nRet = 1;
1504 return nRet;
1507 uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& ,
1508 const uno::Sequence< beans::PropertyValue >& rxOptions )
1509 throw (lang::IllegalArgumentException, uno::RuntimeException)
1511 OGuard aGuard( Application::GetSolarMutex() );
1513 if( NULL == mpDoc )
1514 throw lang::DisposedException();
1516 sal_Bool bExportNotesPages = sal_False;
1517 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1519 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ) )
1520 rxOptions[ nProperty].Value >>= bExportNotesPages;
1522 uno::Sequence< beans::PropertyValue > aRenderer;
1523 if( mpDocShell && mpDoc )
1525 awt::Size aPageSize;
1526 if ( bExportNotesPages )
1528 Size aNotesPageSize = mpDoc->GetSdPage( 0, PK_NOTES )->GetSize();
1529 aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
1531 else
1533 const Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) );
1534 aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() );
1536 aRenderer.realloc( 1 );
1538 aRenderer[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
1539 aRenderer[ 0 ].Value <<= aPageSize;
1541 return aRenderer;
1544 class ImplRenderPaintProc : public ::sdr::contact::ViewObjectContactRedirector
1546 const SdrLayerAdmin& rLayerAdmin;
1547 SdrPageView* pSdrPageView;
1548 vcl::PDFExtOutDevData* pPDFExtOutDevData;
1550 vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject );
1552 public:
1553 sal_Bool IsVisible ( const SdrObject* pObj ) const;
1554 sal_Bool IsPrintable( const SdrObject* pObj ) const;
1556 ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData );
1557 virtual ~ImplRenderPaintProc();
1559 // all default implementations just call the same methods at the original. To do something
1560 // different, overload the method and at least do what the method does.
1561 virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
1562 const sdr::contact::ViewObjectContact& rOriginal,
1563 const sdr::contact::DisplayInfo& rDisplayInfo);
1566 ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData )
1567 : ViewObjectContactRedirector(),
1568 rLayerAdmin ( rLA ),
1569 pSdrPageView ( pView ),
1570 pPDFExtOutDevData ( pData )
1574 ImplRenderPaintProc::~ImplRenderPaintProc()
1578 sal_Int32 ImplPDFGetBookmarkPage( const String& rBookmark, SdDrawDocument& rDoc )
1580 sal_Int32 nPage = -1;
1582 OSL_TRACE("GotoBookmark %s",
1583 ::rtl::OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
1585 String aBookmark( rBookmark );
1587 if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') )
1588 aBookmark = rBookmark.Copy( 1 );
1590 // is the bookmark a page ?
1591 BOOL bIsMasterPage;
1592 USHORT nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage );
1593 SdrObject* pObj = NULL;
1595 if ( nPgNum == SDRPAGE_NOTFOUND )
1597 // is the bookmark a object ?
1598 pObj = rDoc.GetObj( aBookmark );
1599 if (pObj)
1600 nPgNum = pObj->GetPage()->GetPageNum();
1602 if ( nPgNum != SDRPAGE_NOTFOUND )
1603 nPage = ( nPgNum - 1 ) / 2;
1604 return nPage;
1607 void ImplPDFExportShapeInteraction( uno::Reference< drawing::XShape > xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData )
1609 const rtl::OUString sGroup ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) );
1610 const rtl::OUString sOnClick ( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
1611 const rtl::OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
1613 if ( xShape->getShapeType().equals( sGroup ) )
1615 uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY );
1616 if ( xIndexAccess.is() )
1618 sal_Int32 i, nCount = xIndexAccess->getCount();
1619 for ( i = 0; i < nCount; i++ )
1621 uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
1622 if ( xSubShape.is() )
1623 ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData );
1627 else
1629 uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY );
1630 if( xShapePropSet.is() )
1632 Size aPageSize( rDoc.GetSdPage( 0, PK_STANDARD )->GetSize() );
1633 Point aPoint( 0, 0 );
1634 Rectangle aPageRect( aPoint, aPageSize );
1636 awt::Point aShapePos( xShape->getPosition() );
1637 awt::Size aShapeSize( xShape->getSize() );
1638 Rectangle aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) );
1640 presentation::ClickAction eCa;
1641 uno::Any aAny( xShapePropSet->getPropertyValue( sOnClick ) );
1642 if ( aAny >>= eCa )
1644 switch ( eCa )
1646 case presentation::ClickAction_LASTPAGE :
1648 sal_Int32 nCount = rDoc.GetSdPageCount( PK_STANDARD );
1649 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::FitRectangle );
1650 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1651 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1653 break;
1654 case presentation::ClickAction_FIRSTPAGE :
1656 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::FitRectangle );
1657 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1658 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1660 break;
1661 case presentation::ClickAction_PREVPAGE :
1663 sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber();
1664 if ( nDestPage )
1665 nDestPage--;
1666 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1667 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1668 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1670 break;
1671 case presentation::ClickAction_NEXTPAGE :
1673 sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1;
1674 sal_Int32 nLastPage = rDoc.GetSdPageCount( PK_STANDARD ) - 1;
1675 if ( nDestPage > nLastPage )
1676 nDestPage = nLastPage;
1677 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1678 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1679 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1681 break;
1683 case presentation::ClickAction_PROGRAM :
1684 case presentation::ClickAction_BOOKMARK :
1685 case presentation::ClickAction_DOCUMENT :
1687 rtl::OUString aBookmark;
1688 xShapePropSet->getPropertyValue( sBookmark ) >>= aBookmark;
1689 if( aBookmark.getLength() )
1691 switch( eCa )
1693 case presentation::ClickAction_DOCUMENT :
1694 case presentation::ClickAction_PROGRAM :
1696 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1697 rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark );
1699 break;
1700 case presentation::ClickAction_BOOKMARK :
1702 sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc );
1703 if ( nPage != -1 )
1705 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle );
1706 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1707 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1710 break;
1711 default:
1712 break;
1716 break;
1718 case presentation::ClickAction_STOPPRESENTATION :
1719 case presentation::ClickAction_SOUND :
1720 case presentation::ClickAction_INVISIBLE :
1721 case presentation::ClickAction_VERB :
1722 case presentation::ClickAction_VANISH :
1723 case presentation::ClickAction_MACRO :
1724 default :
1725 break;
1732 vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject )
1734 vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement);
1736 if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() )
1738 sal_uInt32 nInventor = rObject.GetObjInventor();
1739 sal_uInt16 nIdentifier = rObject.GetObjIdentifier();
1740 sal_Bool bIsTextObj = rObject.ISA( SdrTextObj );
1742 if ( nInventor == SdrInventor )
1744 if ( nIdentifier == OBJ_GRUP )
1745 eElement = vcl::PDFWriter::Section;
1746 else if ( nIdentifier == OBJ_TITLETEXT )
1747 eElement = vcl::PDFWriter::Heading;
1748 else if ( nIdentifier == OBJ_OUTLINETEXT )
1749 eElement = vcl::PDFWriter::Division;
1750 else if ( !bIsTextObj || !((SdrTextObj&)rObject).HasText() )
1751 eElement = vcl::PDFWriter::Figure;
1755 return eElement;
1758 drawinglayer::primitive2d::Primitive2DSequence ImplRenderPaintProc::createRedirectedPrimitive2DSequence(
1759 const sdr::contact::ViewObjectContact& rOriginal,
1760 const sdr::contact::DisplayInfo& rDisplayInfo)
1762 SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
1764 if(pObject)
1766 drawinglayer::primitive2d::Primitive2DSequence xRetval;
1768 if(pObject->GetPage())
1770 if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
1772 if(IsVisible(pObject) && IsPrintable(pObject))
1774 const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject ));
1775 const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement);
1777 xRetval = ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1779 if(xRetval.hasElements() && bTagUsed)
1781 // embed Primitive2DSequence in a structure tag element for
1782 // exactly this purpose (StructureTagPrimitive2D)
1783 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::StructureTagPrimitive2D(eElement, xRetval));
1784 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
1790 return xRetval;
1792 else
1794 // not an object, maybe a page
1795 return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1799 sal_Bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
1801 sal_Bool bVisible = sal_True;
1802 SdrLayerID nLayerId = pObj->GetLayer();
1803 if( pSdrPageView )
1805 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1806 if ( pSdrLayer )
1808 String aLayerName = pSdrLayer->GetName();
1809 bVisible = pSdrPageView->IsLayerVisible( aLayerName );
1812 return bVisible;
1814 sal_Bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
1816 sal_Bool bPrintable = sal_True;
1817 SdrLayerID nLayerId = pObj->GetLayer();
1818 if( pSdrPageView )
1820 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1821 if ( pSdrLayer )
1823 String aLayerName = pSdrLayer->GetName();
1824 bPrintable = pSdrPageView->IsLayerPrintable( aLayerName );
1827 return bPrintable;
1830 void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
1831 const uno::Sequence< beans::PropertyValue >& rxOptions )
1832 throw (lang::IllegalArgumentException, uno::RuntimeException)
1834 OGuard aGuard( Application::GetSolarMutex() );
1836 if( NULL == mpDoc )
1837 throw lang::DisposedException();
1839 if( mpDocShell && mpDoc )
1841 uno::Reference< awt::XDevice > xRenderDevice;
1842 const sal_Int32 nPageNumber = nRenderer + 1;
1843 PageKind ePageKind = PK_STANDARD;
1844 sal_Bool bExportNotesPages = sal_False;
1846 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1848 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
1849 rxOptions[ nProperty].Value >>= xRenderDevice;
1850 else if ( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ) )
1852 rxOptions[ nProperty].Value >>= bExportNotesPages;
1853 if ( bExportNotesPages )
1854 ePageKind = PK_NOTES;
1858 if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) )
1860 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
1861 OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
1863 if( pOut )
1865 vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() );
1867 ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut, NULL );
1868 Rectangle aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (USHORT)nPageNumber - 1, ePageKind )->GetSize() );
1869 Region aRegion( aVisArea );
1870 Point aOrigin;
1872 ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
1873 ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : NULL;
1875 if ( pOldSdView )
1876 pOldSdView->SdrEndTextEdit();
1878 pView->SetHlplVisible( sal_False );
1879 pView->SetGridVisible( sal_False );
1880 pView->SetBordVisible( sal_False );
1881 pView->SetPageVisible( sal_False );
1882 pView->SetGlueVisible( sal_False );
1884 pOut->SetMapMode( MAP_100TH_MM );
1885 pOut->IntersectClipRegion( aVisArea );
1889 uno::Reference< frame::XModel > xModel;
1890 rSelection >>= xModel;
1892 if( xModel == mpDocShell->GetModel() )
1894 pView->ShowSdrPage( mpDoc->GetSdPage( (USHORT)nPageNumber - 1, ePageKind ));
1895 SdrPageView* pPV = pView->GetSdrPageView();
1897 if( pOldSdView )
1899 SdrPageView* pOldPV = pOldSdView->GetSdrPageView();
1900 if( pPV && pOldPV )
1902 pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() );
1903 pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() );
1907 ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
1908 pPV, pPDFExtOutDevData );
1910 // background color for outliner :o
1911 SdPage* pPage = (SdPage*)pPV->GetPage();
1912 if( pPage )
1914 SdrOutliner& rOutl = mpDoc->GetDrawOutliner( NULL );
1915 bool bScreenDisplay(true);
1917 if(bScreenDisplay && pOut && OUTDEV_PRINTER == pOut->GetOutDevType())
1919 // #i75566# printing; suppress AutoColor BackgroundColor generation
1920 // for visibility reasons by giving GetPageBackgroundColor()
1921 // the needed hint
1922 bScreenDisplay = false;
1925 if(bScreenDisplay && pOut && pOut->GetPDFWriter())
1927 // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
1928 bScreenDisplay = false;
1931 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
1932 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
1933 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) );
1935 pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc );
1937 if ( pPDFExtOutDevData )
1941 uno::Any aAny;
1942 uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) );
1943 if ( xPage.is() )
1945 uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY );
1946 if( xPagePropSet.is() )
1948 // exporting object interactions to pdf
1950 // if necessary, the master page interactions will be exported first
1951 sal_Bool bIsBackgroundObjectsVisible = sal_False; // SJ: #i39428# IsBackgroundObjectsVisible not available for Draw
1952 const rtl::OUString sIsBackgroundObjectsVisible( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundObjectsVisible" ) );
1953 if ( mbImpressDoc && ( xPagePropSet->getPropertyValue( sIsBackgroundObjectsVisible ) >>= bIsBackgroundObjectsVisible ) && bIsBackgroundObjectsVisible )
1955 uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY );
1956 if ( xMasterPageTarget.is() )
1958 uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
1959 if ( xMasterPage.is() )
1961 uno::Reference< drawing::XShapes> xShapes( xMasterPage, uno::UNO_QUERY );
1962 sal_Int32 i, nCount = xShapes->getCount();
1963 for ( i = 0; i < nCount; i++ )
1965 aAny = xShapes->getByIndex( i );
1966 uno::Reference< drawing::XShape > xShape;
1967 if ( aAny >>= xShape )
1968 ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
1974 // exporting slide page object interactions
1975 uno::Reference< drawing::XShapes> xShapes( xPage, uno::UNO_QUERY );
1976 sal_Int32 i, nCount = xShapes->getCount();
1977 for ( i = 0; i < nCount; i++ )
1979 aAny = xShapes->getByIndex( i );
1980 uno::Reference< drawing::XShape > xShape;
1981 if ( aAny >>= xShape )
1982 ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
1985 // exporting transition effects to pdf
1986 if ( mbImpressDoc && pPDFExtOutDevData->GetIsExportTransitionEffects() ) // SJ: #i39428# TransitionEffects not available for Draw
1988 const rtl::OUString sEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) );
1989 const rtl::OUString sSpeed ( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) );
1990 sal_Int32 nTime = 800;
1991 presentation::AnimationSpeed aAs;
1992 aAny = xPagePropSet->getPropertyValue( sSpeed );
1993 if ( aAny >>= aAs )
1995 switch( aAs )
1997 case presentation::AnimationSpeed_SLOW : nTime = 1500; break;
1998 case presentation::AnimationSpeed_FAST : nTime = 300; break;
1999 default:
2000 case presentation::AnimationSpeed_MEDIUM : nTime = 800;
2003 presentation::FadeEffect eFe;
2004 aAny = xPagePropSet->getPropertyValue( sEffect );
2005 vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::Regular;
2006 if ( aAny >>= eFe )
2008 switch( eFe )
2010 case presentation::FadeEffect_HORIZONTAL_LINES :
2011 case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
2012 case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::BlindsHorizontal; break;
2014 case presentation::FadeEffect_VERTICAL_LINES :
2015 case presentation::FadeEffect_VERTICAL_CHECKERBOARD :
2016 case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::BlindsVertical; break;
2018 case presentation::FadeEffect_UNCOVER_TO_RIGHT :
2019 case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
2020 case presentation::FadeEffect_ROLL_FROM_LEFT :
2021 case presentation::FadeEffect_FADE_FROM_UPPERLEFT :
2022 case presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
2023 case presentation::FadeEffect_FADE_FROM_LEFT :
2024 case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::WipeLeftToRight; break;
2026 case presentation::FadeEffect_UNCOVER_TO_BOTTOM :
2027 case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
2028 case presentation::FadeEffect_ROLL_FROM_TOP :
2029 case presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
2030 case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
2031 case presentation::FadeEffect_FADE_FROM_TOP :
2032 case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::WipeTopToBottom; break;
2034 case presentation::FadeEffect_UNCOVER_TO_LEFT :
2035 case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
2036 case presentation::FadeEffect_ROLL_FROM_RIGHT :
2038 case presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
2039 case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
2040 case presentation::FadeEffect_FADE_FROM_RIGHT :
2041 case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::WipeRightToLeft; break;
2043 case presentation::FadeEffect_UNCOVER_TO_TOP :
2044 case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
2045 case presentation::FadeEffect_ROLL_FROM_BOTTOM :
2046 case presentation::FadeEffect_FADE_FROM_LOWERLEFT :
2047 case presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
2048 case presentation::FadeEffect_FADE_FROM_BOTTOM :
2049 case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::WipeBottomToTop; break;
2051 case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::SplitHorizontalInward; break;
2052 case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::SplitHorizontalOutward; break;
2054 case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::SplitVerticalInward; break;
2055 case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::SplitVerticalOutward; break;
2057 case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::BoxInward; break;
2058 case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::BoxOutward; break;
2060 case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::Regular; break;
2062 case presentation::FadeEffect_RANDOM :
2063 case presentation::FadeEffect_DISSOLVE :
2064 default: eType = vcl::PDFWriter::Dissolve; break;
2067 pPDFExtOutDevData->SetPageTransition( eType, nTime, -1 );
2072 Size aPageSize( mpDoc->GetSdPage( 0, PK_STANDARD )->GetSize() );
2073 Point aPoint( 0, 0 );
2074 Rectangle aPageRect( aPoint, aPageSize );
2076 // resolving links found in this page by the method ImpEditEngine::Paint
2077 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
2078 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin();
2079 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
2080 while ( aIBeg != aIEnd )
2082 sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc );
2083 if ( nPage != -1 )
2084 pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ) );
2085 else
2086 pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark );
2087 aIBeg++;
2089 rBookmarks.clear();
2090 //---> i56629, i40318
2091 //get the page name, will be used as outline element in PDF bookmark pane
2092 String aPageName = mpDoc->GetSdPage( (USHORT)nPageNumber - 1 , PK_STANDARD )->GetName();
2093 if( aPageName.Len() > 0 )
2095 // insert the bookmark to this page into the NamedDestinations
2096 if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
2097 pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect, nPageNumber - 1 );
2099 // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
2100 // issue i40318.
2102 if( pPDFExtOutDevData->GetIsExportBookmarks() )
2104 // Destination Export
2105 const sal_Int32 nDestId =
2106 pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 );
2108 // Create a new outline item:
2109 pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
2112 //<--- i56629, i40318
2114 catch( uno::Exception& )
2120 else
2122 uno::Reference< drawing::XShapes > xShapes;
2123 rSelection >>= xShapes;
2125 if( xShapes.is() && xShapes->getCount() )
2127 SdrPageView* pPV = NULL;
2129 ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
2130 pOldSdView ? pOldSdView->GetSdrPageView() : NULL, pPDFExtOutDevData );
2132 for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ )
2134 uno::Reference< drawing::XShape > xShape;
2135 xShapes->getByIndex( i ) >>= xShape;
2137 if( xShape.is() )
2139 SvxShape* pShape = SvxShape::getImplementation( xShape );
2141 if( pShape )
2143 SdrObject* pObj = pShape->GetSdrObject();
2144 if( pObj && pObj->GetPage()
2145 && aImplRenderPaintProc.IsVisible( pObj )
2146 && aImplRenderPaintProc.IsPrintable( pObj ) )
2148 if( !pPV )
2149 pPV = pView->ShowSdrPage( pObj->GetPage() );
2151 if( pPV )
2152 pView->MarkObj( pObj, pPV );
2157 pView->DrawMarkedObj(*pOut);
2161 delete pView;
2167 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
2169 uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
2171 if( !xForb.is() )
2172 mxForbidenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc );
2174 return xForb;
2177 void SdXImpressDocument::initializeDocument()
2179 if( !mbClipBoard )
2181 switch( mpDoc->GetPageCount() )
2183 case 1:
2185 // nasty hack to detect clipboard document
2186 mbClipBoard = true;
2187 break;
2189 case 0:
2191 mpDoc->CreateFirstPages();
2192 mpDoc->StopWorkStartupDelay();
2193 break;
2199 void SAL_CALL SdXImpressDocument::dispose() throw (::com::sun::star::uno::RuntimeException)
2201 if( !mbDisposed )
2204 OGuard aGuard( Application::GetSolarMutex() );
2206 if( mpDoc )
2208 EndListening( *mpDoc );
2209 mpDoc = NULL;
2212 // Call the base class dispose() before setting the mbDisposed flag
2213 // to true. The reason for this is that if close() has not yet been
2214 // called this is done in SfxBaseModel::dispose(). At the end of
2215 // that dispose() is called again. It is important to forward this
2216 // second dispose() to the base class, too.
2217 // As a consequence the following code has to be able to be run twice.
2218 SfxBaseModel::dispose();
2219 mbDisposed = true;
2221 uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies);
2222 if( xStyles.is() )
2224 uno::Reference< lang::XComponent > xComp( xStyles, uno::UNO_QUERY );
2225 if( xComp.is() )
2226 xComp->dispose();
2228 xStyles = 0;
2231 uno::Reference< presentation::XPresentation > xPresentation( mxPresentation );
2232 if( xPresentation.is() )
2234 uno::Reference< ::com::sun::star::presentation::XPresentation2 > xPres( mpDoc->getPresentation().get() );
2235 uno::Reference< lang::XComponent > xPresComp( xPres, uno::UNO_QUERY );
2236 if( xPresComp.is() )
2237 xPresComp->dispose();
2240 uno::Reference< container::XNameAccess > xLinks( mxLinks );
2241 if( xLinks.is() )
2243 uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY );
2244 if( xComp.is() )
2245 xComp->dispose();
2247 xLinks = 0;
2250 uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess );
2251 if( xDrawPagesAccess.is() )
2253 uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY );
2254 if( xComp.is() )
2255 xComp->dispose();
2257 xDrawPagesAccess = 0;
2260 uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess );
2261 if( xDrawPagesAccess.is() )
2263 uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY );
2264 if( xComp.is() )
2265 xComp->dispose();
2267 xDrawPagesAccess = 0;
2270 uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
2271 if( xLayerManager.is() )
2273 uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY );
2274 if( xComp.is() )
2275 xComp->dispose();
2277 xLayerManager = 0;
2280 uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess );
2281 if( xCustomPresentationAccess.is() )
2283 uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY );
2284 if( xComp.is() )
2285 xComp->dispose();
2287 xCustomPresentationAccess = 0;
2290 mxDashTable = 0;
2291 mxGradientTable = 0;
2292 mxHatchTable = 0;
2293 mxBitmapTable = 0;
2294 mxTransGradientTable = 0;
2295 mxMarkerTable = 0;
2296 mxDrawingPool = 0;
2301 //=============================================================================
2302 // class SdDrawPagesAccess
2303 //=============================================================================
2305 SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel ) throw()
2306 : mpModel( &rMyModel)
2310 SdDrawPagesAccess::~SdDrawPagesAccess() throw()
2314 // XIndexAccess
2315 sal_Int32 SAL_CALL SdDrawPagesAccess::getCount()
2316 throw(uno::RuntimeException)
2318 OGuard aGuard( Application::GetSolarMutex() );
2320 if( NULL == mpModel )
2321 throw lang::DisposedException();
2323 return mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2326 uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index )
2327 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2329 OGuard aGuard( Application::GetSolarMutex() );
2331 if( NULL == mpModel )
2332 throw lang::DisposedException();
2334 uno::Any aAny;
2336 if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PK_STANDARD ) ) )
2337 throw lang::IndexOutOfBoundsException();
2339 SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD );
2340 if( pPage )
2342 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2343 aAny <<= xDrawPage;
2346 return aAny;
2349 // XNameAccess
2350 uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
2352 OGuard aGuard( Application::GetSolarMutex() );
2354 if( NULL == mpModel )
2355 throw lang::DisposedException();
2357 if( aName.getLength() != 0 )
2359 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2360 sal_uInt16 nPage;
2361 for( nPage = 0; nPage < nCount; nPage++ )
2363 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2364 if(NULL == pPage)
2365 continue;
2367 if( aName == SdDrawPage::getPageApiName( pPage ) )
2369 uno::Any aAny;
2370 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2371 aAny <<= xDrawPage;
2372 return aAny;
2377 throw container::NoSuchElementException();
2380 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() throw(uno::RuntimeException)
2382 OGuard aGuard( Application::GetSolarMutex() );
2384 if( NULL == mpModel )
2385 throw lang::DisposedException();
2387 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2388 uno::Sequence< OUString > aNames( nCount );
2389 OUString* pNames = aNames.getArray();
2391 sal_uInt16 nPage;
2392 for( nPage = 0; nPage < nCount; nPage++ )
2394 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2395 *pNames++ = SdDrawPage::getPageApiName( pPage );
2398 return aNames;
2401 sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) throw(uno::RuntimeException)
2403 OGuard aGuard( Application::GetSolarMutex() );
2405 if( NULL == mpModel )
2406 throw lang::DisposedException();
2408 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2409 sal_uInt16 nPage;
2410 for( nPage = 0; nPage < nCount; nPage++ )
2412 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2413 if(NULL == pPage)
2414 continue;
2416 if( aName == SdDrawPage::getPageApiName( pPage ) )
2417 return sal_True;
2420 return sal_False;
2423 // XElementAccess
2424 uno::Type SAL_CALL SdDrawPagesAccess::getElementType()
2425 throw(uno::RuntimeException)
2427 return ITYPE( drawing::XDrawPage );
2430 sal_Bool SAL_CALL SdDrawPagesAccess::hasElements()
2431 throw(uno::RuntimeException)
2433 return getCount() > 0;
2436 // XDrawPages
2438 /******************************************************************************
2439 * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
2440 * dazugehoerige SdDrawPage zurueck. *
2441 ******************************************************************************/
2442 uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
2443 throw(uno::RuntimeException)
2445 OGuard aGuard( Application::GetSolarMutex() );
2447 if( NULL == mpModel )
2448 throw lang::DisposedException();
2450 if( mpModel->mpDoc )
2452 SdPage* pPage = mpModel->InsertSdPage( (sal_uInt16)nIndex );
2453 if( pPage )
2455 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2456 return xDrawPage;
2459 uno::Reference< drawing::XDrawPage > xDrawPage;
2460 return xDrawPage;
2463 /******************************************************************************
2464 * Entfernt die angegebenne SdDrawPage aus dem Model und aus der internen *
2465 * Liste. Dies funktioniert nur, wenn mindestens eine *normale* Seite im Model *
2466 * nach dem entfernen dieser Seite vorhanden ist. *
2467 ******************************************************************************/
2468 void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2469 throw(uno::RuntimeException)
2471 OGuard aGuard( Application::GetSolarMutex() );
2473 if( NULL == mpModel || mpModel->mpDoc == NULL )
2474 throw lang::DisposedException();
2476 SdDrawDocument& rDoc = *mpModel->mpDoc;
2478 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD );
2479 if( nPageCount > 1 )
2481 // pPage von xPage besorgen und dann die Id (nPos )ermitteln
2482 SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage );
2483 if( pSvxPage )
2485 SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
2486 if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) )
2488 sal_uInt16 nPage = pPage->GetPageNum();
2490 SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
2492 bool bUndo = rDoc.IsUndoEnabled();
2493 if( bUndo )
2495 // Add undo actions and delete the pages. The order of adding
2496 // the undo actions is important.
2497 rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2498 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2499 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2502 rDoc.RemovePage( nPage ); // the page
2503 rDoc.RemovePage( nPage ); // the notes page
2505 if( bUndo )
2507 rDoc.EndUndo();
2509 else
2511 delete pNotesPage;
2512 delete pPage;
2518 mpModel->SetModified();
2521 // XServiceInfo
2522 sal_Char pSdDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
2524 OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException)
2526 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdDrawPagesAccess" ) );
2529 sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
2531 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdDrawPagesAccessService ) );
2534 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
2536 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdDrawPagesAccessService ) );
2537 uno::Sequence< OUString > aSeq( &aService, 1 );
2538 return aSeq;
2541 // XComponent
2542 void SAL_CALL SdDrawPagesAccess::dispose( ) throw (uno::RuntimeException)
2544 mpModel = NULL;
2547 void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2549 DBG_ERROR( "not implemented!" );
2552 void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2554 DBG_ERROR( "not implemented!" );
2557 //=============================================================================
2558 // class SdMasterPagesAccess
2559 //=============================================================================
2561 SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw()
2562 : mpModel(&rMyModel)
2566 SdMasterPagesAccess::~SdMasterPagesAccess() throw()
2570 // XComponent
2571 void SAL_CALL SdMasterPagesAccess::dispose( ) throw (uno::RuntimeException)
2573 mpModel = NULL;
2576 void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2578 DBG_ERROR( "not implemented!" );
2581 void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2583 DBG_ERROR( "not implemented!" );
2586 // XIndexAccess
2587 sal_Int32 SAL_CALL SdMasterPagesAccess::getCount()
2588 throw(uno::RuntimeException)
2590 OGuard aGuard( Application::GetSolarMutex() );
2592 if( NULL == mpModel->mpDoc )
2593 throw lang::DisposedException();
2595 return mpModel->mpDoc->GetMasterSdPageCount(PK_STANDARD);
2598 /******************************************************************************
2599 * Liefert ein drawing::XDrawPage Interface fuer den Zugriff auf die Masterpage and der *
2600 * angegebennen Position im Model. *
2601 ******************************************************************************/
2602 uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index )
2603 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2605 OGuard aGuard( Application::GetSolarMutex() );
2607 if( NULL == mpModel )
2608 throw lang::DisposedException();
2610 uno::Any aAny;
2612 if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PK_STANDARD ) ) )
2613 throw lang::IndexOutOfBoundsException();
2615 SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD );
2616 if( pPage )
2618 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2619 aAny <<= xDrawPage;
2622 return aAny;
2625 // XElementAccess
2626 uno::Type SAL_CALL SdMasterPagesAccess::getElementType()
2627 throw(uno::RuntimeException)
2629 return ITYPE(drawing::XDrawPage);
2632 sal_Bool SAL_CALL SdMasterPagesAccess::hasElements()
2633 throw(uno::RuntimeException)
2635 return getCount() > 0;
2638 // XDrawPages
2639 uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos )
2640 throw(uno::RuntimeException)
2642 OGuard aGuard( Application::GetSolarMutex() );
2644 if( NULL == mpModel )
2645 throw lang::DisposedException();
2647 uno::Reference< drawing::XDrawPage > xDrawPage;
2649 SdDrawDocument* mpDoc = mpModel->mpDoc;
2650 if( mpDoc )
2652 // calculate internal index and check for range errors
2653 const sal_Int32 nMPageCount = mpDoc->GetMasterPageCount();
2654 nInsertPos = nInsertPos * 2 + 1;
2655 if( nInsertPos < 0 || nInsertPos > nMPageCount )
2656 nInsertPos = nMPageCount;
2658 // now generate a unique name for the new masterpage
2659 const String aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) );
2660 String aPrefix( aStdPrefix );
2662 sal_Bool bUnique = sal_True;
2663 sal_Int32 i = 0;
2666 bUnique = sal_True;
2667 for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ )
2669 SdPage* pPage = (SdPage*)mpDoc->GetMasterPage((USHORT)nMaster);
2670 if( pPage && pPage->GetName() == aPrefix )
2672 bUnique = sal_False;
2673 break;
2677 if( !bUnique )
2679 i++;
2680 aPrefix = aStdPrefix;
2681 aPrefix += sal_Unicode( ' ' );
2682 aPrefix += String::CreateFromInt32( i );
2685 } while( !bUnique );
2687 String aLayoutName( aPrefix );
2688 aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
2689 aLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
2691 // create styles
2692 ((SdStyleSheetPool*)mpDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix );
2694 // get the first page for initial size and border settings
2695 SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD );
2696 SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_NOTES);
2698 // create and instert new draw masterpage
2699 SdPage* pMPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
2700 pMPage->SetSize( pPage->GetSize() );
2701 pMPage->SetBorder( pPage->GetLftBorder(),
2702 pPage->GetUppBorder(),
2703 pPage->GetRgtBorder(),
2704 pPage->GetLwrBorder() );
2705 pMPage->SetLayoutName( aLayoutName );
2706 mpDoc->InsertMasterPage(pMPage, (USHORT)nInsertPos);
2708 { // insert background object
2709 Point aBackgroundPos ( pMPage->GetLftBorder(), pMPage->GetUppBorder() );
2710 Size aBackgroundSize ( pMPage->GetSize() );
2711 aBackgroundSize.Width() -= pMPage->GetLftBorder() + pMPage->GetRgtBorder() - 1;
2712 aBackgroundSize.Height() -= pMPage->GetUppBorder() + pMPage->GetLwrBorder() - 1;
2713 Rectangle aBackgroundRect (aBackgroundPos, aBackgroundSize);
2714 pMPage->CreatePresObj(PRESOBJ_BACKGROUND, FALSE, aBackgroundRect, sal_True );
2717 xDrawPage = uno::Reference< drawing::XDrawPage >::query( pMPage->getUnoPage() );
2719 // create and instert new notes masterpage
2720 SdPage* pMNotesPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
2721 pMNotesPage->SetSize( pRefNotesPage->GetSize() );
2722 pMNotesPage->SetPageKind(PK_NOTES);
2723 pMNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
2724 pRefNotesPage->GetUppBorder(),
2725 pRefNotesPage->GetRgtBorder(),
2726 pRefNotesPage->GetLwrBorder() );
2727 pMNotesPage->SetLayoutName( aLayoutName );
2728 mpDoc->InsertMasterPage(pMNotesPage, (USHORT)nInsertPos + 1);
2729 // pMNotesPage->InsertMasterPage( pMPage->GetPageNum() );
2730 pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True);
2731 mpModel->SetModified();
2734 return( xDrawPage );
2737 /******************************************************************************
2738 * Entfernt die angegebenne SdMasterPage aus dem Model und aus der internen *
2739 * Liste. Dies funktioniert nur, wenn keine *normale* Seite im Model diese *
2740 * Seite als Masterpage benutzt. *
2741 ******************************************************************************/
2742 void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2743 throw(uno::RuntimeException)
2745 OGuard aGuard( Application::GetSolarMutex() );
2747 if( NULL == mpModel || mpModel->mpDoc == NULL )
2748 throw lang::DisposedException();
2750 SdDrawDocument& rDoc = *mpModel->mpDoc;
2752 SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage );
2753 if(pSdPage == NULL)
2754 return;
2756 SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage());
2758 DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?");
2760 if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0))
2761 return; //Todo: this should be excepted
2763 // only standard pages can be removed directly
2764 if( pPage->GetPageKind() == PK_STANDARD )
2766 sal_uInt16 nPage = pPage->GetPageNum();
2768 SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
2770 bool bUndo = rDoc.IsUndoEnabled();
2771 if( bUndo )
2773 // Add undo actions and delete the pages. The order of adding
2774 // the undo actions is important.
2775 rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2776 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2777 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2780 rDoc.RemoveMasterPage( nPage );
2781 rDoc.RemoveMasterPage( nPage );
2783 if( bUndo )
2785 rDoc.EndUndo();
2787 else
2789 delete pNotesPage;
2790 delete pPage;
2795 // XServiceInfo
2796 sal_Char pSdMasterPagesAccessService[sizeof("com.sun.star.drawing.MasterPages")] = "com.sun.star.drawing.MasterPages";
2798 OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) throw(uno::RuntimeException)
2800 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdMasterPagesAccess" ) );
2803 sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
2805 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdMasterPagesAccessService ) );
2808 uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
2810 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdMasterPagesAccessService ) );
2811 uno::Sequence< OUString > aSeq( &aService, 1 );
2812 return aSeq;
2815 //=============================================================================
2816 // class SdDocLinkTargets
2817 //=============================================================================
2819 SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw()
2820 : mpModel( &rMyModel )
2824 SdDocLinkTargets::~SdDocLinkTargets() throw()
2828 // XComponent
2829 void SAL_CALL SdDocLinkTargets::dispose( ) throw (uno::RuntimeException)
2831 mpModel = NULL;
2834 void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2836 DBG_ERROR( "not implemented!" );
2839 void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException)
2841 DBG_ERROR( "not implemented!" );
2844 // XNameAccess
2845 uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName )
2846 throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
2848 OGuard aGuard( Application::GetSolarMutex() );
2850 if( NULL == mpModel )
2851 throw lang::DisposedException();
2853 SdPage* pPage = FindPage( aName );
2855 if( pPage == NULL )
2856 throw container::NoSuchElementException();
2858 uno::Any aAny;
2860 uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY );
2861 if( xProps.is() )
2862 aAny <<= xProps;
2864 return aAny;
2867 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames()
2868 throw(uno::RuntimeException)
2870 OGuard aGuard( Application::GetSolarMutex() );
2872 if( NULL == mpModel )
2873 throw lang::DisposedException();
2875 SdDrawDocument* mpDoc = mpModel->GetDoc();
2876 if( mpDoc == NULL )
2878 uno::Sequence< OUString > aSeq;
2879 return aSeq;
2882 if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW )
2884 const sal_uInt16 nMaxPages = mpDoc->GetSdPageCount( PK_STANDARD );
2885 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterSdPageCount( PK_STANDARD );
2887 uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
2888 OUString* pStr = aSeq.getArray();
2890 sal_uInt16 nPage;
2891 // standard pages
2892 for( nPage = 0; nPage < nMaxPages; nPage++ )
2893 *pStr++ = mpDoc->GetSdPage( nPage, PK_STANDARD )->GetName();
2895 // master pages
2896 for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
2897 *pStr++ = mpDoc->GetMasterSdPage( nPage, PK_STANDARD )->GetName();
2898 return aSeq;
2900 else
2902 const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
2903 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
2905 uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
2906 OUString* pStr = aSeq.getArray();
2908 sal_uInt16 nPage;
2909 // standard pages
2910 for( nPage = 0; nPage < nMaxPages; nPage++ )
2911 *pStr++ = ((SdPage*)mpDoc->GetPage( nPage ))->GetName();
2913 // master pages
2914 for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
2915 *pStr++ = ((SdPage*)mpDoc->GetMasterPage( nPage ))->GetName();
2916 return aSeq;
2920 sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName )
2921 throw(uno::RuntimeException)
2923 OGuard aGuard( Application::GetSolarMutex() );
2925 if( NULL == mpModel )
2926 throw lang::DisposedException();
2928 return FindPage( aName ) != NULL;
2931 // container::XElementAccess
2932 uno::Type SAL_CALL SdDocLinkTargets::getElementType()
2933 throw(uno::RuntimeException)
2935 return ITYPE(beans::XPropertySet);
2938 sal_Bool SAL_CALL SdDocLinkTargets::hasElements()
2939 throw(uno::RuntimeException)
2941 OGuard aGuard( Application::GetSolarMutex() );
2943 if( NULL == mpModel )
2944 throw lang::DisposedException();
2946 return mpModel->GetDoc() != NULL;
2949 SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw()
2951 SdDrawDocument* mpDoc = mpModel->GetDoc();
2952 if( mpDoc == NULL )
2953 return NULL;
2955 const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
2956 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
2958 sal_uInt16 nPage;
2959 SdPage* pPage;
2961 const String aName( rName );
2963 const bool bDraw = mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW;
2965 // standard pages
2966 for( nPage = 0; nPage < nMaxPages; nPage++ )
2968 pPage = (SdPage*)mpDoc->GetPage( nPage );
2969 if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
2970 return pPage;
2973 // master pages
2974 for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
2976 pPage = (SdPage*)mpDoc->GetMasterPage( nPage );
2977 if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
2978 return pPage;
2981 return NULL;
2984 // XServiceInfo
2985 OUString SAL_CALL SdDocLinkTargets::getImplementationName()
2986 throw(uno::RuntimeException)
2988 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDocLinkTargets") );
2991 sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName )
2992 throw(uno::RuntimeException)
2994 return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
2997 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames()
2998 throw(uno::RuntimeException)
3000 const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") );
3001 uno::Sequence< OUString > aSeq( &aSN, 1 );
3002 return aSeq;
3005 rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument* pDocument )
3007 rtl::Reference< SdXImpressDocument > xRet;
3008 if( pDocument )
3010 ::sd::DrawDocShell* pDocShell = pDocument->GetDocSh();
3011 if( pDocShell )
3013 uno::Reference<frame::XModel> xModel(pDocShell->GetModel());
3015 xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) );
3019 return xRet;
3022 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName )
3024 rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3026 if( xModel.is() )
3028 uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) );
3029 ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3030 xModel->notifyEvent(aEvent );
3034 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const uno::Reference< uno::XInterface >& xSource )
3036 rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3038 if( xModel.is() )
3040 ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3041 xModel->notifyEvent(aEvent );