bump product version to 6.4.0.3
[LibreOffice.git] / sd / source / ui / unoidl / unopage.cxx
blobed2fadd7be786143adc6141c9e070797803db5bd
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/awt/XBitmap.hpp>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/presentation/FadeEffect.hpp>
24 #include <com/sun/star/presentation/AnimationSpeed.hpp>
25 #include <com/sun/star/view/PaperOrientation.hpp>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <comphelper/profilezone.hxx>
29 #include <comphelper/servicehelper.hxx>
30 #include <cppuhelper/supportsservice.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <vcl/bitmapex.hxx>
33 #include <vcl/metaact.hxx>
34 #include <toolkit/helper/vclunohelper.hxx>
35 #include <vcl/svapp.hxx>
36 #include <AnnotationEnumeration.hxx>
37 #include <createunopageimpl.hxx>
38 #include <unomodel.hxx>
39 #include <unopage.hxx>
40 #include <svl/itemset.hxx>
41 #include <svx/svdmodel.hxx>
42 #include <sdresid.hxx>
43 #include <strings.hrc>
44 #include <sdpage.hxx>
45 #include <unoprnms.hxx>
46 #include <drawdoc.hxx>
47 #include <svx/unoshape.hxx>
48 #include <svl/style.hxx>
49 #include <comphelper/serviceinfohelper.hxx>
50 #include <comphelper/extract.hxx>
51 #include <svx/svditer.hxx>
52 #include <vcl/wmf.hxx>
53 #include <svx/svdoole2.hxx>
54 #include <svx/svdpool.hxx>
55 #include <svx/svdview.hxx>
56 #include <svx/xfillit0.hxx>
57 #include <DrawDocShell.hxx>
58 #include <ViewShell.hxx>
59 #include <DrawViewShell.hxx>
60 #include "unoobj.hxx"
62 #include <strings.hxx>
63 #include <bitmaps.hlst>
64 #include <unokywds.hxx>
65 #include "unopback.hxx"
66 #include <vcl/dibtools.hxx>
67 #include <tools/debug.hxx>
68 #include <tools/stream.hxx>
70 using ::com::sun::star::animations::XAnimationNode;
71 using ::com::sun::star::animations::XAnimationNodeSupplier;
73 using namespace ::com::sun::star;
74 using namespace ::com::sun::star::uno;
75 using namespace ::com::sun::star::lang;
76 using namespace ::com::sun::star::container;
77 using namespace ::com::sun::star::drawing;
78 using namespace ::com::sun::star::office;
80 // this are the ids for page properties
81 enum WID_PAGE
83 WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH,
84 WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER,
85 WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_HIGHRESDURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP,
86 WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL,
87 WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK,
88 WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT,
89 WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
90 WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
91 WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
92 WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE
95 static sal_Char const sEmptyPageName[sizeof("page")] = "page";
97 // this function stores the property maps for draw pages in impress and draw
98 static const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind ePageKind )
100 static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] =
102 { OUString(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
103 { OUString(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
104 { OUString(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
105 { OUString(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
106 { OUString(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
107 { OUString(UNO_NAME_PAGE_CHANGE), WID_PAGE_CHANGE, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
108 { OUString(UNO_NAME_PAGE_DURATION), WID_PAGE_DURATION, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
109 { OUString(UNO_NAME_PAGE_EFFECT), WID_PAGE_EFFECT, ::cppu::UnoType<presentation::FadeEffect>::get(), 0, 0},
110 { OUString(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
111 { OUString(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
112 { OUString(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0},
113 { OUString(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0},
114 { OUString(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
115 { OUString(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
116 { OUString(UNO_NAME_PAGE_SPEED), WID_PAGE_SPEED, ::cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},
117 { OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
118 { OUString(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
119 { OUString(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
120 { OUString(UNO_NAME_PAGE_PREVIEWMETAFILE), WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
121 { OUString(UNO_NAME_PAGE_VISIBLE), WID_PAGE_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
122 { OUString(UNO_NAME_OBJ_SOUNDFILE), WID_PAGE_SOUNDFILE, cppu::UnoType<Any>::get(), 0, 0},
123 { OUString(sUNO_Prop_IsBackgroundVisible), WID_PAGE_BACKVIS, cppu::UnoType<bool>::get(), 0, 0},
124 { OUString(sUNO_Prop_IsBackgroundObjectsVisible), WID_PAGE_BACKOBJVIS, cppu::UnoType<bool>::get(), 0, 0},
125 { OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
126 { OUString(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, ::cppu::UnoType<OUString>::get(), 0, 0},
127 { OUString("HighResDuration"), WID_PAGE_HIGHRESDURATION, ::cppu::UnoType<double>::get(), 0, 0},
128 { OUString("IsBackgroundDark") , WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
129 { OUString("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
130 { OUString("FooterText"), WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
131 { OUString("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
132 { OUString("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
133 { OUString("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0},
134 { OUString("DateTimeText"), WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
135 { OUString("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
136 { OUString("TransitionType"), WID_TRANSITION_TYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
137 { OUString("TransitionSubtype"), WID_TRANSITION_SUBTYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
138 { OUString("TransitionDirection"), WID_TRANSITION_DIRECTION, ::cppu::UnoType<sal_Bool>::get(), 0, 0},
139 { OUString("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
140 { OUString(UNO_NAME_PAGE_TRANSITION_DURATION), WID_TRANSITION_DURATION, ::cppu::UnoType<double>::get(), 0, 0},
141 { OUString("LoopSound"), WID_LOOP_SOUND, cppu::UnoType<bool>::get(), 0, 0},
142 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0},
143 { OUString(), 0, css::uno::Type(), 0, 0 }
146 #define DRAW_PAGE_NOTES_PROPERTIES \
147 { OUString(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
148 { OUString(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
149 { OUString(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
150 { OUString(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
151 { OUString(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
152 { OUString(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0}, \
153 { OUString(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0}, \
154 { OUString(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0}, \
155 { OUString(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0}, \
156 { OUString(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0}, \
157 { OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
158 { OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},\
159 { OUString("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
160 { OUString("HeaderText"), WID_PAGE_HEADERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
161 { OUString("IsBackgroundDark"), WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, \
162 { OUString("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
163 { OUString("FooterText"), WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
164 { OUString("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
165 { OUString("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
166 { OUString("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0}, \
167 { OUString("DateTimeText"), WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
168 { OUString("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
169 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0}, \
170 { OUString(), 0, css::uno::Type(), 0, 0 }
172 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] =
174 // this must be the first two entries so they can be excluded for PageKind::Standard
175 { OUString(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
176 DRAW_PAGE_NOTES_PROPERTIES
178 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] =
180 DRAW_PAGE_NOTES_PROPERTIES
183 #define GRAPHIC_PAGE_PROPERTIES \
184 { OUString(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
185 { OUString(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
186 { OUString(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
187 { OUString(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
188 { OUString(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
189 { OUString(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0}, \
190 { OUString(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0}, \
191 { OUString(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0}, \
192 { OUString(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0}, \
193 { OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
194 { OUString(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0}, \
195 { OUString(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
196 { OUString(UNO_NAME_PAGE_PREVIEWMETAFILE), WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
197 { OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, \
198 { OUString(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, ::cppu::UnoType<OUString>::get(), 0, 0}, \
199 { OUString("IsBackgroundDark"), WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, \
200 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0}, \
201 { OUString(), 0, css::uno::Type(), 0, 0 }
203 static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] =
205 { OUString(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
206 GRAPHIC_PAGE_PROPERTIES
208 static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] =
210 GRAPHIC_PAGE_PROPERTIES
213 bool bWithoutBackground = ePageKind != PageKind::Standard && ePageKind != PageKind::Handout;
214 const SvxItemPropertySet* pRet = nullptr;
215 if( bImpress )
217 if( ePageKind == PageKind::Standard )
219 //PageKind::Standard always has a background property
220 static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
221 pRet = &aDrawPagePropertySet_Impl;
223 else
225 if(bWithoutBackground)
227 static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
228 pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl;
230 else
232 static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
233 pRet = &aDrawPageNotesHandoutPropertySet_Impl;
237 else
239 if(bWithoutBackground)
241 static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
242 pRet = &aGraphicPagePropertyNoBackSet_Impl;
244 else
246 static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
247 pRet = &aGraphicPagePropertySet_Impl;
250 return pRet;
253 /** this function stores the property map for master pages in impress and draw */
254 static const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
256 static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] =
258 { OUString(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), 0, 0},
259 { OUString(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
260 { OUString(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
261 { OUString(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
262 { OUString(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
263 { OUString(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
264 { OUString(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0},
265 { OUString(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0},
266 { OUString(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
267 { OUString(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
268 { OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
269 { OUString("BackgroundFullSize"), WID_PAGE_BACKFULL, cppu::UnoType<bool>::get(), 0, 0},
270 { OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
271 { OUString("IsBackgroundDark"), WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
272 { OUString(), 0, css::uno::Type(), 0, 0 }
275 static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
277 { OUString(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
278 { OUString(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
279 { OUString(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
280 { OUString(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
281 { OUString(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
282 { OUString(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
283 { OUString(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
284 { OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
285 { OUString(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
286 { OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
287 { OUString("IsBackgroundDark"), WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
288 { OUString("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
289 { OUString("HeaderText"), WID_PAGE_HEADERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
290 { OUString("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
291 { OUString("FooterText"), WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
292 { OUString("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
293 { OUString("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
294 { OUString("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0},
295 { OUString("DateTimeText"), WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
296 { OUString("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
297 { OUString(), 0, css::uno::Type(), 0, 0 }
300 const SvxItemPropertySet* pRet = nullptr;
301 if( ePageKind == PageKind::Handout )
303 static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
304 pRet = &aHandoutMasterPagePropertySet_Impl;
306 else
308 static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
309 pRet = &aMasterPagePropertySet_Impl;
311 return pRet;
314 namespace
316 class theSdGenericDrawPageUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdGenericDrawPageUnoTunnelId> {};
319 const css::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw()
321 return theSdGenericDrawPageUnoTunnelId::get().getSeq();
324 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
326 if( isUnoTunnelId<SdGenericDrawPage>(rId) )
328 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
330 else
332 return SvxFmDrawPage::getSomething( rId );
336 SdGenericDrawPage::SdGenericDrawPage(SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet)
337 : SvxFmDrawPage( static_cast<SdrPage*>(pInPage) ),
338 SdUnoSearchReplaceShape(this),
339 mpDocModel( _pModel ),
340 mpSdrModel(nullptr),
341 mbIsImpressDocument(false),
342 mnTempPageNumber(0),
343 mpPropSet ( _pSet )
345 mpSdrModel = SvxFmDrawPage::mpModel;
346 if( mpDocModel )
347 mbIsImpressDocument = mpDocModel->IsImpressDocument();
351 SdGenericDrawPage::~SdGenericDrawPage() throw()
355 void SdGenericDrawPage::throwIfDisposed() const
357 if( (SvxFmDrawPage::mpModel == nullptr) || (mpDocModel == nullptr) || (SvxFmDrawPage::mpPage == nullptr) )
358 throw lang::DisposedException();
361 SdXImpressDocument* SdGenericDrawPage::GetModel() const
363 if( mpSdrModel != SvxFmDrawPage::mpModel )
364 const_cast<SdGenericDrawPage*>(this)->UpdateModel();
365 return mpDocModel;
368 bool SdGenericDrawPage::IsImpressDocument() const
370 if( mpSdrModel != SvxFmDrawPage::mpModel )
371 const_cast<SdGenericDrawPage*>(this)->UpdateModel();
372 return mbIsImpressDocument;
376 void SdGenericDrawPage::UpdateModel()
378 mpSdrModel = SvxFmDrawPage::mpModel;
379 if( mpSdrModel )
381 uno::Reference< uno::XInterface > xModel( SvxFmDrawPage::mpModel->getUnoModel() );
382 mpDocModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>( xModel );
384 else
386 mpDocModel = nullptr;
388 mbIsImpressDocument = mpDocModel && mpDocModel->IsImpressDocument();
391 // this is called whenever a SdrObject must be created for an empty api shape wrapper
392 SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape )
394 if( nullptr == SvxFmDrawPage::mpPage || !xShape.is() )
395 return nullptr;
397 OUString aType( xShape->getShapeType() );
398 const OUString aPrefix( "com.sun.star.presentation." );
399 if( !aType.startsWith( aPrefix ) )
401 SdrObject* pObj = SvxFmDrawPage::CreateSdrObject_( xShape );
402 return pObj;
405 aType = aType.copy( aPrefix.getLength() );
407 PresObjKind eObjKind = PRESOBJ_NONE;
409 if( aType == "TitleTextShape" )
411 eObjKind = PRESOBJ_TITLE;
413 else if( aType == "OutlinerShape" )
415 eObjKind = PRESOBJ_OUTLINE;
417 else if( aType == "SubtitleShape" )
419 eObjKind = PRESOBJ_TEXT;
421 else if( aType == "OLE2Shape" )
423 eObjKind = PRESOBJ_OBJECT;
425 else if( aType == "ChartShape" )
427 eObjKind = PRESOBJ_CHART;
429 else if( aType == "CalcShape" )
431 eObjKind = PRESOBJ_CALC;
433 else if( aType == "TableShape" )
435 eObjKind = PRESOBJ_TABLE;
437 else if( aType == "GraphicObjectShape" )
439 eObjKind = PRESOBJ_GRAPHIC;
441 else if( aType == "OrgChartShape" )
443 eObjKind = PRESOBJ_ORGCHART;
445 else if( aType == "PageShape" )
447 if( GetPage()->GetPageKind() == PageKind::Notes && GetPage()->IsMasterPage() )
448 eObjKind = PRESOBJ_TITLE;
449 else
450 eObjKind = PRESOBJ_PAGE;
452 else if( aType == "NotesShape" )
454 eObjKind = PRESOBJ_NOTES;
456 else if( aType == "HandoutShape" )
458 eObjKind = PRESOBJ_HANDOUT;
460 else if( aType == "FooterShape" )
462 eObjKind = PRESOBJ_FOOTER;
464 else if( aType == "HeaderShape" )
466 eObjKind = PRESOBJ_HEADER;
468 else if( aType == "SlideNumberShape" )
470 eObjKind = PRESOBJ_SLIDENUMBER;
472 else if( aType == "DateTimeShape" )
474 eObjKind = PRESOBJ_DATETIME;
476 else if( aType == "MediaShape" )
478 eObjKind = PRESOBJ_MEDIA;
481 ::tools::Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() );
483 const awt::Point aPos( aRect.Left(), aRect.Top() );
484 xShape->setPosition( aPos );
486 const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
487 xShape->setSize( aSize );
489 SdrObject *pPresObj = nullptr;
490 if( (eObjKind == PRESOBJ_TABLE) || (eObjKind == PRESOBJ_MEDIA) )
492 pPresObj = SvxFmDrawPage::CreateSdrObject_( xShape );
493 if( pPresObj )
495 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
496 pPresObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true);
497 GetPage()->InsertPresObj( pPresObj, eObjKind );
500 else
502 pPresObj = GetPage()->CreatePresObj( eObjKind, false, aRect );
505 if( pPresObj )
506 pPresObj->SetUserCall( GetPage() );
508 return pPresObj;
511 // XInterface
512 Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType )
514 Any aAny;
516 if (rType == cppu::UnoType<beans::XPropertySet>::get())
518 aAny <<= Reference<beans::XPropertySet>(this);
520 else if (rType == cppu::UnoType<container::XNamed>::get())
522 aAny <<= Reference<container::XNamed>(this);
524 else if (rType == cppu::UnoType<util::XReplaceable>::get())
526 aAny <<= Reference<util::XReplaceable>(this);
528 else if (rType == cppu::UnoType<util::XSearchable>::get())
530 aAny <<= Reference<util::XSearchable>(this);
532 else if (rType == cppu::UnoType<document::XLinkTargetSupplier>::get())
534 aAny <<= Reference<document::XLinkTargetSupplier>(this);
536 else if (rType == cppu::UnoType<drawing::XShapeCombiner>::get())
538 aAny <<= Reference<drawing::XShapeCombiner>(this);
540 else if (rType == cppu::UnoType<drawing::XShapeBinder>::get())
542 aAny <<= Reference<drawing::XShapeBinder>(this);
544 else if (rType == cppu::UnoType<beans::XMultiPropertySet>::get())
546 aAny <<= Reference<beans::XMultiPropertySet>(this);
548 else if (rType == cppu::UnoType<office::XAnnotationAccess>::get())
550 aAny <<= Reference<office::XAnnotationAccess>(this);
552 else if (IsImpressDocument() && rType == cppu::UnoType<XAnimationNodeSupplier>::get())
554 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
556 if( ePageKind == PageKind::Standard )
557 return makeAny( Reference< XAnimationNodeSupplier >( this ) );
559 else
560 return SvxDrawPage::queryInterface( rType );
562 return aAny;
565 // XPropertySet
566 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo()
568 ::SolarMutexGuard aGuard;
569 throwIfDisposed();
570 return mpPropSet->getPropertySetInfo();
573 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
575 ::SolarMutexGuard aGuard;
577 throwIfDisposed();
579 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
581 switch( pEntry ? pEntry->nWID : -1 )
583 case WID_NAVORDER:
584 setNavigationOrder( aValue );
585 break;
586 case WID_PAGE_LEFT:
587 case WID_PAGE_RIGHT:
588 case WID_PAGE_TOP:
589 case WID_PAGE_BOTTOM:
590 case WID_PAGE_LAYOUT:
591 case WID_PAGE_DURATION:
592 case WID_PAGE_CHANGE:
594 sal_Int32 nValue = 0;
595 if(!(aValue >>= nValue))
596 throw lang::IllegalArgumentException();
598 switch( pEntry->nWID )
600 case WID_PAGE_LEFT:
601 SetLeftBorder(nValue);
602 break;
603 case WID_PAGE_RIGHT:
604 SetRightBorder( nValue );
605 break;
606 case WID_PAGE_TOP:
607 SetUpperBorder( nValue );
608 break;
609 case WID_PAGE_BOTTOM:
610 SetLowerBorder( nValue );
611 break;
612 case WID_PAGE_CHANGE:
613 GetPage()->SetPresChange( static_cast<PresChange>(nValue) );
614 break;
615 case WID_PAGE_LAYOUT:
616 GetPage()->SetAutoLayout( static_cast<AutoLayout>(nValue), true );
617 break;
618 case WID_PAGE_DURATION:
619 GetPage()->SetTime(nValue);
620 break;
622 break;
624 case WID_PAGE_HIGHRESDURATION:
626 double fValue = 0;
627 if(!(aValue >>= fValue))
628 throw lang::IllegalArgumentException();
630 GetPage()->SetTime(fValue);
631 break;
633 case WID_PAGE_WIDTH:
635 sal_Int32 nWidth = 0;
636 if(!(aValue >>= nWidth))
637 throw lang::IllegalArgumentException();
639 SetWidth( nWidth );
640 break;
642 case WID_PAGE_HEIGHT:
644 sal_Int32 nHeight = 0;
645 if(!(aValue >>= nHeight))
646 throw lang::IllegalArgumentException();
648 SetHeight( nHeight );
649 break;
651 case WID_PAGE_ORIENT:
653 sal_Int32 nEnum = 0;
654 if(!::cppu::enum2int( nEnum, aValue ))
655 throw lang::IllegalArgumentException();
657 Orientation eOri = (static_cast<view::PaperOrientation>(nEnum) == view::PaperOrientation_PORTRAIT)?Orientation::Portrait:Orientation::Landscape;
659 if( eOri != GetPage()->GetOrientation() )
661 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
662 const PageKind ePageKind = GetPage()->GetPageKind();
664 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
665 for (i = 0; i < nPageCnt; i++)
667 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
668 pPage->SetOrientation( eOri );
671 nPageCnt = rDoc.GetSdPageCount(ePageKind);
673 for (i = 0; i < nPageCnt; i++)
675 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
676 pPage->SetOrientation( eOri );
679 break;
681 case WID_PAGE_EFFECT:
683 sal_Int32 nEnum = 0;
684 if(!::cppu::enum2int( nEnum, aValue ))
685 throw lang::IllegalArgumentException();
687 GetPage()->SetFadeEffect( static_cast<presentation::FadeEffect>(nEnum) );
688 break;
690 case WID_PAGE_BACK:
691 setBackground( aValue );
692 break;
693 case WID_PAGE_SPEED:
695 sal_Int32 nEnum = 0;
696 if(!::cppu::enum2int( nEnum, aValue ))
697 throw lang::IllegalArgumentException();
699 GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 ) );
700 break;
702 case WID_PAGE_VISIBLE :
704 bool bVisible = false;
705 if( ! ( aValue >>= bVisible ) )
706 throw lang::IllegalArgumentException();
707 GetPage()->SetExcluded( !bVisible );
708 break;
710 case WID_PAGE_SOUNDFILE :
712 OUString aURL;
713 if( aValue >>= aURL )
715 GetPage()->SetSoundFile( aURL );
716 GetPage()->SetSound( !aURL.isEmpty() );
717 break;
719 else
721 bool bStopSound = false;
722 if( aValue >>= bStopSound )
724 GetPage()->SetStopSound( bStopSound );
725 break;
729 throw lang::IllegalArgumentException();
731 case WID_LOOP_SOUND:
733 bool bLoop = false;
734 if( ! (aValue >>= bLoop) )
735 throw lang::IllegalArgumentException();
737 GetPage()->SetLoopSound( bLoop );
738 break;
740 case WID_PAGE_BACKFULL:
742 bool bFullSize = false;
743 if( ! ( aValue >>= bFullSize ) )
744 throw lang::IllegalArgumentException();
745 GetPage()->SetBackgroundFullSize( bFullSize );
746 break;
748 case WID_PAGE_BACKVIS:
750 bool bVisible = false;
751 if( ! ( aValue >>= bVisible ) )
752 throw lang::IllegalArgumentException();
754 SdrPage* pPage = GetPage();
755 if( pPage )
757 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
758 if( rDoc.GetMasterPageCount() )
760 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
761 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
762 aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background), bVisible);
763 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
766 break;
768 case WID_PAGE_BACKOBJVIS:
770 bool bVisible = false;
771 if( ! ( aValue >>= bVisible ) )
772 throw lang::IllegalArgumentException();
774 SdrPage* pPage = GetPage();
775 if( pPage )
777 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
778 if( rDoc.GetMasterPageCount() )
780 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
781 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
782 aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects), bVisible);
783 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
787 break;
789 case WID_PAGE_USERATTRIBS:
791 if( !GetPage()->setAlienAttributes( aValue ) )
792 throw lang::IllegalArgumentException();
793 break;
795 case WID_PAGE_BOOKMARK:
797 OUString aBookmarkURL;
798 if( ! ( aValue >>= aBookmarkURL ) )
799 throw lang::IllegalArgumentException();
801 setBookmarkURL( aBookmarkURL );
802 break;
805 case WID_PAGE_HEADERVISIBLE:
806 case WID_PAGE_HEADERTEXT:
807 case WID_PAGE_FOOTERVISIBLE:
808 case WID_PAGE_FOOTERTEXT:
809 case WID_PAGE_PAGENUMBERVISIBLE:
810 case WID_PAGE_DATETIMEVISIBLE:
811 case WID_PAGE_DATETIMEFIXED:
812 case WID_PAGE_DATETIMETEXT:
813 case WID_PAGE_DATETIMEFORMAT:
815 sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() );
817 switch( pEntry->nWID )
819 case WID_PAGE_HEADERVISIBLE:
821 bool bVisible = false;
822 if( ! ( aValue >>= bVisible ) )
823 throw lang::IllegalArgumentException();
825 aHeaderFooterSettings.mbHeaderVisible = bVisible;
826 break;
828 case WID_PAGE_HEADERTEXT:
830 OUString aText;
831 if( ! ( aValue >>= aText ) )
832 throw lang::IllegalArgumentException();
834 aHeaderFooterSettings.maHeaderText = aText;
835 break;
837 case WID_PAGE_FOOTERVISIBLE:
839 bool bVisible = false;
840 if( ! ( aValue >>= bVisible ) )
841 throw lang::IllegalArgumentException();
843 aHeaderFooterSettings.mbFooterVisible = bVisible;
844 break;
846 case WID_PAGE_FOOTERTEXT:
848 OUString aText;
849 if( ! ( aValue >>= aText ) )
850 throw lang::IllegalArgumentException();
852 aHeaderFooterSettings.maFooterText = aText;
853 break;
855 case WID_PAGE_PAGENUMBERVISIBLE:
857 bool bVisible = false;
858 if( ! ( aValue >>= bVisible ) )
859 throw lang::IllegalArgumentException();
861 aHeaderFooterSettings.mbSlideNumberVisible = bVisible;
862 break;
864 case WID_PAGE_DATETIMEVISIBLE:
866 bool bVisible = false;
867 if( ! ( aValue >>= bVisible ) )
868 throw lang::IllegalArgumentException();
870 aHeaderFooterSettings.mbDateTimeVisible = bVisible;
871 break;
873 case WID_PAGE_DATETIMEFIXED:
875 bool bVisible = false;
876 if( ! ( aValue >>= bVisible ) )
877 throw lang::IllegalArgumentException();
879 aHeaderFooterSettings.mbDateTimeIsFixed = bVisible;
880 break;
882 case WID_PAGE_DATETIMETEXT:
884 OUString aText;
885 if( ! ( aValue >>= aText ) )
886 throw lang::IllegalArgumentException();
888 aHeaderFooterSettings.maDateTimeText = aText;
889 break;
891 case WID_PAGE_DATETIMEFORMAT:
893 sal_Int32 nValue = 0;
894 if( ! ( aValue >>= nValue ) )
895 throw lang::IllegalArgumentException();
897 aHeaderFooterSettings.meDateFormat = static_cast<SvxDateFormat>(nValue & 0x0f);
898 aHeaderFooterSettings.meTimeFormat = static_cast<SvxTimeFormat>((nValue >> 4) & 0x0f);
899 break;
903 if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) )
904 GetPage()->setHeaderFooterSettings( aHeaderFooterSettings );
906 break;
909 case WID_PAGE_NUMBER:
910 if( (GetPage()->GetPageKind() == PageKind::Handout) && !GetPage()->IsMasterPage() )
912 if( !(aValue >>= mnTempPageNumber) )
913 throw lang::IllegalArgumentException();
915 break;
917 throw beans::PropertyVetoException();
919 case WID_PAGE_LDBITMAP:
920 case WID_PAGE_LDNAME:
921 case WID_PAGE_ISDARK:
922 throw beans::PropertyVetoException();
924 case WID_TRANSITION_TYPE:
926 sal_Int16 nValue = 0;
927 if( ! ( aValue >>= nValue ) )
928 throw lang::IllegalArgumentException();
930 GetPage()->setTransitionType( nValue );
931 break;
934 case WID_TRANSITION_SUBTYPE:
936 sal_Int16 nValue = 0;
937 if( ! ( aValue >>= nValue ) )
938 throw lang::IllegalArgumentException();
940 GetPage()->setTransitionSubtype( nValue );
941 break;
944 case WID_TRANSITION_DIRECTION:
946 bool bValue = false;
947 if( ! ( aValue >>= bValue ) )
948 throw lang::IllegalArgumentException();
950 GetPage()->setTransitionDirection( bValue );
951 break;
954 case WID_TRANSITION_FADE_COLOR:
956 sal_Int32 nValue = 0;
957 if( ! ( aValue >>= nValue ) )
958 throw lang::IllegalArgumentException();
960 GetPage()->setTransitionFadeColor( nValue );
961 break;
964 case WID_TRANSITION_DURATION:
966 double fValue = 0.0;
967 if( ! ( aValue >>= fValue ) )
968 throw lang::IllegalArgumentException();
970 GetPage()->setTransitionDuration( fValue );
971 break;
974 default:
975 throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this));
978 GetModel()->SetModified();
981 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
983 ::SolarMutexGuard aGuard;
985 throwIfDisposed();
987 uno::Any aAny;
989 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
991 sal_Int16 nEntry = pEntry ? pEntry->nWID : -1;
992 switch (nEntry)
994 case WID_NAVORDER:
995 aAny = getNavigationOrder();
996 break;
997 case WID_PAGE_LEFT:
998 aAny <<= GetPage()->GetLeftBorder();
999 break;
1000 case WID_PAGE_RIGHT:
1001 aAny <<= GetPage()->GetRightBorder();
1002 break;
1003 case WID_PAGE_TOP:
1004 aAny <<= GetPage()->GetUpperBorder();
1005 break;
1006 case WID_PAGE_BOTTOM:
1007 aAny <<= GetPage()->GetLowerBorder();
1008 break;
1009 case WID_PAGE_WIDTH:
1010 aAny <<= static_cast<sal_Int32>( GetPage()->GetSize().getWidth() );
1011 break;
1012 case WID_PAGE_HEIGHT:
1013 aAny <<= static_cast<sal_Int32>( GetPage()->GetSize().getHeight() );
1014 break;
1015 case WID_PAGE_ORIENT:
1016 aAny <<=
1017 GetPage()->GetOrientation() == Orientation::Portrait
1018 ? view::PaperOrientation_PORTRAIT
1019 : view::PaperOrientation_LANDSCAPE;
1020 break;
1021 case WID_PAGE_EFFECT:
1022 aAny <<= GetPage()->GetFadeEffect();
1023 break;
1024 case WID_PAGE_CHANGE:
1025 aAny <<= static_cast<sal_Int32>( GetPage()->GetPresChange() );
1026 break;
1027 case WID_PAGE_SPEED:
1029 const double fDuration = GetPage()->getTransitionDuration();
1030 aAny <<= presentation::AnimationSpeed(
1031 fDuration < 2.0 ? 2 : fDuration > 2.0 ? 0 : 1);
1033 break;
1034 case WID_PAGE_LAYOUT:
1035 aAny <<= static_cast<sal_Int16>( GetPage()->GetAutoLayout() );
1036 break;
1037 case WID_PAGE_NUMBER:
1039 const sal_uInt16 nPageNumber(GetPage()->GetPageNum());
1041 if(nPageNumber > 0)
1043 // for all other pages calculate the number
1044 aAny <<= static_cast<sal_Int16>(static_cast<sal_uInt16>((nPageNumber-1)>>1) + 1);
1046 else
1048 aAny <<= mnTempPageNumber;
1051 break;
1052 case WID_PAGE_DURATION:
1053 aAny <<= static_cast<sal_Int32>( GetPage()->GetTime() + .5 );
1054 break;
1055 case WID_PAGE_HIGHRESDURATION:
1056 aAny <<= GetPage()->GetTime();
1057 break;
1058 case WID_PAGE_LDNAME:
1060 const OUString aName( GetPage()->GetName() );
1061 aAny <<= aName;
1062 break;
1064 case WID_PAGE_LDBITMAP:
1066 Reference< awt::XBitmap > xBitmap(VCLUnoHelper::CreateBitmap(BitmapEx(BMP_PAGE)));
1067 aAny <<= xBitmap;
1069 break;
1070 case WID_PAGE_BACK:
1071 getBackground( aAny );
1072 break;
1073 case WID_PAGE_PREVIEW :
1074 case WID_PAGE_PREVIEWMETAFILE :
1076 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1077 ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
1078 if ( pDocShell )
1080 sal_uInt16 nPgNum = 0;
1081 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
1082 sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1083 while( nPgNum < nPageCount )
1085 rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
1086 nPgNum++;
1088 std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
1089 if (xMetaFile)
1091 Size aSize( GetPage()->GetSize() );
1092 xMetaFile->AddAction( new MetaFillColorAction( COL_WHITE, true ), 0 );
1093 xMetaFile->AddAction( new MetaRectAction( ::tools::Rectangle( Point(), aSize ) ), 1 );
1094 xMetaFile->SetPrefMapMode(MapMode(MapUnit::Map100thMM));
1095 xMetaFile->SetPrefSize( aSize );
1097 SvMemoryStream aDestStrm( 65535, 65535 );
1098 if (nEntry == WID_PAGE_PREVIEW)
1099 // Preview: WMF format.
1100 ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
1101 else
1102 // PreviewMetafile: SVM format.
1103 xMetaFile->Write(aDestStrm);
1104 Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
1105 aAny <<= aSeq;
1109 break;
1111 case WID_PAGE_PREVIEWBITMAP :
1113 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1114 ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
1115 if ( pDocShell )
1117 sal_uInt16 nPgNum = 0;
1118 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
1119 sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1120 while( nPgNum < nPageCount )
1122 rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
1123 nPgNum++;
1125 std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
1126 BitmapEx aBitmap;
1127 if (xMetaFile && xMetaFile->CreateThumbnail(aBitmap))
1129 SvMemoryStream aMemStream;
1130 WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false);
1131 uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aMemStream.GetData()), aMemStream.Tell() );
1132 aAny <<= aSeq;
1136 break;
1138 case WID_PAGE_VISIBLE :
1140 bool bVisible = !GetPage()->IsExcluded();
1141 aAny <<= bVisible;
1142 break;
1145 case WID_PAGE_SOUNDFILE :
1147 if( GetPage()->IsStopSound() )
1149 aAny <<= true;
1151 else
1153 OUString aURL;
1154 if( GetPage()->IsSoundOn() )
1155 aURL = GetPage()->GetSoundFile();
1156 aAny <<= aURL;
1158 break;
1160 case WID_LOOP_SOUND:
1162 aAny <<= GetPage()->IsLoopSound();
1163 break;
1165 case WID_PAGE_BACKFULL:
1167 bool bFullSize = GetPage()->IsBackgroundFullSize();
1168 aAny <<= bFullSize;
1169 break;
1171 case WID_PAGE_BACKVIS:
1173 SdrPage* pPage = GetPage();
1174 if( pPage )
1176 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
1177 if( rDoc.GetMasterPageCount() )
1179 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
1180 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1181 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background));
1183 else
1185 aAny <<= false;
1188 break;
1190 case WID_PAGE_BACKOBJVIS:
1192 SdrPage* pPage = GetPage();
1193 if( pPage )
1195 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
1196 if( rDoc.GetMasterPageCount() )
1198 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
1199 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1200 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects));
1202 else
1204 aAny <<= false;
1207 break;
1209 case WID_PAGE_USERATTRIBS:
1211 GetPage()->getAlienAttributes( aAny );
1212 break;
1214 case WID_PAGE_BOOKMARK:
1216 aAny <<= getBookmarkURL();
1217 break;
1219 case WID_PAGE_ISDARK:
1221 aAny <<= GetPage()->GetPageBackgroundColor().IsDark();
1222 break;
1224 case WID_PAGE_HEADERVISIBLE:
1225 aAny <<= GetPage()->getHeaderFooterSettings().mbHeaderVisible;
1226 break;
1227 case WID_PAGE_HEADERTEXT:
1229 const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText );
1230 aAny <<= aText;
1232 break;
1233 case WID_PAGE_FOOTERVISIBLE:
1234 aAny <<= GetPage()->getHeaderFooterSettings().mbFooterVisible;
1235 break;
1236 case WID_PAGE_FOOTERTEXT:
1238 const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText );
1239 aAny <<= aText;
1241 break;
1242 case WID_PAGE_PAGENUMBERVISIBLE:
1243 aAny <<= GetPage()->getHeaderFooterSettings().mbSlideNumberVisible;
1244 break;
1245 case WID_PAGE_DATETIMEVISIBLE:
1246 aAny <<= GetPage()->getHeaderFooterSettings().mbDateTimeVisible;
1247 break;
1248 case WID_PAGE_DATETIMEFIXED:
1249 aAny <<= GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed;
1250 break;
1251 case WID_PAGE_DATETIMETEXT:
1253 const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText );
1254 aAny <<= aText;
1256 break;
1257 case WID_PAGE_DATETIMEFORMAT:
1259 auto const & rSettings = GetPage()->getHeaderFooterSettings();
1260 sal_Int32 x = static_cast<sal_Int32>(rSettings.meDateFormat) | (static_cast<sal_Int32>(rSettings.meTimeFormat) << 4);
1261 aAny <<= x;
1263 break;
1265 case WID_TRANSITION_TYPE:
1266 aAny <<= GetPage()->getTransitionType();
1267 break;
1269 case WID_TRANSITION_SUBTYPE:
1270 aAny <<= GetPage()->getTransitionSubtype();
1271 break;
1273 case WID_TRANSITION_DIRECTION:
1274 aAny <<= GetPage()->getTransitionDirection();
1275 break;
1277 case WID_TRANSITION_FADE_COLOR:
1278 aAny <<= GetPage()->getTransitionFadeColor();
1279 break;
1281 case WID_TRANSITION_DURATION:
1282 aAny <<= GetPage()->getTransitionDuration();
1283 break;
1285 default:
1286 throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
1288 return aAny;
1291 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {}
1292 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {}
1293 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {}
1294 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {}
1296 // XMultiPropertySet
1297 void SAL_CALL SdGenericDrawPage::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
1299 if( aPropertyNames.getLength() != aValues.getLength() )
1300 throw lang::IllegalArgumentException();
1302 const OUString* pNames = aPropertyNames.getConstArray();
1303 const Any* pValues = aValues.getConstArray();
1304 sal_uInt32 nCount = aValues.getLength();
1305 while( nCount-- )
1309 setPropertyValue( *pNames++, *pValues++ );
1311 catch( beans::UnknownPropertyException& )
1313 // ignore for multi property set
1314 // todo: optimize this!
1319 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames )
1321 sal_Int32 nCount = aPropertyNames.getLength();
1322 Sequence< Any > aValues( nCount );
1323 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.begin(),
1324 [this](const OUString& rName) -> Any {
1325 Any aValue;
1328 aValue = getPropertyValue(rName);
1330 catch( beans::UnknownPropertyException& )
1332 // ignore for multi property set
1333 // todo: optimize this!
1335 return aValue;
1337 return aValues;
1340 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& )
1344 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& )
1348 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& )
1352 Reference< drawing::XShape > SdGenericDrawPage::CreateShape(SdrObject *pObj) const
1354 DBG_ASSERT( GetPage(), "SdGenericDrawPage::CreateShape(), can't create shape for disposed page!" );
1355 DBG_ASSERT( pObj, "SdGenericDrawPage::CreateShape(), invalid call with pObj == 0!" );
1357 if (!pObj)
1358 return Reference< drawing::XShape >();
1360 if (GetPage())
1362 PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
1364 SvxShape* pShape = nullptr;
1366 if(pObj->GetObjInventor() == SdrInventor::Default)
1368 sal_uInt32 nInventor = pObj->GetObjIdentifier();
1369 switch( nInventor )
1371 case OBJ_TITLETEXT:
1372 pShape = new SvxShapeText( pObj );
1373 if( GetPage()->GetPageKind() == PageKind::Notes && GetPage()->IsMasterPage() )
1375 // fake an empty PageShape if it's a title shape on the master page
1376 pShape->SetShapeType("com.sun.star.presentation.PageShape");
1378 else
1380 pShape->SetShapeType("com.sun.star.presentation.TitleTextShape");
1382 eKind = PRESOBJ_NONE;
1383 break;
1384 case OBJ_OUTLINETEXT:
1385 pShape = new SvxShapeText( pObj );
1386 pShape->SetShapeType("com.sun.star.presentation.OutlinerShape");
1387 eKind = PRESOBJ_NONE;
1388 break;
1392 Reference< drawing::XShape > xShape( pShape );
1394 if(!xShape.is())
1395 xShape = SvxFmDrawPage::CreateShape( pObj );
1397 if( eKind != PRESOBJ_NONE )
1399 OUString aShapeType("com.sun.star.presentation.");
1401 switch( eKind )
1403 case PRESOBJ_TITLE:
1404 aShapeType += "TitleTextShape";
1405 break;
1406 case PRESOBJ_OUTLINE:
1407 aShapeType += "OutlinerShape";
1408 break;
1409 case PRESOBJ_TEXT:
1410 aShapeType += "SubtitleShape";
1411 break;
1412 case PRESOBJ_GRAPHIC:
1413 aShapeType += "GraphicObjectShape";
1414 break;
1415 case PRESOBJ_OBJECT:
1416 aShapeType += "OLE2Shape";
1417 break;
1418 case PRESOBJ_CHART:
1419 aShapeType += "ChartShape";
1420 break;
1421 case PRESOBJ_ORGCHART:
1422 aShapeType += "OrgChartShape";
1423 break;
1424 case PRESOBJ_CALC:
1425 aShapeType += "CalcShape";
1426 break;
1427 case PRESOBJ_TABLE:
1428 aShapeType += "TableShape";
1429 break;
1430 case PRESOBJ_MEDIA:
1431 aShapeType += "MediaShape";
1432 break;
1433 case PRESOBJ_PAGE:
1434 aShapeType += "PageShape";
1435 break;
1436 case PRESOBJ_HANDOUT:
1437 aShapeType += "HandoutShape";
1438 break;
1439 case PRESOBJ_NOTES:
1440 aShapeType += "NotesShape";
1441 break;
1442 case PRESOBJ_FOOTER:
1443 aShapeType += "FooterShape";
1444 break;
1445 case PRESOBJ_HEADER:
1446 aShapeType += "HeaderShape";
1447 break;
1448 case PRESOBJ_SLIDENUMBER:
1449 aShapeType += "SlideNumberShape";
1450 break;
1451 case PRESOBJ_DATETIME:
1452 aShapeType += "DateTimeShape";
1453 break;
1454 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
1455 case PRESOBJ_NONE:
1456 case PRESOBJ_MAX:
1457 break;
1460 if( !pShape )
1461 pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
1463 if( pShape )
1464 pShape->SetShapeType( aShapeType );
1467 SvxShape *pSdShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShape);
1468 if (pSdShape)
1470 // SdXShape aggregates SvxShape
1471 new SdXShape(pSdShape, GetModel());
1473 return xShape;
1475 else
1477 return SvxFmDrawPage::CreateShape( pObj );
1482 // XServiceInfo
1483 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames()
1485 Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() );
1486 comphelper::ServiceInfoHelper::addToSequence( aSeq, {"com.sun.star.drawing.GenericDrawPage",
1487 "com.sun.star.document.LinkTarget",
1488 "com.sun.star.document.LinkTargetSupplier"});
1489 return aSeq;
1492 // XLinkTargetSupplier
1493 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( )
1495 return new SdPageLinkTargets( this );
1498 void SdGenericDrawPage::setBackground( const Any& )
1500 OSL_FAIL( "Don't call me, I'm useless!" );
1503 void SdGenericDrawPage::getBackground( Any& )
1505 OSL_FAIL( "Don't call me, I'm useless!" );
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( '#' );
1519 aRet.append( aBookmarkName );
1523 return aRet.makeStringAndClear();
1526 void SdGenericDrawPage::setBookmarkURL( OUString const & rURL )
1528 if( !SvxFmDrawPage::mpPage )
1529 return;
1531 sal_Int32 nIndex = rURL.indexOf( '#' );
1532 if( nIndex == -1 )
1533 return;
1535 const OUString aFileName( rURL.copy( 0, nIndex ) );
1536 const OUString aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 ) ) );
1538 if( !aFileName.isEmpty() && !aBookmarkName.isEmpty() )
1540 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->DisconnectLink();
1541 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetFileName( aFileName );
1542 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetBookmarkName( aBookmarkName );
1543 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->ConnectLink();
1547 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes )
1549 ::SolarMutexGuard aGuard;
1551 throwIfDisposed();
1553 DBG_ASSERT(SvxFmDrawPage::mpPage,"SdrPage is NULL! [CL]");
1554 DBG_ASSERT(mpView, "SdrView is NULL! [CL]");
1556 Reference< drawing::XShape > xShape;
1557 if(mpView==nullptr||!xShapes.is()||GetPage()==nullptr)
1558 return xShape;
1560 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1562 SelectObjectsInView( xShapes, pPageView );
1564 mpView->CombineMarkedObjects( false );
1566 mpView->AdjustMarkHdl();
1567 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1568 if( rMarkList.GetMarkCount() == 1 )
1570 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1571 if( pObj )
1572 xShape.set( pObj->getUnoShape(), UNO_QUERY );
1575 mpView->HideSdrPage();
1577 GetModel()->SetModified();
1579 return xShape;
1582 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup )
1584 ::SolarMutexGuard aGuard;
1586 throwIfDisposed();
1588 if(mpView==nullptr||!xGroup.is()||GetPage()==nullptr)
1589 return;
1591 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1592 SelectObjectInView( xGroup, pPageView );
1593 mpView->DismantleMarkedObjects();
1594 mpView->HideSdrPage();
1596 GetModel()->SetModified();
1599 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes )
1601 ::SolarMutexGuard aGuard;
1603 throwIfDisposed();
1605 uno::Reference< drawing::XShape > xShape;
1606 if(mpView==nullptr||!xShapes.is()||GetPage()==nullptr)
1607 return xShape;
1609 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1611 SelectObjectsInView( xShapes, pPageView );
1613 mpView->CombineMarkedObjects();
1615 mpView->AdjustMarkHdl();
1616 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1617 if( rMarkList.GetMarkCount() == 1 )
1619 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1620 if( pObj )
1621 xShape.set( pObj->getUnoShape(), UNO_QUERY );
1624 mpView->HideSdrPage();
1626 GetModel()->SetModified();
1628 return xShape;
1631 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape )
1633 ::SolarMutexGuard aGuard;
1635 throwIfDisposed();
1637 if(mpView==nullptr||!xShape.is()||GetPage()==nullptr)
1638 return;
1640 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1641 SelectObjectInView( xShape, pPageView );
1642 mpView->DismantleMarkedObjects( true );
1643 mpView->HideSdrPage();
1645 GetModel()->SetModified();
1648 void SdGenericDrawPage::SetLeftBorder( sal_Int32 nValue )
1650 if( nValue == GetPage()->GetLeftBorder() )
1651 return;
1653 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1654 const PageKind ePageKind = GetPage()->GetPageKind();
1656 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1657 for (i = 0; i < nPageCnt; i++)
1659 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1660 pPage->SetLeftBorder( nValue );
1663 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1665 for (i = 0; i < nPageCnt; i++)
1667 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1668 pPage->SetLeftBorder( nValue );
1672 void SdGenericDrawPage::SetRightBorder( sal_Int32 nValue )
1674 if( nValue == GetPage()->GetRightBorder() )
1675 return;
1677 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1678 const PageKind ePageKind = GetPage()->GetPageKind();
1680 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1681 for (i = 0; i < nPageCnt; i++)
1683 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1684 pPage->SetRightBorder( nValue );
1687 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1689 for (i = 0; i < nPageCnt; i++)
1691 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1692 pPage->SetRightBorder( nValue );
1696 void SdGenericDrawPage::SetUpperBorder( sal_Int32 nValue )
1698 if( nValue == GetPage()->GetUpperBorder() )
1699 return;
1701 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1702 const PageKind ePageKind = GetPage()->GetPageKind();
1704 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1705 for (i = 0; i < nPageCnt; i++)
1707 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1708 pPage->SetUpperBorder( nValue );
1711 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1713 for (i = 0; i < nPageCnt; i++)
1715 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1716 pPage->SetUpperBorder( nValue );
1720 void SdGenericDrawPage::SetLowerBorder( sal_Int32 nValue )
1722 if( nValue == GetPage()->GetLowerBorder() )
1723 return;
1725 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1726 const PageKind ePageKind = GetPage()->GetPageKind();
1728 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1729 for (i = 0; i < nPageCnt; i++)
1731 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1732 pPage->SetLowerBorder( nValue );
1735 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1737 for (i = 0; i < nPageCnt; i++)
1739 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1740 pPage->SetLowerBorder( nValue );
1744 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind )
1746 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1747 if ( !pDocShell )
1748 return;
1750 ::sd::ViewShell* pViewSh = pDocShell->GetViewShell();
1752 if( !pViewSh )
1753 return;
1755 if( dynamic_cast<const ::sd::DrawViewShell* >(pViewSh) != nullptr )
1756 static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage();
1758 Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
1759 const long nWidth = aPageSize.Width();
1760 const long nHeight = aPageSize.Height();
1762 Point aPageOrg(nWidth, nHeight / 2);
1763 Size aViewSize(nWidth * 3, nHeight * 2);
1765 pDoc->SetMaxObjSize(aViewSize);
1767 pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), true);
1769 pViewSh->UpdateScrollBars();
1772 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth )
1774 Size aSize( GetPage()->GetSize() );
1775 if( aSize.getWidth() == nWidth )
1776 return;
1778 aSize.setWidth( nWidth );
1780 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1781 const PageKind ePageKind = GetPage()->GetPageKind();
1783 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1784 for (i = 0; i < nPageCnt; i++)
1786 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1787 pPage->SetSize(aSize);
1790 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1792 for (i = 0; i < nPageCnt; i++)
1794 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1795 pPage->SetSize(aSize);
1798 refreshpage( &rDoc, ePageKind );
1801 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight )
1803 Size aSize( GetPage()->GetSize() );
1804 if( aSize.getHeight() == nHeight )
1805 return;
1807 aSize.setHeight( nHeight );
1809 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1810 const PageKind ePageKind = GetPage()->GetPageKind();
1812 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1813 for (i = 0; i < nPageCnt; i++)
1815 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1816 pPage->SetSize(aSize);
1819 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1821 for (i = 0; i < nPageCnt; i++)
1823 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1824 pPage->SetSize(aSize);
1827 refreshpage( &rDoc, ePageKind );
1830 // XInterface
1831 void SdGenericDrawPage::release() throw()
1834 OWeakAggObject::release();
1837 // XComponent
1838 void SdGenericDrawPage::disposing() throw()
1840 mpDocModel = nullptr;
1841 SvxFmDrawPage::disposing();
1844 // XAnimationNodeSupplier
1845 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode()
1847 ::SolarMutexGuard aGuard;
1849 throwIfDisposed();
1851 SdPage *pSdPage = static_cast<SdPage*>(SvxFmDrawPage::mpPage);
1853 return pSdPage->getAnimationNode();
1856 // SdPageLinkTargets
1857 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw()
1859 mxPage = pUnoPage;
1860 mpUnoPage = pUnoPage;
1863 SdPageLinkTargets::~SdPageLinkTargets() throw()
1867 // XElementAccess
1868 uno::Type SAL_CALL SdPageLinkTargets::getElementType()
1870 return cppu::UnoType<beans::XPropertySet>::get();
1873 sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
1875 ::SolarMutexGuard aGuard;
1877 SdPage* pPage = mpUnoPage->GetPage();
1878 if( pPage != nullptr )
1880 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1882 while( aIter.IsMore() )
1884 SdrObject* pObj = aIter.Next();
1885 OUString aStr( pObj->GetName() );
1886 if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != nullptr )
1887 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1888 if( !aStr.isEmpty() )
1889 return true;
1893 return false;
1896 // container::XNameAccess
1898 // XNameAccess
1899 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName )
1901 ::SolarMutexGuard aGuard;
1903 SdPage* pPage = mpUnoPage->GetPage();
1904 if( pPage != nullptr )
1906 SdrObject* pObj = FindObject( aName );
1907 if( pObj )
1909 Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY );
1910 return makeAny( aRef );
1914 throw container::NoSuchElementException();
1917 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames()
1919 ::SolarMutexGuard aGuard;
1921 sal_uInt32 nObjCount = 0;
1923 SdPage* pPage = mpUnoPage->GetPage();
1924 if( pPage != nullptr )
1926 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1927 while( aIter.IsMore() )
1929 SdrObject* pObj = aIter.Next();
1930 OUString aStr( pObj->GetName() );
1931 if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != nullptr )
1932 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1933 if( !aStr.isEmpty() )
1934 nObjCount++;
1938 Sequence< OUString > aSeq( nObjCount );
1939 if( nObjCount > 0 )
1941 OUString* pStr = aSeq.getArray();
1943 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1944 while( aIter.IsMore() )
1946 SdrObject* pObj = aIter.Next();
1947 OUString aStr( pObj->GetName() );
1948 if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != nullptr )
1949 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1950 if( !aStr.isEmpty() )
1951 *pStr++ = aStr;
1955 return aSeq;
1958 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName )
1960 ::SolarMutexGuard aGuard;
1962 return FindObject( aName ) != nullptr;
1965 SdrObject* SdPageLinkTargets::FindObject( const OUString& rName ) const throw()
1967 SdPage* pPage = mpUnoPage->GetPage();
1968 if( pPage == nullptr )
1969 return nullptr;
1971 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1973 while( aIter.IsMore() )
1975 SdrObject* pObj = aIter.Next();
1976 OUString aStr( pObj->GetName() );
1977 if( aStr.isEmpty() && dynamic_cast< const SdrOle2Obj *>( pObj ) != nullptr )
1978 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName();
1979 if( !aStr.isEmpty() && (aStr == rName) )
1980 return pObj;
1983 return nullptr;
1986 // XServiceInfo
1987 OUString SAL_CALL SdPageLinkTargets::getImplementationName()
1989 return "SdPageLinkTargets";
1992 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName )
1994 return cppu::supportsService( this, ServiceName );
1997 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames()
1999 Sequence< OUString > aSeq { "com.sun.star.document.LinkTargets" };
2000 return aSeq;
2003 // SdDrawPage
2004 SdDrawPage::SdDrawPage(SdXImpressDocument* pModel, SdPage* pPage)
2005 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) )
2009 SdDrawPage::~SdDrawPage() throw()
2013 // XInterface
2014 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType )
2016 if( rType == cppu::UnoType<drawing::XMasterPageTarget>::get() )
2018 return makeAny( Reference< drawing::XMasterPageTarget >( this ) );
2020 else if( IsImpressDocument()
2021 && rType == cppu::UnoType<presentation::XPresentationPage>::get() )
2023 SdPage * p = dynamic_cast<SdPage *>(SvxDrawPage::mpPage);
2024 if( p == nullptr || p->GetPageKind() != PageKind::Handout )
2026 return makeAny( Reference< presentation::XPresentationPage >( this ) );
2030 return SdGenericDrawPage::queryInterface( rType );
2033 void SAL_CALL SdDrawPage::acquire() throw()
2035 SvxDrawPage::acquire();
2038 void SAL_CALL SdDrawPage::release() throw()
2040 SvxDrawPage::release();
2043 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage );
2045 // XTypeProvider
2046 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes()
2048 ::SolarMutexGuard aGuard;
2050 throwIfDisposed();
2052 if( !maTypeSequence.hasElements() )
2054 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
2055 bool bPresPage = IsImpressDocument() && ePageKind != PageKind::Handout;
2057 // Collect the types of this class.
2058 ::std::vector<uno::Type> aTypes;
2059 aTypes.reserve(13);
2060 aTypes.push_back(cppu::UnoType<drawing::XDrawPage>::get());
2061 aTypes.push_back(cppu::UnoType<beans::XPropertySet>::get());
2062 aTypes.push_back(cppu::UnoType<container::XNamed>::get());
2063 aTypes.push_back(cppu::UnoType<drawing::XMasterPageTarget>::get());
2064 aTypes.push_back(cppu::UnoType<lang::XServiceInfo>::get());
2065 aTypes.push_back(cppu::UnoType<util::XReplaceable>::get());
2066 aTypes.push_back(cppu::UnoType<document::XLinkTargetSupplier>::get());
2067 aTypes.push_back(cppu::UnoType<drawing::XShapeCombiner>::get());
2068 aTypes.push_back(cppu::UnoType<drawing::XShapeBinder>::get());
2069 aTypes.push_back(cppu::UnoType<office::XAnnotationAccess>::get());
2070 aTypes.push_back(cppu::UnoType<beans::XMultiPropertySet>::get());
2071 if( bPresPage )
2072 aTypes.push_back(cppu::UnoType<presentation::XPresentationPage>::get());
2073 if( bPresPage && ePageKind == PageKind::Standard )
2074 aTypes.push_back(cppu::UnoType<XAnimationNodeSupplier>::get());
2076 // Get types of base class.
2077 // Join those types in a sequence.
2078 return comphelper::concatSequences(
2079 comphelper::containerToSequence(aTypes),
2080 SdGenericDrawPage::getTypes() );
2083 return maTypeSequence;
2086 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId()
2088 return css::uno::Sequence<sal_Int8>();
2091 OUString SdDrawPage::getPageApiName( SdPage const * pPage )
2093 return ::getPageApiName( pPage );
2096 OUString getPageApiName( SdPage const * pPage )
2098 OUString aPageName;
2100 if(pPage)
2102 aPageName = pPage->GetRealName();
2104 if( aPageName.isEmpty() )
2106 const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
2107 aPageName = sEmptyPageName + OUString::number( nPageNum );
2111 return aPageName;
2114 OUString getPageApiNameFromUiName( const OUString& rUIName )
2116 OUString aApiName;
2118 OUString aDefPageName(SdResId(STR_PAGE) + " ");
2120 if( rUIName.startsWith( aDefPageName ) )
2122 aApiName = sEmptyPageName + rUIName.copy( aDefPageName.getLength() );
2124 else
2126 aApiName = rUIName;
2129 return aApiName;
2132 OUString SdDrawPage::getPageApiNameFromUiName( const OUString& rUIName )
2134 return ::getPageApiNameFromUiName( rUIName );
2137 OUString getUiNameFromPageApiNameImpl( const OUString& rApiName )
2139 const OUString aDefPageName( sEmptyPageName );
2140 if( rApiName.startsWith( aDefPageName ) )
2142 OUString aNumber( rApiName.copy( aDefPageName.getLength() ) );
2144 // create the page number
2145 sal_Int32 nPageNumber = aNumber.toInt32();
2147 // check if there are non number characters in the number part
2148 const sal_Int32 nChars = aNumber.getLength();
2149 const sal_Unicode* pString = aNumber.getStr();
2150 sal_Int32 nChar;
2151 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2153 if((*pString < '0') || (*pString > '9'))
2155 // found a non number character, so this is not the default
2156 // name for this page
2157 nPageNumber = -1;
2158 break;
2162 if( nPageNumber != -1)
2164 return SdResId(STR_PAGE) + " " + aNumber;
2168 return rApiName;
2171 OUString SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName )
2173 return getUiNameFromPageApiNameImpl( rApiName );
2176 // XServiceInfo
2177 OUString SAL_CALL SdDrawPage::getImplementationName()
2179 return "SdDrawPage";
2182 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames()
2184 ::SolarMutexGuard aGuard;
2186 throwIfDisposed();
2188 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2189 comphelper::ServiceInfoHelper::addToSequence( aSeq, {"com.sun.star.drawing.DrawPage"} );
2191 if( IsImpressDocument() )
2192 comphelper::ServiceInfoHelper::addToSequence( aSeq, {"com.sun.star.presentation.DrawPage"} );
2194 return aSeq;
2197 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName )
2199 return cppu::supportsService( this, ServiceName );
2202 // XNamed
2203 void SAL_CALL SdDrawPage::setName( const OUString& rName )
2205 ::SolarMutexGuard aGuard;
2207 throwIfDisposed();
2209 DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" );
2211 OUString aName( rName );
2213 if(!(GetPage() && GetPage()->GetPageKind() != PageKind::Notes))
2214 return;
2216 // check if this is the default 'page1234' name
2217 if(aName.startsWith( sEmptyPageName ))
2219 // ok, it maybe is, first get the number part after 'page'
2220 OUString aNumber( aName.copy( sizeof( sEmptyPageName ) - 1 ) );
2222 // create the page number
2223 sal_Int32 nPageNumber = aNumber.toInt32();
2225 // check if there are non number characters in the number part
2226 const sal_Int32 nChars = aNumber.getLength();
2227 const sal_Unicode* pString = aNumber.getStr();
2228 sal_Int32 nChar;
2229 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2231 if((*pString < '0') || (*pString > '9'))
2233 // found a non number character, so this is not the default
2234 // name for this page
2235 nPageNumber = -1;
2236 break;
2240 if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 )
2241 aName.clear();
2243 else
2245 OUString aDefaultPageName( SdResId(STR_PAGE) + " " );
2246 if( aName.startsWith( aDefaultPageName ) )
2247 aName.clear();
2250 GetPage()->SetName( aName );
2252 sal_uInt16 nNotesPageNum = (GetPage()->GetPageNum()-1)>>1;
2253 if( GetModel()->GetDoc()->GetSdPageCount( PageKind::Notes ) > nNotesPageNum )
2255 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PageKind::Notes );
2256 if( pNotesPage )
2257 pNotesPage->SetName(aName);
2260 // fake a mode change to repaint the page tab bar
2261 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2262 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
2263 if( auto pDrawViewSh = dynamic_cast<::sd::DrawViewShell* >(pViewSh) )
2265 EditMode eMode = pDrawViewSh->GetEditMode();
2266 if( eMode == EditMode::Page )
2268 bool bLayer = pDrawViewSh->IsLayerModeActive();
2270 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2271 pDrawViewSh->ChangeEditMode( eMode, bLayer );
2275 GetModel()->SetModified();
2278 OUString SAL_CALL SdDrawPage::getName()
2280 ::SolarMutexGuard aGuard;
2282 throwIfDisposed();
2284 return getPageApiName( GetPage() );
2287 // XMasterPageTarget
2288 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( )
2290 ::SolarMutexGuard aGuard;
2292 throwIfDisposed();
2294 if(GetPage())
2296 Reference< drawing::XDrawPage > xPage;
2298 if(SvxFmDrawPage::mpPage->TRG_HasMasterPage())
2300 SdrPage& rMasterPage = SvxFmDrawPage::mpPage->TRG_GetMasterPage();
2301 xPage.set( rMasterPage.getUnoPage(), uno::UNO_QUERY );
2304 return xPage;
2306 return nullptr;
2309 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage )
2311 ::SolarMutexGuard aGuard;
2312 comphelper::ProfileZone aZone("setMasterPage");
2314 throwIfDisposed();
2316 if(!SvxFmDrawPage::mpPage)
2317 return;
2319 SdMasterPage* pMasterPage = comphelper::getUnoTunnelImplementation<SdMasterPage>( xMasterPage );
2320 if( !(pMasterPage && pMasterPage->isValid()) )
2321 return;
2323 SvxFmDrawPage::mpPage->TRG_ClearMasterPage();
2325 SdPage* pSdPage = static_cast<SdPage*>(pMasterPage->GetSdrPage());
2326 SvxFmDrawPage::mpPage->TRG_SetMasterPage(*pSdPage);
2328 SvxFmDrawPage::mpPage->SetBorder(pSdPage->GetLeftBorder(),pSdPage->GetUpperBorder(),
2329 pSdPage->GetRightBorder(),pSdPage->GetLowerBorder() );
2331 SvxFmDrawPage::mpPage->SetSize( pSdPage->GetSize() );
2332 SvxFmDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() );
2333 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetLayoutName( pSdPage->GetLayoutName() );
2335 // set notes master also
2336 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
2338 pNotesPage->TRG_ClearMasterPage();
2339 sal_uInt16 nNum = SvxFmDrawPage::mpPage->TRG_GetMasterPage().GetPageNum() + 1;
2340 pNotesPage->TRG_SetMasterPage(*SvxFmDrawPage::mpPage->getSdrModelFromSdrPage().GetMasterPage(nNum));
2341 pNotesPage->SetLayoutName( pSdPage->GetLayoutName() );
2343 GetModel()->SetModified();
2346 // XPresentationPage
2347 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage()
2349 ::SolarMutexGuard aGuard;
2351 throwIfDisposed();
2353 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() && SvxFmDrawPage::mpPage->GetPageNum() )
2355 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
2356 if( pNotesPage )
2358 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2359 return xPage;
2362 return nullptr;
2365 // XIndexAccess
2366 sal_Int32 SAL_CALL SdDrawPage::getCount()
2368 return SdGenericDrawPage::getCount();
2371 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index )
2373 return SdGenericDrawPage::getByIndex( Index );
2376 // XElementAccess
2377 uno::Type SAL_CALL SdDrawPage::getElementType()
2379 return SdGenericDrawPage::getElementType();
2382 sal_Bool SAL_CALL SdDrawPage::hasElements()
2384 return SdGenericDrawPage::hasElements();
2387 // XShapes
2388 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape )
2390 SdGenericDrawPage::add( xShape );
2393 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape )
2395 ::SolarMutexGuard aGuard;
2397 throwIfDisposed();
2399 SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
2400 if( pShape )
2402 SdrObject* pObj = pShape->GetSdrObject();
2403 if( pObj )
2405 GetPage()->RemovePresObj(pObj);
2406 pObj->SetUserCall(nullptr);
2410 SdGenericDrawPage::remove( xShape );
2413 void SdDrawPage::setBackground( const Any& rValue )
2415 Reference< beans::XPropertySet > xSet;
2417 if( !(rValue >>= xSet) && !rValue.hasValue() )
2418 throw lang::IllegalArgumentException();
2420 if( !xSet.is() )
2422 // the easy case, no background set. Set drawing::FillStyle_NONE to represent this
2423 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
2424 return;
2427 // is it our own implementation?
2428 SdUnoPageBackground* pBack = comphelper::getUnoTunnelImplementation<SdUnoPageBackground>( xSet );
2430 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{} );
2432 if( pBack )
2434 pBack->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2436 else
2438 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2440 Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2441 Reference< beans::XPropertySet > xDestSet( static_cast<beans::XPropertySet*>(pBackground) );
2442 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() );
2444 const Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
2446 for( const beans::Property& rProp : aProperties )
2448 const OUString aPropName( rProp.Name );
2449 if( xSetInfo->hasPropertyByName( aPropName ) )
2450 xDestSet->setPropertyValue( aPropName,
2451 xSet->getPropertyValue( aPropName ) );
2454 pBackground->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2457 if( aSet.Count() == 0 )
2459 // no background fill, represent by setting drawing::FillStyle_NONE
2460 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
2462 else
2464 // background fill, set at page (not sure if ClearItem is needed)
2465 GetPage()->getSdrPageProperties().ClearItem();
2466 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2469 // repaint only
2470 SvxFmDrawPage::mpPage->ActionChanged();
2473 // XAnnotationAccess:
2474 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation()
2476 if( !GetPage() )
2477 throw DisposedException();
2479 Reference< XAnnotation > xRet;
2480 GetPage()->createAnnotation(xRet);
2481 return xRet;
2484 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation)
2486 GetPage()->removeAnnotation(annotation);
2489 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration()
2491 return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() );
2494 void SdDrawPage::getBackground(Any& rValue)
2496 const SfxItemSet& rFillAttributes = GetPage()->getSdrPageProperties().GetItemSet();
2498 if(drawing::FillStyle_NONE == rFillAttributes.Get(XATTR_FILLSTYLE).GetValue())
2500 // no fill set (switched off by drawing::FillStyle_NONE), clear rValue to represent this
2501 rValue.clear();
2503 else
2505 // there is a fill set, export to rValue
2506 Reference< beans::XPropertySet > xSet(new SdUnoPageBackground(
2507 GetModel()->GetDoc(),
2508 &GetPage()->getSdrPageProperties().GetItemSet()));
2509 rValue <<= xSet;
2513 void SdGenericDrawPage::setNavigationOrder( const Any& rValue )
2515 Reference< XIndexAccess > xIA( rValue, UNO_QUERY );
2516 if( xIA.is() )
2518 if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this )
2520 if( GetPage()->HasObjectNavigationOrder() )
2521 GetPage()->ClearObjectNavigationOrder();
2523 return;
2525 else if( static_cast<size_t>(xIA->getCount()) == GetPage()->GetObjCount() )
2527 GetPage()->SetNavigationOrder(xIA);
2528 return;
2531 throw IllegalArgumentException();
2534 class SdNavigationOrderAccess : public ::cppu::WeakImplHelper< XIndexAccess >
2536 public:
2537 explicit SdNavigationOrderAccess(SdrPage const * pPage);
2539 // XIndexAccess
2540 virtual sal_Int32 SAL_CALL getCount( ) override;
2541 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) override;
2543 // XElementAccess
2544 virtual Type SAL_CALL getElementType( ) override;
2545 virtual sal_Bool SAL_CALL hasElements( ) override;
2547 private:
2548 std::vector< Reference< XShape > > maShapes;
2551 SdNavigationOrderAccess::SdNavigationOrderAccess( SdrPage const * pPage )
2552 : maShapes( pPage ? pPage->GetObjCount() : 0 )
2554 if( pPage )
2556 const size_t nCount = pPage->GetObjCount();
2557 for( size_t nIndex = 0; nIndex < nCount; ++nIndex )
2559 SdrObject* pObj = pPage->GetObj( nIndex );
2560 sal_uInt32 nNavPos = pObj->GetNavigationPosition();
2561 DBG_ASSERT( !maShapes[nNavPos].is(), "sd::SdNavigationOrderAccess::SdNavigationOrderAccess(), duplicate navigation positions from core!" );
2562 maShapes[nNavPos].set( pObj->getUnoShape(), UNO_QUERY );
2567 // XIndexAccess
2568 sal_Int32 SAL_CALL SdNavigationOrderAccess::getCount( )
2570 return static_cast< sal_Int32 >( maShapes.size() );
2573 Any SAL_CALL SdNavigationOrderAccess::getByIndex( sal_Int32 Index )
2575 if( (Index < 0) || (Index > getCount()) )
2576 throw IndexOutOfBoundsException();
2578 return Any( maShapes[Index] );
2581 // XElementAccess
2582 Type SAL_CALL SdNavigationOrderAccess::getElementType( )
2584 return cppu::UnoType<XShape>::get();
2587 sal_Bool SAL_CALL SdNavigationOrderAccess::hasElements( )
2589 return !maShapes.empty();
2592 Any SdGenericDrawPage::getNavigationOrder()
2594 if( GetPage()->HasObjectNavigationOrder() )
2596 return Any( Reference< XIndexAccess >( new SdNavigationOrderAccess( GetPage() ) ) );
2598 else
2600 return Any( Reference< XIndexAccess >( this ) );
2604 // class SdMasterPage
2605 SdMasterPage::SdMasterPage(SdXImpressDocument* pModel, SdPage* pPage)
2606 : SdGenericDrawPage(pModel, pPage, ImplGetMasterPagePropertySet(pPage->GetPageKind()))
2610 SdMasterPage::~SdMasterPage() throw()
2614 // XInterface
2615 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType )
2617 ::SolarMutexGuard aGuard;
2619 throwIfDisposed();
2621 uno::Any aAny;
2623 if( rType == cppu::UnoType<container::XIndexAccess>::get() )
2624 aAny <<= Reference< container::XIndexAccess >(static_cast<presentation::XPresentationPage*>(this));
2625 else if( rType == cppu::UnoType<container::XElementAccess>::get() )
2626 aAny <<= Reference< container::XElementAccess >(static_cast<presentation::XPresentationPage*>(this));
2627 else if( rType == cppu::UnoType<container::XNamed>::get() )
2628 aAny <<= Reference< container::XNamed >(this);
2629 else if( rType == cppu::UnoType<presentation::XPresentationPage>::get() &&
2630 ( IsImpressDocument() &&
2631 GetPage() && GetPage()->GetPageKind() != PageKind::Handout) )
2632 aAny <<= Reference< presentation::XPresentationPage >( this );
2633 else
2634 return SdGenericDrawPage::queryInterface( rType );
2636 return aAny;
2639 void SAL_CALL SdMasterPage::acquire() throw()
2641 SvxDrawPage::acquire();
2644 void SAL_CALL SdMasterPage::release() throw()
2646 SvxDrawPage::release();
2649 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage );
2651 // XTypeProvider
2652 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes()
2654 ::SolarMutexGuard aGuard;
2656 throwIfDisposed();
2658 if( !maTypeSequence.hasElements() )
2660 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
2661 bool bPresPage = IsImpressDocument() && SvxFmDrawPage::mpPage && ePageKind != PageKind::Handout;
2663 // Collect the types of this class.
2664 ::std::vector<uno::Type> aTypes;
2665 aTypes.reserve(12);
2666 aTypes.push_back(cppu::UnoType<drawing::XDrawPage>::get());
2667 aTypes.push_back(cppu::UnoType<beans::XPropertySet>::get());
2668 aTypes.push_back(cppu::UnoType<container::XNamed>::get());
2669 aTypes.push_back(cppu::UnoType<lang::XServiceInfo>::get());
2670 aTypes.push_back(cppu::UnoType<util::XReplaceable>::get());
2671 aTypes.push_back(cppu::UnoType<document::XLinkTargetSupplier>::get());
2672 aTypes.push_back(cppu::UnoType<drawing::XShapeCombiner>::get());
2673 aTypes.push_back(cppu::UnoType<drawing::XShapeBinder>::get());
2674 aTypes.push_back(cppu::UnoType<office::XAnnotationAccess>::get());
2675 aTypes.push_back(cppu::UnoType<beans::XMultiPropertySet>::get());
2676 if( bPresPage )
2677 aTypes.push_back(cppu::UnoType<presentation::XPresentationPage>::get());
2678 if( bPresPage && ePageKind == PageKind::Standard )
2679 aTypes.push_back(cppu::UnoType<XAnimationNodeSupplier>::get());
2681 // Get types of base class.
2682 // Join those types in a sequence.
2683 return comphelper::concatSequences(
2684 comphelper::containerToSequence(aTypes),
2685 SdGenericDrawPage::getTypes() );
2688 return maTypeSequence;
2691 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId()
2693 return css::uno::Sequence<sal_Int8>();
2696 // XServiceInfo
2697 OUString SAL_CALL SdMasterPage::getImplementationName()
2699 return "SdMasterPage";
2702 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames()
2704 ::SolarMutexGuard aGuard;
2706 throwIfDisposed();
2708 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() );
2709 comphelper::ServiceInfoHelper::addToSequence( aSeq, {"com.sun.star.drawing.MasterPage"} );
2711 if( SvxFmDrawPage::mpPage && static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetPageKind() == PageKind::Handout )
2712 comphelper::ServiceInfoHelper::addToSequence( aSeq, {"com.sun.star.presentation.HandoutMasterPage"} );
2714 return aSeq;
2717 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName )
2719 return cppu::supportsService( this, ServiceName );
2722 // XElementAccess
2723 sal_Bool SAL_CALL SdMasterPage::hasElements()
2725 ::SolarMutexGuard aGuard;
2727 throwIfDisposed();
2729 if( SvxFmDrawPage::mpPage == nullptr )
2730 return false;
2732 return SvxFmDrawPage::mpPage->GetObjCount() > 0;
2735 uno::Type SAL_CALL SdMasterPage::getElementType()
2737 return SdGenericDrawPage::getElementType();
2740 // XIndexAccess
2741 sal_Int32 SAL_CALL SdMasterPage::getCount()
2743 ::SolarMutexGuard aGuard;
2745 throwIfDisposed();
2747 return SdGenericDrawPage::getCount();
2750 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index )
2752 ::SolarMutexGuard aGuard;
2754 throwIfDisposed();
2756 return SdGenericDrawPage::getByIndex(Index);
2759 // intern
2760 void SdMasterPage::setBackground( const Any& rValue )
2762 // we need at least a beans::XPropertySet
2763 Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY );
2764 if( !xInputSet.is() )
2765 throw lang::IllegalArgumentException();
2769 if( GetModel() && IsImpressDocument() )
2771 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_SET_THROW );
2772 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ;
2773 OUString aStyleName(sUNO_PseudoSheet_Background);
2775 Reference< beans::XPropertySet > xStyleSet( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2777 Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW );
2778 Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY );
2780 PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap().getPropertyEntries();
2781 for( const auto& rProp : aBackgroundProperties )
2783 if( xSetInfo->hasPropertyByName( rProp.sName ) )
2785 if( !xSetStates.is() || xSetStates->getPropertyState( rProp.sName ) == beans::PropertyState_DIRECT_VALUE )
2786 xStyleSet->setPropertyValue( rProp.sName, xInputSet->getPropertyValue( rProp.sName ) );
2787 else
2788 xSetStates->setPropertyToDefault( rProp.sName );
2792 else
2794 // first fill an item set
2795 // is it our own implementation?
2796 SdUnoPageBackground* pBack = comphelper::getUnoTunnelImplementation<SdUnoPageBackground>( xInputSet );
2798 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{} );
2800 if( pBack )
2802 pBack->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2804 else
2806 SdUnoPageBackground* pBackground = new SdUnoPageBackground();
2808 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW );
2809 Reference< beans::XPropertySet > xDestSet( static_cast<beans::XPropertySet*>(pBackground) );
2810 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_SET_THROW );
2812 const uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
2814 for( const beans::Property& rProp : aProperties )
2816 const OUString aPropName( rProp.Name );
2817 if( xInputSetInfo->hasPropertyByName( aPropName ) )
2818 xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
2821 pBackground->fillItemSet( static_cast<SdDrawDocument*>(&SvxFmDrawPage::mpPage->getSdrModelFromSdrPage()), aSet );
2824 // if we find the background style, copy the set to the background
2825 SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(&SvxFmDrawPage::mpPage->getSdrModelFromSdrPage());
2826 SfxStyleSheetBasePool* pSSPool = pDoc->GetStyleSheetPool();
2827 if(pSSPool)
2829 OUString aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() );
2830 aLayoutName = aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4) +
2831 STR_LAYOUT_BACKGROUND;
2832 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page );
2834 if( pStyleSheet )
2836 pStyleSheet->GetItemSet().Put( aSet );
2838 // repaint only
2839 SvxFmDrawPage::mpPage->ActionChanged();
2840 return;
2844 // if no background style is available, set at page directly. This
2845 // is an error and should NOT happen (and will be asserted from the SdrPage)
2846 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2849 catch( Exception& )
2851 OSL_FAIL("sd::SdMasterPage::setBackground(), exception caught!");
2855 void SdMasterPage::getBackground( Any& rValue )
2857 if( !GetModel() )
2858 return;
2862 if( IsImpressDocument() )
2864 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_SET_THROW );
2865 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW );
2867 const OUString aStyleName(sUNO_PseudoSheet_Background);
2868 rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( aStyleName ), UNO_QUERY_THROW );
2870 else
2872 SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(&SvxFmDrawPage::mpPage->getSdrModelFromSdrPage());
2873 SfxStyleSheetBasePool* pSSPool = pDoc->GetStyleSheetPool();
2874 if(pSSPool)
2876 OUString aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() );
2877 aLayoutName = aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4) +
2878 STR_LAYOUT_BACKGROUND;
2879 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page );
2881 if( pStyleSheet )
2883 SfxItemSet aStyleSet( pStyleSheet->GetItemSet());
2884 if( aStyleSet.Count() )
2886 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) );
2887 return;
2892 // No style found, use fill attributes from page background. This
2893 // should NOT happen and is an error
2894 const SfxItemSet& rFallbackItemSet(SvxFmDrawPage::mpPage->getSdrPageProperties().GetItemSet());
2896 if(drawing::FillStyle_NONE == rFallbackItemSet.Get(XATTR_FILLSTYLE).GetValue())
2898 rValue <<= Reference< beans::XPropertySet >(
2899 new SdUnoPageBackground(GetModel()->GetDoc(), &rFallbackItemSet));
2901 else
2903 rValue.clear();
2907 catch( Exception& )
2909 rValue.clear();
2910 OSL_FAIL("sd::SdMasterPage::getBackground(), exception caught!");
2914 // XNamed
2915 void SAL_CALL SdMasterPage::setName( const OUString& rName )
2917 ::SolarMutexGuard aGuard;
2919 throwIfDisposed();
2921 if(!(SvxFmDrawPage::mpPage && GetPage()->GetPageKind() != PageKind::Notes))
2922 return;
2924 SdDrawDocument* pDoc = GetModel()->GetDoc();
2925 bool bOutDummy;
2927 // Slide Name has to be unique
2928 if( pDoc && pDoc->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
2929 return; // throw Exception ?
2931 GetPage()->SetName( rName );
2933 if( pDoc )
2934 pDoc->RenameLayoutTemplate( GetPage()->GetLayoutName(), rName );
2936 // fake a mode change to repaint the page tab bar
2937 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2938 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
2939 if( auto pDrawViewSh = dynamic_cast< ::sd::DrawViewShell* >(pViewSh) )
2941 EditMode eMode = pDrawViewSh->GetEditMode();
2942 if( eMode == EditMode::MasterPage )
2944 bool bLayer = pDrawViewSh->IsLayerModeActive();
2946 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2947 pDrawViewSh->ChangeEditMode( eMode, bLayer );
2951 GetModel()->SetModified();
2954 OUString SAL_CALL SdMasterPage::getName( )
2956 ::SolarMutexGuard aGuard;
2958 throwIfDisposed();
2960 if(SvxFmDrawPage::mpPage)
2962 OUString aLayoutName( GetPage()->GetLayoutName() );
2963 return aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR));
2966 return OUString();
2969 // XPresentationPage
2970 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage()
2972 ::SolarMutexGuard aGuard;
2974 throwIfDisposed();
2976 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() )
2978 SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
2979 if( pNotesPage )
2981 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2982 return xPage;
2985 return nullptr;
2988 // XShapes
2989 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape )
2991 SdGenericDrawPage::add( xShape );
2994 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape )
2996 ::SolarMutexGuard aGuard;
2998 throwIfDisposed();
3000 SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShape );
3001 if( pShape )
3003 SdrObject* pObj = pShape->GetSdrObject();
3004 if( pObj && GetPage()->IsPresObj( pObj ) )
3005 GetPage()->RemovePresObj(pObj);
3008 SdGenericDrawPage::remove( xShape );
3011 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage )
3013 Reference< uno::XInterface > xPage;
3015 if( pPage )
3017 SdXImpressDocument* pModel = comphelper::getUnoTunnelImplementation<SdXImpressDocument>( pPage->getSdrModelFromSdrPage().getUnoModel() );
3018 if( pModel )
3020 if( pPage->IsMasterPage() )
3022 xPage = static_cast<cppu::OWeakObject*>(new SdMasterPage( pModel, pPage ));
3024 else
3026 xPage = static_cast<cppu::OWeakObject*>(new SdDrawPage( pModel, pPage ));
3031 return xPage;
3034 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */