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