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