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