xref: /AOO41X/main/sd/source/ui/unoidl/unomodel.cxx (revision bd1a492fb221f7df8374ef66fb89a1ec73de4776)
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->urlIsVendor( url ) ) {
1442 			return sal_False;
1443 		} else if ( pLinkMgr->urlIsSafe( url ) ) {
1444 			return sal_True;
1445 		}
1446 		Window* pDlgParent = 0;
1447 		if ( pFrm )
1448 			pDlgParent = &pFrm->GetWindow();
1449 		if ( !pDlgParent )
1450 			pDlgParent = mpDocShell->GetDialogParent( pMedium );
1451 		if ( pDlgParent )
1452 			return pLinkMgr->GetUserAllowsLinkUpdate( pDlgParent );
1453 	}
1454 	return sal_False;
1455 }
1456 
1457 // XLinkTargetSupplier
1458 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
1459 	throw(uno::RuntimeException)
1460 {
1461 	OGuard aGuard( Application::GetSolarMutex() );
1462 
1463 	if( NULL == mpDoc )
1464 		throw lang::DisposedException();
1465 
1466 	uno::Reference< container::XNameAccess > xLinks( mxLinks );
1467 	if( !xLinks.is() )
1468 		mxLinks = xLinks = new SdDocLinkTargets( *this );
1469 	return xLinks;
1470 }
1471 
1472 // XStyleFamiliesSupplier
1473 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies(  )
1474 	throw(uno::RuntimeException)
1475 {
1476 	OGuard aGuard( Application::GetSolarMutex() );
1477 
1478 	if( NULL == mpDoc )
1479 		throw lang::DisposedException();
1480 
1481 	uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) );
1482 	return xStyles;
1483 }
1484 
1485 // XAnyCompareFactory
1486 uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& )
1487     throw (uno::RuntimeException)
1488 {
1489 	return SvxCreateNumRuleCompare();
1490 }
1491 
1492 // XRenderable
1493 sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
1494                                                          const uno::Sequence< beans::PropertyValue >&  )
1495     throw (lang::IllegalArgumentException, uno::RuntimeException)
1496 {
1497 	OGuard      aGuard( Application::GetSolarMutex() );
1498 	sal_Int32   nRet = 0;
1499 
1500 	if( NULL == mpDoc )
1501 		throw lang::DisposedException();
1502 
1503     uno::Sequence< beans::PropertyValue > aRenderer;
1504 
1505     if( mpDocShell && mpDoc )
1506     {
1507         uno::Reference< frame::XModel > xModel;
1508 
1509         rSelection >>= xModel;
1510 
1511         if( xModel == mpDocShell->GetModel() )
1512             nRet = mpDoc->GetSdPageCount( PK_STANDARD );
1513         else
1514         {
1515             uno::Reference< drawing::XShapes > xShapes;
1516 
1517             rSelection >>= xShapes;
1518 
1519             if( xShapes.is() && xShapes->getCount() )
1520                 nRet = 1;
1521         }
1522     }
1523     return nRet;
1524 }
1525 
1526 uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& ,
1527                                                                                 const uno::Sequence< beans::PropertyValue >& rxOptions )
1528     throw (lang::IllegalArgumentException, uno::RuntimeException)
1529 {
1530 	OGuard aGuard( Application::GetSolarMutex() );
1531 
1532 	if( NULL == mpDoc )
1533 		throw lang::DisposedException();
1534 
1535 	sal_Bool bExportNotesPages = sal_False;
1536 	for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1537     {
1538         if( rxOptions[ nProperty ].Name.equalsAscii( "ExportNotesPages" ) )
1539 			rxOptions[ nProperty].Value >>= bExportNotesPages;
1540     }
1541     uno::Sequence< beans::PropertyValue > aRenderer;
1542     if( mpDocShell && mpDoc )
1543     {
1544 		awt::Size aPageSize;
1545 		if ( bExportNotesPages )
1546 		{
1547 			Size aNotesPageSize = mpDoc->GetSdPage( 0, PK_NOTES )->GetSize();
1548 			aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
1549 		}
1550 		else
1551 		{
1552 			const Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) );
1553 			aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() );
1554 		}
1555         aRenderer.realloc( 1 );
1556 
1557         aRenderer[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
1558         aRenderer[ 0 ].Value <<= aPageSize;
1559     }
1560     return aRenderer;
1561 }
1562 
1563 class ImplRenderPaintProc : public ::sdr::contact::ViewObjectContactRedirector
1564 {
1565 	const SdrLayerAdmin&	rLayerAdmin;
1566 	SdrPageView*			pSdrPageView;
1567 	vcl::PDFExtOutDevData*	pPDFExtOutDevData;
1568 
1569 	vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject );
1570 
1571 public:
1572 	sal_Bool IsVisible  ( const SdrObject* pObj ) const;
1573 	sal_Bool IsPrintable( const SdrObject* pObj ) const;
1574 
1575 	ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData );
1576 	virtual ~ImplRenderPaintProc();
1577 
1578 	// all default implementations just call the same methods at the original. To do something
1579 	// different, overload the method and at least do what the method does.
1580 	virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
1581 		const sdr::contact::ViewObjectContact& rOriginal,
1582 		const sdr::contact::DisplayInfo& rDisplayInfo);
1583 };
1584 
1585 ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData )
1586 :	ViewObjectContactRedirector(),
1587 	rLayerAdmin			( rLA ),
1588 	pSdrPageView		( pView ),
1589 	pPDFExtOutDevData	( pData )
1590 {
1591 }
1592 
1593 ImplRenderPaintProc::~ImplRenderPaintProc()
1594 {
1595 }
1596 
1597 sal_Int32 ImplPDFGetBookmarkPage( const String& rBookmark, SdDrawDocument& rDoc )
1598 {
1599 	sal_Int32 nPage = -1;
1600 
1601     OSL_TRACE("GotoBookmark %s",
1602         ::rtl::OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
1603 
1604 	String aBookmark( rBookmark );
1605 
1606 	if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') )
1607 		aBookmark = rBookmark.Copy( 1 );
1608 
1609 	// is the bookmark a page ?
1610 	sal_Bool        bIsMasterPage;
1611     sal_uInt16      nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage );
1612 	SdrObject*  pObj = NULL;
1613 
1614 	if ( nPgNum == SDRPAGE_NOTFOUND )
1615 	{
1616 		// is the bookmark a object ?
1617 		pObj = rDoc.GetObj( aBookmark );
1618 		if (pObj)
1619 			nPgNum = pObj->GetPage()->GetPageNum();
1620 	}
1621 	if ( nPgNum != SDRPAGE_NOTFOUND )
1622 		nPage = ( nPgNum - 1 ) / 2;
1623 	return nPage;
1624 }
1625 
1626 void ImplPDFExportComments( uno::Reference< drawing::XDrawPage > xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData )
1627 {
1628 	try
1629 	{
1630 		uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
1631 		uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
1632 
1633 		LanguageType eLanguage = Application::GetSettings().GetLanguage();
1634 		while( xAnnotationEnumeration->hasMoreElements() )
1635 		{
1636 			uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
1637 
1638 			geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
1639 			uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
1640 //			rtl::OUString sInitials( getInitials( sAuthor ) );
1641 			util::DateTime aDateTime( xAnnotation->getDateTime() );
1642 
1643 			Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
1644 			Time aTime;
1645 			String aStr( SvxDateTimeField::GetFormatted( aDate, aTime, SVXDATEFORMAT_B, *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
1646 
1647 			vcl::PDFNote aNote;
1648 			String sTitle( xAnnotation->getAuthor() );
1649             sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
1650             sTitle += aStr;
1651             aNote.Title = sTitle;
1652 			aNote.Contents = xText->getString();
1653 			rPDFExtOutDevData.CreateNote( Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ),
1654 				static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote );
1655 		}
1656 	}
1657 	catch( uno::Exception& )
1658 	{
1659 	}
1660 }
1661 
1662 void ImplPDFExportShapeInteraction( uno::Reference< drawing::XShape > xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData )
1663 {
1664 	const rtl::OUString sGroup   ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) );
1665 	const rtl::OUString sOnClick ( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
1666 	const rtl::OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
1667 
1668 	if ( xShape->getShapeType().equals( sGroup ) )
1669 	{
1670 		uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY );
1671 		if ( xIndexAccess.is() )
1672 		{
1673 			sal_Int32 i, nCount = xIndexAccess->getCount();
1674 			for ( i = 0; i < nCount; i++ )
1675 			{
1676 				uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
1677 				if ( xSubShape.is() )
1678 					ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData );
1679 			}
1680 		}
1681 	}
1682 	else
1683 	{
1684 		uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY );
1685 		if( xShapePropSet.is() )
1686 		{
1687 			Size		aPageSize( rDoc.GetSdPage( 0, PK_STANDARD )->GetSize() );
1688 			Point aPoint( 0, 0 );
1689 			Rectangle	aPageRect( aPoint, aPageSize );
1690 
1691 			awt::Point	aShapePos( xShape->getPosition() );
1692 			awt::Size	aShapeSize( xShape->getSize() );
1693 			Rectangle	aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) );
1694 
1695 			presentation::ClickAction eCa;
1696 			uno::Any aAny( xShapePropSet->getPropertyValue( sOnClick ) );
1697 			if ( aAny >>= eCa )
1698 			{
1699 				switch ( eCa )
1700 				{
1701 					case presentation::ClickAction_LASTPAGE :
1702 					{
1703 						sal_Int32 nCount = rDoc.GetSdPageCount( PK_STANDARD );
1704 						sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::FitRectangle );
1705 					    sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1706 						rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1707 					}
1708 					break;
1709 					case presentation::ClickAction_FIRSTPAGE :
1710 					{
1711 						sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::FitRectangle );
1712 					    sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1713 						rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1714 					}
1715 					break;
1716 					case presentation::ClickAction_PREVPAGE :
1717 					{
1718 						sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber();
1719 						if ( nDestPage )
1720 							nDestPage--;
1721 						sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1722 					    sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1723 						rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1724 					}
1725 					break;
1726 					case presentation::ClickAction_NEXTPAGE :
1727 					{
1728 						sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1;
1729 						sal_Int32 nLastPage = rDoc.GetSdPageCount( PK_STANDARD ) - 1;
1730 						if ( nDestPage > nLastPage )
1731 							nDestPage = nLastPage;
1732 						sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
1733 					    sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1734 						rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1735 					}
1736 					break;
1737 
1738 					case presentation::ClickAction_PROGRAM :
1739 					case presentation::ClickAction_BOOKMARK :
1740 					case presentation::ClickAction_DOCUMENT :
1741 					{
1742 						rtl::OUString aBookmark;
1743 						xShapePropSet->getPropertyValue( sBookmark ) >>= aBookmark;
1744 						if( aBookmark.getLength() )
1745 						{
1746 							switch( eCa )
1747 							{
1748 								case presentation::ClickAction_DOCUMENT :
1749 								case presentation::ClickAction_PROGRAM :
1750 								{
1751 									sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1752 									rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark );
1753 								}
1754 								break;
1755 								case presentation::ClickAction_BOOKMARK :
1756 								{
1757 									sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc );
1758 									if ( nPage != -1 )
1759 									{
1760 										sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle );
1761 										sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
1762 										rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
1763 									}
1764 								}
1765 								break;
1766 								default:
1767 									break;
1768 							}
1769 						}
1770 					}
1771 					break;
1772 
1773 					case presentation::ClickAction_STOPPRESENTATION :
1774 					case presentation::ClickAction_SOUND :
1775 					case presentation::ClickAction_INVISIBLE :
1776 					case presentation::ClickAction_VERB :
1777 					case presentation::ClickAction_VANISH :
1778 					case presentation::ClickAction_MACRO :
1779 					default :
1780 					break;
1781 				}
1782 			}
1783 		}
1784 	}
1785 }
1786 
1787 vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject )
1788 {
1789 	vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement);
1790 
1791 	if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() )
1792 	{
1793 		sal_uInt32 nInventor   = rObject.GetObjInventor();
1794 		sal_uInt16 nIdentifier = rObject.GetObjIdentifier();
1795 		sal_Bool   bIsTextObj  = rObject.ISA( SdrTextObj );
1796 
1797 		if ( nInventor == SdrInventor )
1798 		{
1799 			if ( nIdentifier == OBJ_GRUP )
1800 				eElement = vcl::PDFWriter::Section;
1801 			else if ( nIdentifier == OBJ_TITLETEXT )
1802 				eElement = vcl::PDFWriter::Heading;
1803 			else if ( nIdentifier == OBJ_OUTLINETEXT )
1804 				eElement = vcl::PDFWriter::Division;
1805 			else if ( !bIsTextObj || !((SdrTextObj&)rObject).HasText() )
1806 				eElement = vcl::PDFWriter::Figure;
1807 		}
1808 	}
1809 
1810 	return eElement;
1811 }
1812 
1813 drawinglayer::primitive2d::Primitive2DSequence ImplRenderPaintProc::createRedirectedPrimitive2DSequence(
1814 	const sdr::contact::ViewObjectContact& rOriginal,
1815 	const sdr::contact::DisplayInfo& rDisplayInfo)
1816 {
1817 	SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
1818 
1819     if(pObject)
1820 	{
1821 		drawinglayer::primitive2d::Primitive2DSequence xRetval;
1822 
1823 		if(pObject->GetPage())
1824 		{
1825 			if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
1826 			{
1827 				if(IsVisible(pObject) && IsPrintable(pObject))
1828 				{
1829 					const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject ));
1830 					const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement);
1831 
1832 					xRetval = ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1833 
1834 					if(xRetval.hasElements() && bTagUsed)
1835 					{
1836 						// embed Primitive2DSequence in a structure tag element for
1837 						// exactly this purpose (StructureTagPrimitive2D)
1838 						const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::StructureTagPrimitive2D(eElement, xRetval));
1839 						xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
1840 					}
1841 				}
1842 			}
1843 		}
1844 
1845 		return xRetval;
1846 	}
1847 	else
1848 	{
1849 		// not an object, maybe a page
1850 		return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
1851 	}
1852 }
1853 
1854 sal_Bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
1855 {
1856 	sal_Bool bVisible = sal_True;
1857 	SdrLayerID nLayerId = pObj->GetLayer();
1858 	if( pSdrPageView )
1859 	{
1860 		const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1861 		if ( pSdrLayer )
1862 		{
1863 			String aLayerName = pSdrLayer->GetName();
1864 			bVisible = pSdrPageView->IsLayerVisible( aLayerName );
1865 		}
1866 	}
1867 	return bVisible;
1868 }
1869 sal_Bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
1870 {
1871 	sal_Bool bPrintable = sal_True;
1872 	SdrLayerID nLayerId = pObj->GetLayer();
1873 	if( pSdrPageView )
1874 	{
1875 		const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
1876 		if ( pSdrLayer )
1877 		{
1878 			String aLayerName = pSdrLayer->GetName();
1879 			bPrintable = pSdrPageView->IsLayerPrintable( aLayerName );
1880 		}
1881 	}
1882 	return bPrintable;
1883 
1884 }
1885 void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
1886                                           const uno::Sequence< beans::PropertyValue >& rxOptions )
1887     throw (lang::IllegalArgumentException, uno::RuntimeException)
1888 {
1889 	OGuard aGuard( Application::GetSolarMutex() );
1890 
1891 	if( NULL == mpDoc )
1892 		throw lang::DisposedException();
1893 
1894     if( mpDocShell && mpDoc )
1895     {
1896         uno::Reference< awt::XDevice >  xRenderDevice;
1897         const sal_Int32					nPageNumber = nRenderer + 1;
1898 		PageKind						ePageKind = PK_STANDARD;
1899 		sal_Bool						bExportNotesPages = sal_False;
1900 
1901 		for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
1902         {
1903 			if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) )
1904 				rxOptions[ nProperty ].Value >>= xRenderDevice;
1905 			else if ( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ) )
1906 			{
1907 				rxOptions[ nProperty].Value >>= bExportNotesPages;
1908 				if ( bExportNotesPages )
1909 					ePageKind = PK_NOTES;
1910 			}
1911         }
1912 
1913         if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) )
1914         {
1915             VCLXDevice*     pDevice = VCLXDevice::GetImplementation( xRenderDevice );
1916             OutputDevice*   pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
1917 
1918             if( pOut )
1919             {
1920 				vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() );
1921 
1922 	            ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut, NULL );
1923 				Rectangle				aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() );
1924         		Region					aRegion( aVisArea );
1925                 Point					aOrigin;
1926 
1927 				::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
1928 				::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : NULL;
1929 
1930 				if  ( pOldSdView )
1931 					pOldSdView->SdrEndTextEdit();
1932 
1933                 pView->SetHlplVisible( sal_False );
1934                 pView->SetGridVisible( sal_False );
1935 	            pView->SetBordVisible( sal_False );
1936 	            pView->SetPageVisible( sal_False );
1937 	            pView->SetGlueVisible( sal_False );
1938 
1939                 pOut->SetMapMode( MAP_100TH_MM );
1940 	            pOut->IntersectClipRegion( aVisArea );
1941 
1942 
1943 
1944                 uno::Reference< frame::XModel > xModel;
1945                 rSelection >>= xModel;
1946 
1947                 if( xModel == mpDocShell->GetModel() )
1948                 {
1949                     pView->ShowSdrPage( mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind ));
1950 					SdrPageView* pPV = pView->GetSdrPageView();
1951 
1952 				    if( pOldSdView )
1953                     {
1954                         SdrPageView* pOldPV = pOldSdView->GetSdrPageView();
1955                         if( pPV && pOldPV )
1956                         {
1957                             pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() );
1958                             pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() );
1959                         }
1960                     }
1961 
1962 					ImplRenderPaintProc	aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
1963 						pPV, pPDFExtOutDevData );
1964 
1965 					// background color for outliner :o
1966 					SdPage* pPage = (SdPage*)pPV->GetPage();
1967 					if( pPage )
1968 					{
1969 						SdrOutliner& rOutl = mpDoc->GetDrawOutliner( NULL );
1970                         bool bScreenDisplay(true);
1971 
1972                         if(bScreenDisplay && pOut && OUTDEV_PRINTER == pOut->GetOutDevType())
1973                         {
1974                             // #i75566# printing; suppress AutoColor BackgroundColor generation
1975                             // for visibility reasons by giving GetPageBackgroundColor()
1976                             // the needed hint
1977                             bScreenDisplay = false;
1978                         }
1979 
1980                         if(bScreenDisplay && pOut && pOut->GetPDFWriter())
1981                         {
1982                             // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
1983                             bScreenDisplay = false;
1984                         }
1985 
1986                         // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
1987                         // hint value if screen display. Only then the AutoColor mechanisms shall be applied
1988 						rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) );
1989 					}
1990 					pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc );
1991 
1992 					if ( pPDFExtOutDevData )
1993 					{
1994 						try
1995 						{
1996 							uno::Any aAny;
1997 							uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) );
1998 							if ( xPage.is() )
1999 							{
2000 								if ( pPDFExtOutDevData->GetIsExportNotes() )
2001 									ImplPDFExportComments( xPage, *pPDFExtOutDevData );
2002 								uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY );
2003 								if( xPagePropSet.is() )
2004 								{
2005 									// exporting object interactions to pdf
2006 
2007 									// if necessary, the master page interactions will be exported first
2008 									sal_Bool bIsBackgroundObjectsVisible = sal_False;	// SJ: #i39428# IsBackgroundObjectsVisible not available for Draw
2009 									const rtl::OUString sIsBackgroundObjectsVisible( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundObjectsVisible" ) );
2010 									if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && ( xPagePropSet->getPropertyValue( sIsBackgroundObjectsVisible ) >>= bIsBackgroundObjectsVisible ) && bIsBackgroundObjectsVisible )
2011 									{
2012 										uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY );
2013 										if ( xMasterPageTarget.is() )
2014 										{
2015 											uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
2016 											if ( xMasterPage.is() )
2017 											{
2018 												uno::Reference< drawing::XShapes> xShapes( xMasterPage, uno::UNO_QUERY );
2019 												sal_Int32 i, nCount = xShapes->getCount();
2020 												for ( i = 0; i < nCount; i++ )
2021 												{
2022 													aAny = xShapes->getByIndex( i );
2023 													uno::Reference< drawing::XShape > xShape;
2024 													if ( aAny >>= xShape )
2025 														ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
2026 												}
2027 											}
2028 										}
2029 									}
2030 
2031 									// exporting slide page object interactions
2032 									uno::Reference< drawing::XShapes> xShapes( xPage, uno::UNO_QUERY );
2033 									sal_Int32 i, nCount = xShapes->getCount();
2034 									for ( i = 0; i < nCount; i++ )
2035 									{
2036 										aAny = xShapes->getByIndex( i );
2037 										uno::Reference< drawing::XShape > xShape;
2038 										if ( aAny >>= xShape )
2039 											ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
2040 									}
2041 
2042 									// exporting transition effects to pdf
2043 									if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && pPDFExtOutDevData->GetIsExportTransitionEffects() )
2044 									{
2045 										const rtl::OUString sEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) );
2046 										const rtl::OUString sSpeed ( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) );
2047 										sal_Int32 nTime = 800;
2048 										presentation::AnimationSpeed aAs;
2049 										aAny = xPagePropSet->getPropertyValue( sSpeed );
2050 										if ( aAny >>= aAs )
2051 										{
2052 											switch( aAs )
2053 											{
2054 												case presentation::AnimationSpeed_SLOW : nTime = 1500; break;
2055 												case presentation::AnimationSpeed_FAST : nTime = 300; break;
2056 												default:
2057 												case presentation::AnimationSpeed_MEDIUM : nTime = 800;
2058 											}
2059 										}
2060 										presentation::FadeEffect eFe;
2061 										aAny = xPagePropSet->getPropertyValue( sEffect );
2062 										vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::Regular;
2063 										if ( aAny >>= eFe )
2064 										{
2065 											switch( eFe )
2066 											{
2067 												case presentation::FadeEffect_HORIZONTAL_LINES :
2068 												case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
2069 												case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::BlindsHorizontal; break;
2070 
2071 												case presentation::FadeEffect_VERTICAL_LINES :
2072 												case presentation::FadeEffect_VERTICAL_CHECKERBOARD :
2073 												case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::BlindsVertical; break;
2074 
2075 												case presentation::FadeEffect_UNCOVER_TO_RIGHT :
2076 												case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
2077 												case presentation::FadeEffect_ROLL_FROM_LEFT :
2078 												case presentation::FadeEffect_FADE_FROM_UPPERLEFT :
2079 												case presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
2080 												case presentation::FadeEffect_FADE_FROM_LEFT :
2081 												case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::WipeLeftToRight; break;
2082 
2083 												case presentation::FadeEffect_UNCOVER_TO_BOTTOM :
2084 												case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
2085 												case presentation::FadeEffect_ROLL_FROM_TOP :
2086 												case presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
2087 												case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
2088 												case presentation::FadeEffect_FADE_FROM_TOP :
2089 												case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::WipeTopToBottom; break;
2090 
2091 												case presentation::FadeEffect_UNCOVER_TO_LEFT :
2092 												case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
2093 												case presentation::FadeEffect_ROLL_FROM_RIGHT :
2094 
2095 												case presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
2096 												case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
2097 												case presentation::FadeEffect_FADE_FROM_RIGHT :
2098 												case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::WipeRightToLeft; break;
2099 
2100 												case presentation::FadeEffect_UNCOVER_TO_TOP :
2101 												case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
2102 												case presentation::FadeEffect_ROLL_FROM_BOTTOM :
2103 												case presentation::FadeEffect_FADE_FROM_LOWERLEFT :
2104 												case presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
2105 												case presentation::FadeEffect_FADE_FROM_BOTTOM :
2106 												case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::WipeBottomToTop; break;
2107 
2108 												case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::SplitHorizontalInward; break;
2109 												case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::SplitHorizontalOutward; break;
2110 
2111 												case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::SplitVerticalInward; break;
2112 												case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::SplitVerticalOutward; break;
2113 
2114 												case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::BoxInward; break;
2115 												case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::BoxOutward; break;
2116 
2117 												case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::Regular; break;
2118 
2119 												case presentation::FadeEffect_RANDOM :
2120 												case presentation::FadeEffect_DISSOLVE :
2121 												default: eType = vcl::PDFWriter::Dissolve; break;
2122 											}
2123 										}
2124 										pPDFExtOutDevData->SetPageTransition( eType, nTime, -1 );
2125 									}
2126 								}
2127 							}
2128 							Size		aPageSize( mpDoc->GetSdPage( 0, PK_STANDARD )->GetSize() );
2129 							Point aPoint( 0, 0 );
2130 							Rectangle	aPageRect( aPoint, aPageSize );
2131 
2132 							// resolving links found in this page by the method ImpEditEngine::Paint
2133 							std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
2134 							std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin();
2135 							std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
2136 							while ( aIBeg != aIEnd )
2137 							{
2138 								sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc );
2139 								if ( nPage != -1 )
2140 								{
2141 									if ( aIBeg->nLinkId != -1 )
2142 										pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ) );
2143 									else
2144 										pPDFExtOutDevData->DescribeRegisteredDest( aIBeg->nDestId, aPageRect, nPage, vcl::PDFWriter::FitRectangle );
2145 								}
2146 								else
2147 									pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark );
2148 								aIBeg++;
2149 							}
2150 							rBookmarks.clear();
2151 							//---> i56629, i40318
2152 							//get the page name, will be used as outline element in PDF bookmark pane
2153 							String aPageName = mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1 , PK_STANDARD )->GetName();
2154 							if( aPageName.Len() > 0 )
2155 							{
2156 								// insert the bookmark to this page into the NamedDestinations
2157 								if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
2158 									pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect,  nPageNumber - 1 );
2159 								//
2160 								// add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
2161 								// issue i40318.
2162 								//
2163 								if( pPDFExtOutDevData->GetIsExportBookmarks() )
2164 								{
2165 									// Destination Export
2166 									const sal_Int32 nDestId =
2167 										pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 );
2168 
2169 									// Create a new outline item:
2170 									pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
2171 								}
2172 							}
2173 							//<--- i56629, i40318
2174 						}
2175 						catch( uno::Exception& )
2176 						{
2177 						}
2178 
2179 					}
2180             	}
2181             	else
2182             	{
2183 		            uno::Reference< drawing::XShapes > xShapes;
2184 		            rSelection >>= xShapes;
2185 
2186 		            if( xShapes.is() && xShapes->getCount() )
2187 		            {
2188 		               SdrPageView* pPV = NULL;
2189 
2190 					   ImplRenderPaintProc	aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
2191 										pOldSdView ? pOldSdView->GetSdrPageView() : NULL, pPDFExtOutDevData );
2192 
2193 			            for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ )
2194 			            {
2195 			                uno::Reference< drawing::XShape > xShape;
2196 				            xShapes->getByIndex( i ) >>= xShape;
2197 
2198 				            if( xShape.is() )
2199 				            {
2200 					            SvxShape* pShape = SvxShape::getImplementation( xShape );
2201 
2202 					            if( pShape )
2203 					            {
2204 						            SdrObject* pObj = pShape->GetSdrObject();
2205 						            if( pObj && pObj->GetPage()
2206 										&& aImplRenderPaintProc.IsVisible( pObj )
2207 											&& aImplRenderPaintProc.IsPrintable( pObj ) )
2208 						            {
2209 						                if( !pPV )
2210                                             pPV = pView->ShowSdrPage( pObj->GetPage() );
2211 
2212                                         if( pPV )
2213 							                pView->MarkObj( pObj, pPV );
2214 							        }
2215 					            }
2216 				            }
2217 			            }
2218                         pView->DrawMarkedObj(*pOut);
2219 		            }
2220 		        }
2221 
2222                 delete pView;
2223             }
2224         }
2225     }
2226 }
2227 
2228 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
2229 {
2230 	uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
2231 
2232 	if( !xForb.is() )
2233 		mxForbidenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc );
2234 
2235 	return xForb;
2236 }
2237 
2238 void SdXImpressDocument::initializeDocument()
2239 {
2240     if( !mbClipBoard )
2241     {
2242         switch( mpDoc->GetPageCount() )
2243         {
2244         case 1:
2245         {
2246             // nasty hack to detect clipboard document
2247             mbClipBoard = true;
2248             break;
2249         }
2250         case 0:
2251         {
2252 	        mpDoc->CreateFirstPages();
2253 		    mpDoc->StopWorkStartupDelay();
2254             break;
2255         }
2256 	    }
2257     }
2258 }
2259 
2260 void SAL_CALL SdXImpressDocument::dispose() throw (::com::sun::star::uno::RuntimeException)
2261 {
2262     if( !mbDisposed )
2263     {
2264         {
2265 			OGuard aGuard( Application::GetSolarMutex() );
2266 
2267 			if( mpDoc )
2268 			{
2269 				EndListening( *mpDoc );
2270 				mpDoc = NULL;
2271 			}
2272 
2273 			// Call the base class dispose() before setting the mbDisposed flag
2274 			// to true.  The reason for this is that if close() has not yet been
2275 			// called this is done in SfxBaseModel::dispose().  At the end of
2276 			// that dispose() is called again.  It is important to forward this
2277 			// second dispose() to the base class, too.
2278 			// As a consequence the following code has to be able to be run twice.
2279 			SfxBaseModel::dispose();
2280 			mbDisposed = true;
2281 
2282 			uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies);
2283 			if( xStyles.is() )
2284 			{
2285 				uno::Reference< lang::XComponent > xComp( xStyles, uno::UNO_QUERY );
2286 				if( xComp.is() )
2287 					xComp->dispose();
2288 
2289 				xStyles = 0;
2290 			}
2291 
2292 			uno::Reference< presentation::XPresentation > xPresentation( mxPresentation );
2293 			if( xPresentation.is() )
2294 			{
2295 				uno::Reference< ::com::sun::star::presentation::XPresentation2 > xPres( mpDoc->getPresentation().get() );
2296 				uno::Reference< lang::XComponent > xPresComp( xPres, uno::UNO_QUERY );
2297 				if( xPresComp.is() )
2298 					xPresComp->dispose();
2299 			}
2300 
2301 			uno::Reference< container::XNameAccess > xLinks( mxLinks );
2302 			if( xLinks.is() )
2303 			{
2304 				uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY );
2305 				if( xComp.is() )
2306 					xComp->dispose();
2307 
2308 				xLinks = 0;
2309 			}
2310 
2311 			uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess );
2312 			if( xDrawPagesAccess.is() )
2313 			{
2314 				uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY );
2315 				if( xComp.is() )
2316 					xComp->dispose();
2317 
2318 				xDrawPagesAccess = 0;
2319 			}
2320 
2321 			uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess );
2322 			if( xDrawPagesAccess.is() )
2323 			{
2324 				uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY );
2325 				if( xComp.is() )
2326 					xComp->dispose();
2327 
2328 				xDrawPagesAccess = 0;
2329 			}
2330 
2331 			uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
2332 			if( xLayerManager.is() )
2333 			{
2334 				uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY );
2335 				if( xComp.is() )
2336 					xComp->dispose();
2337 
2338 				xLayerManager = 0;
2339 			}
2340 
2341 			uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess );
2342 			if( xCustomPresentationAccess.is() )
2343 			{
2344 				uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY );
2345 				if( xComp.is() )
2346 					xComp->dispose();
2347 
2348 				xCustomPresentationAccess = 0;
2349 			}
2350 
2351 			mxDashTable = 0;
2352 			mxGradientTable = 0;
2353 			mxHatchTable = 0;
2354 			mxBitmapTable = 0;
2355 			mxTransGradientTable = 0;
2356 			mxMarkerTable = 0;
2357 			mxDrawingPool = 0;
2358 		}
2359 	}
2360 }
2361 
2362 //=============================================================================
2363 // class SdDrawPagesAccess
2364 //=============================================================================
2365 
2366 SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel )  throw()
2367 :	mpModel( &rMyModel)
2368 {
2369 }
2370 
2371 SdDrawPagesAccess::~SdDrawPagesAccess() throw()
2372 {
2373 }
2374 
2375 // XIndexAccess
2376 sal_Int32 SAL_CALL SdDrawPagesAccess::getCount()
2377 	throw(uno::RuntimeException)
2378 {
2379 	OGuard aGuard( Application::GetSolarMutex() );
2380 
2381 	if( NULL == mpModel )
2382 		throw lang::DisposedException();
2383 
2384 	return mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2385 }
2386 
2387 uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index )
2388 	throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2389 {
2390 	OGuard aGuard( Application::GetSolarMutex() );
2391 
2392 	if( NULL == mpModel )
2393 		throw lang::DisposedException();
2394 
2395 	uno::Any aAny;
2396 
2397 	if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PK_STANDARD ) ) )
2398 		throw lang::IndexOutOfBoundsException();
2399 
2400 	SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD );
2401 	if( pPage )
2402 	{
2403 		uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2404 		aAny <<= xDrawPage;
2405 	}
2406 
2407 	return aAny;
2408 }
2409 
2410 // XNameAccess
2411 uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
2412 {
2413 	OGuard aGuard( Application::GetSolarMutex() );
2414 
2415 	if( NULL == mpModel )
2416 		throw lang::DisposedException();
2417 
2418 	if( aName.getLength() != 0 )
2419 	{
2420 		const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2421 		sal_uInt16 nPage;
2422 		for( nPage = 0; nPage < nCount; nPage++ )
2423 		{
2424 			SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2425 			if(NULL == pPage)
2426 				continue;
2427 
2428 			if( aName == SdDrawPage::getPageApiName( pPage ) )
2429 			{
2430 				uno::Any aAny;
2431 				uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2432 				aAny <<= xDrawPage;
2433 				return aAny;
2434 			}
2435 		}
2436 	}
2437 
2438 	throw container::NoSuchElementException();
2439 }
2440 
2441 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() throw(uno::RuntimeException)
2442 {
2443 	OGuard aGuard( Application::GetSolarMutex() );
2444 
2445 	if( NULL == mpModel )
2446 		throw lang::DisposedException();
2447 
2448 	const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2449 	uno::Sequence< OUString > aNames( nCount );
2450 	OUString* pNames = aNames.getArray();
2451 
2452 	sal_uInt16 nPage;
2453 	for( nPage = 0; nPage < nCount; nPage++ )
2454 	{
2455 		SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2456 		*pNames++ = SdDrawPage::getPageApiName( pPage );
2457 	}
2458 
2459 	return aNames;
2460 }
2461 
2462 sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) throw(uno::RuntimeException)
2463 {
2464 	OGuard aGuard( Application::GetSolarMutex() );
2465 
2466 	if( NULL == mpModel )
2467 		throw lang::DisposedException();
2468 
2469 	const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
2470 	sal_uInt16 nPage;
2471 	for( nPage = 0; nPage < nCount; nPage++ )
2472 	{
2473 		SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
2474 		if(NULL == pPage)
2475 			continue;
2476 
2477 		if( aName == SdDrawPage::getPageApiName( pPage ) )
2478 			return sal_True;
2479 	}
2480 
2481 	return sal_False;
2482 }
2483 
2484 // XElementAccess
2485 uno::Type SAL_CALL SdDrawPagesAccess::getElementType()
2486 	throw(uno::RuntimeException)
2487 {
2488 	return ITYPE( drawing::XDrawPage );
2489 }
2490 
2491 sal_Bool SAL_CALL SdDrawPagesAccess::hasElements()
2492 	throw(uno::RuntimeException)
2493 {
2494 	return getCount() > 0;
2495 }
2496 
2497 // XDrawPages
2498 
2499 /******************************************************************************
2500 * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
2501 * dazugehoerige SdDrawPage zurueck.                                           *
2502 ******************************************************************************/
2503 uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
2504 	throw(uno::RuntimeException)
2505 {
2506 	OGuard aGuard( Application::GetSolarMutex() );
2507 
2508 	if( NULL == mpModel )
2509 		throw lang::DisposedException();
2510 
2511 	if( mpModel->mpDoc )
2512 	{
2513 		SdPage* pPage = mpModel->InsertSdPage( (sal_uInt16)nIndex );
2514 		if( pPage )
2515 		{
2516 			uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2517 			return xDrawPage;
2518 		}
2519 	}
2520 	uno::Reference< drawing::XDrawPage > xDrawPage;
2521 	return xDrawPage;
2522 }
2523 
2524 /******************************************************************************
2525 * Entfernt die angegebenne SdDrawPage aus dem Model und aus der internen      *
2526 * Liste. Dies funktioniert nur, wenn mindestens eine *normale* Seite im Model *
2527 * nach dem entfernen dieser Seite vorhanden ist.							  *
2528 ******************************************************************************/
2529 void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2530 		throw(uno::RuntimeException)
2531 {
2532 	OGuard aGuard( Application::GetSolarMutex() );
2533 
2534 	if( NULL == mpModel || mpModel->mpDoc == NULL )
2535 		throw lang::DisposedException();
2536 
2537 	SdDrawDocument& rDoc = *mpModel->mpDoc;
2538 
2539 	sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD );
2540 	if( nPageCount > 1 )
2541 	{
2542 		// pPage von xPage besorgen und dann die Id (nPos )ermitteln
2543 		SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage );
2544 		if( pSvxPage )
2545 		{
2546 			SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
2547 			if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) )
2548 			{
2549 				sal_uInt16 nPage = pPage->GetPageNum();
2550 
2551 				SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
2552 
2553 				bool bUndo = rDoc.IsUndoEnabled();
2554 				if( bUndo )
2555 				{
2556 					// Add undo actions and delete the pages.  The order of adding
2557 					// the undo actions is important.
2558 					rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2559 					rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2560 					rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2561 				}
2562 
2563 				rDoc.RemovePage( nPage ); // the page
2564 				rDoc.RemovePage( nPage ); // the notes page
2565 
2566 				if( bUndo )
2567 				{
2568 					rDoc.EndUndo();
2569 				}
2570 				else
2571 				{
2572 					delete pNotesPage;
2573 					delete pPage;
2574 				}
2575 			}
2576 		}
2577 	}
2578 
2579 	mpModel->SetModified();
2580 }
2581 
2582 // XServiceInfo
2583 sal_Char pSdDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
2584 
2585 OUString SAL_CALL SdDrawPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
2586 {
2587 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdDrawPagesAccess" ) );
2588 }
2589 
2590 sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
2591 {
2592 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdDrawPagesAccessService ) );
2593 }
2594 
2595 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
2596 {
2597 	OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdDrawPagesAccessService ) );
2598 	uno::Sequence< OUString > aSeq( &aService, 1 );
2599 	return aSeq;
2600 }
2601 
2602 // XComponent
2603 void SAL_CALL SdDrawPagesAccess::dispose(  ) throw (uno::RuntimeException)
2604 {
2605 	mpModel = NULL;
2606 }
2607 
2608 void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2609 {
2610 	DBG_ERROR( "not implemented!" );
2611 }
2612 
2613 void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2614 {
2615 	DBG_ERROR( "not implemented!" );
2616 }
2617 
2618 //=============================================================================
2619 // class SdMasterPagesAccess
2620 //=============================================================================
2621 
2622 SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw()
2623 :	mpModel(&rMyModel)
2624 {
2625 }
2626 
2627 SdMasterPagesAccess::~SdMasterPagesAccess() throw()
2628 {
2629 }
2630 
2631 // XComponent
2632 void SAL_CALL SdMasterPagesAccess::dispose(  ) throw (uno::RuntimeException)
2633 {
2634 	mpModel = NULL;
2635 }
2636 
2637 void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2638 {
2639 	DBG_ERROR( "not implemented!" );
2640 }
2641 
2642 void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2643 {
2644 	DBG_ERROR( "not implemented!" );
2645 }
2646 
2647 // XIndexAccess
2648 sal_Int32 SAL_CALL SdMasterPagesAccess::getCount()
2649 	throw(uno::RuntimeException)
2650 {
2651 	OGuard aGuard( Application::GetSolarMutex() );
2652 
2653 	if( NULL == mpModel->mpDoc )
2654 		throw lang::DisposedException();
2655 
2656 	return mpModel->mpDoc->GetMasterSdPageCount(PK_STANDARD);
2657 }
2658 
2659 /******************************************************************************
2660 * Liefert ein drawing::XDrawPage Interface fuer den Zugriff auf die Masterpage and der *
2661 * angegebennen Position im Model.                                             *
2662 ******************************************************************************/
2663 uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index )
2664 	throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2665 {
2666 	OGuard aGuard( Application::GetSolarMutex() );
2667 
2668 	if( NULL == mpModel )
2669 		throw lang::DisposedException();
2670 
2671 	uno::Any aAny;
2672 
2673 	if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PK_STANDARD ) ) )
2674 		throw lang::IndexOutOfBoundsException();
2675 
2676 	SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD );
2677 	if( pPage )
2678 	{
2679 		uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
2680 		aAny <<= xDrawPage;
2681 	}
2682 
2683 	return aAny;
2684 }
2685 
2686 // XElementAccess
2687 uno::Type SAL_CALL SdMasterPagesAccess::getElementType()
2688 	throw(uno::RuntimeException)
2689 {
2690 	return ITYPE(drawing::XDrawPage);
2691 }
2692 
2693 sal_Bool SAL_CALL SdMasterPagesAccess::hasElements()
2694 	throw(uno::RuntimeException)
2695 {
2696 	return getCount() > 0;
2697 }
2698 
2699 // XDrawPages
2700 uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos )
2701 	throw(uno::RuntimeException)
2702 {
2703 	OGuard aGuard( Application::GetSolarMutex() );
2704 
2705 	if( NULL == mpModel )
2706 		throw lang::DisposedException();
2707 
2708 	uno::Reference< drawing::XDrawPage > xDrawPage;
2709 
2710 	SdDrawDocument* mpDoc = mpModel->mpDoc;
2711 	if( mpDoc )
2712 	{
2713 		// calculate internal index and check for range errors
2714 		const sal_Int32 nMPageCount = mpDoc->GetMasterPageCount();
2715 		nInsertPos = nInsertPos * 2 + 1;
2716 		if( nInsertPos < 0 || nInsertPos > nMPageCount )
2717 			nInsertPos = nMPageCount;
2718 
2719 		// now generate a unique name for the new masterpage
2720 		const String aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) );
2721 		String aPrefix( aStdPrefix );
2722 
2723 		sal_Bool bUnique = sal_True;
2724 		sal_Int32 i = 0;
2725 		do
2726 		{
2727 			bUnique = sal_True;
2728 			for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ )
2729 			{
2730 				SdPage* pPage = (SdPage*)mpDoc->GetMasterPage((sal_uInt16)nMaster);
2731 				if( pPage && pPage->GetName() == aPrefix )
2732 				{
2733 					bUnique = sal_False;
2734 					break;
2735 				}
2736 			}
2737 
2738 			if( !bUnique )
2739 			{
2740 				i++;
2741 				aPrefix = aStdPrefix;
2742 				aPrefix += sal_Unicode( ' ' );
2743 				aPrefix += String::CreateFromInt32( i );
2744 			}
2745 
2746 		} while( !bUnique );
2747 
2748 		String aLayoutName( aPrefix );
2749 		aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
2750 		aLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
2751 
2752 		// create styles
2753 		((SdStyleSheetPool*)mpDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix );
2754 
2755 		// get the first page for initial size and border settings
2756 		SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD );
2757 		SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_NOTES);
2758 
2759 		// create and instert new draw masterpage
2760 		SdPage* pMPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
2761 		pMPage->SetSize( pPage->GetSize() );
2762 		pMPage->SetBorder( pPage->GetLftBorder(),
2763 						   pPage->GetUppBorder(),
2764 						   pPage->GetRgtBorder(),
2765 						   pPage->GetLwrBorder() );
2766 		pMPage->SetLayoutName( aLayoutName );
2767 		mpDoc->InsertMasterPage(pMPage,  (sal_uInt16)nInsertPos);
2768 
2769 		{
2770 			// ensure default MasterPage fill
2771             pMPage->EnsureMasterPageDefaultBackground();
2772 		}
2773 
2774 		xDrawPage = uno::Reference< drawing::XDrawPage >::query( pMPage->getUnoPage() );
2775 
2776 		// create and instert new notes masterpage
2777 		SdPage* pMNotesPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
2778 		pMNotesPage->SetSize( pRefNotesPage->GetSize() );
2779 		pMNotesPage->SetPageKind(PK_NOTES);
2780 		pMNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
2781 								pRefNotesPage->GetUppBorder(),
2782 								pRefNotesPage->GetRgtBorder(),
2783 								pRefNotesPage->GetLwrBorder() );
2784 		pMNotesPage->SetLayoutName( aLayoutName );
2785 		mpDoc->InsertMasterPage(pMNotesPage,  (sal_uInt16)nInsertPos + 1);
2786 //		pMNotesPage->InsertMasterPage( pMPage->GetPageNum() );
2787 		pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True);
2788 		mpModel->SetModified();
2789 	}
2790 
2791 	return( xDrawPage );
2792 }
2793 
2794 /******************************************************************************
2795 * Entfernt die angegebenne SdMasterPage aus dem Model und aus der internen    *
2796 * Liste. Dies funktioniert nur, wenn keine *normale* Seite im Model diese     *
2797 * Seite als Masterpage benutzt.                                               *
2798 ******************************************************************************/
2799 void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
2800 	throw(uno::RuntimeException)
2801 {
2802 	OGuard aGuard( Application::GetSolarMutex() );
2803 
2804 	if( NULL == mpModel || mpModel->mpDoc == NULL )
2805 		throw lang::DisposedException();
2806 
2807 	SdDrawDocument& rDoc = *mpModel->mpDoc;
2808 
2809 	SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage );
2810 	if(pSdPage == NULL)
2811 		return;
2812 
2813 	SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage());
2814 
2815 	DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?");
2816 
2817 	if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0))
2818 		return; //Todo: this should be excepted
2819 
2820 	// only standard pages can be removed directly
2821 	if( pPage->GetPageKind() == PK_STANDARD )
2822 	{
2823 		sal_uInt16 nPage = pPage->GetPageNum();
2824 
2825 		SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
2826 
2827 		bool bUndo = rDoc.IsUndoEnabled();
2828 		if( bUndo )
2829 		{
2830 			// Add undo actions and delete the pages.  The order of adding
2831 			// the undo actions is important.
2832 			rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
2833 			rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
2834 			rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
2835 		}
2836 
2837 		rDoc.RemoveMasterPage( nPage );
2838 		rDoc.RemoveMasterPage( nPage );
2839 
2840 		if( bUndo )
2841 		{
2842 			rDoc.EndUndo();
2843 		}
2844 		else
2845 		{
2846 			delete pNotesPage;
2847 			delete pPage;
2848 		}
2849 	}
2850 }
2851 
2852 // XServiceInfo
2853 sal_Char pSdMasterPagesAccessService[sizeof("com.sun.star.drawing.MasterPages")] = "com.sun.star.drawing.MasterPages";
2854 
2855 OUString SAL_CALL SdMasterPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
2856 {
2857 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdMasterPagesAccess" ) );
2858 }
2859 
2860 sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
2861 {
2862 	return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdMasterPagesAccessService ) );
2863 }
2864 
2865 uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
2866 {
2867 	OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdMasterPagesAccessService ) );
2868 	uno::Sequence< OUString > aSeq( &aService, 1 );
2869 	return aSeq;
2870 }
2871 
2872 //=============================================================================
2873 // class SdDocLinkTargets
2874 //=============================================================================
2875 
2876 SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw()
2877 : mpModel( &rMyModel )
2878 {
2879 }
2880 
2881 SdDocLinkTargets::~SdDocLinkTargets() throw()
2882 {
2883 }
2884 
2885 // XComponent
2886 void SAL_CALL SdDocLinkTargets::dispose(  ) throw (uno::RuntimeException)
2887 {
2888 	mpModel = NULL;
2889 }
2890 
2891 void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2892 {
2893 	DBG_ERROR( "not implemented!" );
2894 }
2895 
2896 void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
2897 {
2898 	DBG_ERROR( "not implemented!" );
2899 }
2900 
2901 // XNameAccess
2902 uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName )
2903 	throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
2904 {
2905 	OGuard aGuard( Application::GetSolarMutex() );
2906 
2907 	if( NULL == mpModel )
2908 		throw lang::DisposedException();
2909 
2910 	SdPage* pPage = FindPage( aName );
2911 
2912 	if( pPage == NULL )
2913 		throw container::NoSuchElementException();
2914 
2915 	uno::Any aAny;
2916 
2917 	uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY );
2918 	if( xProps.is() )
2919 		aAny <<= xProps;
2920 
2921 	return aAny;
2922 }
2923 
2924 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames()
2925 	throw(uno::RuntimeException)
2926 {
2927 	OGuard aGuard( Application::GetSolarMutex() );
2928 
2929 	if( NULL == mpModel )
2930 		throw lang::DisposedException();
2931 
2932 	SdDrawDocument* mpDoc = mpModel->GetDoc();
2933 	if( mpDoc == NULL )
2934 	{
2935 		uno::Sequence< OUString > aSeq;
2936 		return aSeq;
2937 	}
2938 
2939 	if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW )
2940 	{
2941 		const sal_uInt16 nMaxPages = mpDoc->GetSdPageCount( PK_STANDARD );
2942 		const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterSdPageCount( PK_STANDARD );
2943 
2944 		uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
2945 		OUString* pStr = aSeq.getArray();
2946 
2947 		sal_uInt16 nPage;
2948 		// standard pages
2949 		for( nPage = 0; nPage < nMaxPages; nPage++ )
2950 			*pStr++ = mpDoc->GetSdPage( nPage, PK_STANDARD )->GetName();
2951 
2952 		// master pages
2953 		for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
2954 			*pStr++ = mpDoc->GetMasterSdPage( nPage, PK_STANDARD )->GetName();
2955 		return aSeq;
2956 	}
2957 	else
2958 	{
2959 		const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
2960 		const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
2961 
2962 		uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
2963 		OUString* pStr = aSeq.getArray();
2964 
2965 		sal_uInt16 nPage;
2966 		// standard pages
2967 		for( nPage = 0; nPage < nMaxPages; nPage++ )
2968 			*pStr++ = ((SdPage*)mpDoc->GetPage( nPage ))->GetName();
2969 
2970 		// master pages
2971 		for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
2972 			*pStr++ = ((SdPage*)mpDoc->GetMasterPage( nPage ))->GetName();
2973 		return aSeq;
2974 	}
2975 }
2976 
2977 sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName )
2978 	throw(uno::RuntimeException)
2979 {
2980 	OGuard aGuard( Application::GetSolarMutex() );
2981 
2982 	if( NULL == mpModel )
2983 		throw lang::DisposedException();
2984 
2985 	return FindPage( aName ) != NULL;
2986 }
2987 
2988 // container::XElementAccess
2989 uno::Type SAL_CALL SdDocLinkTargets::getElementType()
2990 	throw(uno::RuntimeException)
2991 {
2992 	return ITYPE(beans::XPropertySet);
2993 }
2994 
2995 sal_Bool SAL_CALL SdDocLinkTargets::hasElements()
2996 	throw(uno::RuntimeException)
2997 {
2998 	OGuard aGuard( Application::GetSolarMutex() );
2999 
3000 	if( NULL == mpModel )
3001 		throw lang::DisposedException();
3002 
3003 	return mpModel->GetDoc() != NULL;
3004 }
3005 
3006 SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw()
3007 {
3008 	SdDrawDocument* mpDoc = mpModel->GetDoc();
3009 	if( mpDoc == NULL )
3010 		return NULL;
3011 
3012 	const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
3013 	const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
3014 
3015 	sal_uInt16 nPage;
3016 	SdPage* pPage;
3017 
3018 	const String aName( rName );
3019 
3020 	const bool bDraw = mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW;
3021 
3022 	// standard pages
3023 	for( nPage = 0; nPage < nMaxPages; nPage++ )
3024 	{
3025 		pPage = (SdPage*)mpDoc->GetPage( nPage );
3026 		if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
3027 			return pPage;
3028 	}
3029 
3030 	// master pages
3031 	for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
3032 	{
3033 		pPage = (SdPage*)mpDoc->GetMasterPage( nPage );
3034 		if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
3035 			return pPage;
3036 	}
3037 
3038 	return NULL;
3039 }
3040 
3041 // XServiceInfo
3042 OUString SAL_CALL SdDocLinkTargets::getImplementationName()
3043 	throw(uno::RuntimeException)
3044 {
3045 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDocLinkTargets") );
3046 }
3047 
3048 sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName )
3049 	throw(uno::RuntimeException)
3050 {
3051 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
3052 }
3053 
3054 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames()
3055 	throw(uno::RuntimeException)
3056 {
3057 	const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") );
3058 	uno::Sequence< OUString > aSeq( &aSN, 1 );
3059 	return aSeq;
3060 }
3061 
3062 rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument* pDocument )
3063 {
3064 	rtl::Reference< SdXImpressDocument > xRet;
3065 	if( pDocument )
3066 	{
3067 		::sd::DrawDocShell* pDocShell = pDocument->GetDocSh();
3068 		if( pDocShell )
3069 		{
3070 			uno::Reference<frame::XModel> xModel(pDocShell->GetModel());
3071 
3072 			xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) );
3073 		}
3074 	}
3075 
3076 	return xRet;
3077 }
3078 
3079 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName )
3080 {
3081 	rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3082 
3083 	if( xModel.is() )
3084 	{
3085 		uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) );
3086 		::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3087 		xModel->notifyEvent(aEvent );
3088 	}
3089 }
3090 
3091 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const uno::Reference< uno::XInterface >& xSource )
3092 {
3093 	rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
3094 
3095 	if( xModel.is() )
3096 	{
3097 		::com::sun::star::document::EventObject aEvent( xSource, rEventName );
3098 		xModel->notifyEvent(aEvent );
3099 	}
3100 }
3101