bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / unoidl / unopage.cxx
blob94aac3c8795dac9541bec865740d209ba5c3d1f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/lang/DisposedException.hpp>
21 #include <com/sun/star/presentation/ClickAction.hpp>
22 #include <com/sun/star/presentation/FadeEffect.hpp>
23 #include <com/sun/star/presentation/AnimationEffect.hpp>
24 #include <com/sun/star/presentation/PresentationRange.hpp>
25 #include <com/sun/star/presentation/AnimationSpeed.hpp>
26 #include <com/sun/star/view/PaperOrientation.hpp>
27 #include <com/sun/star/animations/AnimationNodeType.hpp>
28 #include <com/sun/star/presentation/EffectNodeType.hpp>
29 #include <comphelper/processfactory.hxx>
30 #include <comphelper/servicehelper.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <vcl/bitmapex.hxx>
33 #include <vcl/metaact.hxx>
34 #include <toolkit/unohlp.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/settings.hxx>
37 #include <unomodel.hxx>
38 #include <unopage.hxx>
39 #include <svx/svxids.hrc>
40 #include <svl/itemset.hxx>
41 #include <svx/svdmodel.hxx>
42 #include <sdresid.hxx>
43 #include <glob.hrc>
44 #include <sdpage.hxx>
45 #include <unoprnms.hxx>
46 #include <sdattr.hxx>
47 #include <drawdoc.hxx>
48 #include <svx/unoshape.hxx>
49 #include <com/sun/star/style/XStyle.hpp>
50 #include <svx/svdorect.hxx>
51 #include <osl/mutex.hxx>
52 #include <svl/style.hxx>
53 #include <comphelper/serviceinfohelper.hxx>
55 #include <comphelper/extract.hxx>
56 #include <list>
57 #include <svx/svditer.hxx>
58 #include <vcl/wmf.hxx>
59 #include <svx/svdoole2.hxx>
60 #include <svx/svdpool.hxx>
61 #include <svx/svdview.hxx>
62 #include "View.hxx"
63 #include "DrawDocShell.hxx"
64 #include "ViewShell.hxx"
65 #include "DrawViewShell.hxx"
66 #include "unoobj.hxx"
67 #include "res_bmp.hrc"
68 #include "unokywds.hxx"
69 #include "unopback.hxx"
70 #include "unohelp.hxx"
72 using ::com::sun::star::animations::XAnimationNode;
73 using ::com::sun::star::animations::XAnimationNodeSupplier;
75 using namespace ::osl;
76 using namespace ::com::sun::star;
77 using namespace ::com::sun::star::uno;
78 using namespace ::com::sun::star::lang;
79 using namespace ::com::sun::star::container;
80 using namespace ::com::sun::star::drawing;
81 using namespace ::com::sun::star::office;
83 namespace sd {
84 extern Reference< XAnnotation > createAnnotation( const Reference< XComponentContext >& xContext, SdPage* );
85 extern Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& );
88 /* this are the ids for page properties */
89 enum WID_PAGE
91 WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH,
92 WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER,
93 WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_HIGHRESDURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP,
94 WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL,
95 WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK,
96 WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT,
97 WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
98 WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
99 WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
100 WID_NAVORDER
103 #ifndef SEQTYPE
104 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
105 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
106 #else
107 #define SEQTYPE(x) &(x)
108 #endif
109 #endif
111 static sal_Char const sEmptyPageName[sizeof("page")] = "page";
113 /** this function stores the property maps for draw pages in impress and draw */
114 const SvxItemPropertySet* ImplGetDrawPagePropertySet( sal_Bool bImpress, PageKind ePageKind )
116 static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] =
118 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0},
119 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
120 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
121 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
122 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
123 { MAP_CHAR_LEN(UNO_NAME_PAGE_CHANGE), WID_PAGE_CHANGE, &::getCppuType((const sal_Int32*)0), 0, 0},
124 { MAP_CHAR_LEN(UNO_NAME_PAGE_DURATION), WID_PAGE_DURATION, &::getCppuType((const sal_Int32*)0), 0, 0},
125 { MAP_CHAR_LEN(UNO_NAME_PAGE_EFFECT), WID_PAGE_EFFECT, &::getCppuType((const presentation::FadeEffect*)0), 0, 0},
126 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
127 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0},
128 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0},
129 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0},
130 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
131 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
132 { MAP_CHAR_LEN(UNO_NAME_PAGE_SPEED), WID_PAGE_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0},
133 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
134 { 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},
135 { 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},
136 { MAP_CHAR_LEN(UNO_NAME_PAGE_VISIBLE), WID_PAGE_VISIBLE, &::getBooleanCppuType(), 0, 0},
137 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_PAGE_SOUNDFILE, &::getCppuType((const Any*)0), 0, 0},
138 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundVisible), WID_PAGE_BACKVIS, &::getBooleanCppuType(), 0, 0},
139 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundObjectsVisible), WID_PAGE_BACKOBJVIS, &::getBooleanCppuType(), 0, 0},
140 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
141 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0},
142 { MAP_CHAR_LEN("HighResDuration"), WID_PAGE_HIGHRESDURATION, &::getCppuType((const double*)0), 0, 0},
143 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
144 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0},
145 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0},
146 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0},
147 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0},
148 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0},
149 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0},
150 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0},
151 { MAP_CHAR_LEN("TransitionType"), WID_TRANSITION_TYPE, &::getCppuType((const sal_Int16*)0), 0, 0},
152 { MAP_CHAR_LEN("TransitionSubtype"), WID_TRANSITION_SUBTYPE, &::getCppuType((const sal_Int16*)0), 0, 0},
153 { MAP_CHAR_LEN("TransitionDirection"), WID_TRANSITION_DIRECTION, &::getCppuType((const sal_Bool*)0), 0, 0},
154 { MAP_CHAR_LEN("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0},
155 { MAP_CHAR_LEN("TransitionDuration"), WID_TRANSITION_DURATION, &::getCppuType((const double*)0), 0, 0},
156 { MAP_CHAR_LEN("LoopSound"), WID_LOOP_SOUND, &::getBooleanCppuType(), 0, 0},
157 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0},
158 {0,0,0,0,0,0}
161 #define DRAW_PAGE_NOTES_PROPERTIES \
162 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \
163 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
164 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
165 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \
166 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
167 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, \
168 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \
169 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \
170 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \
171 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \
172 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \
173 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},\
174 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
175 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \
176 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \
177 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
178 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \
179 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0}, \
180 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0}, \
181 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0}, \
182 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0}, \
183 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 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}
187 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] =
189 // this must be the first two entries so they can be excluded for PK_STANDARD
190 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0},
191 DRAW_PAGE_NOTES_PROPERTIES
193 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] =
195 DRAW_PAGE_NOTES_PROPERTIES
198 #define GRAPHIC_PAGE_PROPERTIES \
199 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \
200 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
201 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
202 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \
203 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \
204 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \
205 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \
206 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \
207 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \
208 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \
209 { 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}, \
210 { 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},\
211 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, \
212 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, \
213 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \
214 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, \
215 {0,0,0,0,0,0}
217 static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] =
219 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet), beans::PropertyAttribute::MAYBEVOID,0},
220 GRAPHIC_PAGE_PROPERTIES
222 static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] =
224 GRAPHIC_PAGE_PROPERTIES
227 bool bWithoutBackground = ePageKind != PK_STANDARD && ePageKind != PK_HANDOUT;
228 const SvxItemPropertySet* pRet = 0;
229 if( bImpress )
231 if( ePageKind == PK_STANDARD )
233 //PK_STANDARD always has a background property
234 static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
235 pRet = &aDrawPagePropertySet_Impl;
237 else
239 if(bWithoutBackground)
241 static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
242 pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl;
244 else
246 static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
247 pRet = &aDrawPageNotesHandoutPropertySet_Impl;
251 else
253 if(bWithoutBackground)
255 static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
256 pRet = &aGraphicPagePropertyNoBackSet_Impl;
258 else
260 static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
261 pRet = &aGraphicPagePropertySet_Impl;
264 return pRet;
267 /** this function stores the property map for master pages in impress and draw */
268 const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
270 static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] =
272 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE(beans::XPropertySet), 0, 0},
273 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
274 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
275 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
276 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
277 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
278 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0},
279 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0},
280 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
281 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
282 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
283 { MAP_CHAR_LEN("BackgroundFullSize"), WID_PAGE_BACKFULL, &::getBooleanCppuType(), 0, 0},
284 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
285 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
286 {0,0,0,0,0,0}
289 static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
291 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0},
292 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0},
293 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
294 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0},
295 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
296 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0},
297 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0},
298 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0},
299 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0},
300 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
301 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
302 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0},
303 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0},
304 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0},
305 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0},
306 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0},
307 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0},
308 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0},
309 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0},
310 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0},
311 {0,0,0,0,0,0}
314 const SvxItemPropertySet* pRet = 0;
315 if( ePageKind == PK_HANDOUT )
317 static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
318 pRet = &aHandoutMasterPagePropertySet_Impl;
320 else
322 static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
323 pRet = &aMasterPagePropertySet_Impl;
325 return pRet;
328 namespace
330 class theSdGenericDrawPageUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdGenericDrawPageUnoTunnelId> {};
333 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw()
335 return theSdGenericDrawPageUnoTunnelId::get().getSeq();
338 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException)
340 if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(),
341 rId.getConstArray(), 16 ) )
343 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
345 else
347 return SvxFmDrawPage::getSomething( rId );
351 SdGenericDrawPage::SdGenericDrawPage( SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet ) throw()
352 : SvxFmDrawPage( (SdrPage*) pInPage ),
353 SdUnoSearchReplaceShape(this),
354 mpModel ( _pModel ),
355 mpSdrModel(0),
356 mnTempPageNumber(0),
357 mpPropSet ( _pSet ),
358 mbIsImpressDocument(false)
360 mpSdrModel = SvxFmDrawPage::mpModel;
361 if( mpModel )
362 mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
366 SdGenericDrawPage::~SdGenericDrawPage() throw()
370 void SdGenericDrawPage::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException )
372 if( (SvxFmDrawPage::mpModel == 0) || (mpModel == 0) || (SvxFmDrawPage::mpPage == 0) )
373 throw lang::DisposedException();
376 SdXImpressDocument* SdGenericDrawPage::GetModel() const
378 if( mpSdrModel != SvxFmDrawPage::mpModel )
380 const_cast< SdGenericDrawPage* >(this)->mpSdrModel = SvxFmDrawPage::mpModel;
381 if( mpSdrModel )
383 uno::Reference< uno::XInterface > xModel( SvxFmDrawPage::mpModel->getUnoModel() );
384 const_cast< SdGenericDrawPage*>(this)->mpModel = SdXImpressDocument::getImplementation( xModel );
385 if( mpModel )
386 const_cast< SdGenericDrawPage*>(this)->mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false;
388 else
390 const_cast< SdGenericDrawPage* >(this)->mpModel = 0;
394 return mpModel;
397 // this is called whenever a SdrObject must be created for a empty api shape wrapper
398 SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShape >& xShape ) throw()
400 if( NULL == SvxFmDrawPage::mpPage || !xShape.is() )
401 return NULL;
403 String aType( xShape->getShapeType() );
404 const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") );
405 if( aType.CompareTo( aPrefix, aPrefix.Len() ) != 0 )
407 SdrObject* pObj = SvxFmDrawPage::_CreateSdrObject( xShape );
408 if( pObj && ( (pObj->GetObjInventor() != SdrInventor) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
410 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
411 if( pDoc )
412 pObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
414 return pObj;
417 aType = aType.Copy( aPrefix.Len() );
419 PresObjKind eObjKind = PRESOBJ_NONE;
421 if( aType.EqualsAscii( "TitleTextShape" ) )
423 eObjKind = PRESOBJ_TITLE;
425 else if( aType.EqualsAscii( "OutlinerShape" ) )
427 eObjKind = PRESOBJ_OUTLINE;
429 else if( aType.EqualsAscii( "SubtitleShape" ) )
431 eObjKind = PRESOBJ_TEXT;
433 else if( aType.EqualsAscii( "OLE2Shape" ) )
435 eObjKind = PRESOBJ_OBJECT;
437 else if( aType.EqualsAscii( "ChartShape" ) )
439 eObjKind = PRESOBJ_CHART;
441 else if( aType.EqualsAscii( "CalcShape" ) )
443 eObjKind = PRESOBJ_CALC;
445 else if( aType.EqualsAscii( "TableShape" ) )
447 eObjKind = PRESOBJ_TABLE;
449 else if( aType.EqualsAscii( "GraphicObjectShape" ) )
451 eObjKind = PRESOBJ_GRAPHIC;
453 else if( aType.EqualsAscii( "OrgChartShape" ) )
455 eObjKind = PRESOBJ_ORGCHART;
457 else if( aType.EqualsAscii( "PageShape" ) )
459 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
460 eObjKind = PRESOBJ_TITLE;
461 else
462 eObjKind = PRESOBJ_PAGE;
464 else if( aType.EqualsAscii( "NotesShape" ) )
466 eObjKind = PRESOBJ_NOTES;
468 else if( aType.EqualsAscii( "HandoutShape" ) )
470 eObjKind = PRESOBJ_HANDOUT;
472 else if( aType.EqualsAscii( "FooterShape" ) )
474 eObjKind = PRESOBJ_FOOTER;
476 else if( aType.EqualsAscii( "HeaderShape" ) )
478 eObjKind = PRESOBJ_HEADER;
480 else if( aType.EqualsAscii( "SlideNumberShape" ) )
482 eObjKind = PRESOBJ_SLIDENUMBER;
484 else if( aType.EqualsAscii( "DateTimeShape" ) )
486 eObjKind = PRESOBJ_DATETIME;
488 else if( aType.EqualsAscii( "MediaShape" ) )
490 eObjKind = PRESOBJ_MEDIA;
493 Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() );
495 const awt::Point aPos( aRect.Left(), aRect.Top() );
496 xShape->setPosition( aPos );
498 const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
499 xShape->setSize( aSize );
501 SdrObject *pPresObj = 0;
502 if( (eObjKind == PRESOBJ_TABLE) || (eObjKind == PRESOBJ_MEDIA) )
504 pPresObj = SvxFmDrawPage::_CreateSdrObject( xShape );
505 if( pPresObj )
507 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
508 if( pDoc )
509 pPresObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
510 GetPage()->InsertPresObj( pPresObj, eObjKind );
513 else
515 pPresObj = GetPage()->CreatePresObj( eObjKind, sal_False, aRect, sal_True );
518 if( pPresObj )
519 pPresObj->SetUserCall( GetPage() );
521 return pPresObj;
524 // XInterface
525 Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType )
526 throw(uno::RuntimeException)
528 Any aAny;
530 QUERYINT( beans::XPropertySet );
531 else QUERYINT( container::XNamed );
532 else QUERYINT( util::XReplaceable );
533 else QUERYINT( util::XSearchable );
534 else QUERYINT( document::XLinkTargetSupplier );
535 else QUERYINT( drawing::XShapeCombiner );
536 else QUERYINT( drawing::XShapeBinder );
537 else QUERYINT( beans::XMultiPropertySet );
538 else if( rType == ITYPE( office::XAnnotationAccess ) )
540 return Any( Reference< office::XAnnotationAccess >( this ) );
542 else if( rType == ITYPE( XAnimationNodeSupplier ) )
544 if( mbIsImpressDocument )
546 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
548 if( ePageKind == PK_STANDARD )
549 return makeAny( Reference< XAnimationNodeSupplier >( this ) );
552 else
553 return SvxDrawPage::queryInterface( rType );
555 return aAny;
558 // XPropertySet
559 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo()
560 throw(uno::RuntimeException)
562 ::SolarMutexGuard aGuard;
563 throwIfDisposed();
564 return mpPropSet->getPropertySetInfo();
567 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
568 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
570 ::SolarMutexGuard aGuard;
572 throwIfDisposed();
574 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
576 switch( pEntry ? pEntry->nWID : -1 )
578 case WID_NAVORDER:
579 setNavigationOrder( aValue );
580 break;
581 case WID_PAGE_LEFT:
582 case WID_PAGE_RIGHT:
583 case WID_PAGE_TOP:
584 case WID_PAGE_BOTTOM:
585 case WID_PAGE_LAYOUT:
586 case WID_PAGE_DURATION:
587 case WID_PAGE_CHANGE:
589 sal_Int32 nValue = 0;
590 if(!(aValue >>= nValue))
591 throw lang::IllegalArgumentException();
593 switch( pEntry->nWID )
595 case WID_PAGE_LEFT:
596 SetLftBorder(nValue);
597 break;
598 case WID_PAGE_RIGHT:
599 SetRgtBorder( nValue );
600 break;
601 case WID_PAGE_TOP:
602 SetUppBorder( nValue );
603 break;
604 case WID_PAGE_BOTTOM:
605 SetLwrBorder( nValue );
606 break;
607 case WID_PAGE_CHANGE:
608 GetPage()->SetPresChange( (PresChange)nValue );
609 break;
610 case WID_PAGE_LAYOUT:
611 GetPage()->SetAutoLayout( (AutoLayout)nValue, sal_True );
612 break;
613 case WID_PAGE_DURATION:
614 GetPage()->SetTime((sal_Int32)nValue);
615 break;
617 break;
619 case WID_PAGE_HIGHRESDURATION:
621 double fValue = 0;
622 if(!(aValue >>= fValue))
623 throw lang::IllegalArgumentException();
625 GetPage()->SetTime(fValue);
626 break;
628 case WID_PAGE_WIDTH:
630 sal_Int32 nWidth = 0;
631 if(!(aValue >>= nWidth))
632 throw lang::IllegalArgumentException();
634 SetWidth( nWidth );
635 break;
637 case WID_PAGE_HEIGHT:
639 sal_Int32 nHeight = 0;
640 if(!(aValue >>= nHeight))
641 throw lang::IllegalArgumentException();
643 SetHeight( nHeight );
644 break;
646 case WID_PAGE_ORIENT:
648 sal_Int32 nEnum = 0;
649 if(!::cppu::enum2int( nEnum, aValue ))
650 throw lang::IllegalArgumentException();
652 Orientation eOri = (((view::PaperOrientation)nEnum) == view::PaperOrientation_PORTRAIT)?ORIENTATION_PORTRAIT:ORIENTATION_LANDSCAPE;
654 if( eOri != GetPage()->GetOrientation() )
656 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
657 const PageKind ePageKind = GetPage()->GetPageKind();
659 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
660 for (i = 0; i < nPageCnt; i++)
662 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
663 pPage->SetOrientation( eOri );
666 nPageCnt = pDoc->GetSdPageCount(ePageKind);
668 for (i = 0; i < nPageCnt; i++)
670 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
671 pPage->SetOrientation( eOri );
674 break;
676 case WID_PAGE_EFFECT:
678 sal_Int32 nEnum = 0;
679 if(!::cppu::enum2int( nEnum, aValue ))
680 throw lang::IllegalArgumentException();
682 GetPage()->SetFadeEffect( (presentation::FadeEffect)nEnum );
683 break;
685 case WID_PAGE_BACK:
686 setBackground( aValue );
687 break;
688 case WID_PAGE_SPEED:
690 sal_Int32 nEnum = 0;
691 if(!::cppu::enum2int( nEnum, aValue ))
692 throw lang::IllegalArgumentException();
694 GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 ) );
695 break;
697 case WID_PAGE_VISIBLE :
699 sal_Bool bVisible = sal_False;
700 if( ! ( aValue >>= bVisible ) )
701 throw lang::IllegalArgumentException();
702 GetPage()->SetExcluded( bVisible == sal_False );
703 break;
705 case WID_PAGE_SOUNDFILE :
707 OUString aURL;
708 if( aValue >>= aURL )
710 GetPage()->SetSoundFile( aURL );
711 GetPage()->SetSound( !aURL.isEmpty() );
712 break;
714 else
716 sal_Bool bStopSound = sal_False;
717 if( aValue >>= bStopSound )
719 GetPage()->SetStopSound( bStopSound ? true : false );
720 break;
725 throw lang::IllegalArgumentException();
727 case WID_LOOP_SOUND:
729 sal_Bool bLoop = sal_False;
730 if( ! (aValue >>= bLoop) )
731 throw lang::IllegalArgumentException();
733 GetPage()->SetLoopSound( bLoop ? true : false );
734 break;
736 case WID_PAGE_BACKFULL:
738 sal_Bool bFullSize = sal_False;
739 if( ! ( aValue >>= bFullSize ) )
740 throw lang::IllegalArgumentException();
741 GetPage()->SetBackgroundFullSize( bFullSize );
742 break;
744 case WID_PAGE_BACKVIS:
746 sal_Bool bVisible = sal_False;
747 if( ! ( aValue >>= bVisible ) )
748 throw lang::IllegalArgumentException();
750 SdrPage* pPage = GetPage();
751 if( pPage )
753 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
754 if( pDoc->GetMasterPageCount() )
756 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
757 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
758 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False), bVisible);
759 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
762 break;
764 case WID_PAGE_BACKOBJVIS:
766 sal_Bool bVisible = sal_False;
767 if( ! ( aValue >>= bVisible ) )
768 throw lang::IllegalArgumentException();
770 SdrPage* pPage = GetPage();
771 if( pPage )
773 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
774 if( pDoc->GetMasterPageCount() )
776 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
777 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
778 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False), bVisible);
779 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
783 break;
785 case WID_PAGE_USERATTRIBS:
787 if( !GetPage()->setAlienAttributes( aValue ) )
788 throw lang::IllegalArgumentException();
789 break;
791 case WID_PAGE_BOOKMARK:
793 OUString aBookmarkURL;
794 if( ! ( aValue >>= aBookmarkURL ) )
795 throw lang::IllegalArgumentException();
797 setBookmarkURL( aBookmarkURL );
798 break;
801 case WID_PAGE_HEADERVISIBLE:
802 case WID_PAGE_HEADERTEXT:
803 case WID_PAGE_FOOTERVISIBLE:
804 case WID_PAGE_FOOTERTEXT:
805 case WID_PAGE_PAGENUMBERVISIBLE:
806 case WID_PAGE_DATETIMEVISIBLE:
807 case WID_PAGE_DATETIMEFIXED:
808 case WID_PAGE_DATETIMETEXT:
809 case WID_PAGE_DATETIMEFORMAT:
811 sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() );
813 switch( pEntry->nWID )
815 case WID_PAGE_HEADERVISIBLE:
817 sal_Bool bVisible = sal_False;
818 if( ! ( aValue >>= bVisible ) )
819 throw lang::IllegalArgumentException();
821 aHeaderFooterSettings.mbHeaderVisible = bVisible;
822 break;
824 case WID_PAGE_HEADERTEXT:
826 OUString aText;
827 if( ! ( aValue >>= aText ) )
828 throw lang::IllegalArgumentException();
830 aHeaderFooterSettings.maHeaderText = aText;
831 break;
833 case WID_PAGE_FOOTERVISIBLE:
835 sal_Bool bVisible = sal_False;
836 if( ! ( aValue >>= bVisible ) )
837 throw lang::IllegalArgumentException();
839 aHeaderFooterSettings.mbFooterVisible = bVisible;
840 break;
842 case WID_PAGE_FOOTERTEXT:
844 OUString aText;
845 if( ! ( aValue >>= aText ) )
846 throw lang::IllegalArgumentException();
848 aHeaderFooterSettings.maFooterText = aText;
849 break;
851 case WID_PAGE_PAGENUMBERVISIBLE:
853 sal_Bool bVisible = sal_False;
854 if( ! ( aValue >>= bVisible ) )
855 throw lang::IllegalArgumentException();
857 aHeaderFooterSettings.mbSlideNumberVisible = bVisible;
858 break;
860 case WID_PAGE_DATETIMEVISIBLE:
862 sal_Bool bVisible = sal_False;
863 if( ! ( aValue >>= bVisible ) )
864 throw lang::IllegalArgumentException();
866 aHeaderFooterSettings.mbDateTimeVisible = bVisible;
867 break;
869 case WID_PAGE_DATETIMEFIXED:
871 sal_Bool bVisible = sal_False;
872 if( ! ( aValue >>= bVisible ) )
873 throw lang::IllegalArgumentException();
875 aHeaderFooterSettings.mbDateTimeIsFixed = bVisible;
876 break;
878 case WID_PAGE_DATETIMETEXT:
880 OUString aText;
881 if( ! ( aValue >>= aText ) )
882 throw lang::IllegalArgumentException();
884 aHeaderFooterSettings.maDateTimeText = aText;
885 break;
887 case WID_PAGE_DATETIMEFORMAT:
889 sal_Int32 nValue = 0;
890 if( ! ( aValue >>= nValue ) )
891 throw lang::IllegalArgumentException();
893 aHeaderFooterSettings.meDateTimeFormat = nValue;
894 break;
898 if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) )
899 GetPage()->setHeaderFooterSettings( aHeaderFooterSettings );
901 break;
904 case WID_PAGE_NUMBER:
905 if( (GetPage()->GetPageKind() == PK_HANDOUT) && !GetPage()->IsMasterPage() )
907 if( !(aValue >>= mnTempPageNumber) )
908 throw lang::IllegalArgumentException();
910 break;
912 throw beans::PropertyVetoException();
914 case WID_PAGE_LDBITMAP:
915 case WID_PAGE_LDNAME:
916 case WID_PAGE_ISDARK:
917 throw beans::PropertyVetoException();
919 case WID_TRANSITION_TYPE:
921 sal_Int16 nValue = 0;
922 if( ! ( aValue >>= nValue ) )
923 throw lang::IllegalArgumentException();
925 GetPage()->setTransitionType( nValue );
926 break;
929 case WID_TRANSITION_SUBTYPE:
931 sal_Int16 nValue = 0;
932 if( ! ( aValue >>= nValue ) )
933 throw lang::IllegalArgumentException();
935 GetPage()->setTransitionSubtype( nValue );
936 break;
939 case WID_TRANSITION_DIRECTION:
941 sal_Bool bValue = sal_False;
942 if( ! ( aValue >>= bValue ) )
943 throw lang::IllegalArgumentException();
945 GetPage()->setTransitionDirection( bValue );
946 break;
949 case WID_TRANSITION_FADE_COLOR:
951 sal_Int32 nValue = 0;
952 if( ! ( aValue >>= nValue ) )
953 throw lang::IllegalArgumentException();
955 GetPage()->setTransitionFadeColor( nValue );
956 break;
959 case WID_TRANSITION_DURATION:
961 double fValue = 0.0;
962 if( ! ( aValue >>= fValue ) )
963 throw lang::IllegalArgumentException();
965 GetPage()->setTransitionDuration( fValue );
966 break;
969 default:
970 throw beans::UnknownPropertyException();
973 GetModel()->SetModified();
976 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
977 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
979 ::SolarMutexGuard aGuard;
981 throwIfDisposed();
983 uno::Any aAny;
985 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
987 switch( pEntry ? pEntry->nWID : -1 )
989 case WID_NAVORDER:
990 aAny = getNavigationOrder();
991 break;
992 case WID_PAGE_LEFT:
993 aAny <<= (sal_Int32)( GetPage()->GetLftBorder() );
994 break;
995 case WID_PAGE_RIGHT:
996 aAny <<= (sal_Int32)( GetPage()->GetRgtBorder() );
997 break;
998 case WID_PAGE_TOP:
999 aAny <<= (sal_Int32)( GetPage()->GetUppBorder() );
1000 break;
1001 case WID_PAGE_BOTTOM:
1002 aAny <<= (sal_Int32)( GetPage()->GetLwrBorder() );
1003 break;
1004 case WID_PAGE_WIDTH:
1005 aAny <<= (sal_Int32)( GetPage()->GetSize().getWidth() );
1006 break;
1007 case WID_PAGE_HEIGHT:
1008 aAny <<= (sal_Int32)( GetPage()->GetSize().getHeight() );
1009 break;
1010 case WID_PAGE_ORIENT:
1011 aAny = ::cppu::int2enum( (sal_Int32)((GetPage()->GetOrientation() == ORIENTATION_PORTRAIT)? view::PaperOrientation_PORTRAIT: view::PaperOrientation_LANDSCAPE), ::getCppuType((const view::PaperOrientation*)0) );
1012 break;
1013 case WID_PAGE_EFFECT:
1014 aAny = ::cppu::int2enum( (sal_Int32)GetPage()->GetFadeEffect(), ::getCppuType((const presentation::FadeEffect*)0) );
1015 break;
1016 case WID_PAGE_CHANGE:
1017 aAny <<= (sal_Int32)( GetPage()->GetPresChange() );
1018 break;
1019 case WID_PAGE_SPEED:
1021 const double fDuration = GetPage()->getTransitionDuration();
1022 aAny = ::cppu::int2enum( fDuration < 2.0 ? 2 : (fDuration > 2.0 ? 0 : 1), ::getCppuType((const presentation::AnimationSpeed*)0) );
1024 break;
1025 case WID_PAGE_LAYOUT:
1026 aAny <<= (sal_Int16)( GetPage()->GetAutoLayout() );
1027 break;
1028 case WID_PAGE_NUMBER:
1030 const sal_uInt16 nPageNumber(GetPage()->GetPageNum());
1032 if(nPageNumber > 0)
1034 // for all other pages calculate the number
1035 aAny <<= (sal_Int16)((sal_uInt16)((nPageNumber-1)>>1) + 1);
1037 else
1039 aAny <<= mnTempPageNumber;
1042 break;
1043 case WID_PAGE_DURATION:
1044 aAny <<= (sal_Int32)( GetPage()->GetTime() + .5 );
1045 break;
1046 case WID_PAGE_HIGHRESDURATION:
1047 aAny <<= (double)( GetPage()->GetTime() );
1048 break;
1049 case WID_PAGE_LDNAME:
1051 const OUString aName( GetPage()->GetName() );
1052 aAny <<= aName;
1053 break;
1055 case WID_PAGE_LDBITMAP:
1057 Reference< awt::XBitmap > xBitmap(
1058 VCLUnoHelper::CreateBitmap( BitmapEx( SdResId( BMP_PAGE ) ) ) );
1059 aAny <<= xBitmap;
1061 break;
1062 case WID_PAGE_BACK:
1063 getBackground( aAny );
1064 break;
1065 case WID_PAGE_PREVIEW :
1067 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1068 if ( pDoc )
1070 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1071 if ( pDocShell )
1073 sal_uInt16 nPgNum = 0;
1074 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1075 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1076 while( nPgNum < nPageCount )
1078 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1079 nPgNum++;
1081 ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1082 pDocShell->GetPreviewMetaFile();
1083 if ( pMetaFile )
1085 Point aPoint;
1086 Size aSize( GetPage()->GetSize() );
1087 pMetaFile->AddAction( (MetaAction*) new MetaFillColorAction( COL_WHITE, sal_True ), 0 );
1088 pMetaFile->AddAction( (MetaAction*) new MetaRectAction( Rectangle( aPoint, aSize ) ), 1 );
1089 pMetaFile->SetPrefMapMode( MAP_100TH_MM );
1090 pMetaFile->SetPrefSize( aSize );
1092 SvMemoryStream aDestStrm( 65535, 65535 );
1093 ConvertGDIMetaFileToWMF( *pMetaFile, aDestStrm, NULL, sal_False );
1094 Sequence<sal_Int8> aSeq( (sal_Int8*)aDestStrm.GetData(), aDestStrm.Tell() );
1095 aAny <<= aSeq;
1100 break;
1102 case WID_PAGE_PREVIEWBITMAP :
1104 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1105 if ( pDoc )
1107 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1108 if ( pDocShell )
1110 sal_uInt16 nPgNum = 0;
1111 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD );
1112 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1113 while( nPgNum < nPageCount )
1115 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber );
1116 nPgNum++;
1118 ::boost::shared_ptr<GDIMetaFile> pMetaFile =
1119 pDocShell->GetPreviewMetaFile();
1120 BitmapEx aBitmap;
1121 if ( pMetaFile && pMetaFile->CreateThumbnail( 160, /* magic value taken from GraphicHelper::getThumbnailFormatFromGDI_Impl() */
1122 aBitmap ) )
1124 SvMemoryStream aMemStream;
1125 aBitmap.GetBitmap().Write( aMemStream, sal_False, sal_False );
1126 uno::Sequence<sal_Int8> aSeq( (sal_Int8*)aMemStream.GetData(), aMemStream.Tell() );
1127 aAny <<= aSeq;
1132 break;
1134 case WID_PAGE_VISIBLE :
1136 sal_Bool bVisible = GetPage()->IsExcluded() == sal_False;
1137 aAny <<= Any( &bVisible, ::getBooleanCppuType() );
1138 break;
1141 case WID_PAGE_SOUNDFILE :
1143 if( GetPage()->IsStopSound() )
1145 aAny <<= sal_True;
1147 else
1149 OUString aURL;
1150 if( GetPage()->IsSoundOn() )
1151 aURL = GetPage()->GetSoundFile();
1152 aAny <<= aURL;
1154 break;
1156 case WID_LOOP_SOUND:
1158 aAny <<= (sal_Bool)GetPage()->IsLoopSound();
1159 break;
1161 case WID_PAGE_BACKFULL:
1163 sal_Bool bFullSize = GetPage()->IsBackgroundFullSize();
1164 aAny = Any( &bFullSize, ::getBooleanCppuType() );
1165 break;
1167 case WID_PAGE_BACKVIS:
1169 SdrPage* pPage = GetPage();
1170 if( pPage )
1172 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1173 if( pDoc->GetMasterPageCount() )
1175 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1176 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1177 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False));
1179 else
1181 aAny <<= (sal_Bool)sal_False;
1184 break;
1186 case WID_PAGE_BACKOBJVIS:
1188 SdrPage* pPage = GetPage();
1189 if( pPage )
1191 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel();
1192 if( pDoc->GetMasterPageCount() )
1194 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
1195 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1196 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False));
1198 else
1200 aAny <<= (sal_Bool)sal_False;
1203 break;
1205 case WID_PAGE_USERATTRIBS:
1207 GetPage()->getAlienAttributes( aAny );
1208 break;
1210 case WID_PAGE_BOOKMARK:
1212 aAny <<= getBookmarkURL();
1213 break;
1215 case WID_PAGE_ISDARK:
1217 aAny <<= (sal_Bool)GetPage()->GetPageBackgroundColor().IsDark();
1218 break;
1220 case WID_PAGE_HEADERVISIBLE:
1221 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbHeaderVisible;
1222 break;
1223 case WID_PAGE_HEADERTEXT:
1225 const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText );
1226 aAny <<= aText;
1228 break;
1229 case WID_PAGE_FOOTERVISIBLE:
1230 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbFooterVisible;
1231 break;
1232 case WID_PAGE_FOOTERTEXT:
1234 const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText );
1235 aAny <<= aText;
1237 break;
1238 case WID_PAGE_PAGENUMBERVISIBLE:
1239 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbSlideNumberVisible;
1240 break;
1241 case WID_PAGE_DATETIMEVISIBLE:
1242 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeVisible;
1243 break;
1244 case WID_PAGE_DATETIMEFIXED:
1245 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed;
1246 break;
1247 case WID_PAGE_DATETIMETEXT:
1249 const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText );
1250 aAny <<= aText;
1252 break;
1253 case WID_PAGE_DATETIMEFORMAT:
1254 aAny <<= (sal_Int32)GetPage()->getHeaderFooterSettings().meDateTimeFormat;
1255 break;
1257 case WID_TRANSITION_TYPE:
1258 aAny <<= GetPage()->getTransitionType();
1259 break;
1261 case WID_TRANSITION_SUBTYPE:
1262 aAny <<= GetPage()->getTransitionSubtype();
1263 break;
1265 case WID_TRANSITION_DIRECTION:
1266 aAny <<= GetPage()->getTransitionDirection();
1267 break;
1269 case WID_TRANSITION_FADE_COLOR:
1270 aAny <<= GetPage()->getTransitionFadeColor();
1271 break;
1273 case WID_TRANSITION_DURATION:
1274 aAny <<= GetPage()->getTransitionDuration();
1275 break;
1277 default:
1278 throw beans::UnknownPropertyException();
1280 return aAny;
1283 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1284 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1285 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1286 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
1288 // XMultiPropertySet
1289 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 )
1291 if( aPropertyNames.getLength() != aValues.getLength() )
1292 throw lang::IllegalArgumentException();
1294 const OUString* pNames = aPropertyNames.getConstArray();
1295 const Any* pValues = aValues.getConstArray();
1296 sal_uInt32 nCount = aValues.getLength();
1297 while( nCount-- )
1301 setPropertyValue( *pNames++, *pValues++ );
1303 catch( beans::UnknownPropertyException& )
1305 // ignore for multi property set
1306 // todo: optimize this!
1311 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
1313 const OUString* pNames = aPropertyNames.getConstArray();
1314 sal_uInt32 nCount = aPropertyNames.getLength();
1315 Sequence< Any > aValues( nCount );
1316 Any* pValues = aValues.getArray();
1317 while( nCount-- )
1319 Any aValue;
1322 aValue = getPropertyValue( *pNames++ );
1324 catch( beans::UnknownPropertyException& )
1326 // ignore for multi property set
1327 // todo: optimize this!
1329 *pValues++ = aValue;
1331 return aValues;
1334 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1338 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1342 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) throw (RuntimeException)
1346 Reference< drawing::XShape > SdGenericDrawPage::_CreateShape( SdrObject *pObj ) const throw()
1348 DBG_ASSERT( GetPage(), "SdGenericDrawPage::_CreateShape(), can't create shape for disposed page!" );
1349 DBG_ASSERT( pObj, "SdGenericDrawPage::_CreateShape(), invalid call with pObj == 0!" );
1351 if( GetPage() && pObj )
1353 PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
1355 SvxShape* pShape = NULL;
1357 if(pObj->GetObjInventor() == SdrInventor)
1359 sal_uInt32 nInventor = pObj->GetObjIdentifier();
1360 switch( nInventor )
1362 case OBJ_TITLETEXT:
1363 pShape = new SvxShapeText( pObj );
1364 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() )
1366 // fake a empty PageShape if its a title shape on the master page
1367 pShape->SetShapeType("com.sun.star.presentation.PageShape");
1369 else
1371 pShape->SetShapeType("com.sun.star.presentation.TitleTextShape");
1373 eKind = PRESOBJ_NONE;
1374 break;
1375 case OBJ_OUTLINETEXT:
1376 pShape = new SvxShapeText( pObj );
1377 pShape->SetShapeType("com.sun.star.presentation.OutlinerShape");
1378 eKind = PRESOBJ_NONE;
1379 break;
1383 Reference< drawing::XShape > xShape( pShape );
1385 if(!xShape.is())
1386 xShape = SvxFmDrawPage::_CreateShape( pObj );
1389 if( eKind != PRESOBJ_NONE )
1391 OUString aShapeType("com.sun.star.presentation.");
1393 switch( eKind )
1395 case PRESOBJ_TITLE:
1396 aShapeType += "TitleTextShape";
1397 break;
1398 case PRESOBJ_OUTLINE:
1399 aShapeType += "OutlinerShape";
1400 break;
1401 case PRESOBJ_TEXT:
1402 aShapeType += "SubtitleShape";
1403 break;
1404 case PRESOBJ_GRAPHIC:
1405 aShapeType += "GraphicObjectShape";
1406 break;
1407 case PRESOBJ_OBJECT:
1408 aShapeType += "OLE2Shape";
1409 break;
1410 case PRESOBJ_CHART:
1411 aShapeType += "ChartShape";
1412 break;
1413 case PRESOBJ_ORGCHART:
1414 aShapeType += "OrgChartShape";
1415 break;
1416 case PRESOBJ_CALC:
1417 aShapeType += "CalcShape";
1418 break;
1419 case PRESOBJ_TABLE:
1420 aShapeType += "TableShape";
1421 break;
1422 case PRESOBJ_MEDIA:
1423 aShapeType += "MediaShape";
1424 break;
1425 case PRESOBJ_PAGE:
1426 aShapeType += "PageShape";
1427 break;
1428 case PRESOBJ_HANDOUT:
1429 aShapeType += "HandoutShape";
1430 break;
1431 case PRESOBJ_NOTES:
1432 aShapeType += "NotesShape";
1433 break;
1434 case PRESOBJ_FOOTER:
1435 aShapeType += "FooterShape";
1436 break;
1437 case PRESOBJ_HEADER:
1438 aShapeType += "HeaderShape";
1439 break;
1440 case PRESOBJ_SLIDENUMBER:
1441 aShapeType += "SlideNumberShape";
1442 break;
1443 case PRESOBJ_DATETIME:
1444 aShapeType += "DateTimeShape";
1445 break;
1446 case PRESOBJ_NONE:
1447 case PRESOBJ_IMAGE:
1448 case PRESOBJ_MAX:
1449 break;
1452 if( !pShape )
1453 pShape = SvxShape::getImplementation( xShape );
1455 if( pShape )
1456 pShape->SetShapeType( aShapeType );
1459 // SdXShape aggregates SvxShape
1460 new SdXShape( SvxShape::getImplementation( xShape ), GetModel() );
1461 return xShape;
1463 else
1465 return SvxFmDrawPage::_CreateShape( pObj );
1470 //----------------------------------------------------------------------
1472 // XServiceInfo
1473 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames()
1474 throw(uno::RuntimeException)
1476 Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() );
1477 comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.drawing.GenericDrawPage",
1478 "com.sun.star.document.LinkTarget",
1479 "com.sun.star.document.LinkTargetSupplier");
1480 return aSeq;
1483 //----------------------------------------------------------------------
1485 // XLinkTargetSupplier
1486 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( )
1487 throw(uno::RuntimeException)
1489 return new SdPageLinkTargets( (SdGenericDrawPage*)this );
1492 //----------------------------------------------------------------------
1494 void SdGenericDrawPage::setBackground( const Any& ) throw(lang::IllegalArgumentException)
1496 OSL_FAIL( "Don't call me, I'm useless!" );
1499 //----------------------------------------------------------------------
1501 void SdGenericDrawPage::getBackground( Any& ) throw()
1503 OSL_FAIL( "Don't call me, I'm useless!" );
1506 //----------------------------------------------------------------------
1508 OUString SdGenericDrawPage::getBookmarkURL() const
1510 OUStringBuffer aRet;
1511 if( SvxFmDrawPage::mpPage )
1513 OUString aFileName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetFileName() );
1514 if( !aFileName.isEmpty() )
1516 const OUString aBookmarkName( SdDrawPage::getPageApiNameFromUiName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetBookmarkName() ) );
1517 aRet.append( aFileName );
1518 aRet.append( (sal_Unicode)'#' );
1519 aRet.append( aBookmarkName );
1523 return aRet.makeStringAndClear();
1526 //----------------------------------------------------------------------
1527 void SdGenericDrawPage::setBookmarkURL( OUString& rURL )
1529 if( SvxFmDrawPage::mpPage )
1531 sal_Int32 nIndex = rURL.indexOf( (sal_Unicode)'#' );
1532 if( nIndex != -1 )
1534 const String aFileName( rURL.copy( 0, nIndex ) );
1535 const String aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 ) ) );
1537 if( aFileName.Len() && aBookmarkName.Len() )
1539 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->DisconnectLink();
1540 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetFileName( aFileName );
1541 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetBookmarkName( aBookmarkName );
1542 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->ConnectLink();
1548 //----------------------------------------------------------------------
1549 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes )
1550 throw( uno::RuntimeException )
1552 ::SolarMutexGuard aGuard;
1554 throwIfDisposed();
1556 DBG_ASSERT(SvxFmDrawPage::mpPage,"SdrPage is NULL! [CL]");
1557 DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
1559 Reference< drawing::XShape > xShape;
1560 if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1561 return xShape;
1563 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1565 _SelectObjectsInView( xShapes, pPageView );
1567 mpView->CombineMarkedObjects( sal_False );
1569 mpView->AdjustMarkHdl();
1570 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1571 if( rMarkList.GetMarkCount() == 1 )
1573 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1574 if( pObj )
1575 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1578 mpView->HideSdrPage();
1580 GetModel()->SetModified();
1582 return xShape;
1585 //----------------------------------------------------------------------
1586 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup )
1587 throw( uno::RuntimeException )
1589 ::SolarMutexGuard aGuard;
1591 throwIfDisposed();
1593 if(mpView==NULL||!xGroup.is()||GetPage()==NULL)
1594 return;
1596 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1597 _SelectObjectInView( xGroup, pPageView );
1598 mpView->DismantleMarkedObjects( sal_False );
1599 mpView->HideSdrPage();
1601 GetModel()->SetModified();
1604 //----------------------------------------------------------------------
1605 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes )
1606 throw( uno::RuntimeException )
1608 ::SolarMutexGuard aGuard;
1610 throwIfDisposed();
1612 uno::Reference< drawing::XShape > xShape;
1613 if(mpView==NULL||!xShapes.is()||GetPage()==NULL)
1614 return xShape;
1616 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1618 _SelectObjectsInView( xShapes, pPageView );
1620 mpView->CombineMarkedObjects( sal_True );
1622 mpView->AdjustMarkHdl();
1623 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1624 if( rMarkList.GetMarkCount() == 1 )
1626 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1627 if( pObj )
1628 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() );
1631 mpView->HideSdrPage();
1633 GetModel()->SetModified();
1635 return xShape;
1638 //----------------------------------------------------------------------
1639 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape )
1640 throw( uno::RuntimeException )
1642 ::SolarMutexGuard aGuard;
1644 throwIfDisposed();
1646 if(mpView==NULL||!xShape.is()||GetPage()==NULL)
1647 return;
1649 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1650 _SelectObjectInView( xShape, pPageView );
1651 mpView->DismantleMarkedObjects( sal_True );
1652 mpView->HideSdrPage();
1654 GetModel()->SetModified();
1657 void SdGenericDrawPage::SetLftBorder( sal_Int32 nValue )
1659 if( nValue != GetPage()->GetLftBorder() )
1661 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1662 const PageKind ePageKind = GetPage()->GetPageKind();
1664 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1665 for (i = 0; i < nPageCnt; i++)
1667 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1668 pPage->SetLftBorder( nValue );
1671 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1673 for (i = 0; i < nPageCnt; i++)
1675 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1676 pPage->SetLftBorder( nValue );
1681 void SdGenericDrawPage::SetRgtBorder( sal_Int32 nValue )
1683 if( nValue != GetPage()->GetRgtBorder() )
1685 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1686 const PageKind ePageKind = GetPage()->GetPageKind();
1688 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1689 for (i = 0; i < nPageCnt; i++)
1691 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1692 pPage->SetRgtBorder( nValue );
1695 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1697 for (i = 0; i < nPageCnt; i++)
1699 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1700 pPage->SetRgtBorder( nValue );
1705 void SdGenericDrawPage::SetUppBorder( sal_Int32 nValue )
1707 if( nValue != GetPage()->GetUppBorder() )
1709 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1710 const PageKind ePageKind = GetPage()->GetPageKind();
1712 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1713 for (i = 0; i < nPageCnt; i++)
1715 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1716 pPage->SetUppBorder( nValue );
1719 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1721 for (i = 0; i < nPageCnt; i++)
1723 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1724 pPage->SetUppBorder( nValue );
1729 void SdGenericDrawPage::SetLwrBorder( sal_Int32 nValue )
1731 if( nValue != GetPage()->GetLwrBorder() )
1733 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1734 const PageKind ePageKind = GetPage()->GetPageKind();
1736 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1737 for (i = 0; i < nPageCnt; i++)
1739 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1740 pPage->SetLwrBorder( nValue );
1743 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1745 for (i = 0; i < nPageCnt; i++)
1747 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1748 pPage->SetLwrBorder( nValue );
1753 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind )
1755 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1756 if ( pDocShell )
1758 ::sd::ViewShell* pViewSh = pDocShell->GetViewShell();
1760 if( pViewSh )
1762 if( pViewSh->ISA(::sd::DrawViewShell ) )
1763 static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage();
1765 Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
1766 const long nWidth = aPageSize.Width();
1767 const long nHeight = aPageSize.Height();
1769 Point aPageOrg = Point(nWidth, nHeight / 2);
1770 Size aViewSize = Size(nWidth * 3, nHeight * 2);
1772 pDoc->SetMaxObjSize(aViewSize);
1774 pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
1776 pViewSh->UpdateScrollBars();
1781 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth )
1783 Size aSize( GetPage()->GetSize() );
1784 if( aSize.getWidth() != nWidth )
1786 aSize.setWidth( nWidth );
1788 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1789 const PageKind ePageKind = GetPage()->GetPageKind();
1791 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1792 for (i = 0; i < nPageCnt; i++)
1794 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1795 pPage->SetSize(aSize);
1798 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1800 for (i = 0; i < nPageCnt; i++)
1802 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1803 pPage->SetSize(aSize);
1806 refreshpage( pDoc, ePageKind );
1810 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight )
1812 Size aSize( GetPage()->GetSize() );
1813 if( aSize.getHeight() != nHeight )
1815 aSize.setHeight( nHeight );
1817 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
1818 const PageKind ePageKind = GetPage()->GetPageKind();
1820 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
1821 for (i = 0; i < nPageCnt; i++)
1823 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
1824 pPage->SetSize(aSize);
1827 nPageCnt = pDoc->GetSdPageCount(ePageKind);
1829 for (i = 0; i < nPageCnt; i++)
1831 SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
1832 pPage->SetSize(aSize);
1835 refreshpage( pDoc, ePageKind );
1839 // XInterface
1840 void SdGenericDrawPage::release() throw()
1843 OWeakAggObject::release();
1846 // XComponent
1847 void SdGenericDrawPage::disposing() throw()
1849 mpModel = 0;
1850 SvxFmDrawPage::disposing();
1853 // XAnimationNodeSupplier
1854 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode() throw (uno::RuntimeException)
1856 ::SolarMutexGuard aGuard;
1858 throwIfDisposed();
1860 SdPage *pSdPage = static_cast<SdPage*>(SvxFmDrawPage::mpPage);
1863 return pSdPage->getAnimationNode();
1866 //========================================================================
1867 // SdPageLinkTargets
1868 //========================================================================
1870 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw()
1872 mxPage = pUnoPage;
1873 mpUnoPage = pUnoPage;
1876 SdPageLinkTargets::~SdPageLinkTargets() throw()
1880 // XElementAccess
1881 uno::Type SAL_CALL SdPageLinkTargets::getElementType()
1882 throw(uno::RuntimeException)
1884 return ITYPE(beans::XPropertySet);
1887 sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
1888 throw(uno::RuntimeException)
1890 ::SolarMutexGuard aGuard;
1892 SdPage* pPage = mpUnoPage->GetPage();
1893 if( pPage != NULL )
1895 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1897 while( aIter.IsMore() )
1899 SdrObject* pObj = aIter.Next();
1900 String aStr( pObj->GetName() );
1901 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1902 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1903 if( aStr.Len() )
1904 return sal_True;
1908 return sal_False;
1911 // container::XNameAccess
1913 // XNameAccess
1914 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName )
1915 throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1917 ::SolarMutexGuard aGuard;
1919 SdPage* pPage = mpUnoPage->GetPage();
1920 if( pPage != NULL )
1922 SdrObject* pObj = FindObject( aName );
1923 if( pObj )
1925 Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY );
1926 return makeAny( aRef );
1930 throw container::NoSuchElementException();
1933 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames()
1934 throw(uno::RuntimeException)
1936 ::SolarMutexGuard aGuard;
1938 sal_uInt32 nObjCount = 0;
1940 SdPage* pPage = mpUnoPage->GetPage();
1941 if( pPage != NULL )
1943 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1944 while( aIter.IsMore() )
1946 SdrObject* pObj = aIter.Next();
1947 String aStr( pObj->GetName() );
1948 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1949 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1950 if( aStr.Len() )
1951 nObjCount++;
1955 Sequence< OUString > aSeq( nObjCount );
1956 if( nObjCount > 0 )
1958 OUString* pStr = aSeq.getArray();
1960 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1961 while( aIter.IsMore() )
1963 SdrObject* pObj = aIter.Next();
1964 String aStr( pObj->GetName() );
1965 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1966 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1967 if( aStr.Len() )
1968 *pStr++ = aStr;
1972 return aSeq;
1975 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName )
1976 throw(uno::RuntimeException)
1978 ::SolarMutexGuard aGuard;
1980 return FindObject( aName ) != NULL;
1983 SdrObject* SdPageLinkTargets::FindObject( const String& rName ) const throw()
1985 SdPage* pPage = mpUnoPage->GetPage();
1986 if( pPage == NULL )
1987 return NULL;
1989 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
1991 while( aIter.IsMore() )
1993 SdrObject* pObj = aIter.Next();
1994 String aStr( pObj->GetName() );
1995 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) )
1996 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1997 if( aStr.Len() && (aStr == rName) )
1998 return pObj;
2001 return NULL;
2004 // XServiceInfo
2005 OUString SAL_CALL SdPageLinkTargets::getImplementationName()
2006 throw(uno::RuntimeException)
2008 return OUString( "SdPageLinkTargets" );
2011 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName )
2012 throw(uno::RuntimeException)
2014 return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
2017 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames()
2018 throw(uno::RuntimeException)
2020 const OUString aSN( "com.sun.star.document.LinkTargets" );
2021 Sequence< OUString > aSeq( &aSN, 1);
2022 return aSeq;
2025 //========================================================================
2026 // SdDrawPage
2027 //========================================================================
2029 SdDrawPage::SdDrawPage( SdXImpressDocument* pModel, SdPage* pPage ) throw()
2030 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) )
2034 SdDrawPage::~SdDrawPage() throw()
2038 // XInterface
2039 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType )
2040 throw(uno::RuntimeException)
2042 if( rType == ITYPE( drawing::XMasterPageTarget ) )
2044 return makeAny( Reference< drawing::XMasterPageTarget >( this ) );
2046 else
2048 if( mbIsImpressDocument )
2050 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2052 if( ePageKind != PK_HANDOUT && rType == ITYPE( presentation::XPresentationPage ) )
2054 return makeAny( Reference< presentation::XPresentationPage >( this ) );
2059 return SdGenericDrawPage::queryInterface( rType );
2062 void SAL_CALL SdDrawPage::acquire() throw()
2064 SvxDrawPage::acquire();
2067 void SAL_CALL SdDrawPage::release() throw()
2069 SvxDrawPage::release();
2072 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage );
2074 // XTypeProvider
2075 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() throw(uno::RuntimeException)
2077 ::SolarMutexGuard aGuard;
2079 throwIfDisposed();
2081 if( maTypeSequence.getLength() == 0 )
2083 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2084 sal_Bool bPresPage = mbIsImpressDocument && ePageKind != PK_HANDOUT;
2086 // Collect the types of this class.
2087 ::std::vector<uno::Type> aTypes;
2088 aTypes.reserve(13);
2089 aTypes.push_back(ITYPE(drawing::XDrawPage));
2090 aTypes.push_back(ITYPE(beans::XPropertySet));
2091 aTypes.push_back(ITYPE(container::XNamed));
2092 aTypes.push_back(ITYPE(drawing::XMasterPageTarget));
2093 aTypes.push_back(ITYPE(lang::XServiceInfo));
2094 aTypes.push_back(ITYPE(util::XReplaceable));
2095 aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2096 aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2097 aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2098 aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2099 aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2100 if( bPresPage )
2101 aTypes.push_back(ITYPE(presentation::XPresentationPage));
2102 if( bPresPage && ePageKind == PK_STANDARD )
2103 aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2105 // Get types of base class.
2106 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2107 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2108 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2110 // Join those types in a sequence.
2111 maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2112 uno::Type* pTypes = maTypeSequence.getArray();
2113 ::std::vector<uno::Type>::const_iterator iType;
2114 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2115 *pTypes++ = *iType;
2116 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2117 *pTypes++ = *pBaseTypes++;
2120 return maTypeSequence;
2123 namespace
2125 class theSdDrawPageImplementationId : public rtl::Static< UnoTunnelIdInit, theSdDrawPageImplementationId > {};
2128 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId() throw(uno::RuntimeException)
2130 return theSdDrawPageImplementationId::get().getSeq();
2133 OUString SdDrawPage::getPageApiName( SdPage* pPage )
2135 return ::getPageApiName( pPage );
2138 OUString getPageApiName( SdPage* pPage )
2140 OUString aPageName;
2142 if(pPage)
2144 aPageName = pPage->GetRealName();
2146 if( aPageName.isEmpty() )
2148 OUStringBuffer sBuffer;
2149 sBuffer.appendAscii( sEmptyPageName );
2150 const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
2151 sBuffer.append( nPageNum );
2152 aPageName = sBuffer.makeStringAndClear();
2156 return aPageName;
2160 OUString getPageApiNameFromUiName( const String& rUIName )
2162 OUString aApiName;
2164 String aDefPageName(SdResId(STR_PAGE));
2165 aDefPageName += sal_Unicode( ' ' );
2167 if( rUIName.Equals( aDefPageName, 0, aDefPageName.Len() ) )
2169 aApiName = OUString( RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ) );
2170 aApiName += rUIName.Copy( aDefPageName.Len() );
2172 else
2174 aApiName = rUIName;
2177 return aApiName;
2180 OUString SdDrawPage::getPageApiNameFromUiName( const String& rUIName )
2182 return ::getPageApiNameFromUiName( rUIName );
2185 String getUiNameFromPageApiNameImpl( const OUString& rApiName )
2187 const String aDefPageName(RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ));
2188 if( rApiName.compareTo( aDefPageName, aDefPageName.Len() ) == 0 )
2190 OUString aNumber( rApiName.copy( sizeof( sEmptyPageName ) - 1 ) );
2192 // create the page number
2193 sal_Int32 nPageNumber = aNumber.toInt32();
2195 // check if there are non number characters in the number part
2196 const sal_Int32 nChars = aNumber.getLength();
2197 const sal_Unicode* pString = aNumber.getStr();
2198 sal_Int32 nChar;
2199 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2201 if((*pString < sal_Unicode('0')) || (*pString > sal_Unicode('9')))
2203 // found a non number character, so this is not the default
2204 // name for this page
2205 nPageNumber = -1;
2206 break;
2210 if( nPageNumber != -1)
2212 OUStringBuffer sBuffer;
2213 sBuffer.append( String(SdResId(STR_PAGE)) );
2214 sBuffer.append( sal_Unicode( ' ' ) );
2215 sBuffer.append( aNumber );
2216 return sBuffer.makeStringAndClear();
2220 return rApiName;
2223 String SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName )
2225 return getUiNameFromPageApiNameImpl( rApiName );
2228 // XServiceInfo
2229 OUString SAL_CALL SdDrawPage::getImplementationName() throw(uno::RuntimeException)
2231 return OUString( "SdDrawPage" );
2234 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames() throw(uno::RuntimeException)
2236 ::SolarMutexGuard aGuard;
2238 throwIfDisposed();
2240 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2241 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.DrawPage" );
2243 if( mbIsImpressDocument )
2244 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.DrawPage" );
2246 return aSeq;
2249 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName )
2250 throw(uno::RuntimeException)
2252 return SdGenericDrawPage::supportsService( ServiceName );
2255 // XNamed
2256 void SAL_CALL SdDrawPage::setName( const OUString& rName )
2257 throw(uno::RuntimeException)
2259 ::SolarMutexGuard aGuard;
2261 throwIfDisposed();
2263 DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" );
2265 OUString aName( rName );
2267 if(GetPage() && GetPage()->GetPageKind() != PK_NOTES)
2269 // check if this is the default 'page1234' name
2270 if(aName.startsWith( sEmptyPageName ))
2272 // ok, it maybe is, first get the number part after 'page'
2273 OUString aNumber( aName.copy( sizeof( sEmptyPageName ) - 1 ) );
2275 // create the page number
2276 sal_Int32 nPageNumber = aNumber.toInt32();
2278 // check if there are non number characters in the number part
2279 const sal_Int32 nChars = aNumber.getLength();
2280 const sal_Unicode* pString = aNumber.getStr();
2281 sal_Int32 nChar;
2282 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2284 if((*pString < '0') || (*pString > '9'))
2286 // found a non number character, so this is not the default
2287 // name for this page
2288 nPageNumber = -1;
2289 break;
2293 if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 )
2294 aName = OUString();
2296 else
2298 String aDefaultPageName( SdResId(STR_PAGE) );
2299 aDefaultPageName += sal_Unicode( ' ' );
2300 if( aName.compareTo( aDefaultPageName, aDefaultPageName.Len() ) == 0 )
2301 aName = OUString();
2304 GetPage()->SetName( aName );
2306 sal_uInt16 nNotesPageNum = (GetPage()->GetPageNum()-1)>>1;
2307 if( GetModel()->GetDoc()->GetSdPageCount( PK_NOTES ) > nNotesPageNum )
2309 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PK_NOTES );
2310 if( pNotesPage )
2311 pNotesPage->SetName(aName);
2314 // fake a mode change to repaint the page tab bar
2315 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2316 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
2317 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell))
2319 ::sd::DrawViewShell* pDrawViewSh = static_cast<
2320 ::sd::DrawViewShell*>(pViewSh);
2322 EditMode eMode = pDrawViewSh->GetEditMode();
2323 if( eMode == EM_PAGE )
2325 sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
2327 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2328 pDrawViewSh->ChangeEditMode( eMode, bLayer );
2332 GetModel()->SetModified();
2336 OUString SAL_CALL SdDrawPage::getName()
2337 throw(uno::RuntimeException)
2339 ::SolarMutexGuard aGuard;
2341 throwIfDisposed();
2343 return getPageApiName( GetPage() );
2346 // XMasterPageTarget
2347 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( )
2348 throw(uno::RuntimeException)
2350 ::SolarMutexGuard aGuard;
2352 throwIfDisposed();
2354 if(GetPage())
2356 Reference< drawing::XDrawPages > xPages( GetModel()->getMasterPages() );
2357 Reference< drawing::XDrawPage > xPage;
2359 if(SvxFmDrawPage::mpPage->TRG_HasMasterPage())
2361 SdrPage& rMasterPage = SvxFmDrawPage::mpPage->TRG_GetMasterPage();
2362 xPage = uno::Reference< drawing::XDrawPage >( rMasterPage.getUnoPage(), uno::UNO_QUERY );
2365 return xPage;
2367 return NULL;
2370 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage )
2371 throw(uno::RuntimeException)
2373 ::SolarMutexGuard aGuard;
2375 throwIfDisposed();
2377 if(SvxFmDrawPage::mpPage)
2379 SdMasterPage* pMasterPage = SdMasterPage::getImplementation( xMasterPage );
2380 if( pMasterPage && pMasterPage->isValid() )
2382 SvxFmDrawPage::mpPage->TRG_ClearMasterPage();
2384 SdPage* pSdPage = (SdPage*) pMasterPage->GetSdrPage();
2385 SvxFmDrawPage::mpPage->TRG_SetMasterPage(*pSdPage);
2387 SvxFmDrawPage::mpPage->SetBorder(pSdPage->GetLftBorder(),pSdPage->GetUppBorder(),
2388 pSdPage->GetRgtBorder(),pSdPage->GetLwrBorder() );
2390 SvxFmDrawPage::mpPage->SetSize( pSdPage->GetSize() );
2391 SvxFmDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() );
2392 ((SdPage*)SvxFmDrawPage::mpPage)->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2394 // set notes master also
2395 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2397 pNotesPage->TRG_ClearMasterPage();
2398 sal_uInt16 nNum = (SvxFmDrawPage::mpPage->TRG_GetMasterPage()).GetPageNum() + 1;
2399 pNotesPage->TRG_SetMasterPage(*SvxFmDrawPage::mpPage->GetModel()->GetMasterPage(nNum));
2400 pNotesPage->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() );
2402 GetModel()->SetModified();
2408 // XPresentationPage
2409 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage()
2410 throw(uno::RuntimeException)
2412 ::SolarMutexGuard aGuard;
2414 throwIfDisposed();
2416 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() && SvxFmDrawPage::mpPage->GetPageNum() )
2418 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
2419 if( pNotesPage )
2421 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2422 return xPage;
2425 return NULL;
2429 // XIndexAccess
2430 sal_Int32 SAL_CALL SdDrawPage::getCount()
2431 throw(uno::RuntimeException)
2433 return SdGenericDrawPage::getCount();
2436 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index )
2437 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2439 return SdGenericDrawPage::getByIndex( Index );
2442 // XElementAccess
2443 uno::Type SAL_CALL SdDrawPage::getElementType()
2444 throw(uno::RuntimeException)
2446 return SdGenericDrawPage::getElementType();
2449 sal_Bool SAL_CALL SdDrawPage::hasElements()
2450 throw(uno::RuntimeException)
2452 return SdGenericDrawPage::hasElements();
2455 // XShapes
2456 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2458 SdGenericDrawPage::add( xShape );
2461 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
2463 ::SolarMutexGuard aGuard;
2465 throwIfDisposed();
2467 SvxShape* pShape = SvxShape::getImplementation( xShape );
2468 if( pShape )
2470 SdrObject* pObj = pShape->GetSdrObject();
2471 if( pObj )
2473 GetPage()->RemovePresObj(pObj);
2474 pObj->SetUserCall(NULL);
2478 SdGenericDrawPage::remove( xShape );
2481 void SdDrawPage::setBackground( const Any& rValue )
2482 throw( lang::IllegalArgumentException )
2484 Reference< beans::XPropertySet > xSet;
2486 if( !(rValue >>= xSet) && !rValue.hasValue() )
2487 throw lang::IllegalArgumentException();
2489 if( !xSet.is() )
2491 // the easy case, no background set. Set XFILL_NONE to represent this
2492 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
2493 return;
2496 // is it our own implementation?
2497 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet );
2499 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2501 if( pBack )
2503 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2505 else
2507 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2509 Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2510 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground );
2511 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() );
2513 Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
2514 sal_Int32 nCount = aProperties.getLength();
2515 beans::Property* pProp = aProperties.getArray();
2517 while( nCount-- )
2519 const OUString aPropName( pProp->Name );
2520 if( xSetInfo->hasPropertyByName( aPropName ) )
2521 xDestSet->setPropertyValue( aPropName,
2522 xSet->getPropertyValue( aPropName ) );
2524 pProp++;
2527 pBackground->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2530 if( aSet.Count() == 0 )
2532 // no background fill, represent by setting XFILL_NONE
2533 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE));
2535 else
2537 // background fill, set at page (not sure if ClearItem is needed)
2538 GetPage()->getSdrPageProperties().ClearItem();
2539 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2542 // repaint only
2543 SvxFmDrawPage::mpPage->ActionChanged();
2546 // XAnnotationAccess:
2547 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() throw (RuntimeException)
2549 if( !GetPage() )
2550 throw DisposedException();
2552 Reference< XAnnotation > xRet;
2553 GetPage()->createAnnotation(xRet);
2554 return xRet;
2557 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) throw (RuntimeException, IllegalArgumentException)
2559 GetPage()->removeAnnotation(annotation);
2562 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() throw (RuntimeException)
2564 return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() );
2567 void SdDrawPage::getBackground( Any& rValue ) throw()
2569 const SfxItemSet& rFillAttributes = GetPage()->getSdrPageProperties().GetItemSet();
2571 if(XFILL_NONE == ((const XFillStyleItem&)rFillAttributes.Get(XATTR_FILLSTYLE)).GetValue())
2573 // no fill set (switched off by XFILL_NONE), clear rValue to represent this
2574 rValue.clear();
2576 else
2578 // there is a fill set, export to rValue
2579 Reference< beans::XPropertySet > xSet(new SdUnoPageBackground(
2580 GetModel()->GetDoc(),
2581 &GetPage()->getSdrPageProperties().GetItemSet()));
2582 rValue <<= xSet;
2586 void SdGenericDrawPage::setNavigationOrder( const Any& rValue )
2588 Reference< XIndexAccess > xIA( rValue, UNO_QUERY );
2589 if( xIA.is() )
2591 if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this )
2593 if( GetPage()->HasObjectNavigationOrder() )
2594 GetPage()->ClearObjectNavigationOrder();
2596 return;
2598 else if( xIA->getCount() == static_cast< sal_Int32 >( GetPage()->GetObjCount() ) )
2600 GetPage()->SetNavigationOrder(xIA);
2601 return;
2604 throw IllegalArgumentException();
2607 class SdNavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess >
2609 public:
2610 SdNavigationOrderAccess( SdrPage* pPage );
2612 // XIndexAccess
2613 virtual sal_Int32 SAL_CALL getCount( ) throw (RuntimeException);
2614 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
2616 // XElementAccess
2617 virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
2618 virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
2620 private:
2621 std::vector< Reference< XShape > > maShapes;
2624 SdNavigationOrderAccess::SdNavigationOrderAccess( SdrPage* pPage )
2625 : maShapes( static_cast< sal_uInt32 >( pPage ? pPage->GetObjCount() : 0 ) )
2627 if( pPage )
2629 sal_uInt32 nIndex;
2630 const sal_uInt32 nCount = static_cast< sal_uInt32 >( pPage->GetObjCount() );
2631 for( nIndex = 0; nIndex < nCount; ++nIndex )
2633 SdrObject* pObj = pPage->GetObj( nIndex );
2634 sal_uInt32 nNavPos = pObj->GetNavigationPosition();
2635 DBG_ASSERT( !maShapes[nNavPos].is(), "sd::SdNavigationOrderAccess::SdNavigationOrderAccess(), duplicate navigation positions from core!" );
2636 maShapes[nNavPos] = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY );
2641 // XIndexAccess
2642 sal_Int32 SAL_CALL SdNavigationOrderAccess::getCount( ) throw (RuntimeException)
2644 return static_cast< sal_Int32 >( maShapes.size() );
2647 Any SAL_CALL SdNavigationOrderAccess::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
2649 if( (Index < 0) || (Index > getCount()) )
2650 throw IndexOutOfBoundsException();
2652 return Any( maShapes[Index] );
2655 // XElementAccess
2656 Type SAL_CALL SdNavigationOrderAccess::getElementType( ) throw (RuntimeException)
2658 return XShape::static_type();
2661 sal_Bool SAL_CALL SdNavigationOrderAccess::hasElements( ) throw (RuntimeException)
2663 return maShapes.empty() ? sal_False : sal_True;
2666 Any SdGenericDrawPage::getNavigationOrder()
2668 if( GetPage()->HasObjectNavigationOrder() )
2670 return Any( Reference< XIndexAccess >( new SdNavigationOrderAccess( GetPage() ) ) );
2672 else
2674 return Any( Reference< XIndexAccess >( this ) );
2678 //========================================================================
2679 // class SdMasterPage
2680 //========================================================================
2682 SdMasterPage::SdMasterPage( SdXImpressDocument* pModel, SdPage* pPage ) throw()
2683 : SdGenericDrawPage( pModel, pPage, ImplGetMasterPagePropertySet( pPage ? pPage->GetPageKind() : PK_STANDARD ) )
2687 SdMasterPage::~SdMasterPage() throw()
2691 // XInterface
2692 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType )
2693 throw(uno::RuntimeException)
2695 ::SolarMutexGuard aGuard;
2697 throwIfDisposed();
2699 uno::Any aAny;
2701 if( rType == ITYPE( container::XIndexAccess ) )
2702 aAny <<= Reference< container::XIndexAccess >((presentation::XPresentationPage*)(this));
2703 else if( rType == ITYPE( container::XElementAccess ) )
2704 aAny <<= Reference< container::XElementAccess >((presentation::XPresentationPage*)(this));
2705 else if( rType == ITYPE( container::XNamed ) )
2706 aAny <<= Reference< container::XNamed >(this);
2707 else if( rType == ITYPE( presentation::XPresentationPage ) &&
2708 ( mbIsImpressDocument &&
2709 GetPage() && GetPage()->GetPageKind() != PK_HANDOUT) )
2710 aAny <<= Reference< presentation::XPresentationPage >( this );
2711 else
2712 return SdGenericDrawPage::queryInterface( rType );
2714 return aAny;
2717 void SAL_CALL SdMasterPage::acquire() throw()
2719 SvxDrawPage::acquire();
2722 void SAL_CALL SdMasterPage::release() throw()
2724 SvxDrawPage::release();
2727 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage );
2729 // XTypeProvider
2730 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() throw(uno::RuntimeException)
2732 ::SolarMutexGuard aGuard;
2734 throwIfDisposed();
2736 if( maTypeSequence.getLength() == 0 )
2738 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD;
2739 sal_Bool bPresPage = mbIsImpressDocument && SvxFmDrawPage::mpPage && ePageKind != PK_HANDOUT;
2741 // Collect the types of this class.
2742 ::std::vector<uno::Type> aTypes;
2743 aTypes.reserve(12);
2744 aTypes.push_back(ITYPE(drawing::XDrawPage));
2745 aTypes.push_back(ITYPE(beans::XPropertySet));
2746 aTypes.push_back(ITYPE(container::XNamed));
2747 aTypes.push_back(ITYPE(lang::XServiceInfo));
2748 aTypes.push_back(ITYPE(util::XReplaceable));
2749 aTypes.push_back(ITYPE(document::XLinkTargetSupplier));
2750 aTypes.push_back(ITYPE( drawing::XShapeCombiner ));
2751 aTypes.push_back(ITYPE( drawing::XShapeBinder ));
2752 aTypes.push_back(ITYPE( office::XAnnotationAccess ));
2753 aTypes.push_back(ITYPE( beans::XMultiPropertySet ));
2754 if( bPresPage )
2755 aTypes.push_back(ITYPE(presentation::XPresentationPage));
2756 if( bPresPage && ePageKind == PK_STANDARD )
2757 aTypes.push_back(ITYPE(XAnimationNodeSupplier));
2759 // Get types of base class.
2760 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() );
2761 const sal_Int32 nBaseTypes = aBaseTypes.getLength();
2762 const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
2764 // Join those types in a sequence.
2765 maTypeSequence.realloc(aTypes.size() + nBaseTypes);
2766 uno::Type* pTypes = maTypeSequence.getArray();
2767 ::std::vector<uno::Type>::const_iterator iType;
2768 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType)
2769 *pTypes++ = *iType;
2770 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
2771 *pTypes++ = *pBaseTypes++;
2774 return maTypeSequence;
2777 namespace
2779 class theSdMasterPageImplementationId : public rtl::Static< UnoTunnelIdInit, theSdMasterPageImplementationId > {};
2782 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId() throw(uno::RuntimeException)
2784 return theSdMasterPageImplementationId::get().getSeq();
2787 // XServiceInfo
2788 OUString SAL_CALL SdMasterPage::getImplementationName() throw(uno::RuntimeException)
2790 return OUString( "SdMasterPage" );
2793 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames() throw(uno::RuntimeException)
2795 ::SolarMutexGuard aGuard;
2797 throwIfDisposed();
2799 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2800 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.MasterPage" );
2802 if( SvxFmDrawPage::mpPage && ((SdPage*)SvxFmDrawPage::mpPage)->GetPageKind() == PK_HANDOUT )
2803 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.HandoutMasterPage" );
2805 return aSeq;
2808 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName )
2809 throw(uno::RuntimeException)
2811 return SdGenericDrawPage::supportsService( ServiceName );
2814 // XElementAccess
2815 sal_Bool SAL_CALL SdMasterPage::hasElements() throw(uno::RuntimeException)
2817 ::SolarMutexGuard aGuard;
2819 throwIfDisposed();
2821 if( SvxFmDrawPage::mpPage == NULL )
2822 return sal_False;
2824 return SvxFmDrawPage::mpPage->GetObjCount() > 0;
2827 uno::Type SAL_CALL SdMasterPage::getElementType()
2828 throw(uno::RuntimeException)
2830 return SdGenericDrawPage::getElementType();
2833 // XIndexAccess
2834 sal_Int32 SAL_CALL SdMasterPage::getCount()
2835 throw(uno::RuntimeException)
2837 ::SolarMutexGuard aGuard;
2839 throwIfDisposed();
2841 return SdGenericDrawPage::getCount();
2844 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index )
2845 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
2847 ::SolarMutexGuard aGuard;
2849 throwIfDisposed();
2851 return SdGenericDrawPage::getByIndex(Index);
2854 // intern
2855 void SdMasterPage::setBackground( const Any& rValue )
2856 throw( lang::IllegalArgumentException )
2858 // we need at least an beans::XPropertySet
2859 Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY );
2860 if( !xInputSet.is() )
2861 throw lang::IllegalArgumentException();
2865 if( GetModel() && mbIsImpressDocument )
2867 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
2868 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ;
2869 if( xFamily.is() )
2871 OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
2873 Reference< beans::XPropertySet > xStyleSet( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2875 Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2876 Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY );
2878 PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap()->getPropertyEntries();
2879 PropertyEntryVector_t::const_iterator aIt = aBackgroundProperties.begin();
2880 while( aIt != aBackgroundProperties.end() )
2882 if( xSetInfo->hasPropertyByName( aIt->sName ) )
2884 if( !xSetStates.is() || xSetStates->getPropertyState( aIt->sName ) == beans::PropertyState_DIRECT_VALUE )
2885 xStyleSet->setPropertyValue( aIt->sName, xInputSet->getPropertyValue( aIt->sName ) );
2886 else
2887 xSetStates->setPropertyToDefault( aIt->sName );
2890 ++aIt;
2894 else
2896 // first fill an item set
2897 // is it our own implementation?
2898 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xInputSet );
2900 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST );
2902 if( pBack )
2904 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet );
2906 else
2908 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2910 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW );
2911 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground );
2912 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_QUERY_THROW );
2914 uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
2915 sal_Int32 nCount = aProperties.getLength();
2916 beans::Property* pProp = aProperties.getArray();
2918 while( nCount-- )
2920 const OUString aPropName( pProp->Name );
2921 if( xInputSetInfo->hasPropertyByName( aPropName ) )
2922 xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
2924 pProp++;
2927 pBackground->fillItemSet( (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(), aSet );
2930 // if we find the background style, copy the set to the background
2931 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
2932 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
2933 if(pSSPool)
2935 String aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() );
2936 aLayoutName.Erase(aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
2937 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
2938 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
2940 if( pStyleSheet )
2942 pStyleSheet->GetItemSet().Put( aSet );
2944 // repaint only
2945 SvxFmDrawPage::mpPage->ActionChanged();
2946 return;
2950 // if no background style is available, set at page directly. This
2951 // is an error and should NOT happen (and will be asserted from the SdrPage)
2952 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2955 catch( Exception& )
2957 OSL_FAIL("sd::SdMasterPage::setBackground(), exception caught!");
2961 void SdMasterPage::getBackground( Any& rValue ) throw()
2963 if( GetModel() ) try
2965 if( mbIsImpressDocument )
2967 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW );
2968 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW );
2970 const OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) );
2971 rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2973 else
2975 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel();
2976 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool();
2977 if(pSSPool)
2979 String aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() );
2980 aLayoutName.Erase( aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4);
2981 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND));
2982 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE );
2984 if( pStyleSheet )
2986 SfxItemSet aStyleSet( pStyleSheet->GetItemSet());
2987 if( aStyleSet.Count() )
2989 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) );
2990 return;
2995 // No style found, use fill attributes from page background. This
2996 // should NOT happen and is an error
2997 const SfxItemSet& rFallbackItemSet(SvxFmDrawPage::mpPage->getSdrPageProperties().GetItemSet());
2999 if(XFILL_NONE == ((const XFillStyleItem&)rFallbackItemSet.Get(XATTR_FILLSTYLE)).GetValue())
3001 rValue <<= Reference< beans::XPropertySet >(
3002 new SdUnoPageBackground(GetModel()->GetDoc(), &rFallbackItemSet));
3004 else
3006 rValue.clear();
3010 catch( Exception& )
3012 rValue.clear();
3013 OSL_FAIL("sd::SdMasterPage::getBackground(), exception caught!");
3017 // XNamed
3018 void SAL_CALL SdMasterPage::setName( const OUString& rName )
3019 throw(uno::RuntimeException)
3021 ::SolarMutexGuard aGuard;
3023 throwIfDisposed();
3025 if(SvxFmDrawPage::mpPage && GetPage()->GetPageKind() != PK_NOTES)
3027 SdDrawDocument* pDoc = GetModel()->GetDoc();
3028 sal_Bool bOutDummy;
3029 String aNewName( rName );
3031 // Slide Name has to be unique
3032 if( pDoc && pDoc->GetPageByName( aNewName, bOutDummy ) != SDRPAGE_NOTFOUND )
3033 return; // throw Exception ?
3035 GetPage()->SetName( aNewName );
3037 if( pDoc )
3038 pDoc->RenameLayoutTemplate( GetPage()->GetLayoutName(), aNewName );
3040 // fake a mode change to repaint the page tab bar
3041 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
3042 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL;
3043 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell ) )
3045 ::sd::DrawViewShell* pDrawViewSh =
3046 static_cast< ::sd::DrawViewShell*>(pViewSh);
3048 EditMode eMode = pDrawViewSh->GetEditMode();
3049 if( eMode == EM_MASTERPAGE )
3051 sal_Bool bLayer = pDrawViewSh->IsLayerModeActive();
3053 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
3054 pDrawViewSh->ChangeEditMode( eMode, bLayer );
3058 GetModel()->SetModified();
3062 OUString SAL_CALL SdMasterPage::getName( )
3063 throw(uno::RuntimeException)
3065 ::SolarMutexGuard aGuard;
3067 throwIfDisposed();
3069 if(SvxFmDrawPage::mpPage)
3071 String aLayoutName( GetPage()->GetLayoutName() );
3072 aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM((SD_LT_SEPARATOR)))));
3074 return aLayoutName;
3077 return OUString();
3080 // XPresentationPage
3081 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage()
3082 throw(uno::RuntimeException)
3084 ::SolarMutexGuard aGuard;
3086 throwIfDisposed();
3088 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() )
3090 SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES );
3091 if( pNotesPage )
3093 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
3094 return xPage;
3097 return NULL;
3100 // XShapes
3101 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3103 SdGenericDrawPage::add( xShape );
3106 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape ) throw(uno::RuntimeException)
3108 ::SolarMutexGuard aGuard;
3110 throwIfDisposed();
3112 SvxShape* pShape = SvxShape::getImplementation( xShape );
3113 if( pShape )
3115 SdrObject* pObj = pShape->GetSdrObject();
3116 if( pObj )
3118 if( GetPage()->IsPresObj( pObj ) )
3119 GetPage()->RemovePresObj(pObj);
3123 SdGenericDrawPage::remove( xShape );
3127 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage )
3129 Reference< uno::XInterface > xPage;
3131 if( pPage && pPage->GetModel() )
3133 SdXImpressDocument* pModel = SdXImpressDocument::getImplementation( pPage->GetModel()->getUnoModel() );
3134 if( pModel )
3136 if( pPage->IsMasterPage() )
3138 xPage = (::cppu::OWeakObject*)new SdMasterPage( pModel, pPage );
3140 else
3142 xPage = (::cppu::OWeakObject*)new SdDrawPage( pModel, pPage );
3147 return xPage;
3150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */