tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sd / source / ui / unoidl / unopage.cxx
blob8183d6cfbfe6e51ac977c4a260515a0c89d763a2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <initializer_list>
23 #include <string_view>
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 <com/sun/star/util/XTheme.hpp>
33 #include <cppuhelper/implbase.hxx>
34 #include <comphelper/profilezone.hxx>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/supportsservice.hxx>
37 #include <rtl/ustrbuf.hxx>
38 #include <vcl/bitmapex.hxx>
39 #include <vcl/filter/SvmWriter.hxx>
40 #include <vcl/metaact.hxx>
41 #include <toolkit/helper/vclunohelper.hxx>
42 #include <comphelper/diagnose_ex.hxx>
43 #include <vcl/svapp.hxx>
44 #include <Annotation.hxx>
45 #include <svx/annotation/AnnotationEnumeration.hxx>
46 #include <createunopageimpl.hxx>
47 #include <unomodel.hxx>
48 #include <unopage.hxx>
49 #include <svl/itemset.hxx>
50 #include <svx/svdmodel.hxx>
51 #include <sdresid.hxx>
52 #include <strings.hrc>
53 #include <sdpage.hxx>
54 #include <unoprnms.hxx>
55 #include <drawdoc.hxx>
56 #include <svx/unoshape.hxx>
57 #include <svl/style.hxx>
58 #include <comphelper/extract.hxx>
59 #include <comphelper/sequence.hxx>
60 #include <svx/svditer.hxx>
61 #include <vcl/wmf.hxx>
62 #include <svx/svdoole2.hxx>
63 #include <svx/svdpool.hxx>
64 #include <svx/svdview.hxx>
65 #include <svx/xfillit0.hxx>
66 #include <DrawDocShell.hxx>
67 #include <ViewShell.hxx>
68 #include <DrawViewShell.hxx>
69 #include <editeng/unoprnms.hxx>
70 #include "unoobj.hxx"
72 #include <strings.hxx>
73 #include <bitmaps.hlst>
74 #include <unokywds.hxx>
75 #include "unopback.hxx"
76 #include <vcl/dibtools.hxx>
77 #include <tools/debug.hxx>
78 #include <tools/stream.hxx>
79 #include <docmodel/uno/UnoTheme.hxx>
80 #include <docmodel/theme/Theme.hxx>
81 #include <o3tl/string_view.hxx>
83 using ::com::sun::star::animations::XAnimationNode;
84 using ::com::sun::star::animations::XAnimationNodeSupplier;
86 using namespace ::com::sun::star;
87 using namespace ::com::sun::star::uno;
88 using namespace ::com::sun::star::lang;
89 using namespace ::com::sun::star::container;
90 using namespace ::com::sun::star::drawing;
91 using namespace ::com::sun::star::office;
93 namespace {
95 // this are the ids for page properties
96 enum WID_PAGE
98 WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH,
99 WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER,
100 WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_HIGHRESDURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP,
101 WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL,
102 WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK,
103 WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT,
104 WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
105 WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
106 WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
107 WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE, WID_PAGE_THEME, WID_PAGE_THEME_UNO_REPRESENTATION,
108 WID_PAGE_SLIDE_LAYOUT
113 constexpr OUString sEmptyPageName = u"page"_ustr;
115 // this function stores the property maps for draw pages in impress and draw
116 static const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind ePageKind )
118 static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] =
120 { u"" UNO_NAME_PAGE_BACKGROUND ""_ustr, WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
121 { u"" UNO_NAME_PAGE_BOTTOM ""_ustr, WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
122 { u"" UNO_NAME_PAGE_LEFT ""_ustr, WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
123 { u"" UNO_NAME_PAGE_RIGHT ""_ustr, WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
124 { u"" UNO_NAME_PAGE_TOP ""_ustr, WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
125 { u"" UNO_NAME_PAGE_CHANGE ""_ustr, WID_PAGE_CHANGE, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
126 { u"" UNO_NAME_PAGE_DURATION ""_ustr, WID_PAGE_DURATION, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
127 { u"" UNO_NAME_PAGE_EFFECT ""_ustr, WID_PAGE_EFFECT, ::cppu::UnoType<presentation::FadeEffect>::get(), 0, 0},
128 { u"" UNO_NAME_PAGE_HEIGHT ""_ustr, WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
129 { u"" UNO_NAME_PAGE_LAYOUT ""_ustr, WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
130 { UNO_NAME_LINKDISPLAYBITMAP, WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0},
131 { UNO_NAME_LINKDISPLAYNAME, WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0},
132 { u"" UNO_NAME_PAGE_NUMBER ""_ustr, WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
133 { u"" UNO_NAME_PAGE_ORIENTATION ""_ustr, WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
134 { u"" UNO_NAME_PAGE_SPEED ""_ustr, WID_PAGE_SPEED, ::cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},
135 { u"" UNO_NAME_PAGE_WIDTH ""_ustr, WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
136 { u"" UNO_NAME_PAGE_PREVIEW ""_ustr, WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
137 { u"" UNO_NAME_PAGE_PREVIEWBITMAP ""_ustr, WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
138 { u"" UNO_NAME_PAGE_PREVIEWMETAFILE ""_ustr, WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
139 { u"" UNO_NAME_PAGE_VISIBLE ""_ustr, WID_PAGE_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
140 { u"" UNO_NAME_OBJ_SOUNDFILE ""_ustr, WID_PAGE_SOUNDFILE, cppu::UnoType<Any>::get(), 0, 0},
141 { sUNO_Prop_IsBackgroundVisible, WID_PAGE_BACKVIS, cppu::UnoType<bool>::get(), 0, 0},
142 { sUNO_Prop_IsBackgroundObjectsVisible, WID_PAGE_BACKOBJVIS, cppu::UnoType<bool>::get(), 0, 0},
143 { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
144 { sUNO_Prop_BookmarkURL, WID_PAGE_BOOKMARK, ::cppu::UnoType<OUString>::get(), 0, 0},
145 { u"HighResDuration"_ustr, WID_PAGE_HIGHRESDURATION, ::cppu::UnoType<double>::get(), 0, 0},
146 { u"IsBackgroundDark"_ustr , WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
147 { u"IsFooterVisible"_ustr, WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
148 { u"FooterText"_ustr, WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
149 { u"IsPageNumberVisible"_ustr, WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
150 { u"IsDateTimeVisible"_ustr, WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
151 { u"IsDateTimeFixed"_ustr, WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0},
152 { u"DateTimeText"_ustr, WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
153 { u"DateTimeFormat"_ustr, WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
154 { u"TransitionType"_ustr, WID_TRANSITION_TYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
155 { u"TransitionSubtype"_ustr, WID_TRANSITION_SUBTYPE, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
156 { u"TransitionDirection"_ustr, WID_TRANSITION_DIRECTION, ::cppu::UnoType<sal_Bool>::get(), 0, 0},
157 { u"TransitionFadeColor"_ustr, WID_TRANSITION_FADE_COLOR, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
158 { u"" UNO_NAME_PAGE_TRANSITION_DURATION ""_ustr, WID_TRANSITION_DURATION, ::cppu::UnoType<double>::get(), 0, 0},
159 { u"LoopSound"_ustr, WID_LOOP_SOUND, cppu::UnoType<bool>::get(), 0, 0},
160 { u"NavigationOrder"_ustr, WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0},
163 #define DRAW_PAGE_NOTES_PROPERTIES \
164 { u"" UNO_NAME_PAGE_BOTTOM ""_ustr, WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
165 { u"" UNO_NAME_PAGE_LEFT ""_ustr, WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
166 { u"" UNO_NAME_PAGE_RIGHT ""_ustr, WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
167 { u"" UNO_NAME_PAGE_TOP ""_ustr, WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
168 { u"" UNO_NAME_PAGE_HEIGHT ""_ustr, WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
169 { u"" UNO_NAME_PAGE_LAYOUT ""_ustr, WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0}, \
170 { UNO_NAME_LINKDISPLAYBITMAP, WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0}, \
171 { UNO_NAME_LINKDISPLAYNAME, WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0}, \
172 { u"" UNO_NAME_PAGE_NUMBER ""_ustr, WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0}, \
173 { u"" UNO_NAME_PAGE_ORIENTATION ""_ustr, WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0}, \
174 { u"" UNO_NAME_PAGE_WIDTH ""_ustr, WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
175 { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},\
176 { u"IsHeaderVisible"_ustr, WID_PAGE_HEADERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
177 { u"HeaderText"_ustr, WID_PAGE_HEADERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
178 { u"IsBackgroundDark"_ustr, WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, \
179 { u"IsFooterVisible"_ustr, WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
180 { u"FooterText"_ustr, WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
181 { u"IsPageNumberVisible"_ustr, WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
182 { u"IsDateTimeVisible"_ustr, WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0}, \
183 { u"IsDateTimeFixed"_ustr, WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0}, \
184 { u"DateTimeText"_ustr, WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0}, \
185 { u"DateTimeFormat"_ustr, WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
186 { u"NavigationOrder"_ustr, WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0}
188 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] =
190 // this must be the first two entries so they can be excluded for PageKind::Standard
191 { u"" UNO_NAME_PAGE_BACKGROUND ""_ustr, WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
192 DRAW_PAGE_NOTES_PROPERTIES
194 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] =
196 DRAW_PAGE_NOTES_PROPERTIES
199 #define GRAPHIC_PAGE_PROPERTIES \
200 { u"" UNO_NAME_PAGE_BOTTOM ""_ustr, WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
201 { u"" UNO_NAME_PAGE_LEFT ""_ustr, WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
202 { u"" UNO_NAME_PAGE_RIGHT ""_ustr, WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
203 { u"" UNO_NAME_PAGE_TOP ""_ustr, WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
204 { u"" UNO_NAME_PAGE_HEIGHT ""_ustr, WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
205 { UNO_NAME_LINKDISPLAYBITMAP, WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0}, \
206 { UNO_NAME_LINKDISPLAYNAME, WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0}, \
207 { u"" UNO_NAME_PAGE_NUMBER ""_ustr, WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0}, \
208 { u"" UNO_NAME_PAGE_ORIENTATION ""_ustr, WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0}, \
209 { u"" UNO_NAME_PAGE_WIDTH ""_ustr, WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
210 { u"" UNO_NAME_PAGE_PREVIEW ""_ustr, WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0}, \
211 { u"" UNO_NAME_PAGE_PREVIEWBITMAP ""_ustr, WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
212 { u"" UNO_NAME_PAGE_PREVIEWMETAFILE ""_ustr, WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
213 { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, \
214 { sUNO_Prop_BookmarkURL, WID_PAGE_BOOKMARK, ::cppu::UnoType<OUString>::get(), 0, 0}, \
215 { u"IsBackgroundDark"_ustr, WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, \
216 { u"NavigationOrder"_ustr, WID_NAVORDER, cppu::UnoType<css::container::XIndexAccess>::get(),0, 0}
218 static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] =
220 { u"" UNO_NAME_PAGE_BACKGROUND ""_ustr, WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), beans::PropertyAttribute::MAYBEVOID,0},
221 GRAPHIC_PAGE_PROPERTIES
223 static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] =
225 GRAPHIC_PAGE_PROPERTIES
228 bool bWithoutBackground = ePageKind != PageKind::Standard && ePageKind != PageKind::Handout;
229 const SvxItemPropertySet* pRet = nullptr;
230 if( bImpress )
232 if( ePageKind == PageKind::Standard )
234 //PageKind::Standard always has a background property
235 static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
236 pRet = &aDrawPagePropertySet_Impl;
238 else
240 if(bWithoutBackground)
242 static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
243 pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl;
245 else
247 static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
248 pRet = &aDrawPageNotesHandoutPropertySet_Impl;
252 else
254 if(bWithoutBackground)
256 static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
257 pRet = &aGraphicPagePropertyNoBackSet_Impl;
259 else
261 static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
262 pRet = &aGraphicPagePropertySet_Impl;
265 return pRet;
268 /** this function stores the property map for master pages in impress and draw */
269 static const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
271 static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] =
273 { u"" UNO_NAME_PAGE_BACKGROUND ""_ustr, WID_PAGE_BACK, cppu::UnoType<beans::XPropertySet>::get(), 0, 0},
274 { u"" UNO_NAME_PAGE_BOTTOM ""_ustr, WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
275 { u"" UNO_NAME_PAGE_LEFT ""_ustr, WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
276 { u"" UNO_NAME_PAGE_RIGHT ""_ustr, WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
277 { u"" UNO_NAME_PAGE_TOP ""_ustr, WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
278 { u"" UNO_NAME_PAGE_HEIGHT ""_ustr, WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
279 { UNO_NAME_LINKDISPLAYBITMAP, WID_PAGE_LDBITMAP, cppu::UnoType<awt::XBitmap>::get(), beans::PropertyAttribute::READONLY, 0},
280 { UNO_NAME_LINKDISPLAYNAME, WID_PAGE_LDNAME, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0},
281 { u"" UNO_NAME_PAGE_NUMBER ""_ustr, WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
282 { u"" UNO_NAME_PAGE_ORIENTATION ""_ustr, WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
283 { u"" UNO_NAME_PAGE_WIDTH ""_ustr, WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
284 { u"BackgroundFullSize"_ustr, WID_PAGE_BACKFULL, cppu::UnoType<bool>::get(), 0, 0},
285 { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
286 { u"IsBackgroundDark"_ustr, WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
287 { u"Theme"_ustr, WID_PAGE_THEME, cppu::UnoType<util::XTheme>::get(), 0, 0},
288 // backwards compatible view of the theme for use in tests
289 { u"ThemeUnoRepresentation"_ustr, WID_PAGE_THEME_UNO_REPRESENTATION, cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get(), 0, 0},
290 { u"SlideLayout"_ustr, WID_PAGE_SLIDE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0}
293 static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] =
295 { u"" UNO_NAME_PAGE_BOTTOM ""_ustr, WID_PAGE_BOTTOM, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
296 { u"" UNO_NAME_PAGE_LEFT ""_ustr, WID_PAGE_LEFT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
297 { u"" UNO_NAME_PAGE_RIGHT ""_ustr, WID_PAGE_RIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
298 { u"" UNO_NAME_PAGE_TOP ""_ustr, WID_PAGE_TOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
299 { u"" UNO_NAME_PAGE_HEIGHT ""_ustr, WID_PAGE_HEIGHT, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
300 { u"" UNO_NAME_PAGE_ORIENTATION ""_ustr, WID_PAGE_ORIENT, ::cppu::UnoType<view::PaperOrientation>::get(),0, 0},
301 { u"" UNO_NAME_PAGE_NUMBER ""_ustr, WID_PAGE_NUMBER, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0},
302 { u"" UNO_NAME_PAGE_WIDTH ""_ustr, WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
303 { u"" UNO_NAME_PAGE_LAYOUT ""_ustr, WID_PAGE_LAYOUT, ::cppu::UnoType<sal_Int16>::get(), 0, 0},
304 { sUNO_Prop_UserDefinedAttributes,WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
305 { u"IsBackgroundDark"_ustr, WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0},
306 { u"IsHeaderVisible"_ustr, WID_PAGE_HEADERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
307 { u"HeaderText"_ustr, WID_PAGE_HEADERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
308 { u"IsFooterVisible"_ustr, WID_PAGE_FOOTERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
309 { u"FooterText"_ustr, WID_PAGE_FOOTERTEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
310 { u"IsPageNumberVisible"_ustr, WID_PAGE_PAGENUMBERVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
311 { u"IsDateTimeVisible"_ustr, WID_PAGE_DATETIMEVISIBLE, cppu::UnoType<bool>::get(), 0, 0},
312 { u"IsDateTimeFixed"_ustr, WID_PAGE_DATETIMEFIXED, cppu::UnoType<bool>::get(), 0, 0},
313 { u"DateTimeText"_ustr, WID_PAGE_DATETIMETEXT, ::cppu::UnoType<OUString>::get(), 0, 0},
314 { u"DateTimeFormat"_ustr, WID_PAGE_DATETIMEFORMAT, ::cppu::UnoType<sal_Int32>::get(), 0, 0}
317 const SvxItemPropertySet* pRet = nullptr;
318 if( ePageKind == PageKind::Handout )
320 static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
321 pRet = &aHandoutMasterPagePropertySet_Impl;
323 else
325 static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
326 pRet = &aMasterPagePropertySet_Impl;
328 return pRet;
331 const css::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() noexcept
333 static const comphelper::UnoIdInit theSdGenericDrawPageUnoTunnelId;
334 return theSdGenericDrawPageUnoTunnelId.getSeq();
337 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
339 return comphelper::getSomethingImpl(rId, this,
340 comphelper::FallbackToGetSomethingOf<SvxDrawPage>{});
343 SdGenericDrawPage::SdGenericDrawPage(SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet)
344 : SvxDrawPage( static_cast<SdrPage*>(pInPage) ),
345 SdUnoSearchReplaceShape(this),
346 mpDocModel( _pModel ),
347 mpSdrModel(nullptr),
348 mbIsImpressDocument(false),
349 mnTempPageNumber(0),
350 mpPropSet ( _pSet )
352 mpSdrModel = SvxDrawPage::mpModel;
353 if( mpDocModel )
354 mbIsImpressDocument = mpDocModel->IsImpressDocument();
358 SdGenericDrawPage::~SdGenericDrawPage() noexcept
362 void SdGenericDrawPage::throwIfDisposed() const
364 if( (SvxDrawPage::mpModel == nullptr) || (mpDocModel == nullptr) || (SvxDrawPage::mpPage == nullptr) )
365 throw lang::DisposedException();
368 SdXImpressDocument* SdGenericDrawPage::GetModel() const
370 if( mpSdrModel != SvxDrawPage::mpModel )
371 const_cast<SdGenericDrawPage*>(this)->UpdateModel();
372 return mpDocModel;
375 bool SdGenericDrawPage::IsImpressDocument() const
377 if( mpSdrModel != SvxDrawPage::mpModel )
378 const_cast<SdGenericDrawPage*>(this)->UpdateModel();
379 return mbIsImpressDocument;
383 void SdGenericDrawPage::UpdateModel()
385 mpSdrModel = SvxDrawPage::mpModel;
386 if( mpSdrModel )
388 uno::Reference< uno::XInterface > xModel( SvxDrawPage::mpModel->getUnoModel() );
389 mpDocModel = comphelper::getFromUnoTunnel<SdXImpressDocument>( xModel );
391 else
393 mpDocModel = nullptr;
395 mbIsImpressDocument = mpDocModel && mpDocModel->IsImpressDocument();
398 // this is called whenever a SdrObject must be created for an empty api shape wrapper
399 rtl::Reference<SdrObject> SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShape >& xShape )
401 if( nullptr == SvxDrawPage::mpPage || !xShape.is() )
402 return nullptr;
404 OUString aType( xShape->getShapeType() );
405 static constexpr OUString aPrefix( u"com.sun.star.presentation."_ustr );
406 if( !aType.startsWith( aPrefix ) )
408 return SvxDrawPage::CreateSdrObject_( xShape );
411 aType = aType.copy( aPrefix.getLength() );
413 PresObjKind eObjKind = PresObjKind::NONE;
415 if( aType == "TitleTextShape" )
417 eObjKind = PresObjKind::Title;
419 else if( aType == "OutlinerShape" )
421 eObjKind = PresObjKind::Outline;
423 else if( aType == "SubtitleShape" )
425 eObjKind = PresObjKind::Text;
427 else if( aType == "OLE2Shape" )
429 eObjKind = PresObjKind::Object;
431 else if( aType == "ChartShape" )
433 eObjKind = PresObjKind::Chart;
435 else if( aType == "CalcShape" )
437 eObjKind = PresObjKind::Calc;
439 else if( aType == "TableShape" )
441 eObjKind = PresObjKind::Table;
443 else if( aType == "GraphicObjectShape" )
445 eObjKind = PresObjKind::Graphic;
447 else if( aType == "OrgChartShape" )
449 eObjKind = PresObjKind::OrgChart;
451 else if( aType == "PageShape" )
453 if( GetPage()->GetPageKind() == PageKind::Notes && GetPage()->IsMasterPage() )
454 eObjKind = PresObjKind::Title;
455 else
456 eObjKind = PresObjKind::Page;
458 else if( aType == "NotesShape" )
460 eObjKind = PresObjKind::Notes;
462 else if( aType == "HandoutShape" )
464 eObjKind = PresObjKind::Handout;
466 else if( aType == "FooterShape" )
468 eObjKind = PresObjKind::Footer;
470 else if( aType == "HeaderShape" )
472 eObjKind = PresObjKind::Header;
474 else if( aType == "SlideNumberShape" )
476 eObjKind = PresObjKind::SlideNumber;
478 else if( aType == "DateTimeShape" )
480 eObjKind = PresObjKind::DateTime;
482 else if( aType == "MediaShape" )
484 eObjKind = PresObjKind::Media;
487 ::tools::Rectangle aRect( eObjKind == PresObjKind::Title ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() );
489 // OOXML placeholder with "TextAutoGrowHeight" use the height set on the slide
490 sal_Int32 nHeight = xShape->getSize().Height;
491 if (nHeight != 0)
492 aRect.setHeight(nHeight);
494 const awt::Point aPos( aRect.Left(), aRect.Top() );
495 xShape->setPosition( aPos );
497 const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
498 xShape->setSize( aSize );
500 rtl::Reference<SdrObject> pPresObj;
501 if( (eObjKind == PresObjKind::Table) || (eObjKind == PresObjKind::Media) )
503 pPresObj = SvxDrawPage::CreateSdrObject_( xShape );
504 if( pPresObj )
506 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
507 pPresObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true);
508 GetPage()->InsertPresObj( pPresObj.get(), eObjKind );
511 else
513 pPresObj = GetPage()->CreatePresObj( eObjKind, false, aRect );
516 if( pPresObj )
517 pPresObj->SetUserCall( GetPage() );
519 return pPresObj;
522 // XInterface
523 Any SdGenericDrawPage::queryInterface(const uno::Type & rType)
525 Any aAny;
527 if (rType == cppu::UnoType<beans::XPropertySet>::get())
529 aAny <<= Reference<beans::XPropertySet>(this);
531 else if (rType == cppu::UnoType<container::XNamed>::get())
533 aAny <<= Reference<container::XNamed>(this);
535 else if (rType == cppu::UnoType<util::XReplaceable>::get())
537 aAny <<= Reference<util::XReplaceable>(this);
539 else if (rType == cppu::UnoType<util::XSearchable>::get())
541 aAny <<= Reference<util::XSearchable>(this);
543 else if (rType == cppu::UnoType<document::XLinkTargetSupplier>::get())
545 aAny <<= Reference<document::XLinkTargetSupplier>(this);
547 else if (rType == cppu::UnoType<drawing::XShapeCombiner>::get())
549 aAny <<= Reference<drawing::XShapeCombiner>(this);
551 else if (rType == cppu::UnoType<drawing::XShapeBinder>::get())
553 aAny <<= Reference<drawing::XShapeBinder>(this);
555 else if (rType == cppu::UnoType<beans::XMultiPropertySet>::get())
557 aAny <<= Reference<beans::XMultiPropertySet>(this);
559 else if (rType == cppu::UnoType<office::XAnnotationAccess>::get())
561 aAny <<= Reference<office::XAnnotationAccess>(this);
563 else if (IsImpressDocument() && rType == cppu::UnoType<XAnimationNodeSupplier>::get())
565 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
567 if( ePageKind == PageKind::Standard )
568 return Any( Reference< XAnimationNodeSupplier >( this ) );
570 else
571 return SvxDrawPage::queryInterface( rType );
573 return aAny;
576 // XPropertySet
577 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo()
579 ::SolarMutexGuard aGuard;
580 throwIfDisposed();
581 return mpPropSet->getPropertySetInfo();
584 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
586 ::SolarMutexGuard aGuard;
588 throwIfDisposed();
590 const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
592 switch( pEntry ? pEntry->nWID : -1 )
594 case WID_NAVORDER:
595 setNavigationOrder( aValue );
596 break;
597 case WID_PAGE_LEFT:
598 case WID_PAGE_RIGHT:
599 case WID_PAGE_TOP:
600 case WID_PAGE_BOTTOM:
601 case WID_PAGE_LAYOUT:
602 case WID_PAGE_SLIDE_LAYOUT:
603 case WID_PAGE_DURATION:
604 case WID_PAGE_CHANGE:
606 sal_Int32 nValue = 0;
607 if(!(aValue >>= nValue))
608 throw lang::IllegalArgumentException();
610 switch( pEntry->nWID )
612 case WID_PAGE_LEFT:
613 SetLeftBorder(nValue);
614 break;
615 case WID_PAGE_RIGHT:
616 SetRightBorder( nValue );
617 break;
618 case WID_PAGE_TOP:
619 SetUpperBorder( nValue );
620 break;
621 case WID_PAGE_BOTTOM:
622 SetLowerBorder( nValue );
623 break;
624 case WID_PAGE_CHANGE:
625 GetPage()->SetPresChange( static_cast<PresChange>(nValue) );
626 break;
627 case WID_PAGE_LAYOUT:
628 GetPage()->SetAutoLayout( static_cast<AutoLayout>(nValue), true );
629 break;
630 case WID_PAGE_SLIDE_LAYOUT:
631 mSlideLayout <<= nValue;
632 break;
633 case WID_PAGE_DURATION:
634 GetPage()->SetTime(nValue);
635 break;
637 break;
639 case WID_PAGE_HIGHRESDURATION:
641 double fValue = 0;
642 if(!(aValue >>= fValue))
643 throw lang::IllegalArgumentException();
645 GetPage()->SetTime(fValue);
646 break;
648 case WID_PAGE_WIDTH:
650 sal_Int32 nWidth = 0;
651 if(!(aValue >>= nWidth))
652 throw lang::IllegalArgumentException();
654 SetWidth( nWidth );
655 break;
657 case WID_PAGE_HEIGHT:
659 sal_Int32 nHeight = 0;
660 if(!(aValue >>= nHeight))
661 throw lang::IllegalArgumentException();
663 SetHeight( nHeight );
664 break;
666 case WID_PAGE_ORIENT:
668 sal_Int32 nEnum = 0;
669 if(!::cppu::enum2int( nEnum, aValue ))
670 throw lang::IllegalArgumentException();
672 Orientation eOri = (static_cast<view::PaperOrientation>(nEnum) == view::PaperOrientation_PORTRAIT)?Orientation::Portrait:Orientation::Landscape;
674 if( eOri != GetPage()->GetOrientation() )
676 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
677 const PageKind ePageKind = GetPage()->GetPageKind();
679 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
680 for (i = 0; i < nPageCnt; i++)
682 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
683 pPage->SetOrientation( eOri );
686 nPageCnt = rDoc.GetSdPageCount(ePageKind);
688 for (i = 0; i < nPageCnt; i++)
690 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
691 pPage->SetOrientation( eOri );
694 break;
696 case WID_PAGE_EFFECT:
698 sal_Int32 nEnum = 0;
699 if(!::cppu::enum2int( nEnum, aValue ))
700 throw lang::IllegalArgumentException();
702 GetPage()->SetFadeEffect( static_cast<presentation::FadeEffect>(nEnum) );
703 break;
705 case WID_PAGE_BACK:
706 setBackground( aValue );
707 break;
708 case WID_PAGE_SPEED:
710 sal_Int32 nEnum = 0;
711 if(!::cppu::enum2int( nEnum, aValue ))
712 throw lang::IllegalArgumentException();
714 GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 ) );
715 break;
717 case WID_PAGE_VISIBLE :
719 bool bVisible = false;
720 if( ! ( aValue >>= bVisible ) )
721 throw lang::IllegalArgumentException();
722 GetPage()->SetExcluded( !bVisible );
723 break;
725 case WID_PAGE_SOUNDFILE :
727 OUString aURL;
728 if( aValue >>= aURL )
730 GetPage()->SetSoundFile( aURL );
731 GetPage()->SetSound( !aURL.isEmpty() );
732 break;
734 else
736 bool bStopSound = false;
737 if( aValue >>= bStopSound )
739 GetPage()->SetStopSound( bStopSound );
740 break;
744 throw lang::IllegalArgumentException();
746 case WID_LOOP_SOUND:
748 bool bLoop = false;
749 if( ! (aValue >>= bLoop) )
750 throw lang::IllegalArgumentException();
752 GetPage()->SetLoopSound( bLoop );
753 break;
755 case WID_PAGE_BACKFULL:
757 bool bFullSize = false;
758 if( ! ( aValue >>= bFullSize ) )
759 throw lang::IllegalArgumentException();
760 GetPage()->SetBackgroundFullSize( bFullSize );
761 break;
763 case WID_PAGE_BACKVIS:
765 bool bVisible = false;
766 if( ! ( aValue >>= bVisible ) )
767 throw lang::IllegalArgumentException();
769 SdrPage* pPage = GetPage();
770 if( pPage )
772 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
773 if( rDoc.GetMasterPageCount() )
775 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
776 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
777 aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background), bVisible);
778 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
781 break;
783 case WID_PAGE_BACKOBJVIS:
785 bool bVisible = false;
786 if( ! ( aValue >>= bVisible ) )
787 throw lang::IllegalArgumentException();
789 SdrPage* pPage = GetPage();
790 if( pPage )
792 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
793 if( rDoc.GetMasterPageCount() )
795 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
796 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
797 aVisibleLayers.Set(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects), bVisible);
798 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
802 break;
804 case WID_PAGE_USERATTRIBS:
806 if( !GetPage()->setAlienAttributes( aValue ) )
807 throw lang::IllegalArgumentException();
808 break;
810 case WID_PAGE_BOOKMARK:
812 OUString aBookmarkURL;
813 if( ! ( aValue >>= aBookmarkURL ) )
814 throw lang::IllegalArgumentException();
816 setBookmarkURL( aBookmarkURL );
817 break;
820 case WID_PAGE_HEADERVISIBLE:
821 case WID_PAGE_HEADERTEXT:
822 case WID_PAGE_FOOTERVISIBLE:
823 case WID_PAGE_FOOTERTEXT:
824 case WID_PAGE_PAGENUMBERVISIBLE:
825 case WID_PAGE_DATETIMEVISIBLE:
826 case WID_PAGE_DATETIMEFIXED:
827 case WID_PAGE_DATETIMETEXT:
828 case WID_PAGE_DATETIMEFORMAT:
830 sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() );
832 switch( pEntry->nWID )
834 case WID_PAGE_HEADERVISIBLE:
836 bool bVisible = false;
837 if( ! ( aValue >>= bVisible ) )
838 throw lang::IllegalArgumentException();
840 aHeaderFooterSettings.mbHeaderVisible = bVisible;
841 break;
843 case WID_PAGE_HEADERTEXT:
845 OUString aText;
846 if( ! ( aValue >>= aText ) )
847 throw lang::IllegalArgumentException();
849 aHeaderFooterSettings.maHeaderText = aText;
850 break;
852 case WID_PAGE_FOOTERVISIBLE:
854 bool bVisible = false;
855 if( ! ( aValue >>= bVisible ) )
856 throw lang::IllegalArgumentException();
858 aHeaderFooterSettings.mbFooterVisible = bVisible;
859 break;
861 case WID_PAGE_FOOTERTEXT:
863 OUString aText;
864 if( ! ( aValue >>= aText ) )
865 throw lang::IllegalArgumentException();
867 aHeaderFooterSettings.maFooterText = aText;
868 break;
870 case WID_PAGE_PAGENUMBERVISIBLE:
872 bool bVisible = false;
873 if( ! ( aValue >>= bVisible ) )
874 throw lang::IllegalArgumentException();
876 aHeaderFooterSettings.mbSlideNumberVisible = bVisible;
877 break;
879 case WID_PAGE_DATETIMEVISIBLE:
881 bool bVisible = false;
882 if( ! ( aValue >>= bVisible ) )
883 throw lang::IllegalArgumentException();
885 aHeaderFooterSettings.mbDateTimeVisible = bVisible;
886 break;
888 case WID_PAGE_DATETIMEFIXED:
890 bool bVisible = false;
891 if( ! ( aValue >>= bVisible ) )
892 throw lang::IllegalArgumentException();
894 aHeaderFooterSettings.mbDateTimeIsFixed = bVisible;
895 break;
897 case WID_PAGE_DATETIMETEXT:
899 OUString aText;
900 if( ! ( aValue >>= aText ) )
901 throw lang::IllegalArgumentException();
903 aHeaderFooterSettings.maDateTimeText = aText;
904 break;
906 case WID_PAGE_DATETIMEFORMAT:
908 sal_Int32 nValue = 0;
909 if( ! ( aValue >>= nValue ) )
910 throw lang::IllegalArgumentException();
912 aHeaderFooterSettings.meDateFormat = static_cast<SvxDateFormat>(nValue & 0x0f);
913 aHeaderFooterSettings.meTimeFormat = static_cast<SvxTimeFormat>((nValue >> 4) & 0x0f);
914 break;
918 if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) )
919 GetPage()->setHeaderFooterSettings( aHeaderFooterSettings );
921 break;
924 case WID_PAGE_NUMBER:
925 if( (GetPage()->GetPageKind() == PageKind::Handout) && !GetPage()->IsMasterPage() )
927 if( !(aValue >>= mnTempPageNumber) )
928 throw lang::IllegalArgumentException();
930 break;
932 throw beans::PropertyVetoException();
934 case WID_PAGE_LDBITMAP:
935 case WID_PAGE_LDNAME:
936 case WID_PAGE_ISDARK:
937 throw beans::PropertyVetoException();
939 case WID_TRANSITION_TYPE:
941 sal_Int16 nValue = 0;
942 if( ! ( aValue >>= nValue ) )
943 throw lang::IllegalArgumentException();
945 GetPage()->setTransitionType( nValue );
946 break;
949 case WID_TRANSITION_SUBTYPE:
951 sal_Int16 nValue = 0;
952 if( ! ( aValue >>= nValue ) )
953 throw lang::IllegalArgumentException();
955 GetPage()->setTransitionSubtype( nValue );
956 break;
959 case WID_TRANSITION_DIRECTION:
961 bool bValue = false;
962 if( ! ( aValue >>= bValue ) )
963 throw lang::IllegalArgumentException();
965 GetPage()->setTransitionDirection( bValue );
966 break;
969 case WID_TRANSITION_FADE_COLOR:
971 sal_Int32 nValue = 0;
972 if( ! ( aValue >>= nValue ) )
973 throw lang::IllegalArgumentException();
975 GetPage()->setTransitionFadeColor( nValue );
976 break;
979 case WID_TRANSITION_DURATION:
981 double fValue = 0.0;
982 if( ! ( aValue >>= fValue ) )
983 throw lang::IllegalArgumentException();
985 GetPage()->setTransitionDuration( fValue );
986 break;
989 case WID_PAGE_THEME:
991 SdrPage* pPage = GetPage();
992 uno::Reference<util::XTheme> xTheme;
993 if (aValue >>= xTheme)
995 auto& rUnoTheme = dynamic_cast<UnoTheme&>(*xTheme);
996 pPage->getSdrPageProperties().setTheme(rUnoTheme.getTheme());
998 break;
1001 case WID_PAGE_THEME_UNO_REPRESENTATION:
1003 SdrPage* pPage = GetPage();
1004 std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue);
1005 pPage->getSdrPageProperties().setTheme(pTheme);
1006 break;
1009 default:
1010 throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this));
1013 GetModel()->SetModified();
1016 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
1018 ::SolarMutexGuard aGuard;
1020 throwIfDisposed();
1022 uno::Any aAny;
1024 const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
1026 sal_Int16 nEntry = pEntry ? pEntry->nWID : -1;
1027 switch (nEntry)
1029 case WID_NAVORDER:
1030 aAny = getNavigationOrder();
1031 break;
1032 case WID_PAGE_LEFT:
1033 aAny <<= GetPage()->GetLeftBorder();
1034 break;
1035 case WID_PAGE_RIGHT:
1036 aAny <<= GetPage()->GetRightBorder();
1037 break;
1038 case WID_PAGE_TOP:
1039 aAny <<= GetPage()->GetUpperBorder();
1040 break;
1041 case WID_PAGE_BOTTOM:
1042 aAny <<= GetPage()->GetLowerBorder();
1043 break;
1044 case WID_PAGE_WIDTH:
1045 aAny <<= static_cast<sal_Int32>( GetPage()->GetSize().getWidth() );
1046 break;
1047 case WID_PAGE_HEIGHT:
1048 aAny <<= static_cast<sal_Int32>( GetPage()->GetSize().getHeight() );
1049 break;
1050 case WID_PAGE_ORIENT:
1051 aAny <<=
1052 GetPage()->GetOrientation() == Orientation::Portrait
1053 ? view::PaperOrientation_PORTRAIT
1054 : view::PaperOrientation_LANDSCAPE;
1055 break;
1056 case WID_PAGE_EFFECT:
1057 aAny <<= GetPage()->GetFadeEffect();
1058 break;
1059 case WID_PAGE_CHANGE:
1060 aAny <<= static_cast<sal_Int32>( GetPage()->GetPresChange() );
1061 break;
1062 case WID_PAGE_SPEED:
1064 const double fDuration = GetPage()->getTransitionDuration();
1065 aAny <<= presentation::AnimationSpeed(
1066 fDuration < 2.0 ? 2 : fDuration > 2.0 ? 0 : 1);
1068 break;
1069 case WID_PAGE_LAYOUT:
1070 aAny <<= static_cast<sal_Int16>( GetPage()->GetAutoLayout() );
1071 break;
1072 case WID_PAGE_SLIDE_LAYOUT:
1073 aAny = mSlideLayout;
1074 break;
1075 case WID_PAGE_NUMBER:
1077 const sal_uInt16 nPageNumber(GetPage()->GetPageNum());
1079 if(nPageNumber > 0)
1081 // for all other pages calculate the number
1082 aAny <<= static_cast<sal_Int16>(static_cast<sal_uInt16>((nPageNumber-1)>>1) + 1);
1084 else
1086 aAny <<= mnTempPageNumber;
1089 break;
1090 case WID_PAGE_DURATION:
1091 aAny <<= static_cast<sal_Int32>( GetPage()->GetTime() + .5 );
1092 break;
1093 case WID_PAGE_HIGHRESDURATION:
1094 aAny <<= GetPage()->GetTime();
1095 break;
1096 case WID_PAGE_LDNAME:
1098 const OUString aName( GetPage()->GetName() );
1099 aAny <<= aName;
1100 break;
1102 case WID_PAGE_LDBITMAP:
1104 Reference< awt::XBitmap > xBitmap(VCLUnoHelper::CreateBitmap(BitmapEx(BMP_PAGE)));
1105 aAny <<= xBitmap;
1107 break;
1108 case WID_PAGE_BACK:
1109 getBackground( aAny );
1110 break;
1111 case WID_PAGE_PREVIEW :
1112 case WID_PAGE_PREVIEWMETAFILE :
1114 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1115 ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
1116 if ( pDocShell )
1118 sal_uInt16 nPgNum = 0;
1119 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
1120 sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1121 while( nPgNum < nPageCount )
1123 rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
1124 nPgNum++;
1126 std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
1127 if (xMetaFile)
1129 Size aSize( GetPage()->GetSize() );
1130 xMetaFile->AddAction( new MetaFillColorAction( COL_WHITE, true ), 0 );
1131 xMetaFile->AddAction( new MetaRectAction( ::tools::Rectangle( Point(), aSize ) ), 1 );
1132 xMetaFile->SetPrefMapMode(MapMode(MapUnit::Map100thMM));
1133 xMetaFile->SetPrefSize( aSize );
1135 SvMemoryStream aDestStrm( 65535, 65535 );
1136 if (nEntry == WID_PAGE_PREVIEW)
1137 // Preview: WMF format.
1138 ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
1139 else
1141 // PreviewMetafile: SVM format.
1142 SvmWriter aWriter(aDestStrm);
1143 aWriter.Write(*xMetaFile);
1145 Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
1146 aAny <<= aSeq;
1150 break;
1152 case WID_PAGE_PREVIEWBITMAP :
1154 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1155 ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
1156 if ( pDocShell )
1158 sal_uInt16 nPgNum = 0;
1159 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
1160 sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
1161 while( nPgNum < nPageCount )
1163 rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
1164 nPgNum++;
1166 std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
1167 BitmapEx aBitmap;
1168 if (xMetaFile && xMetaFile->CreateThumbnail(aBitmap))
1170 SvMemoryStream aMemStream;
1171 WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false);
1172 uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aMemStream.GetData()), aMemStream.Tell() );
1173 aAny <<= aSeq;
1177 break;
1179 case WID_PAGE_VISIBLE :
1181 bool bVisible = !GetPage()->IsExcluded();
1182 aAny <<= bVisible;
1183 break;
1186 case WID_PAGE_SOUNDFILE :
1188 if( GetPage()->IsStopSound() )
1190 aAny <<= true;
1192 else
1194 OUString aURL;
1195 if( GetPage()->IsSoundOn() )
1196 aURL = GetPage()->GetSoundFile();
1197 aAny <<= aURL;
1199 break;
1201 case WID_LOOP_SOUND:
1203 aAny <<= GetPage()->IsLoopSound();
1204 break;
1206 case WID_PAGE_BACKFULL:
1208 bool bFullSize = GetPage()->IsBackgroundFullSize();
1209 aAny <<= bFullSize;
1210 break;
1212 case WID_PAGE_BACKVIS:
1214 SdrPage* pPage = GetPage();
1215 if( pPage )
1217 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
1218 if( rDoc.GetMasterPageCount() )
1220 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
1221 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1222 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background));
1224 else
1226 aAny <<= false;
1229 break;
1231 case WID_PAGE_BACKOBJVIS:
1233 SdrPage* pPage = GetPage();
1234 if( pPage )
1236 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
1237 if( rDoc.GetMasterPageCount() )
1239 SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
1240 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
1241 aAny <<= aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects));
1243 else
1245 aAny <<= false;
1248 break;
1250 case WID_PAGE_USERATTRIBS:
1252 GetPage()->getAlienAttributes( aAny );
1253 break;
1255 case WID_PAGE_BOOKMARK:
1257 aAny <<= getBookmarkURL();
1258 break;
1260 case WID_PAGE_ISDARK:
1262 aAny <<= GetPage()->GetPageBackgroundColor().IsDark();
1263 break;
1265 case WID_PAGE_HEADERVISIBLE:
1266 aAny <<= GetPage()->getHeaderFooterSettings().mbHeaderVisible;
1267 break;
1268 case WID_PAGE_HEADERTEXT:
1270 const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText );
1271 aAny <<= aText;
1273 break;
1274 case WID_PAGE_FOOTERVISIBLE:
1275 aAny <<= GetPage()->getHeaderFooterSettings().mbFooterVisible;
1276 break;
1277 case WID_PAGE_FOOTERTEXT:
1279 const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText );
1280 aAny <<= aText;
1282 break;
1283 case WID_PAGE_PAGENUMBERVISIBLE:
1284 aAny <<= GetPage()->getHeaderFooterSettings().mbSlideNumberVisible;
1285 break;
1286 case WID_PAGE_DATETIMEVISIBLE:
1287 aAny <<= GetPage()->getHeaderFooterSettings().mbDateTimeVisible;
1288 break;
1289 case WID_PAGE_DATETIMEFIXED:
1290 aAny <<= GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed;
1291 break;
1292 case WID_PAGE_DATETIMETEXT:
1294 const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText );
1295 aAny <<= aText;
1297 break;
1298 case WID_PAGE_DATETIMEFORMAT:
1300 auto const & rSettings = GetPage()->getHeaderFooterSettings();
1301 sal_Int32 x = static_cast<sal_Int32>(rSettings.meDateFormat) | (static_cast<sal_Int32>(rSettings.meTimeFormat) << 4);
1302 aAny <<= x;
1304 break;
1306 case WID_TRANSITION_TYPE:
1307 aAny <<= GetPage()->getTransitionType();
1308 break;
1310 case WID_TRANSITION_SUBTYPE:
1311 aAny <<= GetPage()->getTransitionSubtype();
1312 break;
1314 case WID_TRANSITION_DIRECTION:
1315 aAny <<= GetPage()->getTransitionDirection();
1316 break;
1318 case WID_TRANSITION_FADE_COLOR:
1319 aAny <<= GetPage()->getTransitionFadeColor();
1320 break;
1322 case WID_TRANSITION_DURATION:
1323 aAny <<= GetPage()->getTransitionDuration();
1324 break;
1326 case WID_PAGE_THEME:
1328 SdrPage* pPage = GetPage();
1329 css::uno::Reference<css::util::XTheme> xTheme;
1330 auto pTheme = pPage->getSdrPageProperties().getTheme();
1331 if (pTheme)
1332 xTheme = model::theme::createXTheme(pTheme);
1333 aAny <<= xTheme;
1334 break;
1337 case WID_PAGE_THEME_UNO_REPRESENTATION:
1339 SdrPage* pPage = GetPage();
1340 auto pTheme = pPage->getSdrPageProperties().getTheme();
1341 if (pTheme)
1342 pTheme->ToAny(aAny);
1343 else
1345 beans::PropertyValues aValues;
1346 aAny <<= aValues;
1348 break;
1351 default:
1352 throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
1354 return aAny;
1357 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {}
1358 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {}
1359 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {}
1360 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {}
1362 // XMultiPropertySet
1363 void SAL_CALL SdGenericDrawPage::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues )
1365 if( aPropertyNames.getLength() != aValues.getLength() )
1366 throw lang::IllegalArgumentException();
1368 const OUString* pNames = aPropertyNames.getConstArray();
1369 const Any* pValues = aValues.getConstArray();
1370 sal_uInt32 nCount = aValues.getLength();
1371 while( nCount-- )
1375 setPropertyValue( *pNames++, *pValues++ );
1377 catch( beans::UnknownPropertyException& )
1379 // ignore for multi property set
1380 // todo: optimize this!
1385 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames )
1387 sal_Int32 nCount = aPropertyNames.getLength();
1388 Sequence< Any > aValues( nCount );
1389 std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.getArray(),
1390 [this](const OUString& rName) -> Any {
1391 Any aValue;
1394 aValue = getPropertyValue(rName);
1396 catch( beans::UnknownPropertyException& )
1398 // ignore for multi property set
1399 // todo: optimize this!
1401 return aValue;
1403 return aValues;
1406 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& )
1410 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& )
1414 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& )
1418 Reference< drawing::XShape > SdGenericDrawPage::CreateShape(SdrObject *pObj) const
1420 DBG_ASSERT( GetPage(), "SdGenericDrawPage::CreateShape(), can't create shape for disposed page!" );
1421 DBG_ASSERT( pObj, "SdGenericDrawPage::CreateShape(), invalid call with pObj == 0!" );
1423 if (!pObj)
1424 return Reference< drawing::XShape >();
1426 if (GetPage())
1428 PresObjKind eKind = GetPage()->GetPresObjKind(pObj);
1430 rtl::Reference<SvxShape> pShape;
1432 if(pObj->GetObjInventor() == SdrInventor::Default)
1434 SdrObjKind nInventor = pObj->GetObjIdentifier();
1435 switch( nInventor )
1437 case SdrObjKind::TitleText:
1438 pShape = new SvxShapeText( pObj );
1439 if( GetPage()->GetPageKind() == PageKind::Notes && GetPage()->IsMasterPage() )
1441 // fake an empty PageShape if it's a title shape on the master page
1442 pShape->SetShapeType(u"com.sun.star.presentation.PageShape"_ustr);
1444 else
1446 pShape->SetShapeType(u"com.sun.star.presentation.TitleTextShape"_ustr);
1448 eKind = PresObjKind::NONE;
1449 break;
1450 case SdrObjKind::OutlineText:
1451 pShape = new SvxShapeText( pObj );
1452 pShape->SetShapeType(u"com.sun.star.presentation.OutlinerShape"_ustr);
1453 eKind = PresObjKind::NONE;
1454 break;
1455 default: ;
1459 Reference< drawing::XShape > xShape( pShape );
1461 if(!xShape.is())
1462 xShape = SvxDrawPage::CreateShape( pObj );
1464 if( eKind != PresObjKind::NONE )
1466 OUString aShapeType(u"com.sun.star.presentation."_ustr);
1468 switch( eKind )
1470 case PresObjKind::Title:
1471 aShapeType += "TitleTextShape";
1472 break;
1473 case PresObjKind::Outline:
1474 aShapeType += "OutlinerShape";
1475 break;
1476 case PresObjKind::Text:
1477 aShapeType += "SubtitleShape";
1478 break;
1479 case PresObjKind::Graphic:
1480 aShapeType += "GraphicObjectShape";
1481 break;
1482 case PresObjKind::Object:
1483 aShapeType += "OLE2Shape";
1484 break;
1485 case PresObjKind::Chart:
1486 aShapeType += "ChartShape";
1487 break;
1488 case PresObjKind::OrgChart:
1489 aShapeType += "OrgChartShape";
1490 break;
1491 case PresObjKind::Calc:
1492 aShapeType += "CalcShape";
1493 break;
1494 case PresObjKind::Table:
1495 aShapeType += "TableShape";
1496 break;
1497 case PresObjKind::Media:
1498 aShapeType += "MediaShape";
1499 break;
1500 case PresObjKind::Page:
1501 aShapeType += "PageShape";
1502 break;
1503 case PresObjKind::Handout:
1504 aShapeType += "HandoutShape";
1505 break;
1506 case PresObjKind::Notes:
1507 aShapeType += "NotesShape";
1508 break;
1509 case PresObjKind::Footer:
1510 aShapeType += "FooterShape";
1511 break;
1512 case PresObjKind::Header:
1513 aShapeType += "HeaderShape";
1514 break;
1515 case PresObjKind::SlideNumber:
1516 aShapeType += "SlideNumberShape";
1517 break;
1518 case PresObjKind::DateTime:
1519 aShapeType += "DateTimeShape";
1520 break;
1521 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
1522 case PresObjKind::NONE:
1523 break;
1526 if( !pShape )
1527 pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape );
1529 if( pShape )
1530 pShape->SetShapeType( aShapeType );
1533 SvxShape *pSdShape = comphelper::getFromUnoTunnel<SvxShape>(xShape);
1534 if (pSdShape)
1536 // SdXShape aggregates SvxShape
1537 new SdXShape(pSdShape, GetModel());
1539 return xShape;
1541 else
1543 return SvxDrawPage::CreateShape( pObj );
1548 // XServiceInfo
1549 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames()
1551 return comphelper::concatSequences(
1552 SvxDrawPage::getSupportedServiceNames(),
1553 std::initializer_list<std::u16string_view>{ u"com.sun.star.drawing.GenericDrawPage",
1554 u"com.sun.star.document.LinkTarget",
1555 u"com.sun.star.document.LinkTargetSupplier" });
1558 // XLinkTargetSupplier
1559 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( )
1561 return new SdPageLinkTargets( this );
1564 void SdGenericDrawPage::setBackground( const Any& )
1566 OSL_FAIL( "Don't call me, I'm useless!" );
1569 void SdGenericDrawPage::getBackground( Any& )
1571 OSL_FAIL( "Don't call me, I'm useless!" );
1574 OUString SdGenericDrawPage::getBookmarkURL() const
1576 OUString aRet;
1577 if( SvxDrawPage::mpPage )
1579 OUString aFileName( static_cast<SdPage*>(SvxDrawPage::mpPage)->GetFileName() );
1580 if( !aFileName.isEmpty() )
1582 const OUString aBookmarkName( SdDrawPage::getPageApiNameFromUiName( static_cast<SdPage*>(SvxDrawPage::mpPage)->GetBookmarkName() ) );
1583 aRet = aFileName + "#" + aBookmarkName;
1587 return aRet;
1590 void SdGenericDrawPage::setBookmarkURL( std::u16string_view rURL )
1592 if( !SvxDrawPage::mpPage )
1593 return;
1595 size_t nIndex = rURL.find( '#' );
1596 if( nIndex == std::u16string_view::npos )
1597 return;
1599 const OUString aFileName( rURL.substr( 0, nIndex ) );
1600 const OUString aBookmarkName( SdDrawPage::getUiNameFromPageApiName( OUString(rURL.substr( nIndex+1 )) ) );
1602 if( !aFileName.isEmpty() && !aBookmarkName.isEmpty() )
1604 static_cast<SdPage*>(SvxDrawPage::mpPage)->DisconnectLink();
1605 static_cast<SdPage*>(SvxDrawPage::mpPage)->SetFileName( aFileName );
1606 static_cast<SdPage*>(SvxDrawPage::mpPage)->SetBookmarkName( aBookmarkName );
1607 static_cast<SdPage*>(SvxDrawPage::mpPage)->ConnectLink();
1611 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes )
1613 ::SolarMutexGuard aGuard;
1615 throwIfDisposed();
1617 DBG_ASSERT(SvxDrawPage::mpPage,"SdrPage is NULL! [CL]");
1618 DBG_ASSERT(mpView, "SdrView is NULL! [CL]");
1620 Reference< drawing::XShape > xShape;
1621 if(mpView==nullptr||!xShapes.is()||GetPage()==nullptr)
1622 return xShape;
1624 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1626 SelectObjectsInView( xShapes, pPageView );
1628 mpView->CombineMarkedObjects( false );
1630 mpView->AdjustMarkHdl();
1631 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1632 if( rMarkList.GetMarkCount() == 1 )
1634 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1635 if( pObj )
1636 xShape.set( pObj->getUnoShape(), UNO_QUERY );
1639 mpView->HideSdrPage();
1641 GetModel()->SetModified();
1643 return xShape;
1646 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup )
1648 ::SolarMutexGuard aGuard;
1650 throwIfDisposed();
1652 if(mpView==nullptr||!xGroup.is()||GetPage()==nullptr)
1653 return;
1655 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1656 SelectObjectInView( xGroup, pPageView );
1657 mpView->DismantleMarkedObjects();
1658 mpView->HideSdrPage();
1660 GetModel()->SetModified();
1663 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes )
1665 ::SolarMutexGuard aGuard;
1667 throwIfDisposed();
1669 uno::Reference< drawing::XShape > xShape;
1670 if(mpView==nullptr||!xShapes.is()||GetPage()==nullptr)
1671 return xShape;
1673 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1675 SelectObjectsInView( xShapes, pPageView );
1677 mpView->CombineMarkedObjects();
1679 mpView->AdjustMarkHdl();
1680 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
1681 if( rMarkList.GetMarkCount() == 1 )
1683 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
1684 if( pObj )
1685 xShape.set( pObj->getUnoShape(), UNO_QUERY );
1688 mpView->HideSdrPage();
1690 GetModel()->SetModified();
1692 return xShape;
1695 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape )
1697 ::SolarMutexGuard aGuard;
1699 throwIfDisposed();
1701 if(mpView==nullptr||!xShape.is()||GetPage()==nullptr)
1702 return;
1704 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() );
1705 SelectObjectInView( xShape, pPageView );
1706 mpView->DismantleMarkedObjects( true );
1707 mpView->HideSdrPage();
1709 GetModel()->SetModified();
1712 void SdGenericDrawPage::SetLeftBorder( sal_Int32 nValue )
1714 if( nValue == GetPage()->GetLeftBorder() )
1715 return;
1717 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1718 const PageKind ePageKind = GetPage()->GetPageKind();
1720 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1721 for (i = 0; i < nPageCnt; i++)
1723 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1724 pPage->SetLeftBorder( nValue );
1727 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1729 for (i = 0; i < nPageCnt; i++)
1731 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1732 pPage->SetLeftBorder( nValue );
1736 void SdGenericDrawPage::SetRightBorder( sal_Int32 nValue )
1738 if( nValue == GetPage()->GetRightBorder() )
1739 return;
1741 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1742 const PageKind ePageKind = GetPage()->GetPageKind();
1744 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1745 for (i = 0; i < nPageCnt; i++)
1747 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1748 pPage->SetRightBorder( nValue );
1751 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1753 for (i = 0; i < nPageCnt; i++)
1755 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1756 pPage->SetRightBorder( nValue );
1760 void SdGenericDrawPage::SetUpperBorder( sal_Int32 nValue )
1762 if( nValue == GetPage()->GetUpperBorder() )
1763 return;
1765 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1766 const PageKind ePageKind = GetPage()->GetPageKind();
1768 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1769 for (i = 0; i < nPageCnt; i++)
1771 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1772 pPage->SetUpperBorder( nValue );
1775 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1777 for (i = 0; i < nPageCnt; i++)
1779 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1780 pPage->SetUpperBorder( nValue );
1784 void SdGenericDrawPage::SetLowerBorder( sal_Int32 nValue )
1786 if( nValue == GetPage()->GetLowerBorder() )
1787 return;
1789 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1790 const PageKind ePageKind = GetPage()->GetPageKind();
1792 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1793 for (i = 0; i < nPageCnt; i++)
1795 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1796 pPage->SetLowerBorder( nValue );
1799 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1801 for (i = 0; i < nPageCnt; i++)
1803 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1804 pPage->SetLowerBorder( nValue );
1808 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind )
1810 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
1811 if ( !pDocShell )
1812 return;
1814 ::sd::ViewShell* pViewSh = pDocShell->GetViewShell();
1816 if( !pViewSh )
1817 return;
1819 if( auto pDrawViewShell = dynamic_cast<::sd::DrawViewShell* >(pViewSh) )
1820 pDrawViewShell->ResetActualPage();
1822 Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize();
1823 const tools::Long nWidth = aPageSize.Width();
1824 const tools::Long nHeight = aPageSize.Height();
1826 Point aPageOrg(nWidth, nHeight / 2);
1827 Size aViewSize(nWidth * 3, nHeight * 2);
1829 pDoc->SetMaxObjSize(aViewSize);
1831 pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), true);
1833 pViewSh->UpdateScrollBars();
1836 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth )
1838 Size aSize( GetPage()->GetSize() );
1839 if( aSize.getWidth() == nWidth )
1840 return;
1842 aSize.setWidth( nWidth );
1844 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1845 const PageKind ePageKind = GetPage()->GetPageKind();
1847 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1848 for (i = 0; i < nPageCnt; i++)
1850 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1851 pPage->SetSize(aSize);
1854 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1856 for (i = 0; i < nPageCnt; i++)
1858 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1859 pPage->SetSize(aSize);
1862 refreshpage( &rDoc, ePageKind );
1865 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight )
1867 Size aSize( GetPage()->GetSize() );
1868 if( aSize.getHeight() == nHeight )
1869 return;
1871 aSize.setHeight( nHeight );
1873 SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
1874 const PageKind ePageKind = GetPage()->GetPageKind();
1876 sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
1877 for (i = 0; i < nPageCnt; i++)
1879 SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
1880 pPage->SetSize(aSize);
1883 nPageCnt = rDoc.GetSdPageCount(ePageKind);
1885 for (i = 0; i < nPageCnt; i++)
1887 SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
1888 pPage->SetSize(aSize);
1891 refreshpage( &rDoc, ePageKind );
1894 // XComponent
1895 void SdGenericDrawPage::disposing() noexcept
1897 mpDocModel = nullptr;
1898 SvxDrawPage::disposing();
1901 // XAnimationNodeSupplier
1902 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode()
1904 ::SolarMutexGuard aGuard;
1906 throwIfDisposed();
1908 SdPage *pSdPage = static_cast<SdPage*>(SvxDrawPage::mpPage);
1910 return pSdPage->getAnimationNode();
1913 // SdPageLinkTargets
1914 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) noexcept
1916 mxPage = pUnoPage;
1919 SdPageLinkTargets::~SdPageLinkTargets() noexcept
1923 // XElementAccess
1924 uno::Type SAL_CALL SdPageLinkTargets::getElementType()
1926 return cppu::UnoType<beans::XPropertySet>::get();
1929 sal_Bool SAL_CALL SdPageLinkTargets::hasElements()
1931 ::SolarMutexGuard aGuard;
1933 SdPage* pPage = mxPage->GetPage();
1934 if( pPage != nullptr )
1936 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1938 while( aIter.IsMore() )
1940 SdrObject* pObj = aIter.Next();
1941 OUString aStr( pObj->GetName() );
1942 if( aStr.isEmpty() )
1943 if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
1944 aStr = pOleObj->GetPersistName();
1945 if( !aStr.isEmpty() )
1946 return true;
1950 return false;
1953 // container::XNameAccess
1955 // XNameAccess
1956 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName )
1958 ::SolarMutexGuard aGuard;
1960 SdPage* pPage = mxPage->GetPage();
1961 if( pPage != nullptr )
1963 SdrObject* pObj = FindObject( aName );
1964 if( pObj )
1966 Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY );
1967 return Any( aRef );
1971 throw container::NoSuchElementException();
1974 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames()
1976 ::SolarMutexGuard aGuard;
1978 sal_uInt32 nObjCount = 0;
1980 SdPage* pPage = mxPage->GetPage();
1981 if( pPage != nullptr )
1983 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1984 while( aIter.IsMore() )
1986 SdrObject* pObj = aIter.Next();
1987 OUString aStr( pObj->GetName() );
1988 if( aStr.isEmpty() )
1989 if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
1990 aStr = pOleObj->GetPersistName();
1991 if( !aStr.isEmpty() )
1992 nObjCount++;
1996 Sequence< OUString > aSeq( nObjCount );
1997 if( nObjCount > 0 )
1999 OUString* pStr = aSeq.getArray();
2001 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
2002 while( aIter.IsMore() )
2004 SdrObject* pObj = aIter.Next();
2005 OUString aStr( pObj->GetName() );
2006 if( aStr.isEmpty() )
2007 if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
2008 aStr = pOleObj->GetPersistName();
2009 if( !aStr.isEmpty() )
2010 *pStr++ = aStr;
2014 return aSeq;
2017 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName )
2019 ::SolarMutexGuard aGuard;
2021 return FindObject( aName ) != nullptr;
2024 SdrObject* SdPageLinkTargets::FindObject( std::u16string_view rName ) const noexcept
2026 SdPage* pPage = mxPage->GetPage();
2027 if( pPage == nullptr )
2028 return nullptr;
2030 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
2032 while( aIter.IsMore() )
2034 SdrObject* pObj = aIter.Next();
2035 OUString aStr( pObj->GetName() );
2036 if( aStr.isEmpty() )
2037 if (auto pOleObj = dynamic_cast< const SdrOle2Obj *>( pObj ))
2038 aStr = pOleObj->GetPersistName();
2039 if( !aStr.isEmpty() && (aStr == rName) )
2040 return pObj;
2043 return nullptr;
2046 // XServiceInfo
2047 OUString SAL_CALL SdPageLinkTargets::getImplementationName()
2049 return u"SdPageLinkTargets"_ustr;
2052 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName )
2054 return cppu::supportsService( this, ServiceName );
2057 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames()
2059 return { u"com.sun.star.document.LinkTargets"_ustr };
2062 // SdDrawPage
2063 SdDrawPage::SdDrawPage(SdXImpressDocument* pModel, SdPage* pPage)
2064 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) )
2068 SdDrawPage::~SdDrawPage() noexcept
2072 // XInterface
2073 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType )
2075 if( rType == cppu::UnoType<drawing::XMasterPageTarget>::get() )
2077 return Any( Reference< drawing::XMasterPageTarget >( this ) );
2079 else if( IsImpressDocument()
2080 && rType == cppu::UnoType<presentation::XPresentationPage>::get() )
2082 SdPage * p = dynamic_cast<SdPage *>(SvxDrawPage::mpPage);
2083 if( p == nullptr || p->GetPageKind() != PageKind::Handout )
2085 return Any( Reference< presentation::XPresentationPage >( this ) );
2089 return SdGenericDrawPage::queryInterface( rType );
2092 void SAL_CALL SdDrawPage::acquire() noexcept
2094 SvxDrawPage::acquire();
2097 void SAL_CALL SdDrawPage::release() noexcept
2099 SvxDrawPage::release();
2102 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage );
2104 // XTypeProvider
2105 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes()
2107 ::SolarMutexGuard aGuard;
2109 throwIfDisposed();
2111 if( !maTypeSequence.hasElements() )
2113 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
2114 bool bPresPage = IsImpressDocument() && ePageKind != PageKind::Handout;
2116 // Collect the types of this class.
2117 ::std::vector<uno::Type> aTypes;
2118 aTypes.reserve(13);
2119 aTypes.push_back(cppu::UnoType<drawing::XDrawPage>::get());
2120 aTypes.push_back(cppu::UnoType<beans::XPropertySet>::get());
2121 aTypes.push_back(cppu::UnoType<container::XNamed>::get());
2122 aTypes.push_back(cppu::UnoType<drawing::XMasterPageTarget>::get());
2123 aTypes.push_back(cppu::UnoType<lang::XServiceInfo>::get());
2124 aTypes.push_back(cppu::UnoType<util::XReplaceable>::get());
2125 aTypes.push_back(cppu::UnoType<document::XLinkTargetSupplier>::get());
2126 aTypes.push_back(cppu::UnoType<drawing::XShapeCombiner>::get());
2127 aTypes.push_back(cppu::UnoType<drawing::XShapeBinder>::get());
2128 aTypes.push_back(cppu::UnoType<office::XAnnotationAccess>::get());
2129 aTypes.push_back(cppu::UnoType<beans::XMultiPropertySet>::get());
2130 if( bPresPage )
2131 aTypes.push_back(cppu::UnoType<presentation::XPresentationPage>::get());
2132 if( bPresPage && ePageKind == PageKind::Standard )
2133 aTypes.push_back(cppu::UnoType<XAnimationNodeSupplier>::get());
2135 // Get types of base class.
2136 // Join those types in a sequence.
2137 return comphelper::concatSequences(
2138 comphelper::containerToSequence(aTypes),
2139 SdGenericDrawPage::getTypes() );
2142 return maTypeSequence;
2145 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId()
2147 return css::uno::Sequence<sal_Int8>();
2150 OUString SdDrawPage::getPageApiName( SdPage const * pPage )
2152 return ::getPageApiName( pPage );
2155 OUString getPageApiName( SdPage const * pPage )
2157 OUString aPageName;
2159 if(pPage)
2161 aPageName = pPage->GetRealName();
2163 if( aPageName.isEmpty() )
2165 const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1;
2166 aPageName = sEmptyPageName + OUString::number( nPageNum );
2170 return aPageName;
2173 OUString getPageApiNameFromUiName( const OUString& rUIName )
2175 OUString aApiName;
2177 OUString aDefPageName(SdResId(STR_PAGE) + " ");
2179 if( rUIName.startsWith( aDefPageName ) )
2181 aApiName = OUString::Concat(sEmptyPageName) + rUIName.subView( aDefPageName.getLength() );
2183 else
2185 aApiName = rUIName;
2188 return aApiName;
2191 OUString SdDrawPage::getPageApiNameFromUiName( const OUString& rUIName )
2193 return ::getPageApiNameFromUiName( rUIName );
2196 OUString getUiNameFromPageApiNameImpl( const OUString& rApiName )
2198 const OUString aDefPageName( sEmptyPageName );
2199 if( rApiName.startsWith( aDefPageName ) )
2201 std::u16string_view aNumber( rApiName.subView( aDefPageName.getLength() ) );
2203 // create the page number
2204 sal_Int32 nPageNumber = o3tl::toInt32(aNumber);
2206 // check if there are non number characters in the number part
2207 const size_t nChars = aNumber.size();
2208 const sal_Unicode* pString = aNumber.data();
2209 for( size_t nChar = 0; nChar < nChars; nChar++, pString++ )
2211 if((*pString < '0') || (*pString > '9'))
2213 // found a non number character, so this is not the default
2214 // name for this page
2215 nPageNumber = -1;
2216 break;
2220 if( nPageNumber != -1)
2222 return SdResId(STR_PAGE) + " " + aNumber;
2226 return rApiName;
2229 OUString SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName )
2231 return getUiNameFromPageApiNameImpl( rApiName );
2234 // XServiceInfo
2235 OUString SAL_CALL SdDrawPage::getImplementationName()
2237 return u"SdDrawPage"_ustr;
2240 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames()
2242 ::SolarMutexGuard aGuard;
2244 throwIfDisposed();
2246 std::vector<std::u16string_view> aAdd{ u"com.sun.star.drawing.DrawPage" };
2248 if( IsImpressDocument() )
2249 aAdd.emplace_back(u"com.sun.star.presentation.DrawPage");
2251 return comphelper::concatSequences(SdGenericDrawPage::getSupportedServiceNames(), aAdd);
2254 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName )
2256 return cppu::supportsService( this, ServiceName );
2259 // XNamed
2260 void SAL_CALL SdDrawPage::setName( const OUString& rName )
2262 ::SolarMutexGuard aGuard;
2264 throwIfDisposed();
2266 DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" );
2268 OUString aName( rName );
2270 if(!(GetPage() && GetPage()->GetPageKind() != PageKind::Notes))
2271 return;
2273 // check if this is the default 'page1234' name
2274 std::u16string_view aNumber;
2275 if(o3tl::starts_with(aName, sEmptyPageName, &aNumber ))
2277 // ok, it maybe is, aNumber is the number part after 'page'
2279 // create the page number
2280 sal_Int32 nPageNumber = o3tl::toInt32(aNumber);
2282 // check if there are non number characters in the number part
2283 const sal_Int32 nChars = aNumber.size();
2284 const sal_Unicode* pString = aNumber.data();
2285 sal_Int32 nChar;
2286 for( nChar = 0; nChar < nChars; nChar++, pString++ )
2288 if((*pString < '0') || (*pString > '9'))
2290 // found a non number character, so this is not the default
2291 // name for this page
2292 nPageNumber = -1;
2293 break;
2297 if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 )
2298 aName.clear();
2300 else
2302 OUString aDefaultPageName( SdResId(STR_PAGE) + " " );
2303 if( aName.startsWith( aDefaultPageName ) )
2304 aName.clear();
2307 GetPage()->SetName( aName );
2309 sal_uInt16 nNotesPageNum = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
2310 if( GetModel()->GetDoc()->GetSdPageCount( PageKind::Notes ) > nNotesPageNum )
2312 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PageKind::Notes );
2313 if( pNotesPage )
2314 pNotesPage->SetName(aName);
2317 // fake a mode change to repaint the page tab bar
2318 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2319 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
2320 if( auto pDrawViewSh = dynamic_cast<::sd::DrawViewShell* >(pViewSh) )
2322 EditMode eMode = pDrawViewSh->GetEditMode();
2323 if( eMode == EditMode::Page )
2325 bool bLayer = pDrawViewSh->IsLayerModeActive();
2327 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
2328 pDrawViewSh->ChangeEditMode( eMode, bLayer );
2332 GetModel()->SetModified();
2335 OUString SAL_CALL SdDrawPage::getName()
2337 ::SolarMutexGuard aGuard;
2339 throwIfDisposed();
2341 return getPageApiName( GetPage() );
2344 // XMasterPageTarget
2345 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( )
2347 return static_cast<SdGenericDrawPage*>(getSdMasterPage());
2350 SdMasterPage* SdDrawPage::getSdMasterPage()
2352 ::SolarMutexGuard aGuard;
2354 throwIfDisposed();
2356 if(GetPage())
2358 if(SvxDrawPage::mpPage->TRG_HasMasterPage())
2360 SdrPage& rMasterPage = SvxDrawPage::mpPage->TRG_GetMasterPage();
2361 return dynamic_cast<SdMasterPage*>(rMasterPage.getUnoPage().get());
2364 return nullptr;
2367 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage )
2369 ::SolarMutexGuard aGuard;
2370 comphelper::ProfileZone aZone("setMasterPage");
2372 throwIfDisposed();
2374 if(!SvxDrawPage::mpPage)
2375 return;
2377 SdMasterPage* pMasterPage = comphelper::getFromUnoTunnel<SdMasterPage>( xMasterPage );
2378 if( !(pMasterPage && pMasterPage->isValid()) )
2379 return;
2381 SvxDrawPage::mpPage->TRG_ClearMasterPage();
2383 SdPage* pSdPage = static_cast<SdPage*>(pMasterPage->GetSdrPage());
2384 SvxDrawPage::mpPage->TRG_SetMasterPage(*pSdPage);
2386 SvxDrawPage::mpPage->SetBorder(pSdPage->GetLeftBorder(),pSdPage->GetUpperBorder(),
2387 pSdPage->GetRightBorder(),pSdPage->GetLowerBorder() );
2389 SvxDrawPage::mpPage->SetSize( pSdPage->GetSize() );
2390 SvxDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() );
2391 static_cast<SdPage*>(SvxDrawPage::mpPage)->SetLayoutName( pSdPage->GetLayoutName() );
2393 // set notes master also
2394 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
2396 pNotesPage->TRG_ClearMasterPage();
2397 sal_uInt16 nNum = SvxDrawPage::mpPage->TRG_GetMasterPage().GetPageNum() + 1;
2398 pNotesPage->TRG_SetMasterPage(*SvxDrawPage::mpPage->getSdrModelFromSdrPage().GetMasterPage(nNum));
2399 pNotesPage->SetLayoutName( pSdPage->GetLayoutName() );
2401 GetModel()->SetModified();
2404 // XPresentationPage
2405 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage()
2407 ::SolarMutexGuard aGuard;
2409 throwIfDisposed();
2411 if(SvxDrawPage::mpPage && GetModel()->GetDoc() && SvxDrawPage::mpPage->GetPageNum() )
2413 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
2414 if( pNotesPage )
2416 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
2417 return xPage;
2420 return nullptr;
2423 // XIndexAccess
2424 sal_Int32 SAL_CALL SdDrawPage::getCount()
2426 return SdGenericDrawPage::getCount();
2429 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index )
2431 return SdGenericDrawPage::getByIndex( Index );
2434 // XElementAccess
2435 uno::Type SAL_CALL SdDrawPage::getElementType()
2437 return SdGenericDrawPage::getElementType();
2440 sal_Bool SAL_CALL SdDrawPage::hasElements()
2442 return SdGenericDrawPage::hasElements();
2445 // XShapes
2446 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape )
2448 SdGenericDrawPage::add( xShape );
2451 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape )
2453 ::SolarMutexGuard aGuard;
2455 throwIfDisposed();
2457 SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
2458 if( pObj )
2460 GetPage()->RemovePresObj(pObj);
2461 pObj->SetUserCall(nullptr);
2464 SdGenericDrawPage::remove( xShape );
2467 void SdDrawPage::setBackground( const Any& rValue )
2469 Reference< beans::XPropertySet > xSet;
2471 if( !(rValue >>= xSet) && !rValue.hasValue() )
2472 throw lang::IllegalArgumentException();
2474 if( !xSet.is() )
2476 // the easy case, no background set. Set drawing::FillStyle_NONE to represent this
2477 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
2478 return;
2481 // is it our own implementation?
2482 SdUnoPageBackground* pBack = dynamic_cast<SdUnoPageBackground*>( xSet.get() );
2484 SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aSet( GetModel()->GetDoc()->GetPool() );
2486 if( pBack )
2488 pBack->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2490 else
2492 rtl::Reference<SdUnoPageBackground> pBackground = new SdUnoPageBackground();
2494 Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
2495 Reference< beans::XPropertySetInfo > xDestSetInfo( pBackground->getPropertySetInfo() );
2497 const Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() );
2499 for( const beans::Property& rProp : aProperties )
2501 const OUString aPropName( rProp.Name );
2502 if( xSetInfo->hasPropertyByName( aPropName ) )
2503 pBackground->setPropertyValue( aPropName,
2504 xSet->getPropertyValue( aPropName ) );
2507 pBackground->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2510 if( aSet.Count() == 0 )
2512 // no background fill, represent by setting drawing::FillStyle_NONE
2513 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
2515 else
2517 // background fill, set at page (not sure if ClearItem is needed)
2518 GetPage()->getSdrPageProperties().ClearItem();
2519 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2522 // repaint only
2523 SvxDrawPage::mpPage->ActionChanged();
2526 // XAnnotationAccess:
2527 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation()
2529 if( !GetPage() )
2530 throw DisposedException();
2532 auto xAnnotation = GetPage()->createAnnotation();
2533 GetPage()->addAnnotation(xAnnotation);
2534 return xAnnotation;
2537 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation)
2539 rtl::Reference<sd::Annotation> xSdAnnotation = dynamic_cast<sd::Annotation*>(annotation.get());
2540 assert(bool(annotation) == bool(xSdAnnotation) && "must be of concrete type sd::Annotation");
2541 GetPage()->removeAnnotation(xSdAnnotation);
2544 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration()
2546 return sdr::annotation::createAnnotationEnumeration(std::vector(GetPage()->getAnnotations()));
2549 void SdDrawPage::getBackground(Any& rValue)
2551 const SfxItemSet& rFillAttributes = GetPage()->getSdrPageProperties().GetItemSet();
2553 if(drawing::FillStyle_NONE == rFillAttributes.Get(XATTR_FILLSTYLE).GetValue())
2555 // no fill set (switched off by drawing::FillStyle_NONE), clear rValue to represent this
2556 rValue.clear();
2558 else
2560 // there is a fill set, export to rValue
2561 Reference< beans::XPropertySet > xSet(new SdUnoPageBackground(
2562 GetModel()->GetDoc(),
2563 &GetPage()->getSdrPageProperties().GetItemSet()));
2564 rValue <<= xSet;
2568 void SdGenericDrawPage::setNavigationOrder( const Any& rValue )
2570 Reference< XIndexAccess > xIA( rValue, UNO_QUERY );
2571 if( xIA.is() )
2573 if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this )
2575 if( GetPage()->HasObjectNavigationOrder() )
2576 GetPage()->ClearObjectNavigationOrder();
2578 return;
2580 else if( static_cast<size_t>(xIA->getCount()) == GetPage()->GetObjCount() )
2582 GetPage()->SetNavigationOrder(xIA);
2583 return;
2586 throw IllegalArgumentException();
2589 namespace {
2591 class SdNavigationOrderAccess : public ::cppu::WeakImplHelper< XIndexAccess >
2593 public:
2594 explicit SdNavigationOrderAccess(SdrPage const * pPage);
2596 // XIndexAccess
2597 virtual sal_Int32 SAL_CALL getCount( ) override;
2598 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) override;
2600 // XElementAccess
2601 virtual Type SAL_CALL getElementType( ) override;
2602 virtual sal_Bool SAL_CALL hasElements( ) override;
2604 private:
2605 std::vector< Reference< XShape > > maShapes;
2610 SdNavigationOrderAccess::SdNavigationOrderAccess( SdrPage const * pPage )
2611 : maShapes( pPage ? pPage->GetObjCount() : 0 )
2613 if( pPage )
2615 for (const rtl::Reference<SdrObject>& pObj : *pPage)
2617 sal_uInt32 nNavPos = pObj->GetNavigationPosition();
2618 DBG_ASSERT( !maShapes[nNavPos].is(), "sd::SdNavigationOrderAccess::SdNavigationOrderAccess(), duplicate navigation positions from core!" );
2619 maShapes[nNavPos].set( pObj->getUnoShape(), UNO_QUERY );
2624 // XIndexAccess
2625 sal_Int32 SAL_CALL SdNavigationOrderAccess::getCount( )
2627 return static_cast< sal_Int32 >( maShapes.size() );
2630 Any SAL_CALL SdNavigationOrderAccess::getByIndex( sal_Int32 Index )
2632 if( (Index < 0) || (Index > getCount()) )
2633 throw IndexOutOfBoundsException();
2635 return Any( maShapes[Index] );
2638 // XElementAccess
2639 Type SAL_CALL SdNavigationOrderAccess::getElementType( )
2641 return cppu::UnoType<XShape>::get();
2644 sal_Bool SAL_CALL SdNavigationOrderAccess::hasElements( )
2646 return !maShapes.empty();
2649 Any SdGenericDrawPage::getNavigationOrder()
2651 if( GetPage()->HasObjectNavigationOrder() )
2653 return Any( Reference< XIndexAccess >( new SdNavigationOrderAccess( GetPage() ) ) );
2655 else
2657 return Any( Reference< XIndexAccess >( this ) );
2661 SdMasterPage::SdMasterPage(SdXImpressDocument* pModel, SdPage* pPage)
2662 : SdGenericDrawPage(pModel, pPage, ImplGetMasterPagePropertySet(pPage->GetPageKind()))
2666 SdMasterPage::~SdMasterPage() noexcept
2670 // XInterface
2671 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType )
2673 ::SolarMutexGuard aGuard;
2675 throwIfDisposed();
2677 uno::Any aAny;
2679 if( rType == cppu::UnoType<container::XIndexAccess>::get() )
2680 aAny <<= Reference< container::XIndexAccess >(static_cast<presentation::XPresentationPage*>(this));
2681 else if( rType == cppu::UnoType<container::XElementAccess>::get() )
2682 aAny <<= Reference< container::XElementAccess >(static_cast<presentation::XPresentationPage*>(this));
2683 else if( rType == cppu::UnoType<container::XNamed>::get() )
2684 aAny <<= Reference< container::XNamed >(this);
2685 else if( rType == cppu::UnoType<presentation::XPresentationPage>::get() &&
2686 ( IsImpressDocument() &&
2687 GetPage() && GetPage()->GetPageKind() != PageKind::Handout) )
2688 aAny <<= Reference< presentation::XPresentationPage >( this );
2689 else
2690 return SdGenericDrawPage::queryInterface( rType );
2692 return aAny;
2695 void SAL_CALL SdMasterPage::acquire() noexcept
2697 SvxDrawPage::acquire();
2700 void SAL_CALL SdMasterPage::release() noexcept
2702 SvxDrawPage::release();
2705 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage );
2707 // XTypeProvider
2708 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes()
2710 ::SolarMutexGuard aGuard;
2712 throwIfDisposed();
2714 if( !maTypeSequence.hasElements() )
2716 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PageKind::Standard;
2717 bool bPresPage = IsImpressDocument() && SvxDrawPage::mpPage && ePageKind != PageKind::Handout;
2719 // Collect the types of this class.
2720 ::std::vector<uno::Type> aTypes;
2721 aTypes.reserve(12);
2722 aTypes.push_back(cppu::UnoType<drawing::XDrawPage>::get());
2723 aTypes.push_back(cppu::UnoType<beans::XPropertySet>::get());
2724 aTypes.push_back(cppu::UnoType<container::XNamed>::get());
2725 aTypes.push_back(cppu::UnoType<lang::XServiceInfo>::get());
2726 aTypes.push_back(cppu::UnoType<util::XReplaceable>::get());
2727 aTypes.push_back(cppu::UnoType<document::XLinkTargetSupplier>::get());
2728 aTypes.push_back(cppu::UnoType<drawing::XShapeCombiner>::get());
2729 aTypes.push_back(cppu::UnoType<drawing::XShapeBinder>::get());
2730 aTypes.push_back(cppu::UnoType<office::XAnnotationAccess>::get());
2731 aTypes.push_back(cppu::UnoType<beans::XMultiPropertySet>::get());
2732 if( bPresPage )
2733 aTypes.push_back(cppu::UnoType<presentation::XPresentationPage>::get());
2734 if( bPresPage && ePageKind == PageKind::Standard )
2735 aTypes.push_back(cppu::UnoType<XAnimationNodeSupplier>::get());
2737 // Get types of base class.
2738 // Join those types in a sequence.
2739 return comphelper::concatSequences(
2740 comphelper::containerToSequence(aTypes),
2741 SdGenericDrawPage::getTypes() );
2744 return maTypeSequence;
2747 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId()
2749 return css::uno::Sequence<sal_Int8>();
2752 // XServiceInfo
2753 OUString SAL_CALL SdMasterPage::getImplementationName()
2755 return u"SdMasterPage"_ustr;
2758 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames()
2760 ::SolarMutexGuard aGuard;
2762 throwIfDisposed();
2764 std::vector<std::u16string_view> aAdd{ u"com.sun.star.drawing.MasterPage" };
2766 if( SvxDrawPage::mpPage && static_cast<SdPage*>(SvxDrawPage::mpPage)->GetPageKind() == PageKind::Handout )
2767 aAdd.emplace_back(u"com.sun.star.presentation.HandoutMasterPage");
2769 return comphelper::concatSequences(SdGenericDrawPage::getSupportedServiceNames(), aAdd);
2772 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName )
2774 return cppu::supportsService( this, ServiceName );
2777 // XElementAccess
2778 sal_Bool SAL_CALL SdMasterPage::hasElements()
2780 ::SolarMutexGuard aGuard;
2782 throwIfDisposed();
2784 if( SvxDrawPage::mpPage == nullptr )
2785 return false;
2787 return SvxDrawPage::mpPage->GetObjCount() > 0;
2790 uno::Type SAL_CALL SdMasterPage::getElementType()
2792 return SdGenericDrawPage::getElementType();
2795 // XIndexAccess
2796 sal_Int32 SAL_CALL SdMasterPage::getCount()
2798 ::SolarMutexGuard aGuard;
2800 throwIfDisposed();
2802 return SdGenericDrawPage::getCount();
2805 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index )
2807 ::SolarMutexGuard aGuard;
2809 throwIfDisposed();
2811 return SdGenericDrawPage::getByIndex(Index);
2814 // internal
2815 void SdMasterPage::setBackground( const Any& rValue )
2817 // we need at least a beans::XPropertySet
2818 Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY );
2819 if( !xInputSet.is() )
2820 throw lang::IllegalArgumentException();
2824 if( GetModel() && IsImpressDocument() )
2826 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_SET_THROW );
2827 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ;
2829 Reference< beans::XPropertySet > xStyleSet( xFamily->getByName( sUNO_PseudoSheet_Background ), UNO_QUERY_THROW );
2831 Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW );
2832 Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY );
2834 for( const auto & rPair : ImplGetPageBackgroundPropertySet()->getPropertyMap().getPropertyEntries() )
2836 const SfxItemPropertyMapEntry* pProp = rPair.second;
2837 const OUString& rPropName = pProp->aName;
2838 if( xSetInfo->hasPropertyByName( rPropName ) )
2840 if( !xSetStates.is() || xSetStates->getPropertyState( rPropName ) == beans::PropertyState_DIRECT_VALUE )
2841 xStyleSet->setPropertyValue( rPropName, xInputSet->getPropertyValue( rPropName ) );
2842 else
2843 xSetStates->setPropertyToDefault( rPropName );
2847 else
2849 // first fill an item set
2850 // is it our own implementation?
2851 SdUnoPageBackground* pBack = dynamic_cast<SdUnoPageBackground*>( xInputSet.get() );
2853 SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aSet( GetModel()->GetDoc()->GetPool() );
2855 if( pBack )
2857 pBack->fillItemSet( static_cast<SdDrawDocument*>(&GetPage()->getSdrModelFromSdrPage()), aSet );
2859 else
2861 rtl::Reference<SdUnoPageBackground> pBackground = new SdUnoPageBackground();
2863 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW );
2864 Reference< beans::XPropertySetInfo > xDestSetInfo( pBackground->getPropertySetInfo(), UNO_SET_THROW );
2866 const uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() );
2868 for( const beans::Property& rProp : aProperties )
2870 const OUString aPropName( rProp.Name );
2871 if( xInputSetInfo->hasPropertyByName( aPropName ) )
2872 pBackground->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) );
2875 pBackground->fillItemSet( static_cast<SdDrawDocument*>(&SvxDrawPage::mpPage->getSdrModelFromSdrPage()), aSet );
2878 // if we find the background style, copy the set to the background
2879 SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(&SvxDrawPage::mpPage->getSdrModelFromSdrPage());
2880 SfxStyleSheetBasePool* pSSPool = pDoc->GetStyleSheetPool();
2881 if(pSSPool)
2883 OUString aLayoutName( static_cast< SdPage* >( SvxDrawPage::mpPage )->GetLayoutName() );
2884 aLayoutName = OUString::Concat(aLayoutName.subView(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4)) +
2885 STR_LAYOUT_BACKGROUND;
2886 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page );
2888 if( pStyleSheet )
2890 pStyleSheet->GetItemSet().Put( aSet );
2892 // repaint only
2893 SvxDrawPage::mpPage->ActionChanged();
2894 return;
2898 // if no background style is available, set at page directly. This
2899 // is an error and should NOT happen (and will be asserted from the SdrPage)
2900 GetPage()->getSdrPageProperties().PutItemSet(aSet);
2903 catch( Exception& )
2905 TOOLS_WARN_EXCEPTION( "sd", "sd::SdMasterPage::setBackground()");
2909 void SdMasterPage::getBackground( Any& rValue )
2911 if( !GetModel() )
2912 return;
2916 if( IsImpressDocument() )
2918 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_SET_THROW );
2919 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW );
2921 rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( sUNO_PseudoSheet_Background ), UNO_QUERY_THROW );
2923 else
2925 SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(&SvxDrawPage::mpPage->getSdrModelFromSdrPage());
2926 SfxStyleSheetBasePool* pSSPool = pDoc->GetStyleSheetPool();
2927 if(pSSPool)
2929 OUString aLayoutName( static_cast< SdPage* >(SvxDrawPage::mpPage)->GetLayoutName() );
2930 aLayoutName = OUString::Concat(aLayoutName.subView(0, aLayoutName.indexOf(SD_LT_SEPARATOR)+4)) +
2931 STR_LAYOUT_BACKGROUND;
2932 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SfxStyleFamily::Page );
2934 if( pStyleSheet )
2936 SfxItemSet aStyleSet( pStyleSheet->GetItemSet());
2937 if( aStyleSet.Count() )
2939 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) );
2940 return;
2945 // No style found, use fill attributes from page background. This
2946 // should NOT happen and is an error
2947 const SfxItemSet& rFallbackItemSet(SvxDrawPage::mpPage->getSdrPageProperties().GetItemSet());
2949 if(drawing::FillStyle_NONE == rFallbackItemSet.Get(XATTR_FILLSTYLE).GetValue())
2951 rValue <<= Reference< beans::XPropertySet >(
2952 new SdUnoPageBackground(GetModel()->GetDoc(), &rFallbackItemSet));
2954 else
2956 rValue.clear();
2960 catch( Exception& )
2962 TOOLS_WARN_EXCEPTION( "sd", "sd::SdMasterPage::getBackground()");
2963 rValue.clear();
2967 // XNamed
2968 void SAL_CALL SdMasterPage::setName( const OUString& rName )
2970 ::SolarMutexGuard aGuard;
2972 throwIfDisposed();
2974 if(!(SvxDrawPage::mpPage && GetPage()->GetPageKind() != PageKind::Notes))
2975 return;
2977 SdDrawDocument* pDoc = GetModel()->GetDoc();
2978 bool bOutDummy;
2980 // Slide Name has to be unique
2981 if( pDoc && pDoc->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
2982 return; // throw Exception ?
2984 GetPage()->SetName( rName );
2986 if( pDoc )
2987 pDoc->RenameLayoutTemplate( GetPage()->GetLayoutName(), rName );
2989 // fake a mode change to repaint the page tab bar
2990 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
2991 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
2992 if( auto pDrawViewSh = dynamic_cast< ::sd::DrawViewShell* >(pViewSh) )
2994 EditMode eMode = pDrawViewSh->GetEditMode();
2995 if( eMode == EditMode::MasterPage )
2997 bool bLayer = pDrawViewSh->IsLayerModeActive();
2999 pDrawViewSh->ChangeEditMode( eMode, !bLayer );
3000 pDrawViewSh->ChangeEditMode( eMode, bLayer );
3004 GetModel()->SetModified();
3007 OUString SAL_CALL SdMasterPage::getName( )
3009 ::SolarMutexGuard aGuard;
3011 throwIfDisposed();
3013 if(SvxDrawPage::mpPage)
3015 OUString aLayoutName( GetPage()->GetLayoutName() );
3016 return aLayoutName.copy(0, aLayoutName.indexOf(SD_LT_SEPARATOR));
3019 return OUString();
3022 // XPresentationPage
3023 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage()
3025 ::SolarMutexGuard aGuard;
3027 throwIfDisposed();
3029 if(SvxDrawPage::mpPage && GetModel()->GetDoc() )
3031 SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxDrawPage::mpPage->GetPageNum()-1)>>1, PageKind::Notes );
3032 if( pNotesPage )
3034 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY );
3035 return xPage;
3038 return nullptr;
3041 // XShapes
3042 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape )
3044 SdGenericDrawPage::add( xShape );
3047 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape )
3049 ::SolarMutexGuard aGuard;
3051 throwIfDisposed();
3053 SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape );
3054 if( pObj && GetPage()->IsPresObj( pObj ) )
3055 GetPage()->RemovePresObj(pObj);
3057 SdGenericDrawPage::remove( xShape );
3060 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage )
3062 Reference< uno::XInterface > xPage;
3064 if( pPage )
3066 SdXImpressDocument* pModel = comphelper::getFromUnoTunnel<SdXImpressDocument>( pPage->getSdrModelFromSdrPage().getUnoModel() );
3067 if( pModel )
3069 if( pPage->IsMasterPage() )
3071 xPage = static_cast<cppu::OWeakObject*>(new SdMasterPage( pModel, pPage ));
3073 else
3075 xPage = static_cast<cppu::OWeakObject*>(new SdDrawPage( pModel, pPage ));
3080 return xPage;
3083 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */