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