merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / unoidl / unopage.cxx
blob8a8880d39847652117924b7fa7edcf5edbdcf4e8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unopage.cxx,v $
10 * $Revision: 1.96 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/lang/DisposedException.hpp>
34 #include <com/sun/star/presentation/ClickAction.hpp>
35 #include <com/sun/star/presentation/FadeEffect.hpp>
36 #include <com/sun/star/presentation/AnimationEffect.hpp>
37 #include <com/sun/star/presentation/PresentationRange.hpp>
38 #include <com/sun/star/presentation/AnimationSpeed.hpp>
39 #include <com/sun/star/view/PaperOrientation.hpp>
40 #include <com/sun/star/animations/AnimationNodeType.hpp>
41 #include <com/sun/star/presentation/EffectNodeType.hpp>
42 #include <com/sun/star/lang/DisposedException.hpp>
43 #include <comphelper/processfactory.hxx>
44 #include <rtl/ustrbuf.hxx>
45 #include <vcl/bitmapex.hxx>
46 #include <vcl/metaact.hxx>
47 #ifndef _TOOLKIT_UNOIFACE_HXX
48 #include <toolkit/unohlp.hxx>
49 #endif
50 #include <vcl/svapp.hxx>
51 #include <vcl/settings.hxx>
52 #include <unomodel.hxx>
53 #include <unopage.hxx>
54 #ifndef _SVX_SVXIDS_HRC
55 #include <svx/svxids.hrc>
56 #endif
57 #include <svtools/itemset.hxx>
58 #include <svx/svdmodel.hxx>
59 #include <sdresid.hxx>
60 #include <glob.hrc>
61 #ifndef _SD_PAGE_HXX //autogen
62 #include <sdpage.hxx>
63 #endif
64 #include <unoprnms.hxx>
65 #include <sdattr.hxx>
66 #include <drawdoc.hxx>
67 #include <svx/unoshape.hxx>
68 #include <com/sun/star/style/XStyle.hpp>
69 #include <svx/svdorect.hxx>
70 #include <vos/mutex.hxx>
71 #include <svtools/style.hxx>
72 #include <rtl/uuid.h>
73 #include <rtl/memory.h>
75 #include <comphelper/extract.hxx>
76 #include <list>
77 #include <svx/svditer.hxx>
78 #include <svtools/wmf.hxx>
79 #include <svx/svdoole2.hxx>
81 #include <svx/svdview.hxx>
82 #include "misc.hxx"
83 #include "View.hxx"
84 #ifndef SVX_LIGHT
85 #ifndef SD_DRAW_DOC_SHELL_HXX
86 #include "DrawDocShell.hxx"
87 #endif
88 #endif
89 #include "ViewShell.hxx"
90 #include "DrawViewShell.hxx"
91 #include "unoobj.hxx"
92 #include "res_bmp.hrc"
93 #include "unokywds.hxx"
94 #include "unopback.hxx"
95 #include "unohelp.hxx"
97 using ::com::sun::star::animations::XAnimationNode;
98 using ::com::sun::star::animations::XAnimationNodeSupplier;
99 using ::rtl::OUString;
100 using ::rtl::OUStringBuffer;
102 using namespace ::vos;
103 using namespace ::osl;
104 using namespace ::com::sun::star;
105 using namespace ::com::sun::star::uno;
106 using namespace ::com::sun::star::lang;
107 using namespace ::com::sun::star::container;
108 using namespace ::com::sun::star::drawing;
109 using namespace ::com::sun::star::office;
111 namespace sd {
112 extern Reference< XAnnotation > createAnnotation( const Reference< XComponentContext >& xContext, SdPage* );
113 extern Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& );
116 /* this are the ids for page properties */
117 enum WID_PAGE
119 WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH,
120 WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER,
121 WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP,
122 WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL,
123 WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK,
124 WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT,
125 WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
126 WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
127 WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
128 WID_NAVORDER
131 #ifndef SEQTYPE
132 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
133 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
134 #else
135 #define SEQTYPE(x) &(x)
136 #endif
137 #endif
139 static sal_Char __FAR_DATA sEmptyPageName[sizeof("page")] = "page";
141 /** this function stores the property maps for draw pages in impress and draw */
142 const SvxItemPropertySet* ImplGetDrawPagePropertySet( sal_Bool bImpress, PageKind ePageKind )
144 static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] =
146 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0},
147 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
148 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
149 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
150 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
151 { MAP_CHAR_LEN(UNO_NAME_PAGE_CHANGE), WID_PAGE_CHANGE, &::getCppuType((const sal_Int32*)0), 0, 0},
152 { MAP_CHAR_LEN(UNO_NAME_PAGE_DURATION), WID_PAGE_DURATION, &::getCppuType((const sal_Int32*)0), 0, 0},
153 { MAP_CHAR_LEN(UNO_NAME_PAGE_EFFECT), WID_PAGE_EFFECT, &::getCppuType((const presentation::FadeEffect*)0), 0, 0},
154 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
155 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0},
156 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0},
157 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0},
158 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
159 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
160 { MAP_CHAR_LEN(UNO_NAME_PAGE_SPEED), WID_PAGE_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0},
161 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
162 { 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},
163 { 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},
164 { MAP_CHAR_LEN(UNO_NAME_PAGE_VISIBLE), WID_PAGE_VISIBLE, &::getBooleanCppuType(), 0, 0},
165 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_PAGE_SOUNDFILE, &::getCppuType((const Any*)0), 0, 0},
166 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundVisible), WID_PAGE_BACKVIS, &::getBooleanCppuType(), 0, 0},
167 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundObjectsVisible), WID_PAGE_BACKOBJVIS, &::getBooleanCppuType(), 0, 0},
168 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
169 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},
170 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
171 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0},
172 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0},
173 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0},
174 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0},
175 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0},
176 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0},
177 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0},
178 { MAP_CHAR_LEN("TransitionType"), WID_TRANSITION_TYPE, &::getCppuType((const sal_Int16*)0), 0, 0},
179 { MAP_CHAR_LEN("TransitionSubtype"), WID_TRANSITION_SUBTYPE, &::getCppuType((const sal_Int16*)0), 0, 0},
180 { MAP_CHAR_LEN("TransitionDirection"), WID_TRANSITION_DIRECTION, &::getCppuType((const sal_Bool*)0), 0, 0},
181 { MAP_CHAR_LEN("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0},
182 { MAP_CHAR_LEN("TransitionDuration"), WID_TRANSITION_DURATION, &::getCppuType((const double*)0), 0, 0},
183 { MAP_CHAR_LEN("LoopSound"), WID_LOOP_SOUND, &::getBooleanCppuType(), 0, 0},
184 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0},
185 {0,0,0,0,0,0}
188 #define DRAW_PAGE_NOTES_PROPERTIES \
189 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \
190 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
191 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
192 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \
193 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
194 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, \
195 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \
196 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \
197 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \
198 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \
199 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \
200 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},\
201 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
202 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \
203 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \
204 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
205 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \
206 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
207 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0}, \
208 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0}, \
209 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0}, \
210 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
211 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, \
212 {0,0,0,0,0,0}
214 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] =
216 // this must be the first two entries so they can be excluded for PK_STANDARD
217 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0},
218 DRAW_PAGE_NOTES_PROPERTIES
220 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] =
222 DRAW_PAGE_NOTES_PROPERTIES
225 #define GRAPHIC_PAGE_PROPERTIES \
226 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \
227 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
228 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
229 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \
230 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
231 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \
232 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \
233 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \
234 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \
235 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \
236 { 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}, \
237 { 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},\
238 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, \
239 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, \
240 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \
241 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, \
242 {0,0,0,0,0,0}
244 static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] =
246 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet), beans::PropertyAttribute::MAYBEVOID,0},
247 GRAPHIC_PAGE_PROPERTIES
249 static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] =
251 GRAPHIC_PAGE_PROPERTIES
255 bool bWithoutBackground = ePageKind != PK_STANDARD && ePageKind != PK_HANDOUT;
256 const SvxItemPropertySet* pRet = 0;
257 if( bImpress )
259 if( ePageKind == PK_STANDARD )
261 //PK_STANDARD always has a background property
262 static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl );
263 pRet = &aDrawPagePropertySet_Impl;
265 else
267 if(bWithoutBackground)
269 static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl );
270 pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl;
272 else
274 static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl );
275 pRet = &aDrawPageNotesHandoutPropertySet_Impl;
279 else
281 if(bWithoutBackground)
283 static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl );
284 pRet = &aGraphicPagePropertyNoBackSet_Impl;
286 else
288 static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl );
289 pRet = &aGraphicPagePropertySet_Impl;
292 return pRet;
295 /** this function stores the property map for master pages in impress and draw */
296 const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
298 static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] =
300 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE(beans::XPropertySet), 0, 0},
301 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
302 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
303 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
304 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
305 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
306 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0},
307 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0},
308 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
309 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
310 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
311 { MAP_CHAR_LEN("BackgroundFullSize"), WID_PAGE_BACKFULL, &::getBooleanCppuType(), 0, 0},
312 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
313 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
314 {0,0,0,0,0,0}
317 static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
319 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
320 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
321 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
322 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
323 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
324 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
325 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
326 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0},
327 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
328 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
329 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0},
330 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0},
331 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0},
332 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0},
333 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0},
334 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0},
335 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0},
336 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0},
337 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0},
338 {0,0,0,0,0,0}
341 const SvxItemPropertySet* pRet = 0;
342 if( ePageKind == PK_HANDOUT )
344 static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl );
345 pRet = &aHandoutMasterPagePropertySet_Impl;
347 else
349 static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl );
350 pRet = &aMasterPagePropertySet_Impl;
352 return pRet;
355 UNO3_GETIMPLEMENTATION2_IMPL( SdGenericDrawPage, SvxFmDrawPage );
357 /***********************************************************************
359 ***********************************************************************/
360 SdGenericDrawPage::SdGenericDrawPage( SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet ) throw()
361 : SvxFmDrawPage( (SdrPage*) pInPage ),
362 SdUnoSearchReplaceShape(this),
363 mpModel ( _pModel ),
364 mpSdrModel(0),
365 mpPropSet ( _pSet ),
366 mbHasBackgroundObject(sal_False),
367 mbIsImpressDocument(false)
369 mpSdrModel = SvxFmDrawPage::mpModel;
370 if( mpModel )
371 mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
375 SdGenericDrawPage::~SdGenericDrawPage() throw()
379 void SdGenericDrawPage::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException )
381 if( (SvxFmDrawPage::mpModel == 0) || (mpModel == 0) || (SvxFmDrawPage::mpPage == 0) )
382 throw lang::DisposedException();
385 SdXImpressDocument* SdGenericDrawPage::GetModel() const
387 if( mpSdrModel != SvxFmDrawPage::mpModel )
389 const_cast< SdGenericDrawPage* >(this)->mpSdrModel = SvxFmDrawPage::mpModel;
390 if( mpSdrModel )
392 uno::Reference< uno::XInterface > xModel( SvxFmDrawPage::mpModel->getUnoModel() );
393 const_cast< SdGenericDrawPage*>(this)->mpModel = SdXImpressDocument::getImplementation( xModel );
394 if( mpModel )
395 const_cast< SdGenericDrawPage*>(this)->mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
397 else
399 const_cast< SdGenericDrawPage* >(this)->mpModel = 0;
403 return mpModel;
406 // this is called whenever a SdrObject must be created for a empty api shape wrapper
407 SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShape >& xShape ) throw()
409 if( NULL == SvxFmDrawPage::mpPage || !xShape.is() )
410 return NULL;
412 String aType( xShape->getShapeType() );
413 const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") );
414 if(aType.CompareTo( aPrefix, aPrefix.Len() ) != 0)
416 SdrObject* pObj = SvxFmDrawPage::_CreateSdrObject( xShape );
417 if( pObj && ( (pObj->GetObjInventor() != SdrInventor) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
419 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
420 if( pDoc )
421 pObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
423 return pObj;
426 aType = aType.Copy( aPrefix.Len() );
428 PresObjKind eObjKind = PRESOBJ_NONE;
430 if( aType.EqualsAscii( "TitleTextShape" ) )
432 eObjKind = PRESOBJ_TITLE;
434 else if( aType.EqualsAscii( "OutlinerShape" ) )
436 eObjKind = PRESOBJ_OUTLINE;
438 else if( aType.EqualsAscii( "SubtitleShape" ) )
440 eObjKind = PRESOBJ_TEXT;
442 else if( aType.EqualsAscii( "OLE2Shape" ) )
444 eObjKind = PRESOBJ_OBJECT;
446 else if( aType.EqualsAscii( "ChartShape" ) )
448 eObjKind = PRESOBJ_CHART;
450 else if( aType.EqualsAscii( "TableShape" ) )
452 eObjKind = PRESOBJ_TABLE;
454 else if( aType.EqualsAscii( "GraphicObjectShape" ) )
456 #ifdef STARIMAGE_AVAILABLE
457 eObjKind = PRESOBJ_IMAGE;
458 #else
459 eObjKind = PRESOBJ_GRAPHIC;
460 #endif
462 else if( aType.EqualsAscii( "OrgChartShape" ) )
464 eObjKind = PRESOBJ_ORGCHART;
466 else if( aType.EqualsAscii( "PageShape" ) )
468 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
469 eObjKind = PRESOBJ_TITLE;
470 else
471 eObjKind = PRESOBJ_PAGE;
473 else if( aType.EqualsAscii( "NotesShape" ) )
475 eObjKind = PRESOBJ_NOTES;
477 else if( aType.EqualsAscii( "HandoutShape" ) )
479 eObjKind = PRESOBJ_HANDOUT;
481 else if( aType.EqualsAscii( "FooterShape" ) )
483 eObjKind = PRESOBJ_FOOTER;
485 else if( aType.EqualsAscii( "HeaderShape" ) )
487 eObjKind = PRESOBJ_HEADER;
489 else if( aType.EqualsAscii( "SlideNumberShape" ) )
491 eObjKind = PRESOBJ_SLIDENUMBER;
493 else if( aType.EqualsAscii( "DateTimeShape" ) )
495 eObjKind = PRESOBJ_DATETIME;
498 Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() );
500 const awt::Point aPos( aRect.Left(), aRect.Top() );
501 xShape->setPosition( aPos );
503 const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
504 xShape->setSize( aSize );
506 SdrObject *pPresObj = GetPage()->CreatePresObj( eObjKind, FALSE, aRect, sal_True );
508 if( pPresObj )
509 pPresObj->SetUserCall( GetPage() );
511 return pPresObj;
514 // XInterface
515 Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType )
516 throw(uno::RuntimeException)
518 Any aAny;
520 QUERYINT( beans::XPropertySet );
521 else QUERYINT( container::XNamed );
522 else QUERYINT( util::XReplaceable );
523 else QUERYINT( util::XSearchable );
524 else QUERYINT( document::XLinkTargetSupplier );
525 else QUERYINT( drawing::XShapeCombiner );
526 else QUERYINT( drawing::XShapeBinder );
527 else QUERYINT( beans::XMultiPropertySet );
528 else if( rType == ITYPE( office::XAnnotationAccess ) )
530 return Any( Reference< office::XAnnotationAccess >( this ) );
532 else if( rType == ITYPE( XAnimationNodeSupplier ) )
534 if( mbIsImpressDocument )
536 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
538 if( ePageKind == PK_STANDARD )
539 return makeAny( Reference< XAnimationNodeSupplier >( this ) );
542 else
543 return SvxDrawPage::queryInterface( rType );
545 return aAny;
548 // XPropertySet
549 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo()
550 throw(uno::RuntimeException)
552 OGuard aGuard( Application::GetSolarMutex() );
553 throwIfDisposed();
554 return mpPropSet->getPropertySetInfo();
557 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
558 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
560 OGuard aGuard( Application::GetSolarMutex() );
562 throwIfDisposed();
564 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
566 switch( pEntry ? pEntry->nWID : -1 )
568 case WID_NAVORDER:
569 setNavigationOrder( aValue );
570 break;
571 case WID_PAGE_LEFT:
572 case WID_PAGE_RIGHT:
573 case WID_PAGE_TOP:
574 case WID_PAGE_BOTTOM:
575 case WID_PAGE_LAYOUT:
576 case WID_PAGE_DURATION:
577 case WID_PAGE_CHANGE:
579 sal_Int32 nValue = 0;
580 if(!(aValue >>= nValue))
581 throw lang::IllegalArgumentException();
583 switch( pEntry->nWID )
585 case WID_PAGE_LEFT:
586 SetLftBorder(nValue);
587 break;
588 case WID_PAGE_RIGHT:
589 SetRgtBorder( nValue );
590 break;
591 case WID_PAGE_TOP:
592 SetUppBorder( nValue );
593 break;
594 case WID_PAGE_BOTTOM:
595 SetLwrBorder( nValue );
596 break;
597 case WID_PAGE_CHANGE:
598 GetPage()->SetPresChange( (PresChange)nValue );
599 break;
600 case WID_PAGE_LAYOUT:
601 GetPage()->SetAutoLayout( (AutoLayout)nValue, sal_True );
602 break;
603 case WID_PAGE_DURATION:
604 GetPage()->SetTime((sal_uInt32)nValue);
605 break;
607 break;
609 case WID_PAGE_WIDTH:
611 sal_Int32 nWidth = 0;
612 if(!(aValue >>= nWidth))
613 throw lang::IllegalArgumentException();
615 SetWidth( nWidth );
616 break;
618 case WID_PAGE_HEIGHT:
620 sal_Int32 nHeight = 0;
621 if(!(aValue >>= nHeight))
622 throw lang::IllegalArgumentException();
624 SetHeight( nHeight );
625 break;
627 case WID_PAGE_ORIENT:
629 sal_Int32 nEnum = 0;
630 if(!::cppu::enum2int( nEnum, aValue ))
631 throw lang::IllegalArgumentException();
633 Orientation eOri = (((view::PaperOrientation)nEnum) == view::PaperOrientation_PORTRAIT)?ORIENTATION_PORTRAIT:ORIENTATION_LANDSCAPE;
635 if( eOri != GetPage()->GetOrientation() )
637 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
638 const PageKind ePageKind = GetPage()->GetPageKind();
640 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
641 for (i = 0; i < nPageCnt; i++)
643 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
644 pPage->SetOrientation( eOri );
647 nPageCnt = pDoc->GetSdPageCount(ePageKind);
649 for (i = 0; i < nPageCnt; i++)
651 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
652 pPage->SetOrientation( eOri );
655 break;
657 case WID_PAGE_EFFECT:
659 sal_Int32 nEnum = 0;
660 if(!::cppu::enum2int( nEnum, aValue ))
661 throw lang::IllegalArgumentException();
663 GetPage()->SetFadeEffect( (presentation::FadeEffect)nEnum );
664 break;
666 case WID_PAGE_BACK:
667 setBackground( aValue );
668 break;
669 case WID_PAGE_SPEED:
671 sal_Int32 nEnum = 0;
672 if(!::cppu::enum2int( nEnum, aValue ))
673 throw lang::IllegalArgumentException();
675 GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 ) );
676 break;
678 case WID_PAGE_VISIBLE :
680 sal_Bool bVisible = sal_False;
681 if( ! ( aValue >>= bVisible ) )
682 throw lang::IllegalArgumentException();
683 GetPage()->SetExcluded( bVisible == FALSE );
684 break;
686 case WID_PAGE_SOUNDFILE :
688 OUString aURL;
689 if( aValue >>= aURL )
691 GetPage()->SetSoundFile( aURL );
692 GetPage()->SetSound( aURL.getLength() != 0 ? sal_True : sal_False );
693 break;
695 else
697 sal_Bool bStopSound = sal_False;
698 if( aValue >>= bStopSound )
700 GetPage()->SetStopSound( bStopSound ? true : false );
701 break;
706 throw lang::IllegalArgumentException();
708 case WID_LOOP_SOUND:
710 sal_Bool bLoop = sal_False;
711 if( ! (aValue >>= bLoop) )
712 throw lang::IllegalArgumentException();
714 GetPage()->SetLoopSound( bLoop ? true : false );
715 break;
717 case WID_PAGE_BACKFULL:
719 sal_Bool bFullSize = sal_False;
720 if( ! ( aValue >>= bFullSize ) )
721 throw lang::IllegalArgumentException();
722 GetPage()->SetBackgroundFullSize( bFullSize );
723 break;
725 case WID_PAGE_BACKVIS:
727 sal_Bool bVisible = sal_False;
728 if( ! ( aValue >>= bVisible ) )
729 throw lang::IllegalArgumentException();
731 SdrPage* pPage = GetPage();
732 if( pPage )
734 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
735 if( pDoc->GetMasterPageCount() )
737 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
738 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
739 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), FALSE), bVisible);
740 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
743 break;
745 case WID_PAGE_BACKOBJVIS:
747 sal_Bool bVisible = sal_False;
748 if( ! ( aValue >>= bVisible ) )
749 throw lang::IllegalArgumentException();
751 SdrPage* pPage = GetPage();
752 if( pPage )
754 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
755 if( pDoc->GetMasterPageCount() )
757 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
758 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
759 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), FALSE), bVisible);
760 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
764 break;
766 case WID_PAGE_USERATTRIBS:
768 if( !GetPage()->setAlienAttributes( aValue ) )
769 throw lang::IllegalArgumentException();
770 break;
772 case WID_PAGE_BOOKMARK:
774 OUString aBookmarkURL;
775 if( ! ( aValue >>= aBookmarkURL ) )
776 throw lang::IllegalArgumentException();
778 setBookmarkURL( aBookmarkURL );
779 break;
782 case WID_PAGE_HEADERVISIBLE:
783 case WID_PAGE_HEADERTEXT:
784 case WID_PAGE_FOOTERVISIBLE:
785 case WID_PAGE_FOOTERTEXT:
786 case WID_PAGE_PAGENUMBERVISIBLE:
787 case WID_PAGE_DATETIMEVISIBLE:
788 case WID_PAGE_DATETIMEFIXED:
789 case WID_PAGE_DATETIMETEXT:
790 case WID_PAGE_DATETIMEFORMAT:
792 sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() );
794 switch( pEntry->nWID )
796 case WID_PAGE_HEADERVISIBLE:
798 sal_Bool bVisible = sal_False;
799 if( ! ( aValue >>= bVisible ) )
800 throw lang::IllegalArgumentException();
802 aHeaderFooterSettings.mbHeaderVisible = bVisible;
803 break;
805 case WID_PAGE_HEADERTEXT:
807 OUString aText;
808 if( ! ( aValue >>= aText ) )
809 throw lang::IllegalArgumentException();
811 aHeaderFooterSettings.maHeaderText = aText;
812 break;
814 case WID_PAGE_FOOTERVISIBLE:
816 sal_Bool bVisible = sal_False;
817 if( ! ( aValue >>= bVisible ) )
818 throw lang::IllegalArgumentException();
820 aHeaderFooterSettings.mbFooterVisible = bVisible;
821 break;
823 case WID_PAGE_FOOTERTEXT:
825 OUString aText;
826 if( ! ( aValue >>= aText ) )
827 throw lang::IllegalArgumentException();
829 aHeaderFooterSettings.maFooterText = aText;
830 break;
832 case WID_PAGE_PAGENUMBERVISIBLE:
834 sal_Bool bVisible = sal_False;
835 if( ! ( aValue >>= bVisible ) )
836 throw lang::IllegalArgumentException();
838 aHeaderFooterSettings.mbSlideNumberVisible = bVisible;
839 break;
841 case WID_PAGE_DATETIMEVISIBLE:
843 sal_Bool bVisible = sal_False;
844 if( ! ( aValue >>= bVisible ) )
845 throw lang::IllegalArgumentException();
847 aHeaderFooterSettings.mbDateTimeVisible = bVisible;
848 break;
850 case WID_PAGE_DATETIMEFIXED:
852 sal_Bool bVisible = sal_False;
853 if( ! ( aValue >>= bVisible ) )
854 throw lang::IllegalArgumentException();
856 aHeaderFooterSettings.mbDateTimeIsFixed = bVisible;
857 break;
859 case WID_PAGE_DATETIMETEXT:
861 OUString aText;
862 if( ! ( aValue >>= aText ) )
863 throw lang::IllegalArgumentException();
865 aHeaderFooterSettings.maDateTimeText = aText;
866 break;
868 case WID_PAGE_DATETIMEFORMAT:
870 sal_Int32 nValue = 0;
871 if( ! ( aValue >>= nValue ) )
872 throw lang::IllegalArgumentException();
874 aHeaderFooterSettings.meDateTimeFormat = nValue;
875 break;
879 if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) )
880 GetPage()->setHeaderFooterSettings( aHeaderFooterSettings );
882 break;
885 case WID_PAGE_LDBITMAP:
886 case WID_PAGE_LDNAME:
887 case WID_PAGE_NUMBER:
888 case WID_PAGE_ISDARK:
889 throw beans::PropertyVetoException();
891 case WID_TRANSITION_TYPE:
893 sal_Int16 nValue = 0;
894 if( ! ( aValue >>= nValue ) )
895 throw lang::IllegalArgumentException();
897 GetPage()->setTransitionType( nValue );
898 break;
901 case WID_TRANSITION_SUBTYPE:
903 sal_Int16 nValue = 0;
904 if( ! ( aValue >>= nValue ) )
905 throw lang::IllegalArgumentException();
907 GetPage()->setTransitionSubtype( nValue );
908 break;
911 case WID_TRANSITION_DIRECTION:
913 sal_Bool bValue = sal_False;
914 if( ! ( aValue >>= bValue ) )
915 throw lang::IllegalArgumentException();
917 GetPage()->setTransitionDirection( bValue );
918 break;
921 case WID_TRANSITION_FADE_COLOR:
923 sal_Int32 nValue = 0;
924 if( ! ( aValue >>= nValue ) )
925 throw lang::IllegalArgumentException();
927 GetPage()->setTransitionFadeColor( nValue );
928 break;
931 case WID_TRANSITION_DURATION:
933 double fValue = 0.0;
934 if( ! ( aValue >>= fValue ) )
935 throw lang::IllegalArgumentException();
937 GetPage()->setTransitionDuration( fValue );
938 break;
941 default:
942 throw beans::UnknownPropertyException();
945 GetModel()->SetModified();
948 /***********************************************************************
950 ***********************************************************************/
951 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
952 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
954 OGuard aGuard( Application::GetSolarMutex() );
956 throwIfDisposed();
958 uno::Any aAny;
960 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
962 switch( pEntry ? pEntry->nWID : -1 )
964 case WID_NAVORDER:
965 aAny = getNavigationOrder();
966 break;
967 case WID_PAGE_LEFT:
968 aAny <<= (sal_Int32)( GetPage()->GetLftBorder() );
969 break;
970 case WID_PAGE_RIGHT:
971 aAny <<= (sal_Int32)( GetPage()->GetRgtBorder() );
972 break;
973 case WID_PAGE_TOP:
974 aAny <<= (sal_Int32)( GetPage()->GetUppBorder() );
975 break;
976 case WID_PAGE_BOTTOM:
977 aAny <<= (sal_Int32)( GetPage()->GetLwrBorder() );
978 break;
979 case WID_PAGE_WIDTH:
980 aAny <<= (sal_Int32)( GetPage()->GetSize().getWidth() );
981 break;
982 case WID_PAGE_HEIGHT:
983 aAny <<= (sal_Int32)( GetPage()->GetSize().getHeight() );
984 break;
985 case WID_PAGE_ORIENT:
986 aAny = ::cppu::int2enum( (sal_Int32)((GetPage()->GetOrientation() == ORIENTATION_PORTRAIT)? view::PaperOrientation_PORTRAIT: view::PaperOrientation_LANDSCAPE), ::getCppuType((const view::PaperOrientation*)0) );
987 break;
988 case WID_PAGE_EFFECT:
989 aAny = ::cppu::int2enum( (sal_Int32)GetPage()->GetFadeEffect(), ::getCppuType((const presentation::FadeEffect*)0) );
990 break;
991 case WID_PAGE_CHANGE:
992 aAny <<= (sal_Int32)( GetPage()->GetPresChange() );
993 break;
994 case WID_PAGE_SPEED:
996 const double fDuration = GetPage()->getTransitionDuration();
997 aAny = ::cppu::int2enum( fDuration < 2.0 ? 2 : (fDuration > 2.0 ? 0 : 1), ::getCppuType((const presentation::AnimationSpeed*)0) );
999 break;
1000 case WID_PAGE_LAYOUT:
1001 aAny <<= (sal_Int16)( GetPage()->GetAutoLayout() );
1002 break;
1003 case WID_PAGE_NUMBER:
1004 aAny <<= (sal_Int16)((sal_uInt16)((GetPage()->GetPageNum()-1)>>1) + 1);
1005 break;
1006 case WID_PAGE_DURATION:
1007 aAny <<= (sal_Int32)(GetPage()->GetTime());
1008 break;
1009 case WID_PAGE_LDNAME:
1011 const OUString aName( GetPage()->GetName() );
1012 aAny <<= aName;
1013 break;
1015 case WID_PAGE_LDBITMAP:
1017 BOOL bHC = Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark();
1018 Reference< awt::XBitmap > xBitmap(
1019 VCLUnoHelper::CreateBitmap( BitmapEx( SdResId( bHC ? BMP_PAGE_H : BMP_PAGE ) ) ) );
1020 aAny <<= xBitmap;
1022 break;
1023 case WID_PAGE_BACK:
1024 getBackground( aAny );
1025 break;
1026 case WID_PAGE_PREVIEW :
1028 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1029 if ( pDoc )
1031 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1032 if ( pDocShell )
1034 sal_uInt16 nPgNum = 0;
1035 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1036 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1037 while( nPgNum < nPageCount )
1039 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1040 nPgNum++;
1042 ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1043 pDocShell->GetPreviewMetaFile();
1044 if ( pMetaFile )
1046 Point aPoint;
1047 Size aSize( GetPage()->GetSize() );
1048 pMetaFile->AddAction( (MetaAction*) new MetaFillColorAction( COL_WHITE, TRUE ), 0 );
1049 pMetaFile->AddAction( (MetaAction*) new MetaRectAction( Rectangle( aPoint, aSize ) ), 1 );
1050 pMetaFile->SetPrefMapMode( MAP_100TH_MM );
1051 pMetaFile->SetPrefSize( aSize );
1053 SvMemoryStream aDestStrm( 65535, 65535 );
1054 ConvertGDIMetaFileToWMF( *pMetaFile, aDestStrm, NULL, sal_False );
1055 Sequence<sal_Int8> aSeq( (sal_Int8*)aDestStrm.GetData(), aDestStrm.Tell() );
1056 aAny <<= aSeq;
1061 break;
1063 case WID_PAGE_PREVIEWBITMAP :
1065 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1066 if ( pDoc )
1068 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1069 if ( pDocShell )
1071 sal_uInt16 nPgNum = 0;
1072 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1073 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1074 while( nPgNum < nPageCount )
1076 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1077 nPgNum++;
1079 ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1080 pDocShell->GetPreviewMetaFile();
1081 BitmapEx aBitmap;
1082 if ( pMetaFile && pMetaFile->CreateThumbnail( 160, /* magic value taken from GraphicHelper::getThumbnailFormatFromGDI_Impl() */
1083 aBitmap ) )
1085 SvMemoryStream aMemStream;
1086 aBitmap.GetBitmap().Write( aMemStream, FALSE, FALSE );
1087 uno::Sequence<sal_Int8> aSeq( (sal_Int8*)aMemStream.GetData(), aMemStream.Tell() );
1088 aAny <<= aSeq;
1093 break;
1095 case WID_PAGE_VISIBLE :
1097 sal_Bool bVisible = GetPage()->IsExcluded() == FALSE;
1098 aAny <<= Any( &bVisible, ::getBooleanCppuType() );
1099 break;
1102 case WID_PAGE_SOUNDFILE :
1104 if( GetPage()->IsStopSound() )
1106 aAny <<= sal_True;
1108 else
1110 OUString aURL;
1111 if( GetPage()->IsSoundOn() )
1112 aURL = GetPage()->GetSoundFile();
1113 aAny <<= aURL;
1115 break;
1117 case WID_LOOP_SOUND:
1119 aAny <<= (sal_Bool)GetPage()->IsLoopSound();
1120 break;
1122 case WID_PAGE_BACKFULL:
1124 sal_Bool bFullSize = GetPage()->IsBackgroundFullSize();
1125 aAny = Any( &bFullSize, ::getBooleanCppuType() );
1126 break;
1128 case WID_PAGE_BACKVIS:
1130 SdrPage* pPage = GetPage();
1131 if( pPage )
1133 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1134 if( pDoc->GetMasterPageCount() )
1136 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1137 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1138 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), FALSE));
1140 else
1142 aAny <<= (sal_Bool)sal_False;
1145 break;
1147 case WID_PAGE_BACKOBJVIS:
1149 SdrPage* pPage = GetPage();
1150 if( pPage )
1152 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1153 if( pDoc->GetMasterPageCount() )
1155 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1156 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1157 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), FALSE));
1159 else
1161 aAny <<= (sal_Bool)sal_False;
1164 break;
1166 case WID_PAGE_USERATTRIBS:
1168 GetPage()->getAlienAttributes( aAny );
1169 break;
1171 case WID_PAGE_BOOKMARK:
1173 aAny <<= getBookmarkURL();
1174 break;
1176 case WID_PAGE_ISDARK:
1178 aAny <<= (sal_Bool)GetPage()->GetPageBackgroundColor().IsDark();
1179 break;
1181 case WID_PAGE_HEADERVISIBLE:
1182 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbHeaderVisible;
1183 break;
1184 case WID_PAGE_HEADERTEXT:
1186 const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText );
1187 aAny <<= aText;
1189 break;
1190 case WID_PAGE_FOOTERVISIBLE:
1191 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbFooterVisible;
1192 break;
1193 case WID_PAGE_FOOTERTEXT:
1195 const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText );
1196 aAny <<= aText;
1198 break;
1199 case WID_PAGE_PAGENUMBERVISIBLE:
1200 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbSlideNumberVisible;
1201 break;
1202 case WID_PAGE_DATETIMEVISIBLE:
1203 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeVisible;
1204 break;
1205 case WID_PAGE_DATETIMEFIXED:
1206 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed;
1207 break;
1208 case WID_PAGE_DATETIMETEXT:
1210 const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText );
1211 aAny <<= aText;
1213 break;
1214 case WID_PAGE_DATETIMEFORMAT:
1215 aAny <<= (sal_Int32)GetPage()->getHeaderFooterSettings().meDateTimeFormat;
1216 break;
1218 case WID_TRANSITION_TYPE:
1219 aAny <<= GetPage()->getTransitionType();
1220 break;
1222 case WID_TRANSITION_SUBTYPE:
1223 aAny <<= GetPage()->getTransitionSubtype();
1224 break;
1226 case WID_TRANSITION_DIRECTION:
1227 aAny <<= GetPage()->getTransitionDirection();
1228 break;
1230 case WID_TRANSITION_FADE_COLOR:
1231 aAny <<= GetPage()->getTransitionFadeColor();
1232 break;
1234 case WID_TRANSITION_DURATION:
1235 aAny <<= GetPage()->getTransitionDuration();
1236 break;
1238 default:
1239 throw beans::UnknownPropertyException();
1241 return aAny;
1244 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1245 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1246 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1247 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1249 // XMultiPropertySet
1250 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 )
1252 if( aPropertyNames.getLength() != aValues.getLength() )
1253 throw lang::IllegalArgumentException();
1255 const OUString* pNames = aPropertyNames.getConstArray();
1256 const Any* pValues = aValues.getConstArray();
1257 sal_uInt32 nCount = aValues.getLength();
1258 while( nCount-- )
1262 setPropertyValue( *pNames++, *pValues++ );
1264 catch( beans::UnknownPropertyException& )
1266 // ignore for multi property set
1267 // todo: optimize this!
1272 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
1274 const OUString* pNames = aPropertyNames.getConstArray();
1275 sal_uInt32 nCount = aPropertyNames.getLength();
1276 Sequence< Any > aValues( nCount );
1277 Any* pValues = aValues.getArray();
1278 while( nCount-- )
1280 Any aValue;
1283 aValue = getPropertyValue( *pNames++ );
1285 catch( beans::UnknownPropertyException& )
1287 // ignore for multi property set
1288 // todo: optimize this!
1290 *pValues++ = aValue;
1292 return aValues;
1295 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1299 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1303 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1307 Reference< drawing::XShape > SdGenericDrawPage::_CreateShape( SdrObject *pObj ) const throw()
1309 DBG_ASSERT( GetPage(), "SdGenericDrawPage::_CreateShape(), can't create shape for disposed page!" );
1310 DBG_ASSERT( pObj, "SdGenericDrawPage::_CreateShape(), invalid call with pObj == 0!" );
1312 if( GetPage() && pObj )
1314 PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
1316 SvxShape* pShape = NULL;
1318 if(pObj->GetObjInventor() == SdrInventor)
1320 sal_uInt32 nInventor = pObj->GetObjIdentifier();
1321 switch( nInventor )
1323 case OBJ_TITLETEXT:
1324 pShape = new SvxShapeText( pObj );
1325 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
1327 // fake a empty PageShape if its a title shape on the master page
1328 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape")));
1330 else
1332 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")));
1334 eKind = PRESOBJ_NONE;
1335 break;
1336 case OBJ_OUTLINETEXT:
1337 pShape = new SvxShapeText( pObj );
1338 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape")));
1339 eKind = PRESOBJ_NONE;
1340 break;
1344 Reference< drawing::XShape > xShape( pShape );
1346 if(!xShape.is())
1347 xShape = SvxFmDrawPage::_CreateShape( pObj );
1350 if( eKind != PRESOBJ_NONE )
1352 String aShapeType( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation."));
1354 switch( eKind )
1356 case PRESOBJ_TITLE:
1357 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TitleTextShape") );
1358 break;
1359 case PRESOBJ_OUTLINE:
1360 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OutlinerShape") );
1361 break;
1362 case PRESOBJ_TEXT:
1363 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SubtitleShape") );
1364 break;
1365 case PRESOBJ_GRAPHIC:
1366 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape") );
1367 break;
1368 case PRESOBJ_OBJECT:
1369 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OLE2Shape") );
1370 break;
1371 case PRESOBJ_CHART:
1372 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("ChartShape") );
1373 break;
1374 case PRESOBJ_ORGCHART:
1375 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OrgChartShape") );
1376 break;
1377 case PRESOBJ_TABLE:
1378 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TableShape") );
1379 break;
1380 case PRESOBJ_BACKGROUND:
1381 DBG_ASSERT( sal_False, "Danger! Someone got hold of the horrible background shape!" );
1382 break;
1383 case PRESOBJ_PAGE:
1384 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("PageShape") );
1385 break;
1386 case PRESOBJ_HANDOUT:
1387 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HandoutShape") );
1388 break;
1389 case PRESOBJ_NOTES:
1390 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("NotesShape") );
1391 break;
1392 case PRESOBJ_FOOTER:
1393 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("FooterShape") );
1394 break;
1395 case PRESOBJ_HEADER:
1396 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HeaderShape") );
1397 break;
1398 case PRESOBJ_SLIDENUMBER:
1399 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SlideNumberShape") );
1400 break;
1401 case PRESOBJ_DATETIME:
1402 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("DateTimeShape") );
1403 break;
1404 case PRESOBJ_NONE:
1405 case PRESOBJ_IMAGE:
1406 case PRESOBJ_MAX:
1407 break;
1410 if( !pShape )
1411 pShape = SvxShape::getImplementation( xShape );
1413 if( pShape )
1414 pShape->SetShapeType( aShapeType );
1417 // SdXShape aggregiert SvxShape
1418 new SdXShape( SvxShape::getImplementation( xShape ), GetModel() );
1419 return xShape;
1421 else
1423 return SvxFmDrawPage::_CreateShape( pObj );
1428 //----------------------------------------------------------------------
1430 // XServiceInfo
1431 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames()
1432 throw(uno::RuntimeException)
1434 Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() );
1435 SvxServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.drawing.GenericDrawPage",
1436 "com.sun.star.document.LinkTarget",
1437 "com.sun.star.document.LinkTargetSupplier");
1438 return aSeq;
1441 //----------------------------------------------------------------------
1443 // XLinkTargetSupplier
1444 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( )
1445 throw(uno::RuntimeException)
1447 return new SdPageLinkTargets( (SdGenericDrawPage*)this );
1450 //----------------------------------------------------------------------
1452 void SdGenericDrawPage::setBackground( const Any& ) throw(lang::IllegalArgumentException)
1454 DBG_ERROR( "Don't call me, I'm useless!" );
1457 //----------------------------------------------------------------------
1459 void SdGenericDrawPage::getBackground( Any& ) throw()
1461 DBG_ERROR( "Don't call me, I'm useless!" );
1464 //----------------------------------------------------------------------
1466 OUString SdGenericDrawPage::getBookmarkURL() const
1468 OUStringBuffer aRet;
1469 if( SvxFmDrawPage::mpPage )
1471 OUString aFileName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetFileName() );
1472 if( aFileName.getLength() )
1474 const OUString aBookmarkName( SdDrawPage::getPageApiNameFromUiName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetBookmarkName() ) );
1475 aRet.append( aFileName );
1476 aRet.append( (sal_Unicode)'#' );
1477 aRet.append( aBookmarkName );
1481 return aRet.makeStringAndClear();
1484 //----------------------------------------------------------------------
1485 void SdGenericDrawPage::setBookmarkURL( rtl::OUString& rURL )
1487 if( SvxFmDrawPage::mpPage )
1489 sal_Int32 nIndex = rURL.indexOf( (sal_Unicode)'#' );
1490 if( nIndex != -1 )
1492 const String aFileName( rURL.copy( 0, nIndex ) );
1493 const String aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 ) ) );
1495 if( aFileName.Len() && aBookmarkName.Len() )
1497 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->DisconnectLink();
1498 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetFileName( aFileName );
1499 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetBookmarkName( aBookmarkName );
1500 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->ConnectLink();
1506 //----------------------------------------------------------------------
1507 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes )
1508 throw( uno::RuntimeException )
1510 OGuard aGuard( Application::GetSolarMutex() );
1512 throwIfDisposed();
1514 DBG_ASSERT(SvxFmDrawPage::mpPage,"SdrPage ist NULL! [CL]");
1515 DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
1517 Reference< drawing::XShape > xShape;
1518 if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1519 return xShape;
1521 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1523 _SelectObjectsInView( xShapes, pPageView );
1525 mpView->CombineMarkedObjects( sal_False );
1527 mpView->AdjustMarkHdl();
1528 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1529 if( rMarkList.GetMarkCount() == 1 )
1531 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1532 if( pObj )
1533 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1536 mpView->HideSdrPage();
1538 GetModel()->SetModified();
1540 return xShape;
1543 //----------------------------------------------------------------------
1544 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup )
1545 throw( uno::RuntimeException )
1547 OGuard aGuard( Application::GetSolarMutex() );
1549 throwIfDisposed();
1551 if(mpView==NULL||!xGroup.is()||GetPage()==NULL)
1552 return;
1554 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1555 _SelectObjectInView( xGroup, pPageView );
1556 mpView->DismantleMarkedObjects( sal_False );
1557 mpView->HideSdrPage();
1559 GetModel()->SetModified();
1562 //----------------------------------------------------------------------
1563 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes )
1564 throw( uno::RuntimeException )
1566 OGuard aGuard( Application::GetSolarMutex() );
1568 throwIfDisposed();
1570 uno::Reference< drawing::XShape > xShape;
1571 if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1572 return xShape;
1574 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1576 _SelectObjectsInView( xShapes, pPageView );
1578 mpView->CombineMarkedObjects( sal_True );
1580 mpView->AdjustMarkHdl();
1581 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1582 if( rMarkList.GetMarkCount() == 1 )
1584 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1585 if( pObj )
1586 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1589 mpView->HideSdrPage();
1591 GetModel()->SetModified();
1593 return xShape;
1596 //----------------------------------------------------------------------
1597 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape )
1598 throw( uno::RuntimeException )
1600 OGuard aGuard( Application::GetSolarMutex() );
1602 throwIfDisposed();
1604 if(mpView==NULL||!xShape.is()||GetPage()==NULL)
1605 return;
1607 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1608 _SelectObjectInView( xShape, pPageView );
1609 mpView->DismantleMarkedObjects( sal_True );
1610 mpView->HideSdrPage();
1612 GetModel()->SetModified();
1615 void SdGenericDrawPage::SetLftBorder( sal_Int32 nValue )
1617 if( nValue != GetPage()->GetLftBorder() )
1619 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1620 const PageKind ePageKind = GetPage()->GetPageKind();
1622 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1623 for (i = 0; i < nPageCnt; i++)
1625 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1626 pPage->SetLftBorder( nValue );
1629 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1631 for (i = 0; i < nPageCnt; i++)
1633 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1634 pPage->SetLftBorder( nValue );
1639 void SdGenericDrawPage::SetRgtBorder( sal_Int32 nValue )
1641 if( nValue != GetPage()->GetRgtBorder() )
1643 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1644 const PageKind ePageKind = GetPage()->GetPageKind();
1646 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1647 for (i = 0; i < nPageCnt; i++)
1649 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1650 pPage->SetRgtBorder( nValue );
1653 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1655 for (i = 0; i < nPageCnt; i++)
1657 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1658 pPage->SetRgtBorder( nValue );
1663 void SdGenericDrawPage::SetUppBorder( sal_Int32 nValue )
1665 if( nValue != GetPage()->GetUppBorder() )
1667 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1668 const PageKind ePageKind = GetPage()->GetPageKind();
1670 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1671 for (i = 0; i < nPageCnt; i++)
1673 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1674 pPage->SetUppBorder( nValue );
1677 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1679 for (i = 0; i < nPageCnt; i++)
1681 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1682 pPage->SetUppBorder( nValue );
1687 void SdGenericDrawPage::SetLwrBorder( sal_Int32 nValue )
1689 if( nValue != GetPage()->GetLwrBorder() )
1691 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1692 const PageKind ePageKind = GetPage()->GetPageKind();
1694 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1695 for (i = 0; i < nPageCnt; i++)
1697 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1698 pPage->SetLwrBorder( nValue );
1701 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1703 for (i = 0; i < nPageCnt; i++)
1705 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1706 pPage->SetLwrBorder( nValue );
1711 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind )
1713 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1714 if ( pDocShell )
1716 ::sd::ViewShell* pViewSh = pDocShell->GetViewShell();
1718 if( pViewSh )
1720 if( pViewSh->ISA(::sd::DrawViewShell ) )
1721 static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage();
1723 Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
1724 const long nWidth = aPageSize.Width();
1725 const long nHeight = aPageSize.Height();
1727 Point aPageOrg = Point(nWidth, nHeight / 2);
1728 Size aViewSize = Size(nWidth * 3, nHeight * 2);
1730 pDoc->SetMaxObjSize(aViewSize);
1732 pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), TRUE);
1734 pViewSh->UpdateScrollBars();
1739 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth )
1741 Size aSize( GetPage()->GetSize() );
1742 if( aSize.getWidth() != nWidth )
1744 aSize.setWidth( nWidth );
1746 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1747 const PageKind ePageKind = GetPage()->GetPageKind();
1749 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1750 for (i = 0; i < nPageCnt; i++)
1752 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1753 pPage->SetSize(aSize);
1756 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1758 for (i = 0; i < nPageCnt; i++)
1760 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1761 pPage->SetSize(aSize);
1764 refreshpage( pDoc, ePageKind );
1768 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight )
1770 Size aSize( GetPage()->GetSize() );
1771 if( aSize.getHeight() != nHeight )
1773 aSize.setHeight( nHeight );
1775 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1776 const PageKind ePageKind = GetPage()->GetPageKind();
1778 USHORT i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1779 for (i = 0; i < nPageCnt; i++)
1781 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1782 pPage->SetSize(aSize);
1785 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1787 for (i = 0; i < nPageCnt; i++)
1789 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1790 pPage->SetSize(aSize);
1793 refreshpage( pDoc, ePageKind );
1797 // XInterface
1798 void SdGenericDrawPage::release() throw()
1801 OWeakAggObject::release();
1804 // XComponent
1805 void SdGenericDrawPage::disposing() throw()
1807 mpModel = 0;
1808 SvxFmDrawPage::disposing();
1811 // XAnimationNodeSupplier
1812 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode() throw (uno::RuntimeException)
1814 OGuard aGuard( Application::GetSolarMutex() );
1816 throwIfDisposed();
1818 SdPage *pSdPage = static_cast<SdPage*>(SvxFmDrawPage::mpPage);
1821 return pSdPage->getAnimationNode();
1824 //========================================================================
1825 // SdPageLinkTargets
1826 //========================================================================
1828 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw()
1830 mxPage = pUnoPage;
1831 mpUnoPage = pUnoPage;
1834 SdPageLinkTargets::~SdPageLinkTargets() throw()
1838 // XElementAccess
1839 uno::Type SAL_CALL SdPageLinkTargets::getElementType()
1840 throw(uno::RuntimeException)
1842 return ITYPE(beans::XPropertySet);
1845 sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
1846 throw(uno::RuntimeException)
1848 OGuard aGuard( Application::GetSolarMutex() );
1850 SdPage* pPage = mpUnoPage->GetPage();
1851 if( pPage != NULL )
1853 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1855 while( aIter.IsMore() )
1857 SdrObject* pObj = aIter.Next();
1858 String aStr( pObj->GetName() );
1859 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1860 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1861 if( aStr.Len() )
1862 return sal_True;
1866 return sal_False;
1869 // container::XNameAccess
1871 // XNameAccess
1872 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName )
1873 throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1875 OGuard aGuard( Application::GetSolarMutex() );
1877 SdPage* pPage = mpUnoPage->GetPage();
1878 if( pPage != NULL )
1880 SdrObject* pObj = FindObject( aName );
1881 if( pObj )
1883 Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY );
1884 return makeAny( aRef );
1888 throw container::NoSuchElementException();
1891 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames()
1892 throw(uno::RuntimeException)
1894 OGuard aGuard( Application::GetSolarMutex() );
1896 sal_uInt32 nObjCount = 0;
1898 SdPage* pPage = mpUnoPage->GetPage();
1899 if( pPage != NULL )
1901 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1902 while( aIter.IsMore() )
1904 SdrObject* pObj = aIter.Next();
1905 String aStr( pObj->GetName() );
1906 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1907 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1908 if( aStr.Len() )
1909 nObjCount++;
1913 Sequence< OUString > aSeq( nObjCount );
1914 if( nObjCount > 0 )
1916 OUString* pStr = aSeq.getArray();
1918 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1919 while( aIter.IsMore() )
1921 SdrObject* pObj = aIter.Next();
1922 String aStr( pObj->GetName() );
1923 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1924 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1925 if( aStr.Len() )
1926 *pStr++ = aStr;
1930 return aSeq;
1933 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName )
1934 throw(uno::RuntimeException)
1936 OGuard aGuard( Application::GetSolarMutex() );
1938 return FindObject( aName ) != NULL;
1941 /***********************************************************************
1943 ***********************************************************************/
1944 SdrObject* SdPageLinkTargets::FindObject( const String& rName ) const throw()
1946 SdPage* pPage = mpUnoPage->GetPage();
1947 if( pPage == NULL )
1948 return NULL;
1950 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1952 while( aIter.IsMore() )
1954 SdrObject* pObj = aIter.Next();
1955 String aStr( pObj->GetName() );
1956 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1957 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1958 if( aStr.Len() && (aStr == rName) )
1959 return pObj;
1962 return NULL;
1965 // XServiceInfo
1966 OUString SAL_CALL SdPageLinkTargets::getImplementationName()
1967 throw(uno::RuntimeException)
1969 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdPageLinkTargets") );
1972 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName )
1973 throw(uno::RuntimeException)
1975 return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
1978 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames()
1979 throw(uno::RuntimeException)
1981 const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") );
1982 Sequence< OUString > aSeq( &aSN, 1);
1983 return aSeq;
1986 //========================================================================
1987 // SdDrawPage
1988 //========================================================================
1990 SdDrawPage::SdDrawPage( SdXImpressDocument* pModel, SdPage* pPage ) throw()
1991 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) )
1995 SdDrawPage::~SdDrawPage() throw()
1999 // XInterface
2000 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType )
2001 throw(uno::RuntimeException)
2003 if( rType == ITYPE( drawing::XMasterPageTarget ) )
2005 return makeAny( Reference< drawing::XMasterPageTarget >( this ) );
2007 else
2009 if( mbIsImpressDocument )
2011 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2013 if( ePageKind != PK_HANDOUT && rType == ITYPE( presentation::XPresentationPage ) )
2015 return makeAny( Reference< presentation::XPresentationPage >( this ) );
2020 return SdGenericDrawPage::queryInterface( rType );
2023 void SAL_CALL SdDrawPage::acquire() throw()
2025 SvxDrawPage::acquire();
2028 void SAL_CALL SdDrawPage::release() throw()
2030 SvxDrawPage::release();
2033 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage );
2035 // XTypeProvider
2036 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeException)
2038 OGuard aGuard( Application::GetSolarMutex() );
2040 throwIfDisposed();
2042 if( maTypeSequence.getLength() == 0 )
2044 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2045 sal_Bool bPresPage = mbIsImpressDocument && ePageKind != PK_HANDOUT;
2047 // Collect the types of this class.
2048 ::std::vector<uno::Type> aTypes;
2049 aTypes.reserve(13);
2050 aTypes.push_back(ITYPE(drawing::XDrawPage));
2051 aTypes.push_back(ITYPE(beans::XPropertySet));
2052 aTypes.push_back(ITYPE(container::XNamed));
2053 aTypes.push_back(ITYPE(drawing::XMasterPageTarget));
2054 aTypes.push_back(ITYPE(lang::XServiceInfo));
2055 aTypes.push_back(ITYPE(util::XReplaceable));
2056 aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2057 aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2058 aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2059 aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2060 aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2061 if( bPresPage )
2062 aTypes.push_back(ITYPE(presentation::XPresentationPage));
2063 if( bPresPage && ePageKind == PK_STANDARD )
2064 aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2066 // Get types of base class.
2067 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2068 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2069 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2071 // Join those types in a sequence.
2072 maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2073 uno::Type* pTypes = maTypeSequence.getArray();
2074 ::std::vector<uno::Type>::const_iterator iType;
2075 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2076 *pTypes++ = *iType;
2077 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2078 *pTypes++ = *pBaseTypes++;
2081 return maTypeSequence;
2084 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId() throw(uno::RuntimeException)
2086 OGuard aGuard( Application::GetSolarMutex() );
2088 throwIfDisposed();
2090 static Sequence< sal_Int8 > aId;
2091 if( aId.getLength() == 0 )
2093 aId.realloc( 16 );
2094 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
2096 return aId;
2099 OUString SdDrawPage::getPageApiName( SdPage* pPage )
2101 return ::getPageApiName( pPage );
2104 OUString getPageApiName( SdPage* pPage )
2106 OUString aPageName;
2108 if(pPage)
2110 aPageName = pPage->GetRealName();
2112 if( aPageName.getLength() == 0 )
2114 OUStringBuffer sBuffer;
2115 sBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( sEmptyPageName ) );
2116 const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
2117 sBuffer.append( nPageNum );
2118 aPageName = sBuffer.makeStringAndClear();
2122 return aPageName;
2126 OUString getPageApiNameFromUiName( const String& rUIName )
2128 OUString aApiName;
2130 String aDefPageName(SdResId(STR_PAGE));
2131 aDefPageName += sal_Unicode( ' ' );
2133 if( rUIName.Equals( aDefPageName, 0, aDefPageName.Len() ) )
2135 aApiName = OUString( RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ) );
2136 aApiName += rUIName.Copy( aDefPageName.Len() );
2138 else
2140 aApiName = rUIName;
2143 return aApiName;
2146 OUString SdDrawPage::getPageApiNameFromUiName( const String& rUIName )
2148 return ::getPageApiNameFromUiName( rUIName );
2151 String getUiNameFromPageApiNameImpl( const OUString& rApiName )
2153 const String aDefPageName(RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ));
2154 if( rApiName.compareTo( aDefPageName, aDefPageName.Len() ) == 0 )
2156 OUString aNumber( rApiName.copy( sizeof( sEmptyPageName ) - 1 ) );
2158 // create the page number
2159 sal_Int32 nPageNumber = aNumber.toInt32();
2161 // check if there are non number characters in the number part
2162 const sal_Int32 nChars = aNumber.getLength();
2163 const sal_Unicode* pString = aNumber.getStr();
2164 sal_Int32 nChar;
2165 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2167 if((*pString < sal_Unicode('0')) || (*pString > sal_Unicode('9')))
2169 // found a non number character, so this is not the default
2170 // name for this page
2171 nPageNumber = -1;
2172 break;
2176 if( nPageNumber != -1)
2178 OUStringBuffer sBuffer;
2179 sBuffer.append( String(SdResId(STR_PAGE)) );
2180 sBuffer.append( sal_Unicode( ' ' ) );
2181 sBuffer.append( aNumber );
2182 return sBuffer.makeStringAndClear();
2186 return rApiName;
2189 String SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName )
2191 return getUiNameFromPageApiNameImpl( rApiName );
2194 // XServiceInfo
2195 OUString SAL_CALL SdDrawPage::getImplementationName() throw(uno::RuntimeException)
2197 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDrawPage") );
2200 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames() throw(uno::RuntimeException)
2202 OGuard aGuard( Application::GetSolarMutex() );
2204 throwIfDisposed();
2206 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2207 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.DrawPage" );
2209 if( mbIsImpressDocument )
2210 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.DrawPage" );
2212 return aSeq;
2215 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName )
2216 throw(uno::RuntimeException)
2218 return SdGenericDrawPage::supportsService( ServiceName );
2221 // XNamed
2222 void SAL_CALL SdDrawPage::setName( const OUString& rName )
2223 throw(uno::RuntimeException)
2225 OGuard aGuard( Application::GetSolarMutex() );
2227 throwIfDisposed();
2229 DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" );
2231 OUString aName( rName );
2233 if(GetPage() && GetPage()->GetPageKind() != PK_NOTES)
2235 // check if this is the default 'page1234' name
2236 if(aName.compareToAscii( sEmptyPageName, sizeof( sEmptyPageName ) - 1 ) == 0)
2238 // ok, it maybe is, first get the number part after 'page'
2239 OUString aNumber( aName.copy( sizeof( sEmptyPageName ) - 1 ) );
2241 // create the page number
2242 sal_Int32 nPageNumber = aNumber.toInt32();
2244 // check if there are non number characters in the number part
2245 const sal_Int32 nChars = aNumber.getLength();
2246 const sal_Unicode* pString = aNumber.getStr();
2247 sal_Int32 nChar;
2248 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2250 if((*pString < '0') || (*pString > '9'))
2252 // found a non number character, so this is not the default
2253 // name for this page
2254 nPageNumber = -1;
2255 break;
2259 if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 )
2260 aName = OUString();
2262 else
2264 String aDefaultPageName( SdResId(STR_PAGE) );
2265 aDefaultPageName += sal_Unicode( ' ' );
2266 if( aName.compareTo( aDefaultPageName, aDefaultPageName.Len() ) == 0 )
2267 aName = OUString();
2270 GetPage()->SetName( aName );
2272 USHORT nNotesPageNum = (GetPage()->GetPageNum()-1)>>1;
2273 if( GetModel()->GetDoc()->GetSdPageCount( PK_NOTES ) > nNotesPageNum )
2275 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PK_NOTES );
2276 if( pNotesPage )
2277 pNotesPage->SetName(aName);
2280 // fake a mode change to repaint the page tab bar
2281 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2282 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
2283 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell))
2285 ::sd::DrawViewShell* pDrawViewSh = static_cast<
2286 ::sd::DrawViewShell*>(pViewSh);
2288 EditMode eMode = pDrawViewSh->GetEditMode();
2289 if( eMode == EM_PAGE )
2291 BOOL bLayer = pDrawViewSh->IsLayerModeActive();
2293 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2294 pDrawViewSh->ChangeEditMode( eMode, bLayer );
2298 GetModel()->SetModified();
2302 OUString SAL_CALL SdDrawPage::getName()
2303 throw(uno::RuntimeException)
2305 OGuard aGuard( Application::GetSolarMutex() );
2307 throwIfDisposed();
2309 return getPageApiName( GetPage() );
2312 // XMasterPageTarget
2313 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( )
2314 throw(uno::RuntimeException)
2316 OGuard aGuard( Application::GetSolarMutex() );
2318 throwIfDisposed();
2320 if(GetPage())
2322 Reference< drawing::XDrawPages > xPages( GetModel()->getMasterPages() );
2323 Reference< drawing::XDrawPage > xPage;
2325 if(SvxFmDrawPage::mpPage->TRG_HasMasterPage())
2327 SdrPage& rMasterPage = SvxFmDrawPage::mpPage->TRG_GetMasterPage();
2328 xPage = uno::Reference< drawing::XDrawPage >( rMasterPage.getUnoPage(), uno::UNO_QUERY );
2331 return xPage;
2333 return NULL;
2336 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage )
2337 throw(uno::RuntimeException)
2339 OGuard aGuard( Application::GetSolarMutex() );
2341 throwIfDisposed();
2343 if(SvxFmDrawPage::mpPage)
2345 SdMasterPage* pMasterPage = SdMasterPage::getImplementation( xMasterPage );
2346 if( pMasterPage && pMasterPage->isValid() )
2348 SvxFmDrawPage::mpPage->TRG_ClearMasterPage();
2350 SdPage* pSdPage = (SdPage*) pMasterPage->GetSdrPage();
2351 SvxFmDrawPage::mpPage->TRG_SetMasterPage(*pSdPage);
2353 SvxFmDrawPage::mpPage->SetBorder(pSdPage->GetLftBorder(),pSdPage->GetUppBorder(),
2354 pSdPage->GetRgtBorder(),pSdPage->GetLwrBorder() );
2356 SvxFmDrawPage::mpPage->SetSize( pSdPage->GetSize() );
2357 SvxFmDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() );
2358 ((SdPage*)SvxFmDrawPage::mpPage)->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2360 // set notes master also
2361 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2363 pNotesPage->TRG_ClearMasterPage();
2364 sal_uInt16 nNum = (SvxFmDrawPage::mpPage->TRG_GetMasterPage()).GetPageNum() + 1;
2365 pNotesPage->TRG_SetMasterPage(*SvxFmDrawPage::mpPage->GetModel()->GetMasterPage(nNum));
2366 pNotesPage->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2368 GetModel()->SetModified();
2374 // XPresentationPage
2375 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage()
2376 throw(uno::RuntimeException)
2378 OGuard aGuard( Application::GetSolarMutex() );
2380 throwIfDisposed();
2382 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() && SvxFmDrawPage::mpPage->GetPageNum() )
2384 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2385 if( pNotesPage )
2387 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2388 return xPage;
2391 return NULL;
2395 // XIndexAccess
2396 sal_Int32 SAL_CALL SdDrawPage::getCount()
2397 throw(uno::RuntimeException)
2399 return SdGenericDrawPage::getCount();
2402 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index )
2403 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2405 return SdGenericDrawPage::getByIndex( Index );
2408 // XElementAccess
2409 uno::Type SAL_CALL SdDrawPage::getElementType()
2410 throw(uno::RuntimeException)
2412 return SdGenericDrawPage::getElementType();
2415 sal_Bool SAL_CALL SdDrawPage::hasElements()
2416 throw(uno::RuntimeException)
2418 return SdGenericDrawPage::hasElements();
2421 // XShapes
2422 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2424 SdGenericDrawPage::add( xShape );
2427 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2429 OGuard aGuard( Application::GetSolarMutex() );
2431 throwIfDisposed();
2433 SvxShape* pShape = SvxShape::getImplementation( xShape );
2434 if( pShape )
2436 SdrObject* pObj = pShape->GetSdrObject();
2437 if( pObj )
2439 GetPage()->RemovePresObj(pObj);
2440 pObj->SetUserCall(NULL);
2444 SdGenericDrawPage::remove( xShape );
2447 void SdDrawPage::setBackground( const Any& rValue )
2448 throw( lang::IllegalArgumentException )
2450 Reference< beans::XPropertySet > xSet;
2452 if( !(rValue >>= xSet) && !rValue.hasValue() )
2453 throw lang::IllegalArgumentException();
2455 if( !xSet.is() )
2457 // the easy case, clear the background obj
2458 GetPage()->SetBackgroundObj( NULL );
2460 // #110094#-15
2461 // tell the page that it's visualization has changed
2462 GetPage()->ActionChanged();
2464 return;
2467 // prepare background object
2468 SdrObject* pObj = GetPage()->GetBackgroundObj();
2469 if( NULL == pObj )
2471 pObj = new SdrRectObj();
2472 GetPage()->SetBackgroundObj( pObj );
2474 // #110094#-15
2475 // tell the page that it's visualization has changed
2476 GetPage()->ActionChanged();
2479 const sal_Int32 nLeft = GetPage()->GetLftBorder();
2480 const sal_Int32 nRight = GetPage()->GetRgtBorder();
2481 const sal_Int32 nUpper = GetPage()->GetUppBorder();
2482 const sal_Int32 nLower = GetPage()->GetLwrBorder();
2484 Point aPos ( nLeft, nRight );
2485 Size aSize( GetPage()->GetSize() );
2486 aSize.Width() -= nLeft + nRight - 1;
2487 aSize.Height() -= nUpper + nLower - 1;
2488 Rectangle aRect( aPos, aSize );
2489 pObj->SetLogicRect( aRect );
2491 // is it our own implementation?
2492 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet );
2494 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2496 if( pBack )
2498 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2500 else
2502 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2504 Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2505 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground );
2506 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() );
2508 Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
2509 sal_Int32 nCount = aProperties.getLength();
2510 beans::Property* pProp = aProperties.getArray();
2512 while( nCount-- )
2514 const OUString aPropName( pProp->Name );
2515 if( xSetInfo->hasPropertyByName( aPropName ) )
2516 xDestSet->setPropertyValue( aPropName,
2517 xSet->getPropertyValue( aPropName ) );
2519 pProp++;
2522 pBackground->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2525 //-/ pObj->NbcSetAttributes( aSet, sal_False );
2526 if( aSet.Count() == 0 )
2528 GetPage()->SetBackgroundObj( NULL );
2530 else
2532 pObj->SetMergedItemSet(aSet);
2535 // repaint only
2536 SvxFmDrawPage::mpPage->ActionChanged();
2537 // pPage->SendRepaintBroadcast();
2540 // XAnnotationAccess:
2541 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() throw (RuntimeException)
2543 if( !GetPage() )
2544 throw DisposedException();
2546 Reference< XAnnotation > xRet;
2547 GetPage()->createAnnotation(xRet);
2548 return xRet;
2551 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) throw (RuntimeException, IllegalArgumentException)
2553 GetPage()->removeAnnotation(annotation);
2556 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() throw (RuntimeException)
2558 return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() );
2561 void SdDrawPage::getBackground( Any& rValue ) throw()
2563 SdrObject* pObj = GetPage()->GetBackgroundObj();
2564 if( NULL == pObj )
2566 rValue.clear();
2568 else
2570 Reference< beans::XPropertySet > xSet( new SdUnoPageBackground( GetModel()->GetDoc(), pObj ) );
2571 rValue <<= xSet;
2575 void SdGenericDrawPage::setNavigationOrder( const Any& rValue )
2577 Reference< XIndexAccess > xIA( rValue, UNO_QUERY );
2578 if( xIA.is() )
2580 if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this )
2582 if( GetPage()->HasObjectNavigationOrder() )
2583 GetPage()->ClearObjectNavigationOrder();
2585 return;
2587 else if( xIA->getCount() == static_cast< sal_Int32 >( GetPage()->GetObjCount() ) )
2589 GetPage()->SetNavigationOrder(xIA);
2590 return;
2593 throw IllegalArgumentException();
2596 class NavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess >
2598 public:
2599 NavigationOrderAccess( SdrPage* pPage );
2601 // XIndexAccess
2602 virtual sal_Int32 SAL_CALL getCount( ) throw (RuntimeException);
2603 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
2605 // XElementAccess
2606 virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
2607 virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
2609 private:
2610 std::vector< Reference< XShape > > maShapes;
2613 NavigationOrderAccess::NavigationOrderAccess( SdrPage* pPage )
2614 : maShapes( static_cast< sal_uInt32 >( pPage ? pPage->GetObjCount() : 0 ) )
2616 if( pPage )
2618 sal_uInt32 nIndex;
2619 const sal_uInt32 nCount = static_cast< sal_uInt32 >( pPage->GetObjCount() );
2620 for( nIndex = 0; nIndex < nCount; ++nIndex )
2622 SdrObject* pObj = pPage->GetObj( nIndex );
2623 sal_uInt32 nNavPos = pObj->GetNavigationPosition();
2624 DBG_ASSERT( !maShapes[nNavPos].is(), "sd::NavigationOrderAccess::NavigationOrderAccess(), duplicate navigation positions from core!" );
2625 maShapes[nNavPos] = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
2630 // XIndexAccess
2631 sal_Int32 SAL_CALL NavigationOrderAccess::getCount( ) throw (RuntimeException)
2633 return static_cast< sal_Int32 >( maShapes.size() );
2636 Any SAL_CALL NavigationOrderAccess::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
2638 if( (Index < 0) || (Index > getCount()) )
2639 throw IndexOutOfBoundsException();
2641 return Any( maShapes[Index] );
2644 // XElementAccess
2645 Type SAL_CALL NavigationOrderAccess::getElementType( ) throw (RuntimeException)
2647 return XShape::static_type();
2650 sal_Bool SAL_CALL NavigationOrderAccess::hasElements( ) throw (RuntimeException)
2652 return maShapes.empty() ? sal_False : sal_True;
2655 Any SdGenericDrawPage::getNavigationOrder()
2657 if( GetPage()->HasObjectNavigationOrder() )
2659 return Any( Reference< XIndexAccess >( new NavigationOrderAccess( GetPage() ) ) );
2661 else
2663 return Any( Reference< XIndexAccess >( this ) );
2667 //========================================================================
2668 // class SdMasterPage
2669 //========================================================================
2671 SdMasterPage::SdMasterPage( SdXImpressDocument* pModel, SdPage* pPage ) throw()
2672 : SdGenericDrawPage( pModel, pPage, ImplGetMasterPagePropertySet( pPage ? pPage->GetPageKind() : PK_STANDARD ) )
2674 mbHasBackgroundObject = pPage && GetPage()->GetPageKind() == PK_STANDARD;
2677 SdMasterPage::~SdMasterPage() throw()
2681 // XInterface
2682 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType )
2683 throw(uno::RuntimeException)
2685 OGuard aGuard( Application::GetSolarMutex() );
2687 throwIfDisposed();
2689 uno::Any aAny;
2691 if( rType == ITYPE( container::XIndexAccess ) )
2692 aAny <<= Reference< container::XIndexAccess >((presentation::XPresentationPage*)(this));
2693 else if( rType == ITYPE( container::XElementAccess ) )
2694 aAny <<= Reference< container::XElementAccess >((presentation::XPresentationPage*)(this));
2695 else if( rType == ITYPE( container::XNamed ) )
2696 aAny <<= Reference< container::XNamed >(this);
2697 else if( rType == ITYPE( presentation::XPresentationPage ) &&
2698 ( mbIsImpressDocument &&
2699 GetPage() && GetPage()->GetPageKind() != PK_HANDOUT) )
2700 aAny <<= Reference< presentation::XPresentationPage >( this );
2701 else
2702 return SdGenericDrawPage::queryInterface( rType );
2704 return aAny;
2707 void SAL_CALL SdMasterPage::acquire() throw()
2709 SvxDrawPage::acquire();
2712 void SAL_CALL SdMasterPage::release() throw()
2714 SvxDrawPage::release();
2717 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage );
2719 // XTypeProvider
2720 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeException)
2722 OGuard aGuard( Application::GetSolarMutex() );
2724 throwIfDisposed();
2726 if( maTypeSequence.getLength() == 0 )
2728 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2729 sal_Bool bPresPage = mbIsImpressDocument && SvxFmDrawPage::mpPage && ePageKind != PK_HANDOUT;
2731 // Collect the types of this class.
2732 ::std::vector<uno::Type> aTypes;
2733 aTypes.reserve(12);
2734 aTypes.push_back(ITYPE(drawing::XDrawPage));
2735 aTypes.push_back(ITYPE(beans::XPropertySet));
2736 aTypes.push_back(ITYPE(container::XNamed));
2737 aTypes.push_back(ITYPE(lang::XServiceInfo));
2738 aTypes.push_back(ITYPE(util::XReplaceable));
2739 aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2740 aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2741 aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2742 aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2743 aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2744 if( bPresPage )
2745 aTypes.push_back(ITYPE(presentation::XPresentationPage));
2746 if( bPresPage && ePageKind == PK_STANDARD )
2747 aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2749 // Get types of base class.
2750 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2751 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2752 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2754 // Join those types in a sequence.
2755 maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2756 uno::Type* pTypes = maTypeSequence.getArray();
2757 ::std::vector<uno::Type>::const_iterator iType;
2758 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2759 *pTypes++ = *iType;
2760 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2761 *pTypes++ = *pBaseTypes++;
2764 return maTypeSequence;
2767 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId() throw(uno::RuntimeException)
2769 OGuard aGuard( Application::GetSolarMutex() );
2771 throwIfDisposed();
2773 static Sequence< sal_Int8 > aId;
2774 if( aId.getLength() == 0 )
2776 aId.realloc( 16 );
2777 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
2779 return aId;
2782 // XServiceInfo
2783 OUString SAL_CALL SdMasterPage::getImplementationName() throw(uno::RuntimeException)
2785 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdMasterPage") );
2788 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames() throw(uno::RuntimeException)
2790 OGuard aGuard( Application::GetSolarMutex() );
2792 throwIfDisposed();
2794 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2795 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.MasterPage" );
2797 if( SvxFmDrawPage::mpPage && ((SdPage*)SvxFmDrawPage::mpPage)->GetPageKind() == PK_HANDOUT )
2798 SvxServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.HandoutMasterPage" );
2800 return aSeq;
2803 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName )
2804 throw(uno::RuntimeException)
2806 return SdGenericDrawPage::supportsService( ServiceName );
2809 // XElementAccess
2810 sal_Bool SAL_CALL SdMasterPage::hasElements() throw(uno::RuntimeException)
2812 OGuard aGuard( Application::GetSolarMutex() );
2814 throwIfDisposed();
2816 if( SvxFmDrawPage::mpPage == NULL )
2817 return sal_False;
2819 return (SvxFmDrawPage::mpPage->GetObjCount() > 1) || (!mbHasBackgroundObject && SvxFmDrawPage::mpPage->GetObjCount() == 1 );
2822 uno::Type SAL_CALL SdMasterPage::getElementType()
2823 throw(uno::RuntimeException)
2825 return SdGenericDrawPage::getElementType();
2828 // XIndexAccess
2829 sal_Int32 SAL_CALL SdMasterPage::getCount()
2830 throw(uno::RuntimeException)
2832 OGuard aGuard( Application::GetSolarMutex() );
2834 throwIfDisposed();
2836 sal_Int32 nCount = SdGenericDrawPage::getCount();
2837 DBG_ASSERT( !mbHasBackgroundObject || (nCount > 0), "possible wrong shape count!" );
2839 if( mbHasBackgroundObject && ( nCount > 0 ) )
2840 nCount--;
2842 return nCount;
2845 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index )
2846 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2848 OGuard aGuard( Application::GetSolarMutex() );
2850 throwIfDisposed();
2852 if( mbHasBackgroundObject )
2853 Index++;
2855 return SdGenericDrawPage::getByIndex(Index);
2858 // intern
2859 void SdMasterPage::setBackground( const Any& rValue )
2860 throw( lang::IllegalArgumentException )
2862 // we need at least an beans::XPropertySet
2863 Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY );
2864 if( !xInputSet.is() )
2865 throw lang::IllegalArgumentException();
2869 if( GetModel() && mbIsImpressDocument )
2871 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
2872 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ;
2873 if( xFamily.is() )
2875 OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
2877 Reference< beans::XPropertySet > xStyleSet( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2879 Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2880 Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY );
2882 PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap()->getPropertyEntries();
2883 PropertyEntryVector_t::const_iterator aIt = aBackgroundProperties.begin();
2884 while( aIt != aBackgroundProperties.end() )
2886 if( xSetInfo->hasPropertyByName( aIt->sName ) )
2888 if( !xSetStates.is() || xSetStates->getPropertyState( aIt->sName ) == beans::PropertyState_DIRECT_VALUE )
2889 xStyleSet->setPropertyValue( aIt->sName, xInputSet->getPropertyValue( aIt->sName ) );
2890 else
2891 xSetStates->setPropertyToDefault( aIt->sName );
2894 ++aIt;
2898 else
2900 // first fill an item set
2901 // is it our own implementation?
2902 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xInputSet );
2904 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2906 if( pBack )
2908 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2910 else
2912 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2914 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2915 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground );
2916 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_QUERY_THROW );
2918 uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
2919 sal_Int32 nCount = aProperties.getLength();
2920 beans::Property* pProp = aProperties.getArray();
2922 while( nCount-- )
2924 const OUString aPropName( pProp->Name );
2925 if( xInputSetInfo->hasPropertyByName( aPropName ) )
2926 xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
2928 pProp++;
2931 pBackground->fillItemSet( (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(), aSet );
2934 // if we find the background style, copy the set to the background
2935 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
2936 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
2937 if(pSSPool)
2939 String aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() );
2940 aLayoutName.Erase(aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
2941 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
2942 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
2944 if( pStyleSheet )
2946 pStyleSheet->GetItemSet().Put( aSet );
2948 // repaint only
2949 SvxFmDrawPage::mpPage->ActionChanged();
2950 return;
2955 // if no background style is available, try the background object
2956 SdrObject* pObj = GetPage()->GetPresObj(PRESOBJ_BACKGROUND);
2957 if( pObj == NULL )
2958 return;
2960 pObj->SetMergedItemSet(aSet);
2962 // repaint only
2963 SvxFmDrawPage::mpPage->ActionChanged();
2966 catch( Exception& )
2968 DBG_ERROR("sd::SdMasterPage::setBackground(), exception caught!");
2972 void SdMasterPage::getBackground( Any& rValue ) throw()
2974 if( GetModel() ) try
2976 if( mbIsImpressDocument )
2978 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
2979 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW );
2981 const OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
2982 rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2984 else
2986 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
2987 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
2988 if(pSSPool)
2990 String aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() );
2991 aLayoutName.Erase( aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
2992 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
2993 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
2995 if( pStyleSheet )
2997 SfxItemSet aStyleSet( pStyleSheet->GetItemSet());
2998 if( aStyleSet.Count() )
3000 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) );
3001 return;
3006 // no stylesheet? try old fashion background rectangle
3007 SdrObject* pObj = NULL;
3008 if( SvxFmDrawPage::mpPage->GetObjCount() >= 1 )
3010 pObj = SvxFmDrawPage::mpPage->GetObj(0);
3011 if( pObj->GetObjInventor() != SdrInventor || pObj->GetObjIdentifier() != OBJ_RECT )
3012 pObj = NULL;
3015 if( pObj )
3017 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( GetModel()->GetDoc(), pObj ) );
3018 return;
3022 rValue.clear();
3025 catch( Exception& )
3027 rValue.clear();
3028 DBG_ERROR("sd::SdMasterPage::getBackground(), exception caught!");
3032 // XNamed
3033 void SAL_CALL SdMasterPage::setName( const OUString& aName )
3034 throw(uno::RuntimeException)
3036 OGuard aGuard( Application::GetSolarMutex() );
3038 throwIfDisposed();
3040 if(SvxFmDrawPage::mpPage && GetPage()->GetPageKind() != PK_NOTES)
3042 String aNewName( aName );
3043 GetPage()->SetName( aNewName );
3045 if(GetModel()->GetDoc())
3046 GetModel()->GetDoc()->RenameLayoutTemplate(GetPage()->GetLayoutName(), aNewName);
3048 // fake a mode change to repaint the page tab bar
3049 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
3050 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
3051 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell ) )
3053 ::sd::DrawViewShell* pDrawViewSh =
3054 static_cast< ::sd::DrawViewShell*>(pViewSh);
3056 EditMode eMode = pDrawViewSh->GetEditMode();
3057 if( eMode == EM_MASTERPAGE )
3059 BOOL bLayer = pDrawViewSh->IsLayerModeActive();
3061 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
3062 pDrawViewSh->ChangeEditMode( eMode, bLayer );
3066 GetModel()->SetModified();
3070 OUString SAL_CALL SdMasterPage::getName( )
3071 throw(uno::RuntimeException)
3073 OGuard aGuard( Application::GetSolarMutex() );
3075 throwIfDisposed();
3077 if(SvxFmDrawPage::mpPage)
3079 String aLayoutName( GetPage()->GetLayoutName() );
3080 aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM((SD_LT_SEPARATOR)))));
3082 return aLayoutName;
3085 return OUString();
3088 // XPresentationPage
3089 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage()
3090 throw(uno::RuntimeException)
3092 OGuard aGuard( Application::GetSolarMutex() );
3094 throwIfDisposed();
3096 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() )
3098 SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
3099 if( pNotesPage )
3101 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
3102 return xPage;
3105 return NULL;
3108 // XShapes
3109 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3111 SdGenericDrawPage::add( xShape );
3114 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3116 OGuard aGuard( Application::GetSolarMutex() );
3118 throwIfDisposed();
3120 SvxShape* pShape = SvxShape::getImplementation( xShape );
3121 if( pShape )
3123 SdrObject* pObj = pShape->GetSdrObject();
3124 if( pObj )
3126 if( GetPage()->IsPresObj( pObj ) )
3127 GetPage()->RemovePresObj(pObj);
3131 SdGenericDrawPage::remove( xShape );
3135 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage )
3137 Reference< uno::XInterface > xPage;
3139 if( pPage && pPage->GetModel() )
3141 SdXImpressDocument* pModel = SdXImpressDocument::getImplementation( pPage->GetModel()->getUnoModel() );
3142 if( pModel )
3144 if( pPage->IsMasterPage() )
3146 xPage = (::cppu::OWeakObject*)new SdMasterPage( pModel, pPage );
3148 else
3150 xPage = (::cppu::OWeakObject*)new SdDrawPage( pModel, pPage );
3155 return xPage;