xref: /trunk/main/sd/source/ui/unoidl/unopage.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/presentation/ClickAction.hpp>
28 #include <com/sun/star/presentation/FadeEffect.hpp>
29 #include <com/sun/star/presentation/AnimationEffect.hpp>
30 #include <com/sun/star/presentation/PresentationRange.hpp>
31 #include <com/sun/star/presentation/AnimationSpeed.hpp>
32 #include <com/sun/star/view/PaperOrientation.hpp>
33 #include <com/sun/star/animations/AnimationNodeType.hpp>
34 #include <com/sun/star/presentation/EffectNodeType.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <comphelper/processfactory.hxx>
37 #include <rtl/ustrbuf.hxx>
38 #include <vcl/bitmapex.hxx>
39 #include <vcl/metaact.hxx>
40 #include <toolkit/unohlp.hxx>
41 #include <vcl/svapp.hxx>
42 #include <vcl/settings.hxx>
43 #include <unomodel.hxx>
44 #include <unopage.hxx>
45 #include <svx/svxids.hrc>
46 #include <svl/itemset.hxx>
47 #include <svx/svdmodel.hxx>
48 #include <sdresid.hxx>
49 #include <glob.hrc>
50 #include <sdpage.hxx>
51 #include <unoprnms.hxx>
52 #include <sdattr.hxx>
53 #include <drawdoc.hxx>
54 #include <svx/unoshape.hxx>
55 #include <com/sun/star/style/XStyle.hpp>
56 #include <svx/svdorect.hxx>
57 #include <vos/mutex.hxx>
58 #include <svl/style.hxx>
59 #include <rtl/uuid.h>
60 #include <rtl/memory.h>
61 #include <comphelper/serviceinfohelper.hxx>
62 
63 #include <comphelper/extract.hxx>
64 #include <list>
65 #include <svx/svditer.hxx>
66 #include <svtools/wmf.hxx>
67 #include <svx/svdoole2.hxx>
68 #include <svx/svdpool.hxx>
69 #include <svx/svdview.hxx>
70 #include "misc.hxx"
71 #include "View.hxx"
72 #ifndef SVX_LIGHT
73 #ifndef SD_DRAW_DOC_SHELL_HXX
74 #include "DrawDocShell.hxx"
75 #endif
76 #endif
77 #include "ViewShell.hxx"
78 #include "DrawViewShell.hxx"
79 #include "unoobj.hxx"
80 #include "res_bmp.hrc"
81 #include "unokywds.hxx"
82 #include "unopback.hxx"
83 #include "unohelp.hxx"
84 
85 using ::com::sun::star::animations::XAnimationNode;
86 using ::com::sun::star::animations::XAnimationNodeSupplier;
87 using ::rtl::OUString;
88 using ::rtl::OUStringBuffer;
89 
90 using namespace ::vos;
91 using namespace ::osl;
92 using namespace ::com::sun::star;
93 using namespace ::com::sun::star::uno;
94 using namespace ::com::sun::star::lang;
95 using namespace ::com::sun::star::container;
96 using namespace ::com::sun::star::drawing;
97 using namespace ::com::sun::star::office;
98 
99 namespace sd {
100 extern Reference< XAnnotation > createAnnotation( const Reference< XComponentContext >& xContext, SdPage* );
101 extern Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& );
102 }
103 
104 /* this are the ids for page properties */
105 enum WID_PAGE
106 {
107 	WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH,
108 	WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER,
109 	WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP,
110 	WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL,
111 	WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK,
112 	WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT,
113 	WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
114 	WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
115 	WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
116     WID_NAVORDER
117 };
118 
119 #ifndef SEQTYPE
120  #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
121   #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
122  #else
123   #define SEQTYPE(x) &(x)
124  #endif
125 #endif
126 
127 static sal_Char __FAR_DATA sEmptyPageName[sizeof("page")] = "page";
128 
129 /** this function stores the property maps for draw pages in impress and draw */
130 const SvxItemPropertySet* ImplGetDrawPagePropertySet( sal_Bool bImpress, PageKind ePageKind )
131 {
132 	static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] =
133 	{
134 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND),		WID_PAGE_BACK,		&ITYPE( beans::XPropertySet ),					beans::PropertyAttribute::MAYBEVOID,0},
135 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM),			WID_PAGE_BOTTOM,	&::getCppuType((const sal_Int32*)0),			0,	0},
136 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT),				WID_PAGE_LEFT,		&::getCppuType((const sal_Int32*)0),			0,	0},
137 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT),			WID_PAGE_RIGHT,		&::getCppuType((const sal_Int32*)0),			0,	0},
138 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_TOP),				WID_PAGE_TOP,		&::getCppuType((const sal_Int32*)0),			0,	0},
139 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_CHANGE),			WID_PAGE_CHANGE,	&::getCppuType((const sal_Int32*)0),			0,	0},
140 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_DURATION),			WID_PAGE_DURATION,	&::getCppuType((const sal_Int32*)0),			0,	0},
141 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_EFFECT),			WID_PAGE_EFFECT,	&::getCppuType((const presentation::FadeEffect*)0),		0,	0},
142 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT),			WID_PAGE_HEIGHT,	&::getCppuType((const sal_Int32*)0),			0,	0},
143 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), 			WID_PAGE_LAYOUT,	&::getCppuType((const sal_Int16*)0),			0,	0},
144 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP),		WID_PAGE_LDBITMAP,	&ITYPE( awt::XBitmap),						    beans::PropertyAttribute::READONLY,	0},
145 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME),		WID_PAGE_LDNAME,	&::getCppuType((const OUString*)0),				beans::PropertyAttribute::READONLY,	0},
146 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER),			WID_PAGE_NUMBER,	&::getCppuType((const sal_Int16*)0),			beans::PropertyAttribute::READONLY,	0},
147 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION),		WID_PAGE_ORIENT,	&::getCppuType((const view::PaperOrientation*)0),0,	0},
148 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_SPEED),			WID_PAGE_SPEED,		&::getCppuType((const presentation::AnimationSpeed*)0),	0,	0},
149 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH),			WID_PAGE_WIDTH,		&::getCppuType((const sal_Int32*)0),			0,	0},
150 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW),			WID_PAGE_PREVIEW,	SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
151 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEWBITMAP),	WID_PAGE_PREVIEWBITMAP,	SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
152 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_VISIBLE),			WID_PAGE_VISIBLE,	&::getBooleanCppuType(),						0, 0},
153 		{ MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE),			WID_PAGE_SOUNDFILE,	&::getCppuType((const Any*)0),				0, 0},
154 		{ MAP_CHAR_LEN(sUNO_Prop_IsBackgroundVisible),	WID_PAGE_BACKVIS,	&::getBooleanCppuType(),						0, 0},
155 		{ MAP_CHAR_LEN(sUNO_Prop_IsBackgroundObjectsVisible),	WID_PAGE_BACKOBJVIS,	&::getBooleanCppuType(),						0, 0},
156 		{ MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0)  , 		0,     0},
157 		{ MAP_CHAR_LEN(sUNO_Prop_BookmarkURL),			WID_PAGE_BOOKMARK,	&::getCppuType((const OUString*)0),				0,	0},
158 		{ MAP_CHAR_LEN("IsBackgroundDark" ),			WID_PAGE_ISDARK,	&::getBooleanCppuType(),						beans::PropertyAttribute::READONLY, 0},
159 		{ MAP_CHAR_LEN("IsFooterVisible"),				WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(),					0, 0},
160 		{ MAP_CHAR_LEN("FooterText"),					WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0),				0,	0},
161 		{ MAP_CHAR_LEN("IsPageNumberVisible"),			WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(),					0, 0},
162 		{ MAP_CHAR_LEN("IsDateTimeVisible"),			WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(),					0, 0},
163 		{ MAP_CHAR_LEN("IsDateTimeFixed"),				WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(),					0, 0},
164 		{ MAP_CHAR_LEN("DateTimeText"),					WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0),				0,	0},
165 		{ MAP_CHAR_LEN("DateTimeFormat"),				WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0),			0,	0},
166 		{ MAP_CHAR_LEN("TransitionType"),				WID_TRANSITION_TYPE, &::getCppuType((const sal_Int16*)0),			0,	0},
167 		{ MAP_CHAR_LEN("TransitionSubtype"),			WID_TRANSITION_SUBTYPE, &::getCppuType((const sal_Int16*)0),			0,	0},
168 		{ MAP_CHAR_LEN("TransitionDirection"),			WID_TRANSITION_DIRECTION, &::getCppuType((const sal_Bool*)0),			0,	0},
169 		{ MAP_CHAR_LEN("TransitionFadeColor"),			WID_TRANSITION_FADE_COLOR, &::getCppuType((const sal_Int32*)0),			0,	0},
170 		{ MAP_CHAR_LEN("TransitionDuration"),			WID_TRANSITION_DURATION, &::getCppuType((const double*)0),			0,	0},
171 		{ MAP_CHAR_LEN("LoopSound"),					WID_LOOP_SOUND, &::getBooleanCppuType(),					0, 0},
172 		{ MAP_CHAR_LEN("NavigationOrder"),				WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0,	0},
173 		{0,0,0,0,0,0}
174 	};
175 
176 #define	DRAW_PAGE_NOTES_PROPERTIES \
177 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM),			WID_PAGE_BOTTOM,	&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
178 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT),				WID_PAGE_LEFT,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
179 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT),			WID_PAGE_RIGHT,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
180 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_TOP),				WID_PAGE_TOP,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
181 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT),			WID_PAGE_HEIGHT,	&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
182 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), 			WID_PAGE_LAYOUT,	&::getCppuType((const sal_Int16*)0),			0,	0},                                                                \
183 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP),		WID_PAGE_LDBITMAP,	&ITYPE( awt::XBitmap),						    beans::PropertyAttribute::READONLY,	0},                                \
184 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME),		WID_PAGE_LDNAME,	&::getCppuType((const OUString*)0),				beans::PropertyAttribute::READONLY,	0},                                \
185 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER),			WID_PAGE_NUMBER,	&::getCppuType((const sal_Int16*)0),			beans::PropertyAttribute::READONLY,	0},                                \
186 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION),		WID_PAGE_ORIENT,	&::getCppuType((const view::PaperOrientation*)0),0,	0},                                                                \
187 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH),			WID_PAGE_WIDTH,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                \
188 		{ MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  , 		0,     0},\
189 		{ MAP_CHAR_LEN("IsHeaderVisible"),				WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(),					0, 0},                                                                 \
190 		{ MAP_CHAR_LEN("HeaderText"),					WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0),				0,	0},                                                            \
191 		{ MAP_CHAR_LEN("IsBackgroundDark" ),			WID_PAGE_ISDARK,	&::getBooleanCppuType(),						beans::PropertyAttribute::READONLY, 0},                                \
192 		{ MAP_CHAR_LEN("IsFooterVisible"),				WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(),					0, 0},                                                                 \
193 		{ MAP_CHAR_LEN("FooterText"),					WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0),				0,	0},                                                            \
194 		{ MAP_CHAR_LEN("IsPageNumberVisible"),			WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(),					0, 0},                                                             \
195 		{ MAP_CHAR_LEN("IsDateTimeVisible"),			WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(),					0, 0},                                                                 \
196 		{ MAP_CHAR_LEN("IsDateTimeFixed"),				WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(),					0, 0},                                                                 \
197 		{ MAP_CHAR_LEN("DateTimeText"),					WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0),				0,	0},                                                            \
198 		{ MAP_CHAR_LEN("DateTimeFormat"),				WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0),			0,	0},                                                            \
199 		{ MAP_CHAR_LEN("NavigationOrder"),				WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0,	0},                                                            \
200 		{0,0,0,0,0,0}
201 
202 	static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] =
203 	{
204 		// this must be the first two entries so they can be excluded for PK_STANDARD
205 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND),		WID_PAGE_BACK,		&ITYPE( beans::XPropertySet ),					beans::PropertyAttribute::MAYBEVOID,0},
206 		DRAW_PAGE_NOTES_PROPERTIES
207 	};
208 	static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] =
209 	{
210 		DRAW_PAGE_NOTES_PROPERTIES
211 	};
212 
213 #define GRAPHIC_PAGE_PROPERTIES \
214 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM),			WID_PAGE_BOTTOM,	&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
215 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT),				WID_PAGE_LEFT,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
216 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT),			WID_PAGE_RIGHT,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
217 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_TOP),				WID_PAGE_TOP,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
218 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT),			WID_PAGE_HEIGHT,	&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
219 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP),		WID_PAGE_LDBITMAP,	&ITYPE(awt::XBitmap),						    beans::PropertyAttribute::READONLY,	0},                                             \
220 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME),		WID_PAGE_LDNAME,	&::getCppuType((const OUString*)0),			    beans::PropertyAttribute::READONLY,	0},                                             \
221 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER),			WID_PAGE_NUMBER,	&::getCppuType((const sal_Int16*)0),			beans::PropertyAttribute::READONLY,	0},                                             \
222 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION),		WID_PAGE_ORIENT,	&::getCppuType((const view::PaperOrientation*)0),0,	0},                                                                             \
223 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH),			WID_PAGE_WIDTH,		&::getCppuType((const sal_Int32*)0),			0,	0},                                                                             \
224 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW),			WID_PAGE_PREVIEW,	SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},    \
225 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEWBITMAP),	WID_PAGE_PREVIEWBITMAP,	SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},\
226 		{ MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0)  , 		0,     0},                          \
227 		{ MAP_CHAR_LEN(sUNO_Prop_BookmarkURL),			WID_PAGE_BOOKMARK,	&::getCppuType((const OUString*)0),				0,	0},                                                                             \
228 		{ MAP_CHAR_LEN("IsBackgroundDark" ),			WID_PAGE_ISDARK,	&::getBooleanCppuType(),						beans::PropertyAttribute::READONLY, 0},                                             \
229 		{ MAP_CHAR_LEN("NavigationOrder"),				WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0,	0},                                                                         \
230 		{0,0,0,0,0,0}
231 
232 	static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] =
233 	{
234 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND),		WID_PAGE_BACK,		&ITYPE( beans::XPropertySet),					beans::PropertyAttribute::MAYBEVOID,0},
235 		GRAPHIC_PAGE_PROPERTIES
236 	};
237 	static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] =
238 	{
239 	    GRAPHIC_PAGE_PROPERTIES
240 	};
241 
242 	//
243 	bool bWithoutBackground = ePageKind != PK_STANDARD && ePageKind != PK_HANDOUT;
244 	const SvxItemPropertySet* pRet = 0;
245 	if( bImpress )
246 	{
247 		if( ePageKind == PK_STANDARD )
248 		{
249 			//PK_STANDARD always has a background property
250 			static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
251 			pRet = &aDrawPagePropertySet_Impl;
252 		}
253 		else
254 		{
255 			if(bWithoutBackground)
256 			{
257 			    static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
258 			    pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl;
259 		    }
260 			else
261 			{
262 			    static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
263 			    pRet = &aDrawPageNotesHandoutPropertySet_Impl;
264 		    }
265 		}
266 	}
267 	else
268 	{
269 			if(bWithoutBackground)
270 			{
271 			    static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
272 			    pRet = &aGraphicPagePropertyNoBackSet_Impl;
273 		    }
274 			else
275 			{
276 			    static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
277 			    pRet = &aGraphicPagePropertySet_Impl;
278 		    }
279     }
280     return pRet;
281 }
282 
283 /** this function stores the property map for master pages in impress and draw */
284 const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
285 {
286 	static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] =
287 	{
288 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND),		WID_PAGE_BACK,		&ITYPE(beans::XPropertySet),					0,  0},
289 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM),			WID_PAGE_BOTTOM,	&::getCppuType((const sal_Int32*)0),			0,	0},
290 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT),				WID_PAGE_LEFT,		&::getCppuType((const sal_Int32*)0),			0,	0},
291 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT),			WID_PAGE_RIGHT,		&::getCppuType((const sal_Int32*)0),			0,	0},
292 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_TOP),				WID_PAGE_TOP,		&::getCppuType((const sal_Int32*)0),			0,	0},
293 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT),			WID_PAGE_HEIGHT,	&::getCppuType((const sal_Int32*)0),			0,	0},
294 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP),		WID_PAGE_LDBITMAP,	&ITYPE(awt::XBitmap),							beans::PropertyAttribute::READONLY,	0},
295 		{ MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME),	    WID_PAGE_LDNAME,	&::getCppuType((const OUString*)0),			    beans::PropertyAttribute::READONLY,	0},
296 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER),			WID_PAGE_NUMBER,	&::getCppuType((const sal_Int16*)0),			beans::PropertyAttribute::READONLY,	0},
297 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION),		WID_PAGE_ORIENT,	&::getCppuType((const view::PaperOrientation*)0),0,	0},
298 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH),			WID_PAGE_WIDTH,		&::getCppuType((const sal_Int32*)0),			0,	0},
299 		{ MAP_CHAR_LEN("BackgroundFullSize"),			WID_PAGE_BACKFULL,	&::getBooleanCppuType(),						0, 0},
300 		{ MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0)  , 		0,     0},
301 		{ MAP_CHAR_LEN("IsBackgroundDark" ),			WID_PAGE_ISDARK,	&::getBooleanCppuType(),						beans::PropertyAttribute::READONLY, 0},
302 		{0,0,0,0,0,0}
303 	};
304 
305 	static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
306 	{
307 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM),			WID_PAGE_BOTTOM,	&::getCppuType((const sal_Int32*)0),			0,	0},
308 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT),				WID_PAGE_LEFT,		&::getCppuType((const sal_Int32*)0),			0,	0},
309 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT),			WID_PAGE_RIGHT,		&::getCppuType((const sal_Int32*)0),			0,	0},
310 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_TOP),				WID_PAGE_TOP,		&::getCppuType((const sal_Int32*)0),			0,	0},
311 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT),			WID_PAGE_HEIGHT,	&::getCppuType((const sal_Int32*)0),			0,	0},
312 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION),		WID_PAGE_ORIENT,	&::getCppuType((const view::PaperOrientation*)0),0,	0},
313 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER),			WID_PAGE_NUMBER,	&::getCppuType((const sal_Int16*)0),			beans::PropertyAttribute::READONLY,	0},
314 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH),			WID_PAGE_WIDTH,		&::getCppuType((const sal_Int32*)0),			0,	0},
315 		{ MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), 			WID_PAGE_LAYOUT,	&::getCppuType((const sal_Int16*)0),			0,	0},
316 		{ MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0)  , 		0,     0},
317 		{ MAP_CHAR_LEN("IsBackgroundDark" ),			WID_PAGE_ISDARK,	&::getBooleanCppuType(),						beans::PropertyAttribute::READONLY, 0},
318 		{ MAP_CHAR_LEN("IsHeaderVisible"),				WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(),					0, 0},
319 		{ MAP_CHAR_LEN("HeaderText"),					WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0),				0,	0},
320 		{ MAP_CHAR_LEN("IsFooterVisible"),				WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(),					0, 0},
321 		{ MAP_CHAR_LEN("FooterText"),					WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0),				0,	0},
322 		{ MAP_CHAR_LEN("IsPageNumberVisible"),			WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(),					0, 0},
323 		{ MAP_CHAR_LEN("IsDateTimeVisible"),			WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(),					0, 0},
324 		{ MAP_CHAR_LEN("IsDateTimeFixed"),				WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(),					0, 0},
325 		{ MAP_CHAR_LEN("DateTimeText"),					WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0),				0,	0},
326 		{ MAP_CHAR_LEN("DateTimeFormat"),				WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0),			0,	0},
327 		{0,0,0,0,0,0}
328 	};
329 
330 	const SvxItemPropertySet* pRet = 0;
331 	if( ePageKind == PK_HANDOUT )
332 	{
333 		static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
334 		pRet = &aHandoutMasterPagePropertySet_Impl;
335 	}
336 	else
337 	{
338 		static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
339 		pRet = &aMasterPagePropertySet_Impl;
340 	}
341 	return pRet;
342 }
343 
344 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw()
345 {
346         static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
347         if( !pSeq )
348         {
349                 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
350                 if( !pSeq )
351                 {
352                         static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
353                         rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
354                         pSeq = &aSeq;
355                 }
356         }
357         return *pSeq;
358 }
359 
360 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException)
361 {
362         if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
363             rId.getConstArray(), 16 ) )
364         {
365                 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
366         }
367         else
368         {
369                 return SvxFmDrawPage::getSomething( rId );
370         }
371 }
372 
373 /***********************************************************************
374 *                                                                      *
375 ***********************************************************************/
376 SdGenericDrawPage::SdGenericDrawPage( SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet ) throw()
377 :		SvxFmDrawPage( (SdrPage*) pInPage ),
378 		SdUnoSearchReplaceShape(this),
379 		mpModel		( _pModel ),
380 		mpSdrModel(0),
381 		mnTempPageNumber(0),
382 		mpPropSet	( _pSet ),
383 		mbIsImpressDocument(false)
384 {
385 	mpSdrModel = SvxFmDrawPage::mpModel;
386 	if( mpModel )
387 		mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
388 
389 }
390 
391 SdGenericDrawPage::~SdGenericDrawPage() throw()
392 {
393 }
394 
395 void SdGenericDrawPage::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException )
396 {
397 	if( (SvxFmDrawPage::mpModel == 0) || (mpModel == 0) || (SvxFmDrawPage::mpPage == 0) )
398 		throw lang::DisposedException();
399 }
400 
401 SdXImpressDocument* SdGenericDrawPage::GetModel() const
402 {
403 	if( mpSdrModel != SvxFmDrawPage::mpModel )
404 	{
405 		const_cast< SdGenericDrawPage* >(this)->mpSdrModel = SvxFmDrawPage::mpModel;
406 		if( mpSdrModel )
407 		{
408 			uno::Reference< uno::XInterface > xModel( SvxFmDrawPage::mpModel->getUnoModel() );
409 			const_cast< SdGenericDrawPage*>(this)->mpModel = SdXImpressDocument::getImplementation( xModel );
410 			if( mpModel )
411 				const_cast< SdGenericDrawPage*>(this)->mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
412 		}
413 		else
414 		{
415 			const_cast< SdGenericDrawPage* >(this)->mpModel = 0;
416 		}
417 	}
418 
419 	return mpModel;
420 }
421 
422 // this is called whenever a SdrObject must be created for a empty api shape wrapper
423 SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShape >& xShape ) throw()
424 {
425 	if( NULL == SvxFmDrawPage::mpPage || !xShape.is() )
426 		return NULL;
427 
428 	String aType( xShape->getShapeType() );
429 	const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") );
430 	if( aType.CompareTo( aPrefix, aPrefix.Len() ) != 0 )
431     {
432         SdrObject* pObj = SvxFmDrawPage::_CreateSdrObject( xShape );
433         if( pObj && ( (pObj->GetObjInventor() != SdrInventor) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
434         {
435 			SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
436             if( pDoc )
437                 pObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
438         }
439 		return pObj;
440     }
441 
442 	aType = aType.Copy( aPrefix.Len() );
443 
444 	PresObjKind eObjKind = PRESOBJ_NONE;
445 
446 	if( aType.EqualsAscii( "TitleTextShape" ) )
447 	{
448 		eObjKind = PRESOBJ_TITLE;
449 	}
450 	else if( aType.EqualsAscii( "OutlinerShape" ) )
451 	{
452 		eObjKind = PRESOBJ_OUTLINE;
453 	}
454 	else if( aType.EqualsAscii( "SubtitleShape" ) )
455 	{
456 		eObjKind = PRESOBJ_TEXT;
457 	}
458 	else if( aType.EqualsAscii( "OLE2Shape" ) )
459 	{
460 		eObjKind = PRESOBJ_OBJECT;
461 	}
462 	else if( aType.EqualsAscii( "ChartShape" ) )
463 	{
464 		eObjKind = PRESOBJ_CHART;
465 	}
466 	else if( aType.EqualsAscii( "CalcShape" ) )
467 	{
468 		eObjKind = PRESOBJ_CALC;
469 	}
470 	else if( aType.EqualsAscii( "TableShape" ) )
471 	{
472 		eObjKind = PRESOBJ_TABLE;
473 	}
474 	else if( aType.EqualsAscii( "GraphicObjectShape" ) )
475 	{
476 #ifdef STARIMAGE_AVAILABLE
477 		eObjKind = PRESOBJ_IMAGE;
478 #else
479 		eObjKind = PRESOBJ_GRAPHIC;
480 #endif
481 	}
482 	else if( aType.EqualsAscii( "OrgChartShape" ) )
483 	{
484 		eObjKind = PRESOBJ_ORGCHART;
485 	}
486 	else if( aType.EqualsAscii( "PageShape" ) )
487 	{
488 		if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
489 			eObjKind = PRESOBJ_TITLE;
490 		else
491 			eObjKind = PRESOBJ_PAGE;
492 	}
493 	else if( aType.EqualsAscii( "NotesShape" ) )
494 	{
495 		eObjKind = PRESOBJ_NOTES;
496 	}
497 	else if( aType.EqualsAscii( "HandoutShape" ) )
498 	{
499 		eObjKind = PRESOBJ_HANDOUT;
500 	}
501 	else if( aType.EqualsAscii( "FooterShape" ) )
502 	{
503 		eObjKind = PRESOBJ_FOOTER;
504 	}
505 	else if( aType.EqualsAscii( "HeaderShape" ) )
506 	{
507 		eObjKind = PRESOBJ_HEADER;
508 	}
509 	else if( aType.EqualsAscii( "SlideNumberShape" ) )
510 	{
511 		eObjKind = PRESOBJ_SLIDENUMBER;
512 	}
513 	else if( aType.EqualsAscii( "DateTimeShape" ) )
514 	{
515 		eObjKind = PRESOBJ_DATETIME;
516 	}
517 	else if( aType.EqualsAscii( "MediaShape" ) )
518 	{
519 		eObjKind = PRESOBJ_MEDIA;
520 	}
521 
522 	Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect()  );
523 
524 	const awt::Point aPos( aRect.Left(), aRect.Top() );
525 	xShape->setPosition( aPos );
526 
527 	const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
528 	xShape->setSize( aSize );
529 
530 	SdrObject *pPresObj = 0;
531 	if( (eObjKind == PRESOBJ_TABLE) || (eObjKind == PRESOBJ_MEDIA) )
532 	{
533         pPresObj = SvxFmDrawPage::_CreateSdrObject( xShape );
534         if( pPresObj )
535         {
536 			SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
537             if( pDoc )
538                 pPresObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
539 			GetPage()->InsertPresObj( pPresObj, eObjKind );
540 		}
541 	}
542 	else
543 	{
544 		pPresObj = GetPage()->CreatePresObj( eObjKind, sal_False, aRect, sal_True );
545 	}
546 
547 	if( pPresObj )
548 		pPresObj->SetUserCall( GetPage() );
549 
550 	return pPresObj;
551 }
552 
553 // XInterface
554 Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType )
555 	throw(uno::RuntimeException)
556 {
557 	Any aAny;
558 
559 	QUERYINT( beans::XPropertySet );
560 	else QUERYINT( container::XNamed );
561 	else QUERYINT( util::XReplaceable );
562 	else QUERYINT( util::XSearchable );
563 	else QUERYINT( document::XLinkTargetSupplier );
564 	else QUERYINT( drawing::XShapeCombiner );
565 	else QUERYINT( drawing::XShapeBinder );
566 	else QUERYINT( beans::XMultiPropertySet );
567 	else if( rType == ITYPE( office::XAnnotationAccess ) )
568 	{
569 		return Any( Reference< office::XAnnotationAccess >( this ) );
570 	}
571 	else if( rType == ITYPE( XAnimationNodeSupplier ) )
572 	{
573 		if( mbIsImpressDocument )
574 		{
575 			const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
576 
577 			if( ePageKind == PK_STANDARD )
578 				return makeAny( Reference< XAnimationNodeSupplier >( this ) );
579 		}
580 	}
581 	else
582 		return SvxDrawPage::queryInterface( rType );
583 
584 	return aAny;
585 }
586 
587 // XPropertySet
588 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo()
589 	throw(uno::RuntimeException)
590 {
591 	OGuard aGuard( Application::GetSolarMutex() );
592 	throwIfDisposed();
593 	return mpPropSet->getPropertySetInfo();
594 }
595 
596 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
597 	throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
598 {
599 	OGuard aGuard( Application::GetSolarMutex() );
600 
601 	throwIfDisposed();
602 
603 	const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
604 
605 	switch( pEntry ? pEntry->nWID : -1 )
606 	{
607 		case WID_NAVORDER:
608 			setNavigationOrder( aValue );
609 			break;
610 		case WID_PAGE_LEFT:
611 		case WID_PAGE_RIGHT:
612 		case WID_PAGE_TOP:
613 		case WID_PAGE_BOTTOM:
614 		case WID_PAGE_LAYOUT:
615 		case WID_PAGE_DURATION:
616 		case WID_PAGE_CHANGE:
617 		{
618 			sal_Int32 nValue = 0;
619 			if(!(aValue >>= nValue))
620 				throw lang::IllegalArgumentException();
621 
622 			switch( pEntry->nWID )
623 			{
624 			case WID_PAGE_LEFT:
625 				SetLftBorder(nValue);
626 				break;
627 			case WID_PAGE_RIGHT:
628 				SetRgtBorder( nValue );
629 				break;
630 			case WID_PAGE_TOP:
631 				SetUppBorder( nValue );
632 				break;
633 			case WID_PAGE_BOTTOM:
634 				SetLwrBorder( nValue );
635 				break;
636 			case WID_PAGE_CHANGE:
637 				GetPage()->SetPresChange( (PresChange)nValue );
638 				break;
639 			case WID_PAGE_LAYOUT:
640 				GetPage()->SetAutoLayout( (AutoLayout)nValue, sal_True );
641 				break;
642 			case WID_PAGE_DURATION:
643 				GetPage()->SetTime((sal_uInt32)nValue);
644 				break;
645 			}
646 			break;
647 		}
648 		case WID_PAGE_WIDTH:
649 		{
650 			sal_Int32 nWidth = 0;
651 			if(!(aValue >>= nWidth))
652 				throw lang::IllegalArgumentException();
653 
654 			SetWidth( nWidth );
655 			break;
656 		}
657 		case WID_PAGE_HEIGHT:
658 		{
659 			sal_Int32 nHeight = 0;
660 			if(!(aValue >>= nHeight))
661 				throw lang::IllegalArgumentException();
662 
663 			SetHeight( nHeight );
664 			break;
665 		}
666 		case WID_PAGE_ORIENT:
667 		{
668 			sal_Int32 nEnum = 0;
669 			if(!::cppu::enum2int( nEnum, aValue ))
670 				throw lang::IllegalArgumentException();
671 
672 			Orientation eOri = (((view::PaperOrientation)nEnum) == view::PaperOrientation_PORTRAIT)?ORIENTATION_PORTRAIT:ORIENTATION_LANDSCAPE;
673 
674 			if( eOri != GetPage()->GetOrientation() )
675 			{
676 				SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
677 				const PageKind ePageKind = GetPage()->GetPageKind();
678 
679 				sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
680 				for (i = 0; i < nPageCnt; i++)
681 				{
682 					SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
683 					pPage->SetOrientation( eOri );
684 				}
685 
686 				nPageCnt = pDoc->GetSdPageCount(ePageKind);
687 
688 				for (i = 0; i < nPageCnt; i++)
689 				{
690 					SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
691 					pPage->SetOrientation( eOri );
692 				}
693 			}
694 			break;
695 		}
696 		case WID_PAGE_EFFECT:
697 		{
698 			sal_Int32 nEnum = 0;
699 			if(!::cppu::enum2int( nEnum, aValue ))
700 				throw lang::IllegalArgumentException();
701 
702 			GetPage()->SetFadeEffect( (presentation::FadeEffect)nEnum );
703 			break;
704 		}
705 		case WID_PAGE_BACK:
706 			setBackground( aValue );
707 			break;
708 		case WID_PAGE_SPEED:
709 		{
710 			sal_Int32 nEnum = 0;
711 			if(!::cppu::enum2int( nEnum, aValue ))
712 				throw lang::IllegalArgumentException();
713 
714 			GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 )  );
715 			break;
716 		}
717 		case WID_PAGE_VISIBLE :
718 		{
719 			sal_Bool	bVisible = sal_False;
720 			if( ! ( aValue >>= bVisible ) )
721 				throw lang::IllegalArgumentException();
722 			GetPage()->SetExcluded( bVisible == sal_False );
723 			break;
724 		}
725 		case WID_PAGE_SOUNDFILE :
726 		{
727 			OUString aURL;
728 			if( aValue >>= aURL )
729 			{
730 				GetPage()->SetSoundFile( aURL );
731 				GetPage()->SetSound( aURL.getLength() != 0 ? sal_True : sal_False );
732 				break;
733 			}
734 			else
735 			{
736 				sal_Bool bStopSound = sal_False;
737 				if( aValue >>= bStopSound )
738 				{
739 					GetPage()->SetStopSound( bStopSound ? true : false );
740 					break;
741 				}
742 			}
743 
744 
745 			throw lang::IllegalArgumentException();
746 		}
747 		case WID_LOOP_SOUND:
748 		{
749 			sal_Bool bLoop = sal_False;
750 			if( ! (aValue >>= bLoop) )
751 				throw lang::IllegalArgumentException();
752 
753 			GetPage()->SetLoopSound( bLoop ? true : false );
754 			break;
755 		}
756 		case WID_PAGE_BACKFULL:
757 		{
758 			sal_Bool	bFullSize = sal_False;
759 			if( ! ( aValue >>= bFullSize ) )
760 				throw lang::IllegalArgumentException();
761 			GetPage()->SetBackgroundFullSize( bFullSize );
762 			break;
763 		}
764 		case WID_PAGE_BACKVIS:
765 		{
766 			sal_Bool bVisible = sal_False;
767 			if( ! ( aValue >>= bVisible ) )
768 				throw lang::IllegalArgumentException();
769 
770 			SdrPage* pPage = GetPage();
771 			if( pPage )
772 			{
773 				SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
774 				if( pDoc->GetMasterPageCount() )
775 				{
776 					SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
777 					SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
778 					aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False), bVisible);
779 					pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
780 				}
781 			}
782 			break;
783 		}
784 		case WID_PAGE_BACKOBJVIS:
785 		{
786 			sal_Bool bVisible = sal_False;
787 			if( ! ( aValue >>= bVisible ) )
788 				throw lang::IllegalArgumentException();
789 
790 			SdrPage* pPage = GetPage();
791 			if( pPage )
792 			{
793 				SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
794 				if( pDoc->GetMasterPageCount() )
795 				{
796 					SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
797 					SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
798 					aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False), bVisible);
799 					pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
800 				}
801 			}
802 
803 			break;
804 		}
805 		case WID_PAGE_USERATTRIBS:
806 		{
807 			if( !GetPage()->setAlienAttributes( aValue ) )
808 				throw lang::IllegalArgumentException();
809 			break;
810 		}
811 		case WID_PAGE_BOOKMARK:
812 		{
813 			OUString aBookmarkURL;
814 			if( ! ( aValue >>= aBookmarkURL ) )
815 				throw lang::IllegalArgumentException();
816 
817 			setBookmarkURL( aBookmarkURL );
818 			break;
819 		}
820 
821 		case WID_PAGE_HEADERVISIBLE:
822 		case WID_PAGE_HEADERTEXT:
823 		case WID_PAGE_FOOTERVISIBLE:
824 		case WID_PAGE_FOOTERTEXT:
825 		case WID_PAGE_PAGENUMBERVISIBLE:
826 		case WID_PAGE_DATETIMEVISIBLE:
827 		case WID_PAGE_DATETIMEFIXED:
828 		case WID_PAGE_DATETIMETEXT:
829 		case WID_PAGE_DATETIMEFORMAT:
830 		{
831 			sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() );
832 
833 			switch( pEntry->nWID )
834 			{
835 			case WID_PAGE_HEADERVISIBLE:
836 			{
837 				sal_Bool bVisible = sal_False;
838 				if( ! ( aValue >>= bVisible ) )
839 					throw lang::IllegalArgumentException();
840 
841 				aHeaderFooterSettings.mbHeaderVisible = bVisible;
842 				break;
843 			}
844 			case WID_PAGE_HEADERTEXT:
845 			{
846 				OUString aText;
847 				if( ! ( aValue >>= aText ) )
848 					throw lang::IllegalArgumentException();
849 
850 				aHeaderFooterSettings.maHeaderText = aText;
851 				break;
852 			}
853 			case WID_PAGE_FOOTERVISIBLE:
854 			{
855 				sal_Bool bVisible = sal_False;
856 				if( ! ( aValue >>= bVisible ) )
857 					throw lang::IllegalArgumentException();
858 
859 				aHeaderFooterSettings.mbFooterVisible = bVisible;
860 				break;
861 			}
862 			case WID_PAGE_FOOTERTEXT:
863 			{
864 				OUString aText;
865 				if( ! ( aValue >>= aText ) )
866 					throw lang::IllegalArgumentException();
867 
868 				aHeaderFooterSettings.maFooterText = aText;
869 				break;
870 			}
871 			case WID_PAGE_PAGENUMBERVISIBLE:
872 			{
873 				sal_Bool bVisible = sal_False;
874 				if( ! ( aValue >>= bVisible ) )
875 					throw lang::IllegalArgumentException();
876 
877 				aHeaderFooterSettings.mbSlideNumberVisible = bVisible;
878 				break;
879 			}
880 			case WID_PAGE_DATETIMEVISIBLE:
881 			{
882 				sal_Bool bVisible = sal_False;
883 				if( ! ( aValue >>= bVisible ) )
884 					throw lang::IllegalArgumentException();
885 
886 				aHeaderFooterSettings.mbDateTimeVisible = bVisible;
887 				break;
888 			}
889 			case WID_PAGE_DATETIMEFIXED:
890 			{
891 				sal_Bool bVisible = sal_False;
892 				if( ! ( aValue >>= bVisible ) )
893 					throw lang::IllegalArgumentException();
894 
895 				aHeaderFooterSettings.mbDateTimeIsFixed = bVisible;
896 				break;
897 			}
898 			case WID_PAGE_DATETIMETEXT:
899 			{
900 				OUString aText;
901 				if( ! ( aValue >>= aText ) )
902 					throw lang::IllegalArgumentException();
903 
904 				aHeaderFooterSettings.maDateTimeText = aText;
905 				break;
906 			}
907 			case WID_PAGE_DATETIMEFORMAT:
908 			{
909 				sal_Int32 nValue = 0;
910 				if( ! ( aValue >>= nValue ) )
911 					throw lang::IllegalArgumentException();
912 
913 				aHeaderFooterSettings.meDateTimeFormat = nValue;
914 				break;
915 			}
916 			}
917 
918 			if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) )
919 				GetPage()->setHeaderFooterSettings( aHeaderFooterSettings );
920 
921 			break;
922 		}
923 
924 		case WID_PAGE_NUMBER:
925 			if( (GetPage()->GetPageKind() == PK_HANDOUT) && !GetPage()->IsMasterPage() )
926 			{
927 				if( !(aValue >>= mnTempPageNumber) )
928 					throw lang::IllegalArgumentException();
929 
930 				break;
931 			}
932 			throw beans::PropertyVetoException();
933 
934 		case WID_PAGE_LDBITMAP:
935 		case WID_PAGE_LDNAME:
936 		case WID_PAGE_ISDARK:
937 			throw beans::PropertyVetoException();
938 
939 		case WID_TRANSITION_TYPE:
940 		{
941 			sal_Int16 nValue = 0;
942 			if( ! ( aValue >>= nValue ) )
943 				throw lang::IllegalArgumentException();
944 
945 			GetPage()->setTransitionType( nValue );
946 			break;
947 		}
948 
949 		case WID_TRANSITION_SUBTYPE:
950 		{
951 			sal_Int16 nValue = 0;
952 			if( ! ( aValue >>= nValue ) )
953 				throw lang::IllegalArgumentException();
954 
955 			GetPage()->setTransitionSubtype( nValue );
956 			break;
957 		}
958 
959 		case WID_TRANSITION_DIRECTION:
960 		{
961 			sal_Bool bValue = sal_False;
962 			if( ! ( aValue >>= bValue ) )
963 				throw lang::IllegalArgumentException();
964 
965 			GetPage()->setTransitionDirection( bValue );
966 			break;
967 		}
968 
969 		case WID_TRANSITION_FADE_COLOR:
970 		{
971 			sal_Int32 nValue = 0;
972 			if( ! ( aValue >>= nValue ) )
973 				throw lang::IllegalArgumentException();
974 
975 			GetPage()->setTransitionFadeColor( nValue );
976 			break;
977 		}
978 
979 		case WID_TRANSITION_DURATION:
980 		{
981 			double fValue = 0.0;
982 			if( ! ( aValue >>= fValue ) )
983 				throw lang::IllegalArgumentException();
984 
985 			GetPage()->setTransitionDuration( fValue );
986 			break;
987 		}
988 
989 		default:
990 			throw beans::UnknownPropertyException();
991 	}
992 
993 	GetModel()->SetModified();
994 }
995 
996 /***********************************************************************
997 *                                                                      *
998 ***********************************************************************/
999 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
1000 	throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1001 {
1002 	OGuard aGuard( Application::GetSolarMutex() );
1003 
1004 	throwIfDisposed();
1005 
1006 	uno::Any aAny;
1007 
1008 	const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
1009 
1010 	switch( pEntry ? pEntry->nWID : -1 )
1011 	{
1012 	case WID_NAVORDER:
1013 		aAny = getNavigationOrder();
1014 		break;
1015 	case WID_PAGE_LEFT:
1016 		aAny <<= (sal_Int32)( GetPage()->GetLftBorder() );
1017 		break;
1018 	case WID_PAGE_RIGHT:
1019 		aAny <<= (sal_Int32)( GetPage()->GetRgtBorder() );
1020 		break;
1021 	case WID_PAGE_TOP:
1022 		aAny <<= (sal_Int32)( GetPage()->GetUppBorder() );
1023 		break;
1024 	case WID_PAGE_BOTTOM:
1025 		aAny <<= (sal_Int32)( GetPage()->GetLwrBorder() );
1026 		break;
1027 	case WID_PAGE_WIDTH:
1028 		aAny <<= (sal_Int32)( GetPage()->GetSize().getWidth() );
1029 		break;
1030 	case WID_PAGE_HEIGHT:
1031 		aAny <<= (sal_Int32)( GetPage()->GetSize().getHeight() );
1032 		break;
1033 	case WID_PAGE_ORIENT:
1034 		aAny = ::cppu::int2enum( (sal_Int32)((GetPage()->GetOrientation() == ORIENTATION_PORTRAIT)? view::PaperOrientation_PORTRAIT: view::PaperOrientation_LANDSCAPE), ::getCppuType((const view::PaperOrientation*)0) );
1035 		break;
1036 	case WID_PAGE_EFFECT:
1037 		aAny = ::cppu::int2enum( (sal_Int32)GetPage()->GetFadeEffect(), ::getCppuType((const presentation::FadeEffect*)0) );
1038 		break;
1039 	case WID_PAGE_CHANGE:
1040 		aAny <<= (sal_Int32)( GetPage()->GetPresChange() );
1041 		break;
1042 	case WID_PAGE_SPEED:
1043 		{
1044 			const double fDuration = GetPage()->getTransitionDuration();
1045 			aAny = ::cppu::int2enum( fDuration < 2.0 ? 2 : (fDuration > 2.0 ? 0 : 1), ::getCppuType((const presentation::AnimationSpeed*)0) );
1046 		}
1047 		break;
1048 	case WID_PAGE_LAYOUT:
1049 		aAny <<= (sal_Int16)( GetPage()->GetAutoLayout() );
1050 		break;
1051 	case WID_PAGE_NUMBER:
1052         {
1053             const sal_uInt16 nPageNumber(GetPage()->GetPageNum());
1054 
1055             if(nPageNumber > 0)
1056             {
1057                 // for all other pages calculate the number
1058         		aAny <<= (sal_Int16)((sal_uInt16)((nPageNumber-1)>>1) + 1);
1059             }
1060             else
1061             {
1062                 aAny <<= mnTempPageNumber;
1063             }
1064         }
1065 		break;
1066 	case WID_PAGE_DURATION:
1067 		aAny <<= (sal_Int32)(GetPage()->GetTime());
1068 		break;
1069 	case WID_PAGE_LDNAME:
1070 	{
1071 		const OUString aName( GetPage()->GetName() );
1072 		aAny <<= aName;
1073 		break;
1074 	}
1075 	case WID_PAGE_LDBITMAP:
1076 		{
1077             sal_Bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
1078             Reference< awt::XBitmap > xBitmap(
1079                 VCLUnoHelper::CreateBitmap( BitmapEx( SdResId( bHC ? BMP_PAGE_H : BMP_PAGE ) ) ) );
1080 			aAny <<= xBitmap;
1081 		}
1082 		break;
1083 	case WID_PAGE_BACK:
1084 		getBackground( aAny );
1085 		break;
1086 	case WID_PAGE_PREVIEW :
1087 		{
1088 			SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1089 			if ( pDoc )
1090 			{
1091 				::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1092 				if ( pDocShell )
1093 				{
1094 					sal_uInt16 nPgNum = 0;
1095 					sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1096 					sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1097 					while( nPgNum < nPageCount )
1098 					{
1099 						pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1100 						nPgNum++;
1101 					}
1102                     ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1103                         pDocShell->GetPreviewMetaFile();
1104 					if ( pMetaFile )
1105 					{
1106 						Point	aPoint;
1107 						Size	aSize( GetPage()->GetSize() );
1108 						pMetaFile->AddAction( (MetaAction*) new MetaFillColorAction( COL_WHITE, sal_True ), 0 );
1109 						pMetaFile->AddAction( (MetaAction*) new MetaRectAction( Rectangle( aPoint, aSize ) ), 1 );
1110 						pMetaFile->SetPrefMapMode( MAP_100TH_MM );
1111 						pMetaFile->SetPrefSize( aSize );
1112 
1113 						SvMemoryStream aDestStrm( 65535, 65535 );
1114 						ConvertGDIMetaFileToWMF( *pMetaFile, aDestStrm, NULL, sal_False );
1115 						Sequence<sal_Int8> aSeq( (sal_Int8*)aDestStrm.GetData(), aDestStrm.Tell() );
1116 						aAny <<= aSeq;
1117 					}
1118 				}
1119 			}
1120 		}
1121 		break;
1122 
1123 	case WID_PAGE_PREVIEWBITMAP :
1124 		{
1125 			SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1126 			if ( pDoc )
1127 			{
1128 				::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1129 				if ( pDocShell )
1130 				{
1131 					sal_uInt16 nPgNum = 0;
1132 					sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1133 					sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1134 					while( nPgNum < nPageCount )
1135 					{
1136 						pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1137 						nPgNum++;
1138 					}
1139                     ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1140                         pDocShell->GetPreviewMetaFile();
1141 					BitmapEx aBitmap;
1142 					if ( pMetaFile && pMetaFile->CreateThumbnail( 160, /* magic value taken from GraphicHelper::getThumbnailFormatFromGDI_Impl() */
1143 																  aBitmap ) )
1144 					{
1145 						SvMemoryStream aMemStream;
1146 						aBitmap.GetBitmap().Write( aMemStream, sal_False, sal_False );
1147 						uno::Sequence<sal_Int8> aSeq( (sal_Int8*)aMemStream.GetData(), aMemStream.Tell() );
1148 						aAny <<= aSeq;
1149 					}
1150 				}
1151 			}
1152 		}
1153 		break;
1154 
1155 	case WID_PAGE_VISIBLE :
1156 	{
1157 		sal_Bool bVisible = GetPage()->IsExcluded() == sal_False;
1158 		aAny <<= Any( &bVisible, ::getBooleanCppuType() );
1159 		break;
1160 	}
1161 
1162 	case WID_PAGE_SOUNDFILE :
1163 	{
1164 		if( GetPage()->IsStopSound() )
1165 		{
1166 			aAny <<= sal_True;
1167 		}
1168 		else
1169 		{
1170 			OUString aURL;
1171 			if( GetPage()->IsSoundOn() )
1172 				aURL = GetPage()->GetSoundFile();
1173 			aAny <<= aURL;
1174 		}
1175 		break;
1176 	}
1177 	case WID_LOOP_SOUND:
1178 	{
1179 		aAny <<= (sal_Bool)GetPage()->IsLoopSound();
1180 		break;
1181 	}
1182 	case WID_PAGE_BACKFULL:
1183 	{
1184 		sal_Bool bFullSize = GetPage()->IsBackgroundFullSize();
1185 		aAny = Any( &bFullSize, ::getBooleanCppuType() );
1186 		break;
1187 	}
1188 	case WID_PAGE_BACKVIS:
1189 	{
1190 		SdrPage* pPage = GetPage();
1191 		if( pPage )
1192 		{
1193 			SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1194 			if( pDoc->GetMasterPageCount() )
1195 			{
1196 				SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1197 				SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1198 				aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False));
1199 			}
1200 			else
1201 			{
1202 				aAny <<= (sal_Bool)sal_False;
1203 			}
1204 		}
1205 		break;
1206 	}
1207 	case WID_PAGE_BACKOBJVIS:
1208 	{
1209 		SdrPage* pPage = GetPage();
1210 		if( pPage )
1211 		{
1212 			SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1213 			if( pDoc->GetMasterPageCount() )
1214 			{
1215 				SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1216 				SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1217 				aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False));
1218 			}
1219 			else
1220 			{
1221 				aAny <<= (sal_Bool)sal_False;
1222 			}
1223 		}
1224 		break;
1225 	}
1226 	case WID_PAGE_USERATTRIBS:
1227 	{
1228 		GetPage()->getAlienAttributes( aAny );
1229 		break;
1230 	}
1231 	case WID_PAGE_BOOKMARK:
1232 	{
1233 		aAny <<= getBookmarkURL();
1234 		break;
1235 	}
1236 	case WID_PAGE_ISDARK:
1237 	{
1238 		aAny <<= (sal_Bool)GetPage()->GetPageBackgroundColor().IsDark();
1239 		break;
1240 	}
1241 	case WID_PAGE_HEADERVISIBLE:
1242 		aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbHeaderVisible;
1243 		break;
1244 	case WID_PAGE_HEADERTEXT:
1245 		{
1246 			const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText );
1247 			aAny <<= aText;
1248 		}
1249 		break;
1250 	case WID_PAGE_FOOTERVISIBLE:
1251 		aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbFooterVisible;
1252 		break;
1253 	case WID_PAGE_FOOTERTEXT:
1254 		{
1255 			const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText );
1256 			aAny <<= aText;
1257 		}
1258 		break;
1259 	case WID_PAGE_PAGENUMBERVISIBLE:
1260 		aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbSlideNumberVisible;
1261 		break;
1262 	case WID_PAGE_DATETIMEVISIBLE:
1263 		aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeVisible;
1264 		break;
1265 	case WID_PAGE_DATETIMEFIXED:
1266 		aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed;
1267 		break;
1268 	case WID_PAGE_DATETIMETEXT:
1269 		{
1270 			const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText );
1271 			aAny <<= aText;
1272 		}
1273 		break;
1274 	case WID_PAGE_DATETIMEFORMAT:
1275 		aAny <<= (sal_Int32)GetPage()->getHeaderFooterSettings().meDateTimeFormat;
1276 		break;
1277 
1278 	case WID_TRANSITION_TYPE:
1279 		aAny <<= GetPage()->getTransitionType();
1280 		break;
1281 
1282 	case WID_TRANSITION_SUBTYPE:
1283 		aAny <<= GetPage()->getTransitionSubtype();
1284 		break;
1285 
1286 	case WID_TRANSITION_DIRECTION:
1287 		aAny <<= GetPage()->getTransitionDirection();
1288 		break;
1289 
1290 	case WID_TRANSITION_FADE_COLOR:
1291 		aAny <<= GetPage()->getTransitionFadeColor();
1292 		break;
1293 
1294 	case WID_TRANSITION_DURATION:
1295 		aAny <<= GetPage()->getTransitionDuration();
1296 		break;
1297 
1298 	default:
1299 		throw beans::UnknownPropertyException();
1300 	}
1301 	return aAny;
1302 }
1303 
1304 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1305 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1306 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1307 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1308 
1309 // XMultiPropertySet
1310 void SAL_CALL SdGenericDrawPage::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
1311 {
1312 	if( aPropertyNames.getLength() != aValues.getLength() )
1313 		throw lang::IllegalArgumentException();
1314 
1315 	const OUString* pNames = aPropertyNames.getConstArray();
1316 	const Any* pValues = aValues.getConstArray();
1317 	sal_uInt32 nCount = aValues.getLength();
1318 	while( nCount-- )
1319 	{
1320 		try
1321 		{
1322 			setPropertyValue( *pNames++, *pValues++ );
1323 		}
1324 		catch( beans::UnknownPropertyException& )
1325 		{
1326 			// ignore for multi property set
1327 			// todo: optimize this!
1328 		}
1329 	}
1330 }
1331 
1332 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
1333 {
1334 	const OUString* pNames = aPropertyNames.getConstArray();
1335 	sal_uInt32 nCount = aPropertyNames.getLength();
1336 	Sequence< Any > aValues( nCount );
1337 	Any* pValues = aValues.getArray();
1338 	while( nCount-- )
1339 	{
1340 		Any aValue;
1341 		try
1342 		{
1343 			aValue = getPropertyValue( *pNames++ );
1344 		}
1345 		catch( beans::UnknownPropertyException& )
1346 		{
1347 			// ignore for multi property set
1348 			// todo: optimize this!
1349 		}
1350 		*pValues++ = aValue;
1351 	}
1352 	return aValues;
1353 }
1354 
1355 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >&  ) throw (RuntimeException)
1356 {
1357 }
1358 
1359 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >&  ) throw (RuntimeException)
1360 {
1361 }
1362 
1363 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >&  ) throw (RuntimeException)
1364 {
1365 }
1366 
1367 Reference< drawing::XShape >  SdGenericDrawPage::_CreateShape( SdrObject *pObj ) const throw()
1368 {
1369 	DBG_ASSERT( GetPage(), "SdGenericDrawPage::_CreateShape(), can't create shape for disposed page!" );
1370 	DBG_ASSERT( pObj, "SdGenericDrawPage::_CreateShape(), invalid call with pObj == 0!" );
1371 
1372 	if( GetPage() && pObj )
1373 	{
1374 		PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
1375 
1376 		SvxShape* pShape = NULL;
1377 
1378 		if(pObj->GetObjInventor() == SdrInventor)
1379 		{
1380 			sal_uInt32 nInventor = pObj->GetObjIdentifier();
1381 			switch( nInventor )
1382 			{
1383 			case OBJ_TITLETEXT:
1384 				pShape = new SvxShapeText( pObj );
1385 				if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
1386 				{
1387 					// fake a empty PageShape if its a title shape on the master page
1388 					pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape")));
1389 				}
1390 				else
1391 				{
1392 					pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")));
1393 				}
1394 				eKind = PRESOBJ_NONE;
1395 				break;
1396 			case OBJ_OUTLINETEXT:
1397 				pShape = new SvxShapeText( pObj );
1398 				pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape")));
1399 				eKind = PRESOBJ_NONE;
1400 				break;
1401 			}
1402 		}
1403 
1404 		Reference< drawing::XShape >  xShape( pShape );
1405 
1406 		if(!xShape.is())
1407 			xShape = SvxFmDrawPage::_CreateShape( pObj );
1408 
1409 
1410 		if( eKind != PRESOBJ_NONE )
1411 		{
1412 			String aShapeType( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation."));
1413 
1414 			switch( eKind )
1415 			{
1416 			case PRESOBJ_TITLE:
1417 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TitleTextShape") );
1418 				break;
1419 			case PRESOBJ_OUTLINE:
1420 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OutlinerShape") );
1421 				break;
1422 			case PRESOBJ_TEXT:
1423 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SubtitleShape") );
1424 				break;
1425 			case PRESOBJ_GRAPHIC:
1426 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape") );
1427 				break;
1428 			case PRESOBJ_OBJECT:
1429 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OLE2Shape") );
1430 				break;
1431 			case PRESOBJ_CHART:
1432 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("ChartShape") );
1433 				break;
1434 			case PRESOBJ_ORGCHART:
1435 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OrgChartShape") );
1436 				break;
1437 			case PRESOBJ_CALC:
1438 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("CalcShape") );
1439 				break;
1440 			case PRESOBJ_TABLE:
1441 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TableShape") );
1442 				break;
1443 			case PRESOBJ_MEDIA:
1444 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("MediaShape") );
1445 				break;
1446 			case PRESOBJ_PAGE:
1447 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("PageShape") );
1448 				break;
1449 			case PRESOBJ_HANDOUT:
1450 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HandoutShape") );
1451 				break;
1452 			case PRESOBJ_NOTES:
1453 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("NotesShape") );
1454 				break;
1455 			case PRESOBJ_FOOTER:
1456 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("FooterShape") );
1457 				break;
1458 			case PRESOBJ_HEADER:
1459 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HeaderShape") );
1460 				break;
1461 			case PRESOBJ_SLIDENUMBER:
1462 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SlideNumberShape") );
1463 				break;
1464 			case PRESOBJ_DATETIME:
1465 				aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("DateTimeShape") );
1466 				break;
1467 			case PRESOBJ_NONE:
1468 			case PRESOBJ_IMAGE:
1469 			case PRESOBJ_MAX:
1470 				break;
1471 			}
1472 
1473 			if( !pShape )
1474 				pShape = SvxShape::getImplementation( xShape );
1475 
1476 			if( pShape )
1477 				pShape->SetShapeType( aShapeType );
1478 		}
1479 
1480 		// SdXShape aggregiert SvxShape
1481 		new SdXShape( SvxShape::getImplementation( xShape ), GetModel() );
1482 		return xShape;
1483 	}
1484 	else
1485 	{
1486 		return SvxFmDrawPage::_CreateShape( pObj );
1487 	}
1488 
1489 }
1490 
1491 //----------------------------------------------------------------------
1492 
1493 // XServiceInfo
1494 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames()
1495 	throw(uno::RuntimeException)
1496 {
1497 	Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() );
1498 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.drawing.GenericDrawPage",
1499 												  "com.sun.star.document.LinkTarget",
1500 												  "com.sun.star.document.LinkTargetSupplier");
1501 	return aSeq;
1502 }
1503 
1504 //----------------------------------------------------------------------
1505 
1506 // XLinkTargetSupplier
1507 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks(  )
1508 	throw(uno::RuntimeException)
1509 {
1510 	return new SdPageLinkTargets( (SdGenericDrawPage*)this );
1511 }
1512 
1513 //----------------------------------------------------------------------
1514 
1515 void SdGenericDrawPage::setBackground( const Any& ) throw(lang::IllegalArgumentException)
1516 {
1517 	DBG_ERROR( "Don't call me, I'm useless!" );
1518 }
1519 
1520 //----------------------------------------------------------------------
1521 
1522 void SdGenericDrawPage::getBackground( Any& ) throw()
1523 {
1524 	DBG_ERROR( "Don't call me, I'm useless!" );
1525 }
1526 
1527 //----------------------------------------------------------------------
1528 
1529 OUString SdGenericDrawPage::getBookmarkURL() const
1530 {
1531 	OUStringBuffer aRet;
1532 	if( SvxFmDrawPage::mpPage )
1533 	{
1534 		OUString aFileName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetFileName() );
1535 		if( aFileName.getLength() )
1536 		{
1537 			const OUString aBookmarkName( SdDrawPage::getPageApiNameFromUiName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetBookmarkName() ) );
1538 			aRet.append( aFileName );
1539 			aRet.append( (sal_Unicode)'#' );
1540 			aRet.append( aBookmarkName );
1541 		}
1542 	}
1543 
1544 	return aRet.makeStringAndClear();
1545 }
1546 
1547 //----------------------------------------------------------------------
1548 void SdGenericDrawPage::setBookmarkURL( rtl::OUString& rURL )
1549 {
1550 	if( SvxFmDrawPage::mpPage )
1551 	{
1552 		sal_Int32 nIndex = rURL.indexOf( (sal_Unicode)'#' );
1553 		if( nIndex != -1 )
1554 		{
1555 			const String aFileName( rURL.copy( 0, nIndex ) );
1556 			const String aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 )  ) );
1557 
1558 			if( aFileName.Len() && aBookmarkName.Len() )
1559 			{
1560 				static_cast<SdPage*>(SvxFmDrawPage::mpPage)->DisconnectLink();
1561 				static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetFileName( aFileName );
1562 				static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetBookmarkName( aBookmarkName );
1563 				static_cast<SdPage*>(SvxFmDrawPage::mpPage)->ConnectLink();
1564 			}
1565 		}
1566 	}
1567 }
1568 
1569 //----------------------------------------------------------------------
1570 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes )
1571 	throw( uno::RuntimeException )
1572 {
1573 	OGuard aGuard( Application::GetSolarMutex() );
1574 
1575 	throwIfDisposed();
1576 
1577 	DBG_ASSERT(SvxFmDrawPage::mpPage,"SdrPage ist NULL! [CL]");
1578 	DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
1579 
1580 	Reference< drawing::XShape > xShape;
1581 	if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1582 		return xShape;
1583 
1584 	SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1585 
1586 	_SelectObjectsInView( xShapes, pPageView );
1587 
1588 	mpView->CombineMarkedObjects( sal_False );
1589 
1590 	mpView->AdjustMarkHdl();
1591 	const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1592 	if( rMarkList.GetMarkCount() == 1 )
1593 	{
1594 		SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1595 		if( pObj )
1596 			xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1597 	}
1598 
1599 	mpView->HideSdrPage();
1600 
1601 	GetModel()->SetModified();
1602 
1603 	return xShape;
1604 }
1605 
1606 //----------------------------------------------------------------------
1607 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup )
1608 	throw( uno::RuntimeException )
1609 {
1610 	OGuard aGuard( Application::GetSolarMutex() );
1611 
1612 	throwIfDisposed();
1613 
1614 	if(mpView==NULL||!xGroup.is()||GetPage()==NULL)
1615 		return;
1616 
1617 	SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1618 	_SelectObjectInView( xGroup, pPageView );
1619 	mpView->DismantleMarkedObjects( sal_False );
1620 	mpView->HideSdrPage();
1621 
1622 	GetModel()->SetModified();
1623 }
1624 
1625 //----------------------------------------------------------------------
1626 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes )
1627 	throw( uno::RuntimeException )
1628 {
1629 	OGuard aGuard( Application::GetSolarMutex() );
1630 
1631 	throwIfDisposed();
1632 
1633 	uno::Reference< drawing::XShape > xShape;
1634 	if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1635 		return xShape;
1636 
1637 	SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1638 
1639 	_SelectObjectsInView( xShapes, pPageView );
1640 
1641 	mpView->CombineMarkedObjects( sal_True );
1642 
1643 	mpView->AdjustMarkHdl();
1644 	const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1645 	if( rMarkList.GetMarkCount() == 1 )
1646 	{
1647 		SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1648 		if( pObj )
1649 			xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1650 	}
1651 
1652 	mpView->HideSdrPage();
1653 
1654 	GetModel()->SetModified();
1655 
1656 	return xShape;
1657 }
1658 
1659 //----------------------------------------------------------------------
1660 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape )
1661 	throw( uno::RuntimeException )
1662 {
1663 	OGuard aGuard( Application::GetSolarMutex() );
1664 
1665 	throwIfDisposed();
1666 
1667 	if(mpView==NULL||!xShape.is()||GetPage()==NULL)
1668 		return;
1669 
1670 	SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1671 	_SelectObjectInView( xShape, pPageView );
1672 	mpView->DismantleMarkedObjects( sal_True );
1673 	mpView->HideSdrPage();
1674 
1675 	GetModel()->SetModified();
1676 }
1677 
1678 void SdGenericDrawPage::SetLftBorder( sal_Int32 nValue )
1679 {
1680 	if( nValue != GetPage()->GetLftBorder() )
1681 	{
1682 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1683 		const PageKind ePageKind = GetPage()->GetPageKind();
1684 
1685 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1686 		for (i = 0; i < nPageCnt; i++)
1687 		{
1688 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1689 			pPage->SetLftBorder( nValue );
1690 		}
1691 
1692 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1693 
1694 		for (i = 0; i < nPageCnt; i++)
1695 		{
1696 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1697 			pPage->SetLftBorder( nValue );
1698 		}
1699 	}
1700 }
1701 
1702 void SdGenericDrawPage::SetRgtBorder( sal_Int32 nValue )
1703 {
1704 	if( nValue != GetPage()->GetRgtBorder() )
1705 	{
1706 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1707 		const PageKind ePageKind = GetPage()->GetPageKind();
1708 
1709 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1710 		for (i = 0; i < nPageCnt; i++)
1711 		{
1712 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1713 			pPage->SetRgtBorder( nValue );
1714 		}
1715 
1716 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1717 
1718 		for (i = 0; i < nPageCnt; i++)
1719 		{
1720 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1721 			pPage->SetRgtBorder( nValue );
1722 		}
1723 	}
1724 }
1725 
1726 void SdGenericDrawPage::SetUppBorder( sal_Int32 nValue )
1727 {
1728 	if( nValue != GetPage()->GetUppBorder() )
1729 	{
1730 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1731 		const PageKind ePageKind = GetPage()->GetPageKind();
1732 
1733 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1734 		for (i = 0; i < nPageCnt; i++)
1735 		{
1736 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1737 			pPage->SetUppBorder( nValue );
1738 		}
1739 
1740 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1741 
1742 		for (i = 0; i < nPageCnt; i++)
1743 		{
1744 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1745 			pPage->SetUppBorder( nValue );
1746 		}
1747 	}
1748 }
1749 
1750 void SdGenericDrawPage::SetLwrBorder( sal_Int32 nValue )
1751 {
1752 	if( nValue != GetPage()->GetLwrBorder() )
1753 	{
1754 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1755 		const PageKind ePageKind = GetPage()->GetPageKind();
1756 
1757 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1758 		for (i = 0; i < nPageCnt; i++)
1759 		{
1760 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1761 			pPage->SetLwrBorder( nValue );
1762 		}
1763 
1764 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1765 
1766 		for (i = 0; i < nPageCnt; i++)
1767 		{
1768 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1769 			pPage->SetLwrBorder( nValue );
1770 		}
1771 	}
1772 }
1773 
1774 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind )
1775 {
1776 	::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1777 	if ( pDocShell )
1778 	{
1779 		::sd::ViewShell* pViewSh = pDocShell->GetViewShell();
1780 
1781 		if( pViewSh )
1782 		{
1783 			if( pViewSh->ISA(::sd::DrawViewShell ) )
1784 				static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage();
1785 
1786 			Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
1787 			const long nWidth = aPageSize.Width();
1788 			const long nHeight = aPageSize.Height();
1789 
1790 			Point aPageOrg = Point(nWidth, nHeight / 2);
1791 			Size aViewSize = Size(nWidth * 3, nHeight * 2);
1792 
1793 			pDoc->SetMaxObjSize(aViewSize);
1794 
1795 			pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
1796 
1797 			pViewSh->UpdateScrollBars();
1798 		}
1799 	}
1800 }
1801 
1802 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth )
1803 {
1804 	Size aSize( GetPage()->GetSize() );
1805 	if( aSize.getWidth() != nWidth )
1806 	{
1807 		aSize.setWidth( nWidth );
1808 
1809 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1810 		const PageKind ePageKind = GetPage()->GetPageKind();
1811 
1812 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1813 		for (i = 0; i < nPageCnt; i++)
1814 		{
1815 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1816 			pPage->SetSize(aSize);
1817 		}
1818 
1819 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1820 
1821 		for (i = 0; i < nPageCnt; i++)
1822 		{
1823 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1824 			pPage->SetSize(aSize);
1825 		}
1826 
1827 		refreshpage( pDoc, ePageKind );
1828 	}
1829 }
1830 
1831 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight )
1832 {
1833 	Size aSize( GetPage()->GetSize() );
1834 	if( aSize.getHeight() != nHeight )
1835 	{
1836 		aSize.setHeight( nHeight );
1837 
1838 		SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1839 		const PageKind ePageKind = GetPage()->GetPageKind();
1840 
1841 		sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1842 		for (i = 0; i < nPageCnt; i++)
1843 		{
1844 			SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1845 			pPage->SetSize(aSize);
1846 		}
1847 
1848 		nPageCnt = pDoc->GetSdPageCount(ePageKind);
1849 
1850 		for (i = 0; i < nPageCnt; i++)
1851 		{
1852 			SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1853 			pPage->SetSize(aSize);
1854 		}
1855 
1856 		refreshpage( pDoc, ePageKind );
1857 	}
1858 }
1859 
1860 // XInterface
1861 void SdGenericDrawPage::release() throw()
1862 {
1863 
1864 	OWeakAggObject::release();
1865 }
1866 
1867 // XComponent
1868 void SdGenericDrawPage::disposing() throw()
1869 {
1870     mpModel = 0;
1871 	SvxFmDrawPage::disposing();
1872 }
1873 
1874 // XAnimationNodeSupplier
1875 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode() throw (uno::RuntimeException)
1876 {
1877 	OGuard aGuard( Application::GetSolarMutex() );
1878 
1879 	throwIfDisposed();
1880 
1881 	SdPage *pSdPage = static_cast<SdPage*>(SvxFmDrawPage::mpPage);
1882 
1883 
1884 	return pSdPage->getAnimationNode();
1885 }
1886 
1887 //========================================================================
1888 // SdPageLinkTargets
1889 //========================================================================
1890 
1891 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw()
1892 {
1893 	mxPage = pUnoPage;
1894 	mpUnoPage = pUnoPage;
1895 }
1896 
1897 SdPageLinkTargets::~SdPageLinkTargets() throw()
1898 {
1899 }
1900 
1901 	// XElementAccess
1902 uno::Type SAL_CALL SdPageLinkTargets::getElementType()
1903 	throw(uno::RuntimeException)
1904 {
1905 	return ITYPE(beans::XPropertySet);
1906 }
1907 
1908 sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
1909 	throw(uno::RuntimeException)
1910 {
1911 	OGuard aGuard( Application::GetSolarMutex() );
1912 
1913 	SdPage* pPage = mpUnoPage->GetPage();
1914 	if( pPage != NULL )
1915 	{
1916 		SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1917 
1918 		while( aIter.IsMore() )
1919 		{
1920 			SdrObject* pObj = aIter.Next();
1921 			String aStr( pObj->GetName() );
1922 			if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1923 				aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1924 			if( aStr.Len() )
1925 				return sal_True;
1926 		}
1927 	}
1928 
1929 	return sal_False;
1930 }
1931 
1932 // container::XNameAccess
1933 
1934 // XNameAccess
1935 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName )
1936 	throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1937 {
1938 	OGuard aGuard( Application::GetSolarMutex() );
1939 
1940 	SdPage* pPage = mpUnoPage->GetPage();
1941 	if( pPage != NULL )
1942 	{
1943 		SdrObject* pObj = FindObject( aName );
1944 		if( pObj )
1945 		{
1946 			Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY );
1947 			return makeAny( aRef );
1948 		}
1949 	}
1950 
1951 	throw container::NoSuchElementException();
1952 }
1953 
1954 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames()
1955 	throw(uno::RuntimeException)
1956 {
1957 	OGuard aGuard( Application::GetSolarMutex() );
1958 
1959 	sal_uInt32 nObjCount = 0;
1960 
1961 	SdPage* pPage = mpUnoPage->GetPage();
1962 	if( pPage != NULL )
1963 	{
1964 		SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1965 		while( aIter.IsMore() )
1966 		{
1967 			SdrObject* pObj = aIter.Next();
1968 			String aStr( pObj->GetName() );
1969 			if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1970 				aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1971 			if( aStr.Len() )
1972 				nObjCount++;
1973 		}
1974 	}
1975 
1976 	Sequence< OUString > aSeq( nObjCount );
1977 	if( nObjCount > 0 )
1978 	{
1979 		OUString* pStr = aSeq.getArray();
1980 
1981 		SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1982 		while( aIter.IsMore() )
1983 		{
1984 			SdrObject* pObj = aIter.Next();
1985 			String aStr( pObj->GetName() );
1986 			if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1987 				aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1988 			if( aStr.Len() )
1989 				*pStr++ = aStr;
1990 		}
1991 	}
1992 
1993 	return aSeq;
1994 }
1995 
1996 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName )
1997 	throw(uno::RuntimeException)
1998 {
1999 	OGuard aGuard( Application::GetSolarMutex() );
2000 
2001 	return FindObject( aName ) != NULL;
2002 }
2003 
2004 /***********************************************************************
2005 *                                                                      *
2006 ***********************************************************************/
2007 SdrObject* SdPageLinkTargets::FindObject( const String& rName ) const throw()
2008 {
2009 	SdPage* pPage = mpUnoPage->GetPage();
2010 	if( pPage == NULL )
2011 		return NULL;
2012 
2013 	SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
2014 
2015 	while( aIter.IsMore() )
2016 	{
2017 		SdrObject* pObj = aIter.Next();
2018 		String aStr( pObj->GetName() );
2019 		if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
2020 			aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
2021 		if( aStr.Len() && (aStr == rName) )
2022 			return pObj;
2023 	}
2024 
2025 	return NULL;
2026 }
2027 
2028 // XServiceInfo
2029 OUString SAL_CALL SdPageLinkTargets::getImplementationName()
2030 	throw(uno::RuntimeException)
2031 {
2032 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SdPageLinkTargets") );
2033 }
2034 
2035 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName )
2036 	throw(uno::RuntimeException)
2037 {
2038 	return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
2039 }
2040 
2041 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames()
2042 	throw(uno::RuntimeException)
2043 {
2044 	const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") );
2045 	Sequence< OUString > aSeq( &aSN, 1);
2046 	return aSeq;
2047 }
2048 
2049 //========================================================================
2050 // SdDrawPage
2051 //========================================================================
2052 
2053 SdDrawPage::SdDrawPage(  SdXImpressDocument* pModel, SdPage* pPage ) throw()
2054 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) )
2055 {
2056 }
2057 
2058 SdDrawPage::~SdDrawPage() throw()
2059 {
2060 }
2061 
2062 // XInterface
2063 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType )
2064 	throw(uno::RuntimeException)
2065 {
2066 	if( rType == ITYPE( drawing::XMasterPageTarget ) )
2067 	{
2068 		return makeAny( Reference< drawing::XMasterPageTarget >( this ) );
2069 	}
2070 	else
2071 	{
2072 		if( mbIsImpressDocument )
2073 		{
2074 			const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2075 
2076 			if( ePageKind != PK_HANDOUT && rType == ITYPE( presentation::XPresentationPage ) )
2077 			{
2078 				return makeAny( Reference< presentation::XPresentationPage >( this ) );
2079 			}
2080 		}
2081 	}
2082 
2083 	return SdGenericDrawPage::queryInterface( rType );
2084 }
2085 
2086 void SAL_CALL SdDrawPage::acquire() throw()
2087 {
2088 	SvxDrawPage::acquire();
2089 }
2090 
2091 void SAL_CALL SdDrawPage::release() throw()
2092 {
2093 	SvxDrawPage::release();
2094 }
2095 
2096 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage );
2097 
2098 // XTypeProvider
2099 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeException)
2100 {
2101 	OGuard aGuard( Application::GetSolarMutex() );
2102 
2103 	throwIfDisposed();
2104 
2105 	if( maTypeSequence.getLength() == 0 )
2106 	{
2107 		const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2108 		sal_Bool bPresPage = mbIsImpressDocument && ePageKind != PK_HANDOUT;
2109 
2110         // Collect the types of this class.
2111         ::std::vector<uno::Type> aTypes;
2112         aTypes.reserve(13);
2113         aTypes.push_back(ITYPE(drawing::XDrawPage));
2114         aTypes.push_back(ITYPE(beans::XPropertySet));
2115         aTypes.push_back(ITYPE(container::XNamed));
2116         aTypes.push_back(ITYPE(drawing::XMasterPageTarget));
2117         aTypes.push_back(ITYPE(lang::XServiceInfo));
2118         aTypes.push_back(ITYPE(util::XReplaceable));
2119         aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2120         aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2121         aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2122 		aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2123 		aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2124         if( bPresPage )
2125             aTypes.push_back(ITYPE(presentation::XPresentationPage));
2126         if( bPresPage && ePageKind == PK_STANDARD )
2127             aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2128 
2129         // Get types of base class.
2130         const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2131         const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2132         const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2133 
2134         // Join those types in a sequence.
2135         maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2136         uno::Type* pTypes = maTypeSequence.getArray();
2137         ::std::vector<uno::Type>::const_iterator iType;
2138         for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2139             *pTypes++ = *iType;
2140         for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2141             *pTypes++ = *pBaseTypes++;
2142 	}
2143 
2144 	return maTypeSequence;
2145 }
2146 
2147 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId() throw(uno::RuntimeException)
2148 {
2149 	OGuard aGuard( Application::GetSolarMutex() );
2150 
2151 	throwIfDisposed();
2152 
2153 	static Sequence< sal_Int8 > aId;
2154 	if( aId.getLength() == 0 )
2155 	{
2156 		aId.realloc( 16 );
2157 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
2158 	}
2159 	return aId;
2160 }
2161 
2162 OUString SdDrawPage::getPageApiName( SdPage* pPage )
2163 {
2164 	return ::getPageApiName( pPage );
2165 }
2166 
2167 OUString getPageApiName( SdPage* pPage )
2168 {
2169 	OUString aPageName;
2170 
2171 	if(pPage)
2172 	{
2173 		aPageName = pPage->GetRealName();
2174 
2175 		if( aPageName.getLength() == 0 )
2176 		{
2177 			OUStringBuffer sBuffer;
2178 			sBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( sEmptyPageName ) );
2179 			const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
2180 			sBuffer.append( nPageNum );
2181 			aPageName = sBuffer.makeStringAndClear();
2182 		}
2183 	}
2184 
2185 	return aPageName;
2186 }
2187 
2188 
2189 OUString getPageApiNameFromUiName( const String& rUIName )
2190 {
2191 	OUString aApiName;
2192 
2193 	String aDefPageName(SdResId(STR_PAGE));
2194 	aDefPageName += sal_Unicode( ' ' );
2195 
2196 	if( rUIName.Equals( aDefPageName, 0, aDefPageName.Len() ) )
2197 	{
2198 		aApiName = OUString( RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ) );
2199 		aApiName += rUIName.Copy( aDefPageName.Len() );
2200 	}
2201 	else
2202 	{
2203 		aApiName = rUIName;
2204 	}
2205 
2206 	return aApiName;
2207 }
2208 
2209 OUString SdDrawPage::getPageApiNameFromUiName( const String& rUIName )
2210 {
2211 	return ::getPageApiNameFromUiName( rUIName );
2212 }
2213 
2214 String getUiNameFromPageApiNameImpl( const OUString& rApiName )
2215 {
2216 	const String aDefPageName(RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ));
2217 	if( rApiName.compareTo( aDefPageName, aDefPageName.Len() ) == 0 )
2218 	{
2219 		OUString aNumber( rApiName.copy( sizeof( sEmptyPageName ) - 1 ) );
2220 
2221 		// create the page number
2222 		sal_Int32 nPageNumber = aNumber.toInt32();
2223 
2224 		// check if there are non number characters in the number part
2225 		const sal_Int32 nChars = aNumber.getLength();
2226 		const sal_Unicode* pString = aNumber.getStr();
2227 		sal_Int32 nChar;
2228 		for( nChar = 0; nChar < nChars; nChar++, pString++ )
2229 		{
2230 			if((*pString < sal_Unicode('0')) || (*pString > sal_Unicode('9')))
2231 			{
2232 				// found a non number character, so this is not the default
2233 				// name for this page
2234 				nPageNumber = -1;
2235 				break;
2236 			}
2237 		}
2238 
2239 		if( nPageNumber != -1)
2240 		{
2241 			OUStringBuffer sBuffer;
2242 			sBuffer.append( String(SdResId(STR_PAGE)) );
2243 			sBuffer.append( sal_Unicode( ' ' ) );
2244 			sBuffer.append( aNumber );
2245 			return sBuffer.makeStringAndClear();
2246 		}
2247 	}
2248 
2249 	return rApiName;
2250 }
2251 
2252 String SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName )
2253 {
2254 	return getUiNameFromPageApiNameImpl( rApiName );
2255 }
2256 
2257 // XServiceInfo
2258 OUString SAL_CALL SdDrawPage::getImplementationName() throw(uno::RuntimeException)
2259 {
2260 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDrawPage") );
2261 }
2262 
2263 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames() throw(uno::RuntimeException)
2264 {
2265 	OGuard aGuard( Application::GetSolarMutex() );
2266 
2267 	throwIfDisposed();
2268 
2269 	Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2270 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.DrawPage" );
2271 
2272 	if( mbIsImpressDocument )
2273 		comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.DrawPage" );
2274 
2275 	return aSeq;
2276 }
2277 
2278 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName )
2279 	throw(uno::RuntimeException)
2280 {
2281 	return SdGenericDrawPage::supportsService( ServiceName );
2282 }
2283 
2284 // XNamed
2285 void SAL_CALL SdDrawPage::setName( const OUString& rName )
2286 	throw(uno::RuntimeException)
2287 {
2288 	OGuard aGuard( Application::GetSolarMutex() );
2289 
2290 	throwIfDisposed();
2291 
2292 	DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" );
2293 
2294 	OUString aName( rName );
2295 
2296 	if(GetPage() && GetPage()->GetPageKind() != PK_NOTES)
2297 	{
2298 		// check if this is the default 'page1234' name
2299 		if(aName.compareToAscii( sEmptyPageName, sizeof( sEmptyPageName ) - 1 ) == 0)
2300 		{
2301 			// ok, it maybe is, first get the number part after 'page'
2302 			OUString aNumber( aName.copy( sizeof( sEmptyPageName ) - 1 ) );
2303 
2304 			// create the page number
2305 			sal_Int32 nPageNumber = aNumber.toInt32();
2306 
2307 			// check if there are non number characters in the number part
2308 			const sal_Int32 nChars = aNumber.getLength();
2309 			const sal_Unicode* pString = aNumber.getStr();
2310 			sal_Int32 nChar;
2311 			for( nChar = 0; nChar < nChars; nChar++, pString++ )
2312 			{
2313 				if((*pString < '0') || (*pString > '9'))
2314 				{
2315 					// found a non number character, so this is not the default
2316 					// name for this page
2317 					nPageNumber = -1;
2318 					break;
2319 				}
2320 			}
2321 
2322 			if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 )
2323 				aName = OUString();
2324 		}
2325 		else
2326 		{
2327 			String aDefaultPageName( SdResId(STR_PAGE) );
2328 			aDefaultPageName += sal_Unicode( ' ' );
2329 			if( aName.compareTo( aDefaultPageName, aDefaultPageName.Len() ) == 0 )
2330 				aName = OUString();
2331 		}
2332 
2333 		GetPage()->SetName( aName );
2334 
2335 		sal_uInt16 nNotesPageNum = (GetPage()->GetPageNum()-1)>>1;
2336 		if( GetModel()->GetDoc()->GetSdPageCount( PK_NOTES ) > nNotesPageNum )
2337 		{
2338 			SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PK_NOTES );
2339 			if( pNotesPage )
2340 				pNotesPage->SetName(aName);
2341 		}
2342 
2343 		// fake a mode change to repaint the page tab bar
2344 		::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2345 		::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
2346 		if( pViewSh && pViewSh->ISA(::sd::DrawViewShell))
2347 		{
2348 			::sd::DrawViewShell* pDrawViewSh = static_cast<
2349                   ::sd::DrawViewShell*>(pViewSh);
2350 
2351 			EditMode eMode = pDrawViewSh->GetEditMode();
2352 			if( eMode == EM_PAGE )
2353 			{
2354 				sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
2355 
2356 				pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2357 				pDrawViewSh->ChangeEditMode( eMode, bLayer );
2358 			}
2359 		}
2360 
2361 		GetModel()->SetModified();
2362 	}
2363 }
2364 
2365 OUString SAL_CALL SdDrawPage::getName()
2366 	throw(uno::RuntimeException)
2367 {
2368 	OGuard aGuard( Application::GetSolarMutex() );
2369 
2370 	throwIfDisposed();
2371 
2372 	return getPageApiName( GetPage() );
2373 }
2374 
2375 // XMasterPageTarget
2376 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage(  )
2377 	throw(uno::RuntimeException)
2378 {
2379 	OGuard aGuard( Application::GetSolarMutex() );
2380 
2381 	throwIfDisposed();
2382 
2383 	if(GetPage())
2384 	{
2385 		Reference< drawing::XDrawPages >	xPages( GetModel()->getMasterPages() );
2386 		Reference< drawing::XDrawPage >	xPage;
2387 
2388 		if(SvxFmDrawPage::mpPage->TRG_HasMasterPage())
2389 		{
2390 			SdrPage& rMasterPage = SvxFmDrawPage::mpPage->TRG_GetMasterPage();
2391 			xPage = uno::Reference< drawing::XDrawPage >( rMasterPage.getUnoPage(), uno::UNO_QUERY );
2392 		}
2393 
2394 		return xPage;
2395 	}
2396 	return NULL;
2397 }
2398 
2399 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage )
2400 	throw(uno::RuntimeException)
2401 {
2402 	OGuard aGuard( Application::GetSolarMutex() );
2403 
2404 	throwIfDisposed();
2405 
2406 	if(SvxFmDrawPage::mpPage)
2407 	{
2408 		SdMasterPage* pMasterPage = SdMasterPage::getImplementation( xMasterPage );
2409 		if( pMasterPage && pMasterPage->isValid() )
2410 		{
2411 			SvxFmDrawPage::mpPage->TRG_ClearMasterPage();
2412 
2413 			SdPage* pSdPage = (SdPage*) pMasterPage->GetSdrPage();
2414 			SvxFmDrawPage::mpPage->TRG_SetMasterPage(*pSdPage);
2415 
2416 			SvxFmDrawPage::mpPage->SetBorder(pSdPage->GetLftBorder(),pSdPage->GetUppBorder(),
2417 							  pSdPage->GetRgtBorder(),pSdPage->GetLwrBorder() );
2418 
2419 			SvxFmDrawPage::mpPage->SetSize( pSdPage->GetSize() );
2420 			SvxFmDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() );
2421 			((SdPage*)SvxFmDrawPage::mpPage)->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2422 
2423 			// set notes master also
2424 			SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2425 
2426 			pNotesPage->TRG_ClearMasterPage();
2427 			sal_uInt16 nNum = (SvxFmDrawPage::mpPage->TRG_GetMasterPage()).GetPageNum() + 1;
2428 			pNotesPage->TRG_SetMasterPage(*SvxFmDrawPage::mpPage->GetModel()->GetMasterPage(nNum));
2429 			pNotesPage->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2430 
2431 			GetModel()->SetModified();
2432 		}
2433 
2434 	}
2435 }
2436 
2437 // XPresentationPage
2438 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage()
2439 	throw(uno::RuntimeException)
2440 {
2441 	OGuard aGuard( Application::GetSolarMutex() );
2442 
2443 	throwIfDisposed();
2444 
2445 	if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() && SvxFmDrawPage::mpPage->GetPageNum() )
2446 	{
2447 		SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2448 		if( pNotesPage )
2449 		{
2450 			Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2451 			return xPage;
2452 		}
2453 	}
2454 	return NULL;
2455 }
2456 
2457 
2458 // XIndexAccess
2459 sal_Int32 SAL_CALL SdDrawPage::getCount()
2460 	throw(uno::RuntimeException)
2461 {
2462 	return SdGenericDrawPage::getCount();
2463 }
2464 
2465 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index )
2466 	throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2467 {
2468 	return SdGenericDrawPage::getByIndex( Index );
2469 }
2470 
2471 // XElementAccess
2472 uno::Type SAL_CALL SdDrawPage::getElementType()
2473 	throw(uno::RuntimeException)
2474 {
2475 	return SdGenericDrawPage::getElementType();
2476 }
2477 
2478 sal_Bool SAL_CALL SdDrawPage::hasElements()
2479 	throw(uno::RuntimeException)
2480 {
2481 	return SdGenericDrawPage::hasElements();
2482 }
2483 
2484 // XShapes
2485 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2486 {
2487 	SdGenericDrawPage::add( xShape );
2488 }
2489 
2490 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2491 {
2492 	OGuard aGuard( Application::GetSolarMutex() );
2493 
2494 	throwIfDisposed();
2495 
2496 	SvxShape* pShape = SvxShape::getImplementation( xShape );
2497 	if( pShape )
2498 	{
2499 		SdrObject* pObj = pShape->GetSdrObject();
2500 		if( pObj )
2501 		{
2502 			GetPage()->RemovePresObj(pObj);
2503 			pObj->SetUserCall(NULL);
2504 		}
2505 	}
2506 
2507 	SdGenericDrawPage::remove( xShape );
2508 }
2509 
2510 void SdDrawPage::setBackground( const Any& rValue )
2511 	throw( lang::IllegalArgumentException )
2512 {
2513 	Reference< beans::XPropertySet > xSet;
2514 
2515 	if( !(rValue >>= xSet) && !rValue.hasValue() )
2516 		throw lang::IllegalArgumentException();
2517 
2518 	if( !xSet.is() )
2519 	{
2520 		// the easy case, no background set. Set XFILL_NONE to represent this
2521         GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
2522 		return;
2523 	}
2524 
2525 	// is it our own implementation?
2526 	SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet );
2527 
2528 	SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2529 
2530 	if( pBack )
2531 	{
2532 		pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2533 	}
2534 	else
2535 	{
2536 		SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2537 
2538 		Reference< beans::XPropertySetInfo >  xSetInfo( xSet->getPropertySetInfo() );
2539 		Reference< beans::XPropertySet >  xDestSet( (beans::XPropertySet*)pBackground );
2540 		Reference< beans::XPropertySetInfo >  xDestSetInfo( xDestSet->getPropertySetInfo() );
2541 
2542 		Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
2543 		sal_Int32 nCount = aProperties.getLength();
2544 		beans::Property* pProp = aProperties.getArray();
2545 
2546 		while( nCount-- )
2547 		{
2548 			const OUString aPropName( pProp->Name );
2549 			if( xSetInfo->hasPropertyByName( aPropName ) )
2550 				xDestSet->setPropertyValue( aPropName,
2551 						xSet->getPropertyValue( aPropName ) );
2552 
2553 			pProp++;
2554 		}
2555 
2556 		pBackground->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2557 	}
2558 
2559 //-/	pObj->NbcSetAttributes( aSet, sal_False );
2560 	if( aSet.Count() == 0 )
2561 	{
2562 		// no background fill, represent by setting XFILL_NONE
2563         GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
2564 	}
2565 	else
2566 	{
2567 		// background fill, set at page (not sure if ClearItem is needed)
2568         GetPage()->getSdrPageProperties().ClearItem();
2569         GetPage()->getSdrPageProperties().PutItemSet(aSet);
2570 	}
2571 
2572 	// repaint only
2573 	SvxFmDrawPage::mpPage->ActionChanged();
2574 	// pPage->SendRepaintBroadcast();
2575 }
2576 
2577 // XAnnotationAccess:
2578 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() throw (RuntimeException)
2579 {
2580     if( !GetPage() )
2581         throw DisposedException();
2582 
2583 	Reference< XAnnotation > xRet;
2584 	GetPage()->createAnnotation(xRet);
2585 	return xRet;
2586 }
2587 
2588 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) throw (RuntimeException, IllegalArgumentException)
2589 {
2590 	GetPage()->removeAnnotation(annotation);
2591 }
2592 
2593 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() throw (RuntimeException)
2594 {
2595 	return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() );
2596 }
2597 
2598 void SdDrawPage::getBackground( Any& rValue ) throw()
2599 {
2600     const SfxItemSet& rFillAttributes = GetPage()->getSdrPageProperties().GetItemSet();
2601 
2602    	if(XFILL_NONE == ((const XFillStyleItem&)rFillAttributes.Get(XATTR_FILLSTYLE)).GetValue())
2603     {
2604 		// no fill set (switched off by XFILL_NONE), clear rValue to represent this
2605 		rValue.clear();
2606     }
2607     else
2608     {
2609 		// there is a fill set, export to rValue
2610 		Reference< beans::XPropertySet > xSet(new SdUnoPageBackground(
2611             GetModel()->GetDoc(),
2612             &GetPage()->getSdrPageProperties().GetItemSet()));
2613 		rValue <<= xSet;
2614     }
2615 }
2616 
2617 void SdGenericDrawPage::setNavigationOrder( const Any& rValue )
2618 {
2619 	Reference< XIndexAccess > xIA( rValue, UNO_QUERY );
2620 	if( xIA.is() )
2621 	{
2622 		if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this )
2623 		{
2624 			if( GetPage()->HasObjectNavigationOrder() )
2625 				GetPage()->ClearObjectNavigationOrder();
2626 
2627 			return;
2628 		}
2629 		else if( xIA->getCount() == static_cast< sal_Int32 >( GetPage()->GetObjCount() ) )
2630 		{
2631             GetPage()->SetNavigationOrder(xIA);
2632             return;
2633 		}
2634 	}
2635 	throw IllegalArgumentException();
2636 }
2637 
2638 class NavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess >
2639 {
2640 public:
2641 	NavigationOrderAccess( SdrPage* pPage );
2642 
2643 	// XIndexAccess
2644     virtual sal_Int32 SAL_CALL getCount(  ) throw (RuntimeException);
2645     virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
2646 
2647     // XElementAccess
2648     virtual Type SAL_CALL getElementType(  ) throw (RuntimeException);
2649     virtual sal_Bool SAL_CALL hasElements(  ) throw (RuntimeException);
2650 
2651 private:
2652 	std::vector< Reference< XShape > > maShapes;
2653 };
2654 
2655 NavigationOrderAccess::NavigationOrderAccess( SdrPage* pPage )
2656 : maShapes( static_cast< sal_uInt32 >( pPage ? pPage->GetObjCount() : 0 ) )
2657 {
2658 	if( pPage )
2659 	{
2660 		sal_uInt32 nIndex;
2661 		const sal_uInt32 nCount = static_cast< sal_uInt32 >( pPage->GetObjCount() );
2662 		for( nIndex = 0; nIndex < nCount; ++nIndex )
2663 		{
2664 			SdrObject* pObj = pPage->GetObj( nIndex );
2665 			sal_uInt32 nNavPos = pObj->GetNavigationPosition();
2666 			DBG_ASSERT( !maShapes[nNavPos].is(), "sd::NavigationOrderAccess::NavigationOrderAccess(), duplicate navigation positions from core!" );
2667 			maShapes[nNavPos] = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
2668 		}
2669 	}
2670 }
2671 
2672 // XIndexAccess
2673 sal_Int32 SAL_CALL NavigationOrderAccess::getCount(  ) throw (RuntimeException)
2674 {
2675 	return static_cast< sal_Int32 >( maShapes.size() );
2676 }
2677 
2678 Any SAL_CALL NavigationOrderAccess::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
2679 {
2680 	if( (Index < 0) || (Index > getCount()) )
2681 		throw IndexOutOfBoundsException();
2682 
2683 	return Any( maShapes[Index] );
2684 }
2685 
2686 // XElementAccess
2687 Type SAL_CALL NavigationOrderAccess::getElementType(  ) throw (RuntimeException)
2688 {
2689 	return XShape::static_type();
2690 }
2691 
2692 sal_Bool SAL_CALL NavigationOrderAccess::hasElements(  ) throw (RuntimeException)
2693 {
2694 	return maShapes.empty() ? sal_False : sal_True;
2695 }
2696 
2697 Any SdGenericDrawPage::getNavigationOrder()
2698 {
2699 	if( GetPage()->HasObjectNavigationOrder() )
2700 	{
2701 		return Any( Reference< XIndexAccess >( new NavigationOrderAccess( GetPage() ) ) );
2702 	}
2703 	else
2704 	{
2705 		return Any( Reference< XIndexAccess >( this ) );
2706 	}
2707 }
2708 
2709 //========================================================================
2710 // class SdMasterPage
2711 //========================================================================
2712 
2713 SdMasterPage::SdMasterPage( SdXImpressDocument* pModel, SdPage* pPage ) throw()
2714 : SdGenericDrawPage( pModel, pPage, ImplGetMasterPagePropertySet( pPage ? pPage->GetPageKind() : PK_STANDARD ) )
2715 {
2716 }
2717 
2718 SdMasterPage::~SdMasterPage() throw()
2719 {
2720 }
2721 
2722 // XInterface
2723 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType )
2724 	throw(uno::RuntimeException)
2725 {
2726 	OGuard aGuard( Application::GetSolarMutex() );
2727 
2728 	throwIfDisposed();
2729 
2730 	uno::Any aAny;
2731 
2732 	if( rType == ITYPE( container::XIndexAccess ) )
2733 		aAny <<= Reference< container::XIndexAccess >((presentation::XPresentationPage*)(this));
2734 	else if( rType == ITYPE( container::XElementAccess ) )
2735 		aAny <<=  Reference< container::XElementAccess >((presentation::XPresentationPage*)(this));
2736 	else if( rType == ITYPE( container::XNamed ) )
2737 		aAny <<=  Reference< container::XNamed >(this);
2738 	else if( rType == ITYPE( presentation::XPresentationPage ) &&
2739 			 ( mbIsImpressDocument &&
2740 			   GetPage()  && GetPage()->GetPageKind() != PK_HANDOUT) )
2741 		aAny <<= Reference< presentation::XPresentationPage >( this );
2742 	else
2743 		return SdGenericDrawPage::queryInterface( rType );
2744 
2745 	return aAny;
2746 }
2747 
2748 void SAL_CALL SdMasterPage::acquire() throw()
2749 {
2750 	SvxDrawPage::acquire();
2751 }
2752 
2753 void SAL_CALL SdMasterPage::release() throw()
2754 {
2755 	SvxDrawPage::release();
2756 }
2757 
2758 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage );
2759 
2760 // XTypeProvider
2761 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeException)
2762 {
2763 	OGuard aGuard( Application::GetSolarMutex() );
2764 
2765 	throwIfDisposed();
2766 
2767 	if( maTypeSequence.getLength() == 0 )
2768 	{
2769 		const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2770 		sal_Bool bPresPage = mbIsImpressDocument && SvxFmDrawPage::mpPage && ePageKind != PK_HANDOUT;
2771 
2772         // Collect the types of this class.
2773         ::std::vector<uno::Type> aTypes;
2774         aTypes.reserve(12);
2775         aTypes.push_back(ITYPE(drawing::XDrawPage));
2776         aTypes.push_back(ITYPE(beans::XPropertySet));
2777         aTypes.push_back(ITYPE(container::XNamed));
2778         aTypes.push_back(ITYPE(lang::XServiceInfo));
2779         aTypes.push_back(ITYPE(util::XReplaceable));
2780         aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2781         aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2782         aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2783 		aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2784 		aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2785         if( bPresPage )
2786             aTypes.push_back(ITYPE(presentation::XPresentationPage));
2787         if( bPresPage && ePageKind == PK_STANDARD )
2788             aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2789 
2790         // Get types of base class.
2791         const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2792         const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2793         const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2794 
2795         // Join those types in a sequence.
2796         maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2797         uno::Type* pTypes = maTypeSequence.getArray();
2798         ::std::vector<uno::Type>::const_iterator iType;
2799         for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2800             *pTypes++ = *iType;
2801         for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2802             *pTypes++ = *pBaseTypes++;
2803 	}
2804 
2805 	return maTypeSequence;
2806 }
2807 
2808 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId() throw(uno::RuntimeException)
2809 {
2810 	OGuard aGuard( Application::GetSolarMutex() );
2811 
2812 	throwIfDisposed();
2813 
2814 	static Sequence< sal_Int8 > aId;
2815 	if( aId.getLength() == 0 )
2816 	{
2817 		aId.realloc( 16 );
2818 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
2819 	}
2820 	return aId;
2821 }
2822 
2823 // XServiceInfo
2824 OUString SAL_CALL SdMasterPage::getImplementationName() throw(uno::RuntimeException)
2825 {
2826 	return OUString( RTL_CONSTASCII_USTRINGPARAM("SdMasterPage") );
2827 }
2828 
2829 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames() throw(uno::RuntimeException)
2830 {
2831 	OGuard aGuard( Application::GetSolarMutex() );
2832 
2833 	throwIfDisposed();
2834 
2835 	Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2836 	comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.MasterPage" );
2837 
2838 	if( SvxFmDrawPage::mpPage && ((SdPage*)SvxFmDrawPage::mpPage)->GetPageKind() == PK_HANDOUT )
2839 		comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.HandoutMasterPage" );
2840 
2841 	return aSeq;
2842 }
2843 
2844 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName )
2845 	throw(uno::RuntimeException)
2846 {
2847 	return SdGenericDrawPage::supportsService( ServiceName );
2848 }
2849 
2850 // XElementAccess
2851 sal_Bool SAL_CALL SdMasterPage::hasElements() throw(uno::RuntimeException)
2852 {
2853 	OGuard aGuard( Application::GetSolarMutex() );
2854 
2855 	throwIfDisposed();
2856 
2857 	if( SvxFmDrawPage::mpPage == NULL )
2858 		return sal_False;
2859 
2860 	return SvxFmDrawPage::mpPage->GetObjCount() > 0;
2861 }
2862 
2863 uno::Type SAL_CALL SdMasterPage::getElementType()
2864 	throw(uno::RuntimeException)
2865 {
2866 	return SdGenericDrawPage::getElementType();
2867 }
2868 
2869 // XIndexAccess
2870 sal_Int32 SAL_CALL SdMasterPage::getCount()
2871 	throw(uno::RuntimeException)
2872 {
2873 	OGuard aGuard( Application::GetSolarMutex() );
2874 
2875 	throwIfDisposed();
2876 
2877 	return SdGenericDrawPage::getCount();
2878 }
2879 
2880 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index )
2881 	throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2882 {
2883 	OGuard aGuard( Application::GetSolarMutex() );
2884 
2885 	throwIfDisposed();
2886 
2887 	return SdGenericDrawPage::getByIndex(Index);
2888 }
2889 
2890 // intern
2891 void SdMasterPage::setBackground( const Any& rValue )
2892 	throw( lang::IllegalArgumentException )
2893 {
2894 	// we need at least an beans::XPropertySet
2895 	Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY );
2896 	if( !xInputSet.is() )
2897 		throw lang::IllegalArgumentException();
2898 
2899 	try
2900 	{
2901 		if( GetModel() && mbIsImpressDocument )
2902 		{
2903 			Reference< container::XNameAccess >  xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
2904 			Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ;
2905 			if( xFamily.is() )
2906 			{
2907 				OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
2908 
2909 				Reference< beans::XPropertySet >  xStyleSet( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2910 
2911 				Reference< beans::XPropertySetInfo >  xSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2912 				Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY );
2913 
2914                 PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap()->getPropertyEntries();
2915                 PropertyEntryVector_t::const_iterator aIt = aBackgroundProperties.begin();
2916 				while( aIt != aBackgroundProperties.end() )
2917 				{
2918 					if( xSetInfo->hasPropertyByName( aIt->sName ) )
2919 					{
2920 						if( !xSetStates.is() || xSetStates->getPropertyState( aIt->sName ) == beans::PropertyState_DIRECT_VALUE )
2921 							xStyleSet->setPropertyValue( aIt->sName,	xInputSet->getPropertyValue( aIt->sName ) );
2922 						else
2923 							xSetStates->setPropertyToDefault( aIt->sName );
2924 					}
2925 
2926 					++aIt;
2927 				}
2928 			}
2929 		}
2930 		else
2931 		{
2932 			// first fill an item set
2933 			// is it our own implementation?
2934 			SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xInputSet );
2935 
2936 			SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2937 
2938 			if( pBack )
2939 			{
2940 				pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2941 			}
2942 			else
2943 			{
2944 				SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2945 
2946 				Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2947 				Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground );
2948 				Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_QUERY_THROW );
2949 
2950 				uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
2951 				sal_Int32 nCount = aProperties.getLength();
2952 				beans::Property* pProp = aProperties.getArray();
2953 
2954 				while( nCount-- )
2955 				{
2956 					const OUString aPropName( pProp->Name );
2957 					if( xInputSetInfo->hasPropertyByName( aPropName ) )
2958 						xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
2959 
2960 					pProp++;
2961 				}
2962 
2963 				pBackground->fillItemSet( (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(), aSet );
2964 			}
2965 
2966 			// if we find the background style, copy the set to the background
2967 			SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
2968 			SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
2969 			if(pSSPool)
2970 			{
2971 				String aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() );
2972 				aLayoutName.Erase(aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
2973 				aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
2974 				SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
2975 
2976 				if( pStyleSheet )
2977 				{
2978 					pStyleSheet->GetItemSet().Put( aSet );
2979 
2980 					// repaint only
2981 					SvxFmDrawPage::mpPage->ActionChanged();
2982 					return;
2983 				}
2984 			}
2985 
2986 			// if no background style is available, set at page directly. This
2987 			// is an error and should NOT happen (and will be asserted from the SdrPage)
2988             GetPage()->getSdrPageProperties().PutItemSet(aSet);
2989 		}
2990 	}
2991 	catch( Exception& )
2992 	{
2993 		DBG_ERROR("sd::SdMasterPage::setBackground(), exception caught!");
2994 	}
2995 }
2996 
2997 void SdMasterPage::getBackground( Any& rValue ) throw()
2998 {
2999 	if( GetModel() ) try
3000 	{
3001 		if( mbIsImpressDocument )
3002 		{
3003 			Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
3004 			Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW );
3005 
3006 			const OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
3007 			rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
3008 		}
3009 		else
3010 		{
3011 			SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
3012 			SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
3013 			if(pSSPool)
3014 			{
3015 				String aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() );
3016 				aLayoutName.Erase( aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
3017 				aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
3018 				SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
3019 
3020 				if( pStyleSheet )
3021 				{
3022 					SfxItemSet aStyleSet( pStyleSheet->GetItemSet());
3023 					if( aStyleSet.Count() )
3024 					{
3025 						rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) );
3026 						return;
3027 					}
3028 				}
3029 			}
3030 
3031 			// No style found, use fill attributes from page background. This
3032 			// should NOT happen and is an error
3033 			const SfxItemSet& rFallbackItemSet(SvxFmDrawPage::mpPage->getSdrPageProperties().GetItemSet());
3034 
3035 			if(XFILL_NONE == ((const XFillStyleItem&)rFallbackItemSet.Get(XATTR_FILLSTYLE)).GetValue())
3036 			{
3037 				rValue <<= Reference< beans::XPropertySet >(
3038 					new SdUnoPageBackground(GetModel()->GetDoc(), &rFallbackItemSet));
3039 			}
3040 			else
3041 			{
3042 				rValue.clear();
3043 			}
3044 		}
3045 	}
3046 	catch( Exception& )
3047 	{
3048 		rValue.clear();
3049 		DBG_ERROR("sd::SdMasterPage::getBackground(), exception caught!");
3050 	}
3051 }
3052 
3053 // XNamed
3054 void SAL_CALL SdMasterPage::setName( const OUString& aName )
3055 	throw(uno::RuntimeException)
3056 {
3057 	OGuard aGuard( Application::GetSolarMutex() );
3058 
3059 	throwIfDisposed();
3060 
3061 	if(SvxFmDrawPage::mpPage && GetPage()->GetPageKind() != PK_NOTES)
3062 	{
3063 		String aNewName( aName );
3064 		GetPage()->SetName( aNewName );
3065 
3066 		if(GetModel()->GetDoc())
3067 			GetModel()->GetDoc()->RenameLayoutTemplate(GetPage()->GetLayoutName(), aNewName);
3068 
3069 		// fake a mode change to repaint the page tab bar
3070 		::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
3071 		::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
3072 		if( pViewSh && pViewSh->ISA(::sd::DrawViewShell ) )
3073 		{
3074 			::sd::DrawViewShell* pDrawViewSh =
3075                   static_cast< ::sd::DrawViewShell*>(pViewSh);
3076 
3077 			EditMode eMode = pDrawViewSh->GetEditMode();
3078 			if( eMode == EM_MASTERPAGE )
3079 			{
3080 				sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
3081 
3082 				pDrawViewSh->ChangeEditMode( eMode, !bLayer );
3083 				pDrawViewSh->ChangeEditMode( eMode, bLayer );
3084 			}
3085 		}
3086 
3087 		GetModel()->SetModified();
3088 	}
3089 }
3090 
3091 OUString SAL_CALL SdMasterPage::getName(  )
3092 	throw(uno::RuntimeException)
3093 {
3094 	OGuard aGuard( Application::GetSolarMutex() );
3095 
3096 	throwIfDisposed();
3097 
3098 	if(SvxFmDrawPage::mpPage)
3099 	{
3100 		String aLayoutName( GetPage()->GetLayoutName() );
3101 		aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM((SD_LT_SEPARATOR)))));
3102 
3103 		return aLayoutName;
3104 	}
3105 
3106 	return OUString();
3107 }
3108 
3109 // XPresentationPage
3110 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage()
3111 	throw(uno::RuntimeException)
3112 {
3113 	OGuard aGuard( Application::GetSolarMutex() );
3114 
3115 	throwIfDisposed();
3116 
3117 	if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() )
3118 	{
3119 		SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
3120 		if( pNotesPage )
3121 		{
3122 			Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
3123 			return xPage;
3124 		}
3125 	}
3126 	return NULL;
3127 }
3128 
3129 // XShapes
3130 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3131 {
3132 	SdGenericDrawPage::add( xShape );
3133 }
3134 
3135 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3136 {
3137 	OGuard aGuard( Application::GetSolarMutex() );
3138 
3139 	throwIfDisposed();
3140 
3141 	SvxShape* pShape = SvxShape::getImplementation( xShape );
3142 	if( pShape )
3143 	{
3144 		SdrObject* pObj = pShape->GetSdrObject();
3145 		if( pObj )
3146 		{
3147 			if( GetPage()->IsPresObj( pObj ) )
3148                 GetPage()->RemovePresObj(pObj);
3149 		}
3150 	}
3151 
3152 	SdGenericDrawPage::remove( xShape );
3153 }
3154 
3155 
3156 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage )
3157 {
3158 	Reference< uno::XInterface > xPage;
3159 
3160 	if( pPage && pPage->GetModel() )
3161 	{
3162 		SdXImpressDocument* pModel = SdXImpressDocument::getImplementation( pPage->GetModel()->getUnoModel() );
3163 		if( pModel )
3164 		{
3165 			if( pPage->IsMasterPage() )
3166 			{
3167 				xPage = (::cppu::OWeakObject*)new SdMasterPage( pModel, pPage );
3168 			}
3169 			else
3170 			{
3171 				xPage = (::cppu::OWeakObject*)new SdDrawPage( pModel, pPage );
3172 			}
3173 		}
3174 	}
3175 
3176 	return xPage;
3177 }
3178