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