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