File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 113, column 13 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||
2 | /* | ||||||||
3 | * This file is part of the LibreOffice project. | ||||||||
4 | * | ||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||
8 | * | ||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||
10 | * | ||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||
13 | * with this work for additional information regarding copyright | ||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||
18 | */ | ||||||||
19 | |||||||||
20 | #include <memory> | ||||||||
21 | #include <boost/property_tree/json_parser.hpp> | ||||||||
22 | |||||||||
23 | #include <com/sun/star/presentation/XPresentation2.hpp> | ||||||||
24 | |||||||||
25 | #include <com/sun/star/lang/DisposedException.hpp> | ||||||||
26 | #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> | ||||||||
27 | #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> | ||||||||
28 | #include <com/sun/star/lang/Locale.hpp> | ||||||||
29 | #include <com/sun/star/awt/XDevice.hpp> | ||||||||
30 | #include <com/sun/star/document/IndexedPropertyValues.hpp> | ||||||||
31 | #include <com/sun/star/beans/PropertyAttribute.hpp> | ||||||||
32 | |||||||||
33 | #include <com/sun/star/embed/Aspects.hpp> | ||||||||
34 | |||||||||
35 | #include <comphelper/lok.hxx> | ||||||||
36 | #include <comphelper/sequence.hxx> | ||||||||
37 | #include <comphelper/servicehelper.hxx> | ||||||||
38 | #include <cppuhelper/supportsservice.hxx> | ||||||||
39 | #include <comphelper/processfactory.hxx> | ||||||||
40 | #include <comphelper/profilezone.hxx> | ||||||||
41 | |||||||||
42 | #include <sal/log.hxx> | ||||||||
43 | #include <editeng/unofield.hxx> | ||||||||
44 | #include <notifydocumentevent.hxx> | ||||||||
45 | #include <unomodel.hxx> | ||||||||
46 | #include "unopool.hxx" | ||||||||
47 | #include <sfx2/lokhelper.hxx> | ||||||||
48 | #include <vcl/svapp.hxx> | ||||||||
49 | #include <vcl/settings.hxx> | ||||||||
50 | #include <LibreOfficeKit/LibreOfficeKitEnums.h> | ||||||||
51 | |||||||||
52 | #include <editeng/UnoForbiddenCharsTable.hxx> | ||||||||
53 | #include <svx/svdoutl.hxx> | ||||||||
54 | #include <o3tl/safeint.hxx> | ||||||||
55 | #include <svx/UnoNamespaceMap.hxx> | ||||||||
56 | #include <svx/svdlayer.hxx> | ||||||||
57 | #include <svx/svdsob.hxx> | ||||||||
58 | #include <svx/svdundo.hxx> | ||||||||
59 | #include <svx/unoapi.hxx> | ||||||||
60 | #include <svx/unofill.hxx> | ||||||||
61 | #include <editeng/flditem.hxx> | ||||||||
62 | #include <editeng/fontitem.hxx> | ||||||||
63 | #include <toolkit/awt/vclxdevice.hxx> | ||||||||
64 | #include <svx/svdpool.hxx> | ||||||||
65 | #include <svx/svdpagv.hxx> | ||||||||
66 | #include <svtools/unoimap.hxx> | ||||||||
67 | #include <svtools/slidesorterbaropt.hxx> | ||||||||
68 | #include <svx/unoshape.hxx> | ||||||||
69 | #include <editeng/unonrule.hxx> | ||||||||
70 | #include <editeng/eeitem.hxx> | ||||||||
71 | #include <unotools/datetime.hxx> | ||||||||
72 | #include <unotools/saveopt.hxx> | ||||||||
73 | #include <xmloff/autolayout.hxx> | ||||||||
74 | |||||||||
75 | // Support creation of GraphicStorageHandler and EmbeddedObjectResolver | ||||||||
76 | #include <svx/xmleohlp.hxx> | ||||||||
77 | #include <svx/xmlgrhlp.hxx> | ||||||||
78 | #include <DrawDocShell.hxx> | ||||||||
79 | #include <ViewShellBase.hxx> | ||||||||
80 | #include "UnoDocumentSettings.hxx" | ||||||||
81 | |||||||||
82 | #include <Annotation.hxx> | ||||||||
83 | #include <drawdoc.hxx> | ||||||||
84 | #include <sdmod.hxx> | ||||||||
85 | #include <sdresid.hxx> | ||||||||
86 | #include <sdpage.hxx> | ||||||||
87 | |||||||||
88 | #include <strings.hrc> | ||||||||
89 | #include <strings.hxx> | ||||||||
90 | #include "unolayer.hxx" | ||||||||
91 | #include <unopage.hxx> | ||||||||
92 | #include "unocpres.hxx" | ||||||||
93 | #include "unoobj.hxx" | ||||||||
94 | #include <stlpool.hxx> | ||||||||
95 | #include "unopback.hxx" | ||||||||
96 | #include <unokywds.hxx> | ||||||||
97 | |||||||||
98 | #include <FrameView.hxx> | ||||||||
99 | #include <ClientView.hxx> | ||||||||
100 | #include <DrawViewShell.hxx> | ||||||||
101 | #include <ViewShell.hxx> | ||||||||
102 | #include <Window.hxx> | ||||||||
103 | #include <optsitem.hxx> | ||||||||
104 | |||||||||
105 | #include <vcl/pdfextoutdevdata.hxx> | ||||||||
106 | #include <com/sun/star/presentation/AnimationSpeed.hpp> | ||||||||
107 | #include <com/sun/star/presentation/ClickAction.hpp> | ||||||||
108 | #include <svx/sdr/contact/viewobjectcontact.hxx> | ||||||||
109 | #include <svx/sdr/contact/viewcontact.hxx> | ||||||||
110 | #include <svx/sdr/contact/displayinfo.hxx> | ||||||||
111 | |||||||||
112 | #include <com/sun/star/office/XAnnotation.hpp> | ||||||||
113 | #include <com/sun/star/office/XAnnotationAccess.hpp> | ||||||||
114 | #include <com/sun/star/office/XAnnotationEnumeration.hpp> | ||||||||
115 | #include <com/sun/star/geometry/RealPoint2D.hpp> | ||||||||
116 | #include <com/sun/star/util/DateTime.hpp> | ||||||||
117 | |||||||||
118 | #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx> | ||||||||
119 | |||||||||
120 | #include <sfx2/lokcharthelper.hxx> | ||||||||
121 | #include <tools/gen.hxx> | ||||||||
122 | #include <tools/debug.hxx> | ||||||||
123 | #include <tools/diagnose_ex.h> | ||||||||
124 | #include <tools/json_writer.hxx> | ||||||||
125 | #include <tools/UnitConversion.hxx> | ||||||||
126 | |||||||||
127 | #define TWIPS_PER_PIXEL15 15 | ||||||||
128 | |||||||||
129 | using namespace ::cppu; | ||||||||
130 | using namespace ::com::sun::star; | ||||||||
131 | using namespace ::sd; | ||||||||
132 | |||||||||
133 | namespace { | ||||||||
134 | |||||||||
135 | class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable, | ||||||||
136 | public SfxListener | ||||||||
137 | { | ||||||||
138 | public: | ||||||||
139 | explicit SdUnoForbiddenCharsTable(SdrModel* pModel); | ||||||||
140 | virtual ~SdUnoForbiddenCharsTable() override; | ||||||||
141 | |||||||||
142 | // SfxListener | ||||||||
143 | virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw () override; | ||||||||
144 | protected: | ||||||||
145 | virtual void onChange() override; | ||||||||
146 | |||||||||
147 | private: | ||||||||
148 | SdrModel* mpModel; | ||||||||
149 | }; | ||||||||
150 | |||||||||
151 | } | ||||||||
152 | |||||||||
153 | SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel ) | ||||||||
154 | : SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel ) | ||||||||
155 | { | ||||||||
156 | StartListening( *pModel ); | ||||||||
157 | } | ||||||||
158 | |||||||||
159 | void SdUnoForbiddenCharsTable::onChange() | ||||||||
160 | { | ||||||||
161 | if( mpModel ) | ||||||||
162 | { | ||||||||
163 | mpModel->ReformatAllTextObjects(); | ||||||||
164 | } | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable() | ||||||||
168 | { | ||||||||
169 | SolarMutexGuard g; | ||||||||
170 | |||||||||
171 | if( mpModel ) | ||||||||
172 | EndListening( *mpModel ); | ||||||||
173 | } | ||||||||
174 | |||||||||
175 | void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() | ||||||||
176 | { | ||||||||
177 | if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint) | ||||||||
178 | return; | ||||||||
179 | const SdrHint* pSdrHint = static_cast<const SdrHint*>( &rHint ); | ||||||||
180 | if( SdrHintKind::ModelCleared == pSdrHint->GetKind() ) | ||||||||
181 | { | ||||||||
182 | mpModel = nullptr; | ||||||||
183 | } | ||||||||
184 | } | ||||||||
185 | |||||||||
186 | const sal_uInt16 WID_MODEL_LANGUAGE = 1; | ||||||||
187 | const sal_uInt16 WID_MODEL_TABSTOP = 2; | ||||||||
188 | const sal_uInt16 WID_MODEL_VISAREA = 3; | ||||||||
189 | const sal_uInt16 WID_MODEL_MAPUNIT = 4; | ||||||||
190 | const sal_uInt16 WID_MODEL_FORBCHARS = 5; | ||||||||
191 | const sal_uInt16 WID_MODEL_CONTFOCUS = 6; | ||||||||
192 | const sal_uInt16 WID_MODEL_DSGNMODE = 7; | ||||||||
193 | const sal_uInt16 WID_MODEL_BASICLIBS = 8; | ||||||||
194 | const sal_uInt16 WID_MODEL_RUNTIMEUID = 9; | ||||||||
195 | const sal_uInt16 WID_MODEL_BUILDID = 10; | ||||||||
196 | const sal_uInt16 WID_MODEL_HASVALIDSIGNATURES = 11; | ||||||||
197 | const sal_uInt16 WID_MODEL_DIALOGLIBS = 12; | ||||||||
198 | const sal_uInt16 WID_MODEL_FONTS = 13; | ||||||||
199 | const sal_uInt16 WID_MODEL_INTEROPGRABBAG = 14; | ||||||||
200 | |||||||||
201 | static const SvxItemPropertySet* ImplGetDrawModelPropertySet() | ||||||||
202 | { | ||||||||
203 | // Attention: the first parameter HAS TO BE sorted!!! | ||||||||
204 | const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] = | ||||||||
205 | { | ||||||||
206 | { u"BuildId", WID_MODEL_BUILDID, ::cppu::UnoType<OUString>::get(), 0, 0}, | ||||||||
207 | { sUNO_Prop_CharLocale, WID_MODEL_LANGUAGE, ::cppu::UnoType<lang::Locale>::get(), 0, 0}, | ||||||||
208 | { sUNO_Prop_TabStop, WID_MODEL_TABSTOP, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, | ||||||||
209 | { sUNO_Prop_VisibleArea, WID_MODEL_VISAREA, ::cppu::UnoType<awt::Rectangle>::get(), 0, 0}, | ||||||||
210 | { sUNO_Prop_MapUnit, WID_MODEL_MAPUNIT, ::cppu::UnoType<sal_Int16>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
211 | { sUNO_Prop_ForbiddenCharacters, WID_MODEL_FORBCHARS, cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
212 | { sUNO_Prop_AutomContFocus, WID_MODEL_CONTFOCUS, cppu::UnoType<bool>::get(), 0, 0}, | ||||||||
213 | { sUNO_Prop_ApplyFrmDsgnMode, WID_MODEL_DSGNMODE, cppu::UnoType<bool>::get(), 0, 0}, | ||||||||
214 | { u"BasicLibraries", WID_MODEL_BASICLIBS, cppu::UnoType<script::XLibraryContainer>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
215 | { u"DialogLibraries", WID_MODEL_DIALOGLIBS, cppu::UnoType<script::XLibraryContainer>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
216 | { sUNO_Prop_RuntimeUID, WID_MODEL_RUNTIMEUID, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
217 | { sUNO_Prop_HasValidSignatures, WID_MODEL_HASVALIDSIGNATURES, ::cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
218 | { u"Fonts", WID_MODEL_FONTS, cppu::UnoType<uno::Sequence<uno::Any>>::get(), beans::PropertyAttribute::READONLY, 0}, | ||||||||
219 | { sUNO_Prop_InteropGrabBag, WID_MODEL_INTEROPGRABBAG, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0}, | ||||||||
220 | { u"", 0, css::uno::Type(), 0, 0 } | ||||||||
221 | }; | ||||||||
222 | static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); | ||||||||
223 | return &aDrawModelPropertySet_Impl; | ||||||||
224 | } | ||||||||
225 | |||||||||
226 | // this ctor is used from the DocShell | ||||||||
227 | SdXImpressDocument::SdXImpressDocument(::sd::DrawDocShell* pShell, bool bClipBoard) | ||||||||
228 | : SfxBaseModel( pShell ), | ||||||||
229 | mpDocShell( pShell ), | ||||||||
230 | mpDoc( pShell ? pShell->GetDoc() : nullptr ), | ||||||||
231 | mbDisposed(false), | ||||||||
232 | mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DocumentType::Impress ), | ||||||||
233 | mbClipBoard( bClipBoard ), | ||||||||
234 | mpPropSet( ImplGetDrawModelPropertySet() ) | ||||||||
235 | { | ||||||||
236 | if( mpDoc ) | ||||||||
237 | { | ||||||||
238 | StartListening( *mpDoc ); | ||||||||
239 | } | ||||||||
240 | else | ||||||||
241 | { | ||||||||
242 | OSL_FAIL("DocShell is invalid")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "242" ": "), "%s", "DocShell is invalid"); } } while (false ); | ||||||||
243 | } | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | SdXImpressDocument::SdXImpressDocument(SdDrawDocument* pDoc, bool bClipBoard) | ||||||||
247 | : SfxBaseModel( nullptr ), | ||||||||
248 | mpDocShell( nullptr ), | ||||||||
249 | mpDoc( pDoc ), | ||||||||
250 | mbDisposed(false), | ||||||||
251 | mbImpressDoc( pDoc && pDoc->GetDocumentType() == DocumentType::Impress ), | ||||||||
252 | mbClipBoard( bClipBoard ), | ||||||||
253 | mpPropSet( ImplGetDrawModelPropertySet() ) | ||||||||
254 | { | ||||||||
255 | if( mpDoc ) | ||||||||
256 | { | ||||||||
257 | StartListening( *mpDoc ); | ||||||||
258 | } | ||||||||
259 | else | ||||||||
260 | { | ||||||||
261 | OSL_FAIL("SdDrawDocument is invalid")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "261" ": "), "%s", "SdDrawDocument is invalid"); } } while (false); | ||||||||
262 | } | ||||||||
263 | } | ||||||||
264 | |||||||||
265 | /*********************************************************************** | ||||||||
266 | * * | ||||||||
267 | ***********************************************************************/ | ||||||||
268 | SdXImpressDocument::~SdXImpressDocument() throw() | ||||||||
269 | { | ||||||||
270 | } | ||||||||
271 | |||||||||
272 | // XInterface | ||||||||
273 | uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) | ||||||||
274 | { | ||||||||
275 | uno::Any aAny; | ||||||||
276 | |||||||||
277 | if (rType == cppu::UnoType<lang::XServiceInfo>::get()) | ||||||||
278 | aAny <<= uno::Reference<lang::XServiceInfo>(this); | ||||||||
279 | else if (rType == cppu::UnoType<beans::XPropertySet>::get()) | ||||||||
280 | aAny <<= uno::Reference<beans::XPropertySet>(this); | ||||||||
281 | else if (rType == cppu::UnoType<lang::XMultiServiceFactory>::get()) | ||||||||
282 | aAny <<= uno::Reference<lang::XMultiServiceFactory>(this); | ||||||||
283 | else if (rType == cppu::UnoType<drawing::XDrawPageDuplicator>::get()) | ||||||||
284 | aAny <<= uno::Reference<drawing::XDrawPageDuplicator>(this); | ||||||||
285 | else if (rType == cppu::UnoType<drawing::XLayerSupplier>::get()) | ||||||||
286 | aAny <<= uno::Reference<drawing::XLayerSupplier>(this); | ||||||||
287 | else if (rType == cppu::UnoType<drawing::XMasterPagesSupplier>::get()) | ||||||||
288 | aAny <<= uno::Reference<drawing::XMasterPagesSupplier>(this); | ||||||||
289 | else if (rType == cppu::UnoType<drawing::XDrawPagesSupplier>::get()) | ||||||||
290 | aAny <<= uno::Reference<drawing::XDrawPagesSupplier>(this); | ||||||||
291 | else if (rType == cppu::UnoType<presentation::XHandoutMasterSupplier>::get()) | ||||||||
292 | aAny <<= uno::Reference<presentation::XHandoutMasterSupplier>(this); | ||||||||
293 | else if (rType == cppu::UnoType<document::XLinkTargetSupplier>::get()) | ||||||||
294 | aAny <<= uno::Reference<document::XLinkTargetSupplier>(this); | ||||||||
295 | else if (rType == cppu::UnoType<style::XStyleFamiliesSupplier>::get()) | ||||||||
296 | aAny <<= uno::Reference<style::XStyleFamiliesSupplier>(this); | ||||||||
297 | else if (rType == cppu::UnoType<css::ucb::XAnyCompareFactory>::get()) | ||||||||
298 | aAny <<= uno::Reference<css::ucb::XAnyCompareFactory>(this); | ||||||||
299 | else if (rType == cppu::UnoType<view::XRenderable>::get()) | ||||||||
300 | aAny <<= uno::Reference<view::XRenderable>(this); | ||||||||
301 | else if (mbImpressDoc && rType == cppu::UnoType<presentation::XPresentationSupplier>::get()) | ||||||||
302 | aAny <<= uno::Reference< presentation::XPresentationSupplier >(this); | ||||||||
303 | else if (mbImpressDoc && rType == cppu::UnoType<presentation::XCustomPresentationSupplier>::get()) | ||||||||
304 | aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this); | ||||||||
305 | else | ||||||||
306 | return SfxBaseModel::queryInterface(rType); | ||||||||
307 | |||||||||
308 | return aAny; | ||||||||
309 | } | ||||||||
310 | |||||||||
311 | void SAL_CALL SdXImpressDocument::acquire() throw ( ) | ||||||||
312 | { | ||||||||
313 | SfxBaseModel::acquire(); | ||||||||
314 | } | ||||||||
315 | |||||||||
316 | void SAL_CALL SdXImpressDocument::release() throw ( ) | ||||||||
317 | { | ||||||||
318 | if (osl_atomic_decrement( &m_refCount )__sync_sub_and_fetch((&m_refCount), 1) != 0) | ||||||||
319 | return; | ||||||||
320 | |||||||||
321 | // restore reference count: | ||||||||
322 | osl_atomic_increment( &m_refCount )__sync_add_and_fetch((&m_refCount), 1); | ||||||||
323 | if(!mbDisposed) | ||||||||
324 | { | ||||||||
325 | try | ||||||||
326 | { | ||||||||
327 | dispose(); | ||||||||
328 | } | ||||||||
329 | catch (const uno::RuntimeException&) | ||||||||
330 | { | ||||||||
331 | // don't break throw () | ||||||||
332 | TOOLS_WARN_EXCEPTION( "sd", "" )do { css::uno::Any tools_warn_exception( DbgGetCaughtException () ); do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "332" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "" << " " << exceptionToString (tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "332" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "" << " " << exceptionToString(tools_warn_exception )) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ( "sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "332" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "" << " " << exceptionToString (tools_warn_exception)), 0); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "" << " " << exceptionToString (tools_warn_exception); ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN ), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "332" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); } while (false); | ||||||||
333 | } | ||||||||
334 | } | ||||||||
335 | SfxBaseModel::release(); | ||||||||
336 | } | ||||||||
337 | |||||||||
338 | namespace | ||||||||
339 | { | ||||||||
340 | class theSdXImpressDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentUnoTunnelId> {}; | ||||||||
341 | } | ||||||||
342 | |||||||||
343 | // XUnoTunnel | ||||||||
344 | const css::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw() | ||||||||
345 | { | ||||||||
346 | return theSdXImpressDocumentUnoTunnelId::get().getSeq(); | ||||||||
347 | } | ||||||||
348 | |||||||||
349 | sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) | ||||||||
350 | { | ||||||||
351 | if( isUnoTunnelId<SdXImpressDocument>(rIdentifier) ) | ||||||||
352 | return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); | ||||||||
353 | |||||||||
354 | if( isUnoTunnelId<SdrModel>(rIdentifier) ) | ||||||||
355 | return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc)); | ||||||||
356 | |||||||||
357 | return SfxBaseModel::getSomething( rIdentifier ); | ||||||||
358 | } | ||||||||
359 | |||||||||
360 | // XTypeProvider | ||||||||
361 | uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) | ||||||||
362 | { | ||||||||
363 | ::SolarMutexGuard aGuard; | ||||||||
364 | |||||||||
365 | if( !maTypeSequence.hasElements() ) | ||||||||
366 | { | ||||||||
367 | uno::Sequence< uno::Type > aTypes( SfxBaseModel::getTypes() ); | ||||||||
368 | aTypes = comphelper::concatSequences(aTypes, | ||||||||
369 | uno::Sequence { | ||||||||
370 | cppu::UnoType<beans::XPropertySet>::get(), | ||||||||
371 | cppu::UnoType<lang::XServiceInfo>::get(), | ||||||||
372 | cppu::UnoType<lang::XMultiServiceFactory>::get(), | ||||||||
373 | cppu::UnoType<drawing::XDrawPageDuplicator>::get(), | ||||||||
374 | cppu::UnoType<drawing::XLayerSupplier>::get(), | ||||||||
375 | cppu::UnoType<drawing::XMasterPagesSupplier>::get(), | ||||||||
376 | cppu::UnoType<drawing::XDrawPagesSupplier>::get(), | ||||||||
377 | cppu::UnoType<document::XLinkTargetSupplier>::get(), | ||||||||
378 | cppu::UnoType<style::XStyleFamiliesSupplier>::get(), | ||||||||
379 | cppu::UnoType<css::ucb::XAnyCompareFactory>::get(), | ||||||||
380 | cppu::UnoType<view::XRenderable>::get() }); | ||||||||
381 | if( mbImpressDoc ) | ||||||||
382 | { | ||||||||
383 | aTypes = comphelper::concatSequences(aTypes, | ||||||||
384 | uno::Sequence { | ||||||||
385 | cppu::UnoType<presentation::XPresentationSupplier>::get(), | ||||||||
386 | cppu::UnoType<presentation::XCustomPresentationSupplier>::get(), | ||||||||
387 | cppu::UnoType<presentation::XHandoutMasterSupplier>::get() }); | ||||||||
388 | } | ||||||||
389 | maTypeSequence = aTypes; | ||||||||
390 | } | ||||||||
391 | |||||||||
392 | return maTypeSequence; | ||||||||
393 | } | ||||||||
394 | |||||||||
395 | uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId( ) | ||||||||
396 | { | ||||||||
397 | return css::uno::Sequence<sal_Int8>(); | ||||||||
398 | } | ||||||||
399 | |||||||||
400 | /*********************************************************************** | ||||||||
401 | * * | ||||||||
402 | ***********************************************************************/ | ||||||||
403 | void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) | ||||||||
404 | { | ||||||||
405 | if( mpDoc ) | ||||||||
406 | { | ||||||||
407 | if (rHint.GetId() == SfxHintId::ThisIsAnSdrHint) | ||||||||
408 | { | ||||||||
409 | const SdrHint* pSdrHint = static_cast<const SdrHint*>( &rHint ); | ||||||||
410 | if( hasEventListeners() ) | ||||||||
411 | { | ||||||||
412 | document::EventObject aEvent; | ||||||||
413 | if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) ) | ||||||||
414 | notifyEvent( aEvent ); | ||||||||
415 | } | ||||||||
416 | |||||||||
417 | if( pSdrHint->GetKind() == SdrHintKind::ModelCleared ) | ||||||||
418 | { | ||||||||
419 | if( mpDoc ) | ||||||||
420 | EndListening( *mpDoc ); | ||||||||
421 | mpDoc = nullptr; | ||||||||
422 | mpDocShell = nullptr; | ||||||||
423 | } | ||||||||
424 | } | ||||||||
425 | else | ||||||||
426 | { | ||||||||
427 | // did our SdDrawDocument just died? | ||||||||
428 | if(rHint.GetId() == SfxHintId::Dying) | ||||||||
429 | { | ||||||||
430 | // yes, so we ask for a new one | ||||||||
431 | if( mpDocShell ) | ||||||||
432 | { | ||||||||
433 | SdDrawDocument *pNewDoc = mpDocShell->GetDoc(); | ||||||||
434 | |||||||||
435 | // is there a new one? | ||||||||
436 | if( pNewDoc != mpDoc ) | ||||||||
437 | { | ||||||||
438 | mpDoc = pNewDoc; | ||||||||
439 | if(mpDoc) | ||||||||
440 | StartListening( *mpDoc ); | ||||||||
441 | } | ||||||||
442 | } | ||||||||
443 | } | ||||||||
444 | } | ||||||||
445 | } | ||||||||
446 | SfxBaseModel::Notify( rBC, rHint ); | ||||||||
447 | } | ||||||||
448 | |||||||||
449 | /****************************************************************************** | ||||||||
450 | * * | ||||||||
451 | ******************************************************************************/ | ||||||||
452 | SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, bool bDuplicate ) | ||||||||
453 | { | ||||||||
454 | sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
455 | SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); | ||||||||
456 | SdrLayerID aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); | ||||||||
457 | SdrLayerID aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); | ||||||||
458 | |||||||||
459 | SdPage* pStandardPage = nullptr; | ||||||||
460 | |||||||||
461 | if( 0 == nPageCount ) | ||||||||
462 | { | ||||||||
463 | // this is only used for clipboard where we only have one page | ||||||||
464 | pStandardPage = mpDoc->AllocSdPage(false); | ||||||||
465 | |||||||||
466 | Size aDefSize(21000, 29700); // A4 portrait orientation | ||||||||
467 | pStandardPage->SetSize( aDefSize ); | ||||||||
468 | mpDoc->InsertPage(pStandardPage, 0); | ||||||||
469 | } | ||||||||
470 | else | ||||||||
471 | { | ||||||||
472 | // here we determine the page after which we should insert | ||||||||
473 | SdPage* pPreviousStandardPage = mpDoc->GetSdPage( std::min( static_cast<sal_uInt16>(nPageCount - 1), nPage ), PageKind::Standard ); | ||||||||
474 | SdrLayerIDSet aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers(); | ||||||||
475 | bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd ); | ||||||||
476 | bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj ); | ||||||||
477 | |||||||||
478 | // AutoLayouts must be ready | ||||||||
479 | mpDoc->StopWorkStartupDelay(); | ||||||||
480 | |||||||||
481 | /* First we create a standard page and then a notes page. It is | ||||||||
482 | guaranteed, that after a standard page the corresponding notes page | ||||||||
483 | follows. */ | ||||||||
484 | |||||||||
485 | sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2; | ||||||||
486 | SdPage* pPreviousNotesPage = static_cast<SdPage*>( mpDoc->GetPage( nStandardPageNum - 1 ) ); | ||||||||
487 | sal_uInt16 nNotesPageNum = nStandardPageNum + 1; | ||||||||
488 | |||||||||
489 | /************************************************************** | ||||||||
490 | * standard page | ||||||||
491 | **************************************************************/ | ||||||||
492 | if( bDuplicate ) | ||||||||
493 | pStandardPage = static_cast<SdPage*>( pPreviousStandardPage->CloneSdrPage(*mpDoc) ); | ||||||||
494 | else | ||||||||
495 | pStandardPage = mpDoc->AllocSdPage(false); | ||||||||
496 | |||||||||
497 | pStandardPage->SetSize( pPreviousStandardPage->GetSize() ); | ||||||||
498 | pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(), | ||||||||
499 | pPreviousStandardPage->GetUpperBorder(), | ||||||||
500 | pPreviousStandardPage->GetRightBorder(), | ||||||||
501 | pPreviousStandardPage->GetLowerBorder() ); | ||||||||
502 | pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() ); | ||||||||
503 | pStandardPage->SetName(OUString()); | ||||||||
504 | |||||||||
505 | // insert page after current page | ||||||||
506 | mpDoc->InsertPage(pStandardPage, nStandardPageNum); | ||||||||
507 | |||||||||
508 | if( !bDuplicate ) | ||||||||
509 | { | ||||||||
510 | // use MasterPage of the current page | ||||||||
511 | pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage()); | ||||||||
512 | pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() ); | ||||||||
513 | pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, true ); | ||||||||
514 | } | ||||||||
515 | |||||||||
516 | aBckgrnd = rLayerAdmin.GetLayerID(sUNO_LayerName_background); | ||||||||
517 | aBckgrndObj = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); | ||||||||
518 | aVisibleLayers.Set(aBckgrnd, bIsPageBack); | ||||||||
519 | aVisibleLayers.Set(aBckgrndObj, bIsPageObj); | ||||||||
520 | pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); | ||||||||
521 | |||||||||
522 | /************************************************************** | ||||||||
523 | * notes page | ||||||||
524 | **************************************************************/ | ||||||||
525 | SdPage* pNotesPage = nullptr; | ||||||||
526 | |||||||||
527 | if( bDuplicate ) | ||||||||
528 | pNotesPage = static_cast<SdPage*>( pPreviousNotesPage->CloneSdrPage(*mpDoc) ); | ||||||||
529 | else | ||||||||
530 | pNotesPage = mpDoc->AllocSdPage(false); | ||||||||
531 | |||||||||
532 | pNotesPage->SetSize( pPreviousNotesPage->GetSize() ); | ||||||||
533 | pNotesPage->SetBorder( pPreviousNotesPage->GetLeftBorder(), | ||||||||
534 | pPreviousNotesPage->GetUpperBorder(), | ||||||||
535 | pPreviousNotesPage->GetRightBorder(), | ||||||||
536 | pPreviousNotesPage->GetLowerBorder() ); | ||||||||
537 | pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() ); | ||||||||
538 | pNotesPage->SetName(OUString()); | ||||||||
539 | pNotesPage->SetPageKind(PageKind::Notes); | ||||||||
540 | |||||||||
541 | // insert page after current page | ||||||||
542 | mpDoc->InsertPage(pNotesPage, nNotesPageNum); | ||||||||
543 | |||||||||
544 | if( !bDuplicate ) | ||||||||
545 | { | ||||||||
546 | // use MasterPage of the current page | ||||||||
547 | pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage()); | ||||||||
548 | pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() ); | ||||||||
549 | pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true ); | ||||||||
550 | } | ||||||||
551 | } | ||||||||
552 | |||||||||
553 | SetModified(); | ||||||||
554 | |||||||||
555 | return pStandardPage; | ||||||||
556 | } | ||||||||
557 | |||||||||
558 | void SdXImpressDocument::SetModified() throw() | ||||||||
559 | { | ||||||||
560 | if( mpDoc ) | ||||||||
561 | mpDoc->SetChanged(); | ||||||||
562 | } | ||||||||
563 | |||||||||
564 | // XModel | ||||||||
565 | void SAL_CALL SdXImpressDocument::lockControllers( ) | ||||||||
566 | { | ||||||||
567 | ::SolarMutexGuard aGuard; | ||||||||
568 | |||||||||
569 | if( nullptr == mpDoc ) | ||||||||
570 | throw lang::DisposedException(); | ||||||||
571 | |||||||||
572 | mpDoc->setLock(true); | ||||||||
573 | } | ||||||||
574 | |||||||||
575 | void SAL_CALL SdXImpressDocument::unlockControllers( ) | ||||||||
576 | { | ||||||||
577 | ::SolarMutexGuard aGuard; | ||||||||
578 | |||||||||
579 | if( nullptr == mpDoc ) | ||||||||
580 | throw lang::DisposedException(); | ||||||||
581 | |||||||||
582 | if( mpDoc->isLocked() ) | ||||||||
583 | { | ||||||||
584 | mpDoc->setLock(false); | ||||||||
585 | } | ||||||||
586 | } | ||||||||
587 | |||||||||
588 | sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked( ) | ||||||||
589 | { | ||||||||
590 | ::SolarMutexGuard aGuard; | ||||||||
591 | |||||||||
592 | if( nullptr == mpDoc ) | ||||||||
593 | throw lang::DisposedException(); | ||||||||
594 | |||||||||
595 | return mpDoc->isLocked(); | ||||||||
596 | } | ||||||||
597 | |||||||||
598 | uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData() | ||||||||
599 | { | ||||||||
600 | ::SolarMutexGuard aGuard; | ||||||||
601 | |||||||||
602 | if( nullptr == mpDoc ) | ||||||||
603 | throw lang::DisposedException(); | ||||||||
604 | |||||||||
605 | uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() ); | ||||||||
606 | |||||||||
607 | if( !xRet.is() ) | ||||||||
608 | { | ||||||||
609 | const std::vector<std::unique_ptr<sd::FrameView>> &rList = mpDoc->GetFrameViewList(); | ||||||||
610 | |||||||||
611 | if( !rList.empty() ) | ||||||||
612 | { | ||||||||
613 | xRet = document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ); | ||||||||
614 | |||||||||
615 | uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY ); | ||||||||
616 | DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" )do { if (true && (!(xCont.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "616" ": "), "%s", "SdXImpressDocument::getViewData() failed for OLE object" ); } } while (false); | ||||||||
617 | if( xCont.is() ) | ||||||||
618 | { | ||||||||
619 | for( sal_uInt32 i = 0, n = rList.size(); i < n; i++ ) | ||||||||
620 | { | ||||||||
621 | ::sd::FrameView* pFrameView = rList[ i ].get(); | ||||||||
622 | |||||||||
623 | uno::Sequence< beans::PropertyValue > aSeq; | ||||||||
624 | pFrameView->WriteUserDataSequence( aSeq ); | ||||||||
625 | xCont->insertByIndex( i, uno::makeAny( aSeq ) ); | ||||||||
626 | } | ||||||||
627 | } | ||||||||
628 | } | ||||||||
629 | } | ||||||||
630 | |||||||||
631 | return xRet; | ||||||||
632 | } | ||||||||
633 | |||||||||
634 | void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData ) | ||||||||
635 | { | ||||||||
636 | ::SolarMutexGuard aGuard; | ||||||||
637 | |||||||||
638 | if( nullptr == mpDoc ) | ||||||||
639 | throw lang::DisposedException(); | ||||||||
640 | |||||||||
641 | SfxBaseModel::setViewData( xData ); | ||||||||
642 | if( !(mpDocShell && (mpDocShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED) && xData.is()) ) | ||||||||
643 | return; | ||||||||
644 | |||||||||
645 | const sal_Int32 nCount = xData->getCount(); | ||||||||
646 | |||||||||
647 | std::vector<std::unique_ptr<sd::FrameView>> &rViews = mpDoc->GetFrameViewList(); | ||||||||
648 | |||||||||
649 | rViews.clear(); | ||||||||
650 | |||||||||
651 | uno::Sequence< beans::PropertyValue > aSeq; | ||||||||
652 | for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) | ||||||||
653 | { | ||||||||
654 | if( xData->getByIndex( nIndex ) >>= aSeq ) | ||||||||
655 | { | ||||||||
656 | std::unique_ptr<::sd::FrameView> pFrameView(new ::sd::FrameView( mpDoc )); | ||||||||
657 | pFrameView->ReadUserDataSequence( aSeq ); | ||||||||
658 | rViews.push_back( std::move(pFrameView) ); | ||||||||
659 | } | ||||||||
660 | } | ||||||||
661 | } | ||||||||
662 | |||||||||
663 | // XDrawPageDuplicator | ||||||||
664 | uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage ) | ||||||||
665 | { | ||||||||
666 | ::SolarMutexGuard aGuard; | ||||||||
667 | |||||||||
668 | if( nullptr == mpDoc ) | ||||||||
669 | throw lang::DisposedException(); | ||||||||
670 | |||||||||
671 | // get pPage from xPage and determine the Id (nPos ) afterwards | ||||||||
672 | SvxDrawPage* pSvxPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( xPage ); | ||||||||
673 | if( pSvxPage ) | ||||||||
674 | { | ||||||||
675 | SdPage* pPage = static_cast<SdPage*>( pSvxPage->GetSdrPage() ); | ||||||||
676 | sal_uInt16 nPos = pPage->GetPageNum(); | ||||||||
677 | nPos = ( nPos - 1 ) / 2; | ||||||||
678 | pPage = InsertSdPage( nPos, true ); | ||||||||
679 | if( pPage ) | ||||||||
680 | { | ||||||||
681 | uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
682 | return xDrawPage; | ||||||||
683 | } | ||||||||
684 | } | ||||||||
685 | |||||||||
686 | uno::Reference< drawing::XDrawPage > xDrawPage; | ||||||||
687 | return xDrawPage; | ||||||||
688 | } | ||||||||
689 | |||||||||
690 | // XDrawPagesSupplier | ||||||||
691 | uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages() | ||||||||
692 | { | ||||||||
693 | ::SolarMutexGuard aGuard; | ||||||||
694 | |||||||||
695 | if( nullptr == mpDoc ) | ||||||||
696 | throw lang::DisposedException(); | ||||||||
697 | |||||||||
698 | uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess ); | ||||||||
699 | |||||||||
700 | if( !xDrawPages.is() ) | ||||||||
701 | { | ||||||||
702 | initializeDocument(); | ||||||||
703 | mxDrawPagesAccess = xDrawPages = new SdDrawPagesAccess(*this); | ||||||||
704 | } | ||||||||
705 | |||||||||
706 | return xDrawPages; | ||||||||
707 | } | ||||||||
708 | |||||||||
709 | // XMasterPagesSupplier | ||||||||
710 | uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages() | ||||||||
711 | { | ||||||||
712 | ::SolarMutexGuard aGuard; | ||||||||
713 | |||||||||
714 | if( nullptr == mpDoc ) | ||||||||
715 | throw lang::DisposedException(); | ||||||||
716 | |||||||||
717 | uno::Reference< drawing::XDrawPages > xMasterPages( mxMasterPagesAccess ); | ||||||||
718 | |||||||||
719 | if( !xMasterPages.is() ) | ||||||||
720 | { | ||||||||
721 | if ( !hasControllersLocked() ) | ||||||||
722 | initializeDocument(); | ||||||||
723 | mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this); | ||||||||
724 | } | ||||||||
725 | |||||||||
726 | return xMasterPages; | ||||||||
727 | } | ||||||||
728 | |||||||||
729 | // XLayerManagerSupplier | ||||||||
730 | uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager( ) | ||||||||
731 | { | ||||||||
732 | ::SolarMutexGuard aGuard; | ||||||||
733 | |||||||||
734 | if( nullptr == mpDoc ) | ||||||||
735 | throw lang::DisposedException(); | ||||||||
736 | |||||||||
737 | uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager ); | ||||||||
738 | |||||||||
739 | if( !xLayerManager.is() ) | ||||||||
740 | mxLayerManager = xLayerManager = new SdLayerManager(*this); | ||||||||
741 | |||||||||
742 | return xLayerManager; | ||||||||
743 | } | ||||||||
744 | |||||||||
745 | // XCustomPresentationSupplier | ||||||||
746 | uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations() | ||||||||
747 | { | ||||||||
748 | ::SolarMutexGuard aGuard; | ||||||||
749 | |||||||||
750 | if( nullptr == mpDoc ) | ||||||||
751 | throw lang::DisposedException(); | ||||||||
752 | |||||||||
753 | uno::Reference< container::XNameContainer > xCustomPres( mxCustomPresentationAccess ); | ||||||||
754 | |||||||||
755 | if( !xCustomPres.is() ) | ||||||||
756 | mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this); | ||||||||
757 | |||||||||
758 | return xCustomPres; | ||||||||
759 | } | ||||||||
760 | |||||||||
761 | // XPresentationSupplier | ||||||||
762 | uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation() | ||||||||
763 | { | ||||||||
764 | ::SolarMutexGuard aGuard; | ||||||||
765 | |||||||||
766 | if( nullptr == mpDoc ) | ||||||||
767 | throw lang::DisposedException(); | ||||||||
768 | |||||||||
769 | return uno::Reference< presentation::XPresentation >( mpDoc->getPresentation().get() ); | ||||||||
770 | } | ||||||||
771 | |||||||||
772 | // XHandoutMasterSupplier | ||||||||
773 | uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage() | ||||||||
774 | { | ||||||||
775 | ::SolarMutexGuard aGuard; | ||||||||
776 | |||||||||
777 | if( nullptr == mpDoc ) | ||||||||
778 | throw lang::DisposedException(); | ||||||||
779 | |||||||||
780 | uno::Reference< drawing::XDrawPage > xPage; | ||||||||
781 | |||||||||
782 | initializeDocument(); | ||||||||
783 | SdPage* pPage = mpDoc->GetMasterSdPage(0, PageKind::Handout); | ||||||||
784 | if (pPage) | ||||||||
785 | xPage.set(pPage->getUnoPage(), uno::UNO_QUERY); | ||||||||
786 | return xPage; | ||||||||
787 | } | ||||||||
788 | |||||||||
789 | // XMultiServiceFactory ( SvxFmMSFactory ) | ||||||||
790 | |||||||||
791 | css::uno::Reference<css::uno::XInterface> SdXImpressDocument::create( | ||||||||
792 | OUString const & aServiceSpecifier, OUString const & referer) | ||||||||
793 | { | ||||||||
794 | ::SolarMutexGuard aGuard; | ||||||||
795 | |||||||||
796 | if( nullptr == mpDoc ) | ||||||||
797 | throw lang::DisposedException(); | ||||||||
798 | |||||||||
799 | if( aServiceSpecifier == "com.sun.star.drawing.DashTable" ) | ||||||||
800 | { | ||||||||
801 | if( !mxDashTable.is() ) | ||||||||
802 | mxDashTable = SvxUnoDashTable_createInstance( mpDoc ); | ||||||||
803 | |||||||||
804 | return mxDashTable; | ||||||||
805 | } | ||||||||
806 | if( aServiceSpecifier == "com.sun.star.drawing.GradientTable" ) | ||||||||
807 | { | ||||||||
808 | if( !mxGradientTable.is() ) | ||||||||
809 | mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc ); | ||||||||
810 | |||||||||
811 | return mxGradientTable; | ||||||||
812 | } | ||||||||
813 | if( aServiceSpecifier == "com.sun.star.drawing.HatchTable" ) | ||||||||
814 | { | ||||||||
815 | if( !mxHatchTable.is() ) | ||||||||
816 | mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc ); | ||||||||
817 | |||||||||
818 | return mxHatchTable; | ||||||||
819 | } | ||||||||
820 | if( aServiceSpecifier == "com.sun.star.drawing.BitmapTable" ) | ||||||||
821 | { | ||||||||
822 | if( !mxBitmapTable.is() ) | ||||||||
823 | mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc ); | ||||||||
824 | |||||||||
825 | return mxBitmapTable; | ||||||||
826 | } | ||||||||
827 | if( aServiceSpecifier == "com.sun.star.drawing.TransparencyGradientTable" ) | ||||||||
828 | { | ||||||||
829 | if( !mxTransGradientTable.is() ) | ||||||||
830 | mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc ); | ||||||||
831 | |||||||||
832 | return mxTransGradientTable; | ||||||||
833 | } | ||||||||
834 | if( aServiceSpecifier == "com.sun.star.drawing.MarkerTable" ) | ||||||||
835 | { | ||||||||
836 | if( !mxMarkerTable.is() ) | ||||||||
837 | mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc ); | ||||||||
838 | |||||||||
839 | return mxMarkerTable; | ||||||||
840 | } | ||||||||
841 | if( aServiceSpecifier == "com.sun.star.text.NumberingRules" ) | ||||||||
842 | { | ||||||||
843 | return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY ); | ||||||||
844 | } | ||||||||
845 | if( aServiceSpecifier == "com.sun.star.drawing.Background" ) | ||||||||
846 | { | ||||||||
847 | return uno::Reference< uno::XInterface >( | ||||||||
848 | static_cast<uno::XWeak*>(new SdUnoPageBackground( mpDoc ))); | ||||||||
849 | } | ||||||||
850 | |||||||||
851 | if( aServiceSpecifier == "com.sun.star.drawing.Defaults" ) | ||||||||
852 | { | ||||||||
853 | if( !mxDrawingPool.is() ) | ||||||||
854 | mxDrawingPool = SdUnoCreatePool( mpDoc ); | ||||||||
855 | |||||||||
856 | return mxDrawingPool; | ||||||||
857 | |||||||||
858 | } | ||||||||
859 | |||||||||
860 | if ( aServiceSpecifier == sUNO_Service_ImageMapRectangleObject ) | ||||||||
861 | { | ||||||||
862 | return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() ); | ||||||||
863 | } | ||||||||
864 | |||||||||
865 | if ( aServiceSpecifier == sUNO_Service_ImageMapCircleObject ) | ||||||||
866 | { | ||||||||
867 | return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() ); | ||||||||
868 | } | ||||||||
869 | |||||||||
870 | if ( aServiceSpecifier == sUNO_Service_ImageMapPolygonObject ) | ||||||||
871 | { | ||||||||
872 | return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() ); | ||||||||
873 | } | ||||||||
874 | |||||||||
875 | if( aServiceSpecifier == "com.sun.star.document.Settings" || | ||||||||
876 | ( !mbImpressDoc && ( aServiceSpecifier == "com.sun.star.drawing.DocumentSettings" ) ) || | ||||||||
877 | ( mbImpressDoc && ( aServiceSpecifier == "com.sun.star.presentation.DocumentSettings" ) ) ) | ||||||||
878 | { | ||||||||
879 | return sd::DocumentSettings_createInstance( this ); | ||||||||
880 | } | ||||||||
881 | |||||||||
882 | if( aServiceSpecifier == "com.sun.star.text.TextField.DateTime" || | ||||||||
883 | aServiceSpecifier == "com.sun.star.text.textfield.DateTime" ) | ||||||||
884 | { | ||||||||
885 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::DATE )); | ||||||||
886 | } | ||||||||
887 | |||||||||
888 | if( aServiceSpecifier == "com.sun.star.presentation.TextField.Header" || | ||||||||
889 | aServiceSpecifier == "com.sun.star.presentation.textfield.Header" ) | ||||||||
890 | { | ||||||||
891 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::PRESENTATION_HEADER )); | ||||||||
892 | } | ||||||||
893 | |||||||||
894 | if( aServiceSpecifier == "com.sun.star.presentation.TextField.Footer" || | ||||||||
895 | aServiceSpecifier == "com.sun.star.presentation.textfield.Footer" ) | ||||||||
896 | { | ||||||||
897 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::PRESENTATION_FOOTER )); | ||||||||
898 | } | ||||||||
899 | |||||||||
900 | if( aServiceSpecifier == "com.sun.star.presentation.TextField.DateTime" || | ||||||||
901 | aServiceSpecifier == "com.sun.star.presentation.textfield.DateTime" ) | ||||||||
902 | { | ||||||||
903 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::PRESENTATION_DATE_TIME )); | ||||||||
904 | } | ||||||||
905 | |||||||||
906 | if( aServiceSpecifier == "com.sun.star.text.TextField.PageName" || | ||||||||
907 | aServiceSpecifier == "com.sun.star.text.textfield.PageName" ) | ||||||||
908 | { | ||||||||
909 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField( text::textfield::Type::PAGE_NAME )); | ||||||||
910 | } | ||||||||
911 | |||||||||
912 | if (aServiceSpecifier == "com.sun.star.text.TextField.DocInfo.Custom" || | ||||||||
913 | aServiceSpecifier == "com.sun.star.text.textfield.DocInfo.Custom") | ||||||||
914 | { | ||||||||
915 | return static_cast<cppu::OWeakObject *>(new SvxUnoTextField(text::textfield::Type::DOCINFO_CUSTOM)); | ||||||||
916 | } | ||||||||
917 | |||||||||
918 | if( aServiceSpecifier == "com.sun.star.xml.NamespaceMap" ) | ||||||||
919 | { | ||||||||
920 | static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 }; | ||||||||
921 | |||||||||
922 | return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() ); | ||||||||
923 | } | ||||||||
924 | |||||||||
925 | // Support creation of GraphicStorageHandler and EmbeddedObjectResolver | ||||||||
926 | if (aServiceSpecifier == "com.sun.star.document.ExportGraphicStorageHandler") | ||||||||
927 | { | ||||||||
928 | return static_cast<cppu::OWeakObject *>(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Write )); | ||||||||
929 | } | ||||||||
930 | |||||||||
931 | if (aServiceSpecifier == "com.sun.star.document.ImportGraphicStorageHandler") | ||||||||
932 | { | ||||||||
933 | return static_cast<cppu::OWeakObject *>(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Read )); | ||||||||
934 | } | ||||||||
935 | |||||||||
936 | if( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" ) | ||||||||
937 | { | ||||||||
938 | comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist(); | ||||||||
939 | if( nullptr == pPersist ) | ||||||||
940 | throw lang::DisposedException(); | ||||||||
941 | |||||||||
942 | return static_cast<cppu::OWeakObject *>(new SvXMLEmbeddedObjectHelper( *pPersist, SvXMLEmbeddedObjectHelperMode::Write )); | ||||||||
943 | } | ||||||||
944 | |||||||||
945 | if( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" ) | ||||||||
946 | { | ||||||||
947 | comphelper::IEmbeddedHelper* pPersist = mpDoc->GetPersist(); | ||||||||
948 | if( nullptr == pPersist ) | ||||||||
949 | throw lang::DisposedException(); | ||||||||
950 | |||||||||
951 | return static_cast<cppu::OWeakObject *>(new SvXMLEmbeddedObjectHelper( *pPersist, SvXMLEmbeddedObjectHelperMode::Read )); | ||||||||
952 | } | ||||||||
953 | |||||||||
954 | uno::Reference< uno::XInterface > xRet; | ||||||||
955 | |||||||||
956 | if( aServiceSpecifier.startsWith( "com.sun.star.presentation.") ) | ||||||||
957 | { | ||||||||
958 | const OUString aType( aServiceSpecifier.copy(26) ); | ||||||||
959 | SvxShape* pShape = nullptr; | ||||||||
960 | |||||||||
961 | sal_uInt16 nType = OBJ_TEXT; | ||||||||
962 | // create a shape wrapper | ||||||||
963 | if( aType.startsWith( "TitleTextShape" ) ) | ||||||||
964 | { | ||||||||
965 | nType = OBJ_TEXT; | ||||||||
966 | } | ||||||||
967 | else if( aType.startsWith( "OutlinerShape" ) ) | ||||||||
968 | { | ||||||||
969 | nType = OBJ_TEXT; | ||||||||
970 | } | ||||||||
971 | else if( aType.startsWith( "SubtitleShape" ) ) | ||||||||
972 | { | ||||||||
973 | nType = OBJ_TEXT; | ||||||||
974 | } | ||||||||
975 | else if( aType.startsWith( "GraphicObjectShape" ) ) | ||||||||
976 | { | ||||||||
977 | nType = OBJ_GRAF; | ||||||||
978 | } | ||||||||
979 | else if( aType.startsWith( "PageShape" ) ) | ||||||||
980 | { | ||||||||
981 | nType = OBJ_PAGE; | ||||||||
982 | } | ||||||||
983 | else if( aType.startsWith( "OLE2Shape" ) ) | ||||||||
984 | { | ||||||||
985 | nType = OBJ_OLE2; | ||||||||
986 | } | ||||||||
987 | else if( aType.startsWith( "ChartShape" ) ) | ||||||||
988 | { | ||||||||
989 | nType = OBJ_OLE2; | ||||||||
990 | } | ||||||||
991 | else if( aType.startsWith( "CalcShape" ) ) | ||||||||
992 | { | ||||||||
993 | nType = OBJ_OLE2; | ||||||||
994 | } | ||||||||
995 | else if( aType.startsWith( "TableShape" ) ) | ||||||||
996 | { | ||||||||
997 | nType = OBJ_TABLE; | ||||||||
998 | } | ||||||||
999 | else if( aType.startsWith( "OrgChartShape" ) ) | ||||||||
1000 | { | ||||||||
1001 | nType = OBJ_OLE2; | ||||||||
1002 | } | ||||||||
1003 | else if( aType.startsWith( "NotesShape" ) ) | ||||||||
1004 | { | ||||||||
1005 | nType = OBJ_TEXT; | ||||||||
1006 | } | ||||||||
1007 | else if( aType.startsWith( "HandoutShape" ) ) | ||||||||
1008 | { | ||||||||
1009 | nType = OBJ_PAGE; | ||||||||
1010 | } | ||||||||
1011 | else if( aType.startsWith( "FooterShape" ) ) | ||||||||
1012 | { | ||||||||
1013 | nType = OBJ_TEXT; | ||||||||
1014 | } | ||||||||
1015 | else if( aType.startsWith( "HeaderShape" ) ) | ||||||||
1016 | { | ||||||||
1017 | nType = OBJ_TEXT; | ||||||||
1018 | } | ||||||||
1019 | else if( aType.startsWith( "SlideNumberShape" ) ) | ||||||||
1020 | { | ||||||||
1021 | nType = OBJ_TEXT; | ||||||||
1022 | } | ||||||||
1023 | else if( aType.startsWith( "DateTimeShape" ) ) | ||||||||
1024 | { | ||||||||
1025 | nType = OBJ_TEXT; | ||||||||
1026 | } | ||||||||
1027 | else if( aType.startsWith( "MediaShape" ) ) | ||||||||
1028 | { | ||||||||
1029 | nType = OBJ_MEDIA; | ||||||||
1030 | } | ||||||||
1031 | else | ||||||||
1032 | { | ||||||||
1033 | throw lang::ServiceNotRegisteredException(); | ||||||||
1034 | } | ||||||||
1035 | |||||||||
1036 | // create the API wrapper | ||||||||
1037 | pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor::Default, referer ); | ||||||||
1038 | |||||||||
1039 | // set shape type | ||||||||
1040 | if( pShape && !mbClipBoard ) | ||||||||
1041 | pShape->SetShapeType(aServiceSpecifier); | ||||||||
1042 | |||||||||
1043 | xRet = static_cast<uno::XWeak*>(pShape); | ||||||||
1044 | } | ||||||||
1045 | else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" ) | ||||||||
1046 | { | ||||||||
1047 | SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor::Default, referer ); | ||||||||
1048 | if( pShape && !mbClipBoard ) | ||||||||
1049 | pShape->SetShapeType(aServiceSpecifier); | ||||||||
1050 | |||||||||
1051 | xRet = static_cast<uno::XWeak*>(pShape); | ||||||||
1052 | } | ||||||||
1053 | else | ||||||||
1054 | { | ||||||||
1055 | xRet = SvxFmMSFactory::createInstance( aServiceSpecifier ); | ||||||||
1056 | } | ||||||||
1057 | |||||||||
1058 | uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY ); | ||||||||
1059 | SvxShape* pShape = xShape.is() ? comphelper::getUnoTunnelImplementation<SvxShape>(xShape) : nullptr; | ||||||||
1060 | if (pShape) | ||||||||
1061 | { | ||||||||
1062 | xRet.clear(); | ||||||||
1063 | new SdXShape( pShape, this ); | ||||||||
1064 | xRet = xShape; | ||||||||
1065 | xShape.clear(); | ||||||||
1066 | } | ||||||||
1067 | |||||||||
1068 | return xRet; | ||||||||
1069 | } | ||||||||
1070 | |||||||||
1071 | uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier ) | ||||||||
1072 | { | ||||||||
1073 | return create(aServiceSpecifier, ""); | ||||||||
1074 | } | ||||||||
1075 | |||||||||
1076 | css::uno::Reference<css::uno::XInterface> | ||||||||
1077 | SdXImpressDocument::createInstanceWithArguments( | ||||||||
1078 | OUString const & ServiceSpecifier, | ||||||||
1079 | css::uno::Sequence<css::uno::Any> const & Arguments) | ||||||||
1080 | { | ||||||||
1081 | OUString arg; | ||||||||
1082 | if ((ServiceSpecifier == "com.sun.star.drawing.GraphicObjectShape" | ||||||||
1083 | || ServiceSpecifier == "com.sun.star.drawing.MediaShape" | ||||||||
1084 | || ServiceSpecifier == "com.sun.star.presentation.MediaShape") | ||||||||
1085 | && Arguments.getLength() == 1 && (Arguments[0] >>= arg)) | ||||||||
1086 | { | ||||||||
1087 | return create(ServiceSpecifier, arg); | ||||||||
1088 | } | ||||||||
1089 | return SvxFmMSFactory::createInstanceWithArguments( | ||||||||
1090 | ServiceSpecifier, Arguments); | ||||||||
1091 | } | ||||||||
1092 | |||||||||
1093 | uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames() | ||||||||
1094 | { | ||||||||
1095 | ::SolarMutexGuard aGuard; | ||||||||
1096 | |||||||||
1097 | if( nullptr == mpDoc ) | ||||||||
1098 | throw lang::DisposedException(); | ||||||||
1099 | |||||||||
1100 | const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() ); | ||||||||
1101 | |||||||||
1102 | uno::Sequence< OUString > aSNS( mbImpressDoc ? 36 : 19 ); | ||||||||
1103 | |||||||||
1104 | sal_uInt16 i(0); | ||||||||
1105 | |||||||||
1106 | aSNS[i++] = "com.sun.star.drawing.DashTable"; | ||||||||
1107 | aSNS[i++] = "com.sun.star.drawing.GradientTable"; | ||||||||
1108 | aSNS[i++] = "com.sun.star.drawing.HatchTable"; | ||||||||
1109 | aSNS[i++] = "com.sun.star.drawing.BitmapTable"; | ||||||||
1110 | aSNS[i++] = "com.sun.star.drawing.TransparencyGradientTable"; | ||||||||
1111 | aSNS[i++] = "com.sun.star.drawing.MarkerTable"; | ||||||||
1112 | aSNS[i++] = "com.sun.star.text.NumberingRules"; | ||||||||
1113 | aSNS[i++] = "com.sun.star.drawing.Background"; | ||||||||
1114 | aSNS[i++] = "com.sun.star.document.Settings"; | ||||||||
1115 | aSNS[i++] = sUNO_Service_ImageMapRectangleObject; | ||||||||
1116 | aSNS[i++] = sUNO_Service_ImageMapCircleObject; | ||||||||
1117 | aSNS[i++] = sUNO_Service_ImageMapPolygonObject; | ||||||||
1118 | aSNS[i++] = "com.sun.star.xml.NamespaceMap"; | ||||||||
1119 | |||||||||
1120 | // Support creation of GraphicStorageHandler and EmbeddedObjectResolver | ||||||||
1121 | aSNS[i++] = "com.sun.star.document.ExportGraphicStorageHandler"; | ||||||||
1122 | aSNS[i++] = "com.sun.star.document.ImportGraphicStorageHandler"; | ||||||||
1123 | aSNS[i++] = "com.sun.star.document.ExportEmbeddedObjectResolver"; | ||||||||
1124 | aSNS[i++] = "com.sun.star.document.ImportEmbeddedObjectResolver"; | ||||||||
1125 | aSNS[i++] = "com.sun.star.drawing.TableShape"; | ||||||||
1126 | |||||||||
1127 | if(mbImpressDoc) | ||||||||
1128 | { | ||||||||
1129 | aSNS[i++] = "com.sun.star.presentation.TitleTextShape"; | ||||||||
1130 | aSNS[i++] = "com.sun.star.presentation.OutlinerShape"; | ||||||||
1131 | aSNS[i++] = "com.sun.star.presentation.SubtitleShape"; | ||||||||
1132 | aSNS[i++] = "com.sun.star.presentation.GraphicObjectShape"; | ||||||||
1133 | aSNS[i++] = "com.sun.star.presentation.ChartShape"; | ||||||||
1134 | aSNS[i++] = "com.sun.star.presentation.PageShape"; | ||||||||
1135 | aSNS[i++] = "com.sun.star.presentation.OLE2Shape"; | ||||||||
1136 | aSNS[i++] = "com.sun.star.presentation.TableShape"; | ||||||||
1137 | aSNS[i++] = "com.sun.star.presentation.OrgChartShape"; | ||||||||
1138 | aSNS[i++] = "com.sun.star.presentation.NotesShape"; | ||||||||
1139 | aSNS[i++] = "com.sun.star.presentation.HandoutShape"; | ||||||||
1140 | aSNS[i++] = "com.sun.star.presentation.DocumentSettings"; | ||||||||
1141 | aSNS[i++] = "com.sun.star.presentation.FooterShape"; | ||||||||
1142 | aSNS[i++] = "com.sun.star.presentation.HeaderShape"; | ||||||||
1143 | aSNS[i++] = "com.sun.star.presentation.SlideNumberShape"; | ||||||||
1144 | aSNS[i++] = "com.sun.star.presentation.DateTimeShape"; | ||||||||
1145 | aSNS[i++] = "com.sun.star.presentation.CalcShape"; | ||||||||
1146 | aSNS[i++] = "com.sun.star.presentation.MediaShape"; | ||||||||
1147 | } | ||||||||
1148 | else | ||||||||
1149 | { | ||||||||
1150 | aSNS[i++] = "com.sun.star.drawing.DocumentSettings"; | ||||||||
1151 | } | ||||||||
1152 | |||||||||
1153 | DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" )do { if (true && (!(i == aSNS.getLength()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "1153" ": "), "%s", "Sequence overrun!"); } } while (false ); | ||||||||
1154 | |||||||||
1155 | return comphelper::concatSequences( aSNS_ORG, aSNS ); | ||||||||
1156 | } | ||||||||
1157 | |||||||||
1158 | // lang::XServiceInfo | ||||||||
1159 | OUString SAL_CALL SdXImpressDocument::getImplementationName() | ||||||||
1160 | { | ||||||||
1161 | return "SdXImpressDocument"; | ||||||||
1162 | /* // Matching the .component information: | ||||||||
1163 | return mbImpressDoc | ||||||||
1164 | ? OUString("com.sun.star.comp.Draw.PresentationDocument") | ||||||||
1165 | : OUString("com.sun.star.comp.Draw.DrawingDocument"); | ||||||||
1166 | */ | ||||||||
1167 | } | ||||||||
1168 | |||||||||
1169 | sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName ) | ||||||||
1170 | { | ||||||||
1171 | return cppu::supportsService(this, ServiceName); | ||||||||
1172 | } | ||||||||
1173 | |||||||||
1174 | uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() | ||||||||
1175 | { | ||||||||
1176 | ::SolarMutexGuard aGuard; | ||||||||
1177 | |||||||||
1178 | return { "com.sun.star.document.OfficeDocument", | ||||||||
1179 | "com.sun.star.drawing.GenericDrawingDocument", | ||||||||
1180 | "com.sun.star.drawing.DrawingDocumentFactory", | ||||||||
1181 | mbImpressDoc?OUString("com.sun.star.presentation.PresentationDocument"):OUString("com.sun.star.drawing.DrawingDocument") }; | ||||||||
1182 | } | ||||||||
1183 | |||||||||
1184 | // XPropertySet | ||||||||
1185 | uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo( ) | ||||||||
1186 | { | ||||||||
1187 | ::SolarMutexGuard aGuard; | ||||||||
1188 | return mpPropSet->getPropertySetInfo(); | ||||||||
1189 | } | ||||||||
1190 | |||||||||
1191 | void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) | ||||||||
1192 | { | ||||||||
1193 | ::SolarMutexGuard aGuard; | ||||||||
1194 | |||||||||
1195 | if( nullptr == mpDoc ) | ||||||||
1196 | throw lang::DisposedException(); | ||||||||
1197 | |||||||||
1198 | const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName); | ||||||||
1199 | |||||||||
1200 | switch( pEntry ? pEntry->nWID : -1 ) | ||||||||
1201 | { | ||||||||
1202 | case WID_MODEL_LANGUAGE: | ||||||||
1203 | { | ||||||||
1204 | lang::Locale aLocale; | ||||||||
1205 | if(!(aValue >>= aLocale)) | ||||||||
1206 | throw lang::IllegalArgumentException(); | ||||||||
1207 | |||||||||
1208 | mpDoc->SetLanguage( LanguageTag::convertToLanguageType(aLocale), EE_CHAR_LANGUAGE ); | ||||||||
1209 | break; | ||||||||
1210 | } | ||||||||
1211 | case WID_MODEL_TABSTOP: | ||||||||
1212 | { | ||||||||
1213 | sal_Int32 nValue = 0; | ||||||||
1214 | if(!(aValue >>= nValue) || nValue < 0 ) | ||||||||
1215 | throw lang::IllegalArgumentException(); | ||||||||
1216 | |||||||||
1217 | mpDoc->SetDefaultTabulator(static_cast<sal_uInt16>(nValue)); | ||||||||
1218 | break; | ||||||||
1219 | } | ||||||||
1220 | case WID_MODEL_VISAREA: | ||||||||
1221 | { | ||||||||
1222 | SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); | ||||||||
1223 | if( !pEmbeddedObj ) | ||||||||
1224 | break; | ||||||||
1225 | |||||||||
1226 | awt::Rectangle aVisArea; | ||||||||
1227 | if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) ) | ||||||||
1228 | throw lang::IllegalArgumentException(); | ||||||||
1229 | |||||||||
1230 | sal_Int32 nRight, nTop; | ||||||||
1231 | if (o3tl::checked_add(aVisArea.X, aVisArea.Width, nRight) || o3tl::checked_add(aVisArea.Y, aVisArea.Height, nTop)) | ||||||||
1232 | throw lang::IllegalArgumentException(); | ||||||||
1233 | |||||||||
1234 | pEmbeddedObj->SetVisArea(::tools::Rectangle(aVisArea.X, aVisArea.Y, nRight, nTop)); | ||||||||
1235 | } | ||||||||
1236 | break; | ||||||||
1237 | case WID_MODEL_CONTFOCUS: | ||||||||
1238 | { | ||||||||
1239 | bool bFocus = false; | ||||||||
1240 | if( !(aValue >>= bFocus ) ) | ||||||||
1241 | throw lang::IllegalArgumentException(); | ||||||||
1242 | mpDoc->SetAutoControlFocus( bFocus ); | ||||||||
1243 | } | ||||||||
1244 | break; | ||||||||
1245 | case WID_MODEL_DSGNMODE: | ||||||||
1246 | { | ||||||||
1247 | bool bMode = false; | ||||||||
1248 | if( !(aValue >>= bMode ) ) | ||||||||
1249 | throw lang::IllegalArgumentException(); | ||||||||
1250 | mpDoc->SetOpenInDesignMode( bMode ); | ||||||||
1251 | } | ||||||||
1252 | break; | ||||||||
1253 | case WID_MODEL_BUILDID: | ||||||||
1254 | aValue >>= maBuildId; | ||||||||
1255 | return; | ||||||||
1256 | case WID_MODEL_MAPUNIT: | ||||||||
1257 | case WID_MODEL_BASICLIBS: | ||||||||
1258 | case WID_MODEL_RUNTIMEUID: // is read-only | ||||||||
1259 | case WID_MODEL_DIALOGLIBS: | ||||||||
1260 | case WID_MODEL_FONTS: | ||||||||
1261 | throw beans::PropertyVetoException(); | ||||||||
1262 | case WID_MODEL_INTEROPGRABBAG: | ||||||||
1263 | setGrabBagItem(aValue); | ||||||||
1264 | break; | ||||||||
1265 | default: | ||||||||
1266 | throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); | ||||||||
1267 | } | ||||||||
1268 | |||||||||
1269 | SetModified(); | ||||||||
1270 | } | ||||||||
1271 | |||||||||
1272 | uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName ) | ||||||||
1273 | { | ||||||||
1274 | ::SolarMutexGuard aGuard; | ||||||||
1275 | |||||||||
1276 | uno::Any aAny; | ||||||||
1277 | if( nullptr == mpDoc ) | ||||||||
1278 | throw lang::DisposedException(); | ||||||||
1279 | |||||||||
1280 | const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName); | ||||||||
1281 | |||||||||
1282 | switch( pEntry ? pEntry->nWID : -1 ) | ||||||||
1283 | { | ||||||||
1284 | case WID_MODEL_LANGUAGE: | ||||||||
1285 | { | ||||||||
1286 | LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE ); | ||||||||
1287 | aAny <<= LanguageTag::convertToLocale( eLang); | ||||||||
1288 | break; | ||||||||
1289 | } | ||||||||
1290 | case WID_MODEL_TABSTOP: | ||||||||
1291 | aAny <<= static_cast<sal_Int32>(mpDoc->GetDefaultTabulator()); | ||||||||
1292 | break; | ||||||||
1293 | case WID_MODEL_VISAREA: | ||||||||
1294 | { | ||||||||
1295 | SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); | ||||||||
1296 | if( !pEmbeddedObj ) | ||||||||
1297 | break; | ||||||||
1298 | |||||||||
1299 | const ::tools::Rectangle& aRect = pEmbeddedObj->GetVisArea(); | ||||||||
1300 | awt::Rectangle aVisArea( aRect.Left(), aRect.Top(), aRect.getWidth(), aRect.getHeight() ); | ||||||||
1301 | aAny <<= aVisArea; | ||||||||
1302 | } | ||||||||
1303 | break; | ||||||||
1304 | case WID_MODEL_MAPUNIT: | ||||||||
1305 | { | ||||||||
1306 | SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); | ||||||||
1307 | if( !pEmbeddedObj ) | ||||||||
1308 | break; | ||||||||
1309 | |||||||||
1310 | sal_Int16 nMeasureUnit = 0; | ||||||||
1311 | SvxMapUnitToMeasureUnit( pEmbeddedObj->GetMapUnit(), nMeasureUnit ); | ||||||||
1312 | aAny <<= nMeasureUnit; | ||||||||
1313 | } | ||||||||
1314 | break; | ||||||||
1315 | case WID_MODEL_FORBCHARS: | ||||||||
1316 | { | ||||||||
1317 | aAny <<= getForbiddenCharsTable(); | ||||||||
1318 | } | ||||||||
1319 | break; | ||||||||
1320 | case WID_MODEL_CONTFOCUS: | ||||||||
1321 | aAny <<= mpDoc->GetAutoControlFocus(); | ||||||||
1322 | break; | ||||||||
1323 | case WID_MODEL_DSGNMODE: | ||||||||
1324 | aAny <<= mpDoc->GetOpenInDesignMode(); | ||||||||
1325 | break; | ||||||||
1326 | case WID_MODEL_BASICLIBS: | ||||||||
1327 | aAny <<= mpDocShell->GetBasicContainer(); | ||||||||
1328 | break; | ||||||||
1329 | case WID_MODEL_DIALOGLIBS: | ||||||||
1330 | aAny <<= mpDocShell->GetDialogContainer(); | ||||||||
1331 | break; | ||||||||
1332 | case WID_MODEL_RUNTIMEUID: | ||||||||
1333 | aAny <<= getRuntimeUID(); | ||||||||
1334 | break; | ||||||||
1335 | case WID_MODEL_BUILDID: | ||||||||
1336 | return uno::Any( maBuildId ); | ||||||||
1337 | case WID_MODEL_HASVALIDSIGNATURES: | ||||||||
1338 | aAny <<= hasValidSignatures(); | ||||||||
1339 | break; | ||||||||
1340 | case WID_MODEL_FONTS: | ||||||||
1341 | { | ||||||||
1342 | uno::Sequence<uno::Any> aSeq; | ||||||||
1343 | int nSeqIndex = 0; | ||||||||
1344 | |||||||||
1345 | sal_uInt16 const aWhichIds[] { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK, | ||||||||
1346 | EE_CHAR_FONTINFO_CTL }; | ||||||||
1347 | |||||||||
1348 | const SfxItemPool& rPool = mpDoc->GetPool(); | ||||||||
1349 | |||||||||
1350 | for(sal_uInt16 nWhichId : aWhichIds) | ||||||||
1351 | { | ||||||||
1352 | sal_uInt32 nItems = rPool.GetItemCount2( nWhichId ); | ||||||||
1353 | |||||||||
1354 | aSeq.realloc( aSeq.getLength() + nItems*5 + 5 ); | ||||||||
1355 | |||||||||
1356 | for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nWhichId)) | ||||||||
1357 | { | ||||||||
1358 | const SvxFontItem *pFont = static_cast<const SvxFontItem *>(pItem); | ||||||||
1359 | |||||||||
1360 | aSeq[nSeqIndex++] <<= pFont->GetFamilyName(); | ||||||||
1361 | aSeq[nSeqIndex++] <<= pFont->GetStyleName(); | ||||||||
1362 | aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetFamily()); | ||||||||
1363 | aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetPitch()); | ||||||||
1364 | aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetCharSet()); | ||||||||
1365 | } | ||||||||
1366 | |||||||||
1367 | const SvxFontItem& rFont = static_cast<const SvxFontItem&>(rPool.GetDefaultItem( nWhichId )); | ||||||||
1368 | |||||||||
1369 | aSeq[nSeqIndex++] <<= rFont.GetFamilyName(); | ||||||||
1370 | aSeq[nSeqIndex++] <<= rFont.GetStyleName(); | ||||||||
1371 | aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetFamily()); | ||||||||
1372 | aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetPitch()); | ||||||||
1373 | aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetCharSet()); | ||||||||
1374 | |||||||||
1375 | } | ||||||||
1376 | |||||||||
1377 | aSeq.realloc( nSeqIndex ); | ||||||||
1378 | aAny <<= aSeq; | ||||||||
1379 | break; | ||||||||
1380 | } | ||||||||
1381 | case WID_MODEL_INTEROPGRABBAG: | ||||||||
1382 | getGrabBagItem(aAny); | ||||||||
1383 | break; | ||||||||
1384 | default: | ||||||||
1385 | throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this)); | ||||||||
1386 | } | ||||||||
1387 | |||||||||
1388 | return aAny; | ||||||||
1389 | } | ||||||||
1390 | |||||||||
1391 | void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {} | ||||||||
1392 | void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {} | ||||||||
1393 | void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {} | ||||||||
1394 | void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {} | ||||||||
1395 | |||||||||
1396 | // XLinkTargetSupplier | ||||||||
1397 | uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks() | ||||||||
1398 | { | ||||||||
1399 | ::SolarMutexGuard aGuard; | ||||||||
1400 | |||||||||
1401 | if( nullptr == mpDoc ) | ||||||||
1402 | throw lang::DisposedException(); | ||||||||
1403 | |||||||||
1404 | uno::Reference< container::XNameAccess > xLinks( mxLinks ); | ||||||||
1405 | if( !xLinks.is() ) | ||||||||
1406 | mxLinks = xLinks = new SdDocLinkTargets( *this ); | ||||||||
1407 | return xLinks; | ||||||||
1408 | } | ||||||||
1409 | |||||||||
1410 | // XStyleFamiliesSupplier | ||||||||
1411 | uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies( ) | ||||||||
1412 | { | ||||||||
1413 | ::SolarMutexGuard aGuard; | ||||||||
1414 | |||||||||
1415 | if( nullptr == mpDoc ) | ||||||||
1416 | throw lang::DisposedException(); | ||||||||
1417 | |||||||||
1418 | uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) ); | ||||||||
1419 | return xStyles; | ||||||||
1420 | } | ||||||||
1421 | |||||||||
1422 | // XAnyCompareFactory | ||||||||
1423 | uno::Reference< css::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& ) | ||||||||
1424 | { | ||||||||
1425 | return SvxCreateNumRuleCompare(); | ||||||||
1426 | } | ||||||||
1427 | |||||||||
1428 | // XRenderable | ||||||||
1429 | sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection, | ||||||||
1430 | const uno::Sequence< beans::PropertyValue >& ) | ||||||||
1431 | { | ||||||||
1432 | ::SolarMutexGuard aGuard; | ||||||||
1433 | sal_Int32 nRet = 0; | ||||||||
1434 | |||||||||
1435 | if( nullptr == mpDoc ) | ||||||||
1436 | throw lang::DisposedException(); | ||||||||
1437 | |||||||||
1438 | if (mpDocShell) | ||||||||
1439 | { | ||||||||
1440 | uno::Reference< frame::XModel > xModel; | ||||||||
1441 | |||||||||
1442 | rSelection >>= xModel; | ||||||||
1443 | |||||||||
1444 | if( xModel == mpDocShell->GetModel() ) | ||||||||
1445 | nRet = mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
1446 | else | ||||||||
1447 | { | ||||||||
1448 | uno::Reference< drawing::XShapes > xShapes; | ||||||||
1449 | |||||||||
1450 | rSelection >>= xShapes; | ||||||||
1451 | |||||||||
1452 | if( xShapes.is() && xShapes->getCount() ) | ||||||||
1453 | nRet = 1; | ||||||||
1454 | } | ||||||||
1455 | } | ||||||||
1456 | return nRet; | ||||||||
1457 | } | ||||||||
1458 | |||||||||
1459 | uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& , | ||||||||
1460 | const uno::Sequence< beans::PropertyValue >& rxOptions ) | ||||||||
1461 | { | ||||||||
1462 | ::SolarMutexGuard aGuard; | ||||||||
1463 | |||||||||
1464 | if( nullptr == mpDoc ) | ||||||||
1465 | throw lang::DisposedException(); | ||||||||
1466 | |||||||||
1467 | bool bExportNotesPages = false; | ||||||||
1468 | for( const auto& rOption : rxOptions ) | ||||||||
1469 | { | ||||||||
1470 | if ( rOption.Name == "ExportNotesPages" ) | ||||||||
1471 | rOption.Value >>= bExportNotesPages; | ||||||||
1472 | } | ||||||||
1473 | uno::Sequence< beans::PropertyValue > aRenderer; | ||||||||
1474 | if (mpDocShell) | ||||||||
1475 | { | ||||||||
1476 | awt::Size aPageSize; | ||||||||
1477 | if ( bExportNotesPages ) | ||||||||
1478 | { | ||||||||
1479 | Size aNotesPageSize = mpDoc->GetSdPage( 0, PageKind::Notes )->GetSize(); | ||||||||
1480 | aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() ); | ||||||||
1481 | } | ||||||||
1482 | else | ||||||||
1483 | { | ||||||||
1484 | const ::tools::Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) ); | ||||||||
1485 | aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() ); | ||||||||
1486 | } | ||||||||
1487 | aRenderer.realloc( 1 ); | ||||||||
1488 | |||||||||
1489 | aRenderer[ 0 ].Name = "PageSize" ; | ||||||||
1490 | aRenderer[ 0 ].Value <<= aPageSize; | ||||||||
1491 | } | ||||||||
1492 | return aRenderer; | ||||||||
1493 | } | ||||||||
1494 | |||||||||
1495 | namespace { | ||||||||
1496 | |||||||||
1497 | class ImplRenderPaintProc : public sdr::contact::ViewObjectContactRedirector | ||||||||
1498 | { | ||||||||
1499 | const SdrLayerAdmin& rLayerAdmin; | ||||||||
1500 | SdrPageView* pSdrPageView; | ||||||||
1501 | vcl::PDFExtOutDevData* pPDFExtOutDevData; | ||||||||
1502 | |||||||||
1503 | vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject ); | ||||||||
1504 | |||||||||
1505 | public: | ||||||||
1506 | bool IsVisible ( const SdrObject* pObj ) const; | ||||||||
1507 | bool IsPrintable( const SdrObject* pObj ) const; | ||||||||
1508 | |||||||||
1509 | ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData ); | ||||||||
1510 | |||||||||
1511 | // all default implementations just call the same methods at the original. To do something | ||||||||
1512 | // different, override the method and at least do what the method does. | ||||||||
1513 | virtual drawinglayer::primitive2d::Primitive2DContainer createRedirectedPrimitive2DSequence( | ||||||||
1514 | const sdr::contact::ViewObjectContact& rOriginal, | ||||||||
1515 | const sdr::contact::DisplayInfo& rDisplayInfo) override; | ||||||||
1516 | }; | ||||||||
1517 | |||||||||
1518 | } | ||||||||
1519 | |||||||||
1520 | ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData ) | ||||||||
1521 | : ViewObjectContactRedirector(), | ||||||||
1522 | rLayerAdmin ( rLA ), | ||||||||
1523 | pSdrPageView ( pView ), | ||||||||
1524 | pPDFExtOutDevData ( pData ) | ||||||||
1525 | { | ||||||||
1526 | } | ||||||||
1527 | |||||||||
1528 | static sal_Int32 ImplPDFGetBookmarkPage( const OUString& rBookmark, SdDrawDocument const & rDoc ) | ||||||||
1529 | { | ||||||||
1530 | sal_Int32 nPage = -1; | ||||||||
1531 | |||||||||
1532 | OUString aBookmark( rBookmark ); | ||||||||
1533 | |||||||||
1534 | if( rBookmark.startsWith("#") ) | ||||||||
1535 | aBookmark = rBookmark.copy( 1 ); | ||||||||
1536 | |||||||||
1537 | // is the bookmark a page ? | ||||||||
1538 | bool bIsMasterPage; | ||||||||
1539 | sal_uInt16 nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage ); | ||||||||
1540 | |||||||||
1541 | if ( nPgNum == SDRPAGE_NOTFOUND0xFFFF ) | ||||||||
1542 | { | ||||||||
1543 | // is the bookmark an object ? | ||||||||
1544 | SdrObject* pObj = rDoc.GetObj( aBookmark ); | ||||||||
1545 | if (pObj) | ||||||||
1546 | nPgNum = pObj->getSdrPageFromSdrObject()->GetPageNum(); | ||||||||
1547 | } | ||||||||
1548 | if ( nPgNum != SDRPAGE_NOTFOUND0xFFFF ) | ||||||||
1549 | nPage = ( nPgNum - 1 ) / 2; | ||||||||
1550 | return nPage; | ||||||||
1551 | } | ||||||||
1552 | |||||||||
1553 | static void ImplPDFExportComments( const uno::Reference< drawing::XDrawPage >& xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData ) | ||||||||
1554 | { | ||||||||
1555 | try | ||||||||
1556 | { | ||||||||
1557 | uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW ); | ||||||||
1558 | uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); | ||||||||
1559 | |||||||||
1560 | while( xAnnotationEnumeration->hasMoreElements() ) | ||||||||
1561 | { | ||||||||
1562 | uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() ); | ||||||||
1563 | |||||||||
1564 | geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() ); | ||||||||
1565 | uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); | ||||||||
1566 | |||||||||
1567 | vcl::PDFNote aNote; | ||||||||
1568 | aNote.Title = xAnnotation->getAuthor(); | ||||||||
1569 | aNote.Contents = xText->getString(); | ||||||||
1570 | aNote.maModificationDate = xAnnotation->getDateTime(); | ||||||||
1571 | |||||||||
1572 | rPDFExtOutDevData.CreateNote( ::tools::Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ), | ||||||||
1573 | static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote ); | ||||||||
1574 | } | ||||||||
1575 | } | ||||||||
1576 | catch (const uno::Exception&) | ||||||||
1577 | { | ||||||||
1578 | } | ||||||||
1579 | } | ||||||||
1580 | |||||||||
1581 | static void ImplPDFExportShapeInteraction( const uno::Reference< drawing::XShape >& xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData ) | ||||||||
1582 | { | ||||||||
1583 | if ( xShape->getShapeType() == "com.sun.star.drawing.GroupShape" ) | ||||||||
1584 | { | ||||||||
1585 | uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY ); | ||||||||
1586 | if ( xIndexAccess.is() ) | ||||||||
1587 | { | ||||||||
1588 | sal_Int32 i, nCount = xIndexAccess->getCount(); | ||||||||
1589 | for ( i = 0; i < nCount; i++ ) | ||||||||
1590 | { | ||||||||
1591 | uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY ); | ||||||||
1592 | if ( xSubShape.is() ) | ||||||||
1593 | ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData ); | ||||||||
1594 | } | ||||||||
1595 | } | ||||||||
1596 | } | ||||||||
1597 | else | ||||||||
1598 | { | ||||||||
1599 | uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY ); | ||||||||
1600 | if( xShapePropSet.is() ) | ||||||||
1601 | { | ||||||||
1602 | Size aPageSize( rDoc.GetSdPage( 0, PageKind::Standard )->GetSize() ); | ||||||||
1603 | Point aPoint( 0, 0 ); | ||||||||
1604 | ::tools::Rectangle aPageRect( aPoint, aPageSize ); | ||||||||
1605 | |||||||||
1606 | awt::Point aShapePos( xShape->getPosition() ); | ||||||||
1607 | awt::Size aShapeSize( xShape->getSize() ); | ||||||||
1608 | ::tools::Rectangle aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) ); | ||||||||
1609 | |||||||||
1610 | // Handle linked videos. | ||||||||
1611 | if (xShape->getShapeType() == "com.sun.star.drawing.MediaShape" || xShape->getShapeType() == "com.sun.star.presentation.MediaShape") | ||||||||
1612 | { | ||||||||
1613 | OUString aMediaURL; | ||||||||
1614 | xShapePropSet->getPropertyValue("MediaURL") >>= aMediaURL; | ||||||||
1615 | if (!aMediaURL.isEmpty()) | ||||||||
1616 | { | ||||||||
1617 | sal_Int32 nScreenId = rPDFExtOutDevData.CreateScreen(aLinkRect, rPDFExtOutDevData.GetCurrentPageNumber()); | ||||||||
1618 | if (aMediaURL.startsWith("vnd.sun.star.Package:")) | ||||||||
1619 | { | ||||||||
1620 | OUString aTempFileURL; | ||||||||
1621 | xShapePropSet->getPropertyValue("PrivateTempFileURL") >>= aTempFileURL; | ||||||||
1622 | rPDFExtOutDevData.SetScreenStream(nScreenId, aTempFileURL); | ||||||||
1623 | } | ||||||||
1624 | else | ||||||||
1625 | rPDFExtOutDevData.SetScreenURL(nScreenId, aMediaURL); | ||||||||
1626 | } | ||||||||
1627 | } | ||||||||
1628 | |||||||||
1629 | presentation::ClickAction eCa; | ||||||||
1630 | uno::Any aAny( xShapePropSet->getPropertyValue( "OnClick" ) ); | ||||||||
1631 | if ( aAny >>= eCa ) | ||||||||
1632 | { | ||||||||
1633 | switch ( eCa ) | ||||||||
1634 | { | ||||||||
1635 | case presentation::ClickAction_LASTPAGE : | ||||||||
1636 | { | ||||||||
1637 | sal_Int32 nCount = rDoc.GetSdPageCount( PageKind::Standard ); | ||||||||
1638 | sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
1639 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1640 | rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); | ||||||||
1641 | } | ||||||||
1642 | break; | ||||||||
1643 | case presentation::ClickAction_FIRSTPAGE : | ||||||||
1644 | { | ||||||||
1645 | sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
1646 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1647 | rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); | ||||||||
1648 | } | ||||||||
1649 | break; | ||||||||
1650 | case presentation::ClickAction_PREVPAGE : | ||||||||
1651 | { | ||||||||
1652 | sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber(); | ||||||||
1653 | if ( nDestPage ) | ||||||||
1654 | nDestPage--; | ||||||||
1655 | sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
1656 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1657 | rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); | ||||||||
1658 | } | ||||||||
1659 | break; | ||||||||
1660 | case presentation::ClickAction_NEXTPAGE : | ||||||||
1661 | { | ||||||||
1662 | sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1; | ||||||||
1663 | sal_Int32 nLastPage = rDoc.GetSdPageCount( PageKind::Standard ) - 1; | ||||||||
1664 | if ( nDestPage > nLastPage ) | ||||||||
1665 | nDestPage = nLastPage; | ||||||||
1666 | sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
1667 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1668 | rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); | ||||||||
1669 | } | ||||||||
1670 | break; | ||||||||
1671 | |||||||||
1672 | case presentation::ClickAction_PROGRAM : | ||||||||
1673 | case presentation::ClickAction_BOOKMARK : | ||||||||
1674 | case presentation::ClickAction_DOCUMENT : | ||||||||
1675 | { | ||||||||
1676 | OUString aBookmark; | ||||||||
1677 | xShapePropSet->getPropertyValue( "Bookmark" ) >>= aBookmark; | ||||||||
1678 | if( !aBookmark.isEmpty() ) | ||||||||
1679 | { | ||||||||
1680 | switch( eCa ) | ||||||||
1681 | { | ||||||||
1682 | case presentation::ClickAction_DOCUMENT : | ||||||||
1683 | case presentation::ClickAction_PROGRAM : | ||||||||
1684 | { | ||||||||
1685 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1686 | rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark ); | ||||||||
1687 | } | ||||||||
1688 | break; | ||||||||
1689 | case presentation::ClickAction_BOOKMARK : | ||||||||
1690 | { | ||||||||
1691 | sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc ); | ||||||||
1692 | if ( nPage != -1 ) | ||||||||
1693 | { | ||||||||
1694 | sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
1695 | sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect ); | ||||||||
1696 | rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); | ||||||||
1697 | } | ||||||||
1698 | } | ||||||||
1699 | break; | ||||||||
1700 | default: | ||||||||
1701 | break; | ||||||||
1702 | } | ||||||||
1703 | } | ||||||||
1704 | } | ||||||||
1705 | break; | ||||||||
1706 | |||||||||
1707 | case presentation::ClickAction_STOPPRESENTATION : | ||||||||
1708 | case presentation::ClickAction_SOUND : | ||||||||
1709 | case presentation::ClickAction_INVISIBLE : | ||||||||
1710 | case presentation::ClickAction_VERB : | ||||||||
1711 | case presentation::ClickAction_VANISH : | ||||||||
1712 | case presentation::ClickAction_MACRO : | ||||||||
1713 | default : | ||||||||
1714 | break; | ||||||||
1715 | } | ||||||||
1716 | } | ||||||||
1717 | } | ||||||||
1718 | } | ||||||||
1719 | } | ||||||||
1720 | |||||||||
1721 | vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject ) | ||||||||
1722 | { | ||||||||
1723 | vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement); | ||||||||
1724 | |||||||||
1725 | if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() ) | ||||||||
1726 | { | ||||||||
1727 | SdrInventor nInventor = rObject.GetObjInventor(); | ||||||||
1728 | sal_uInt16 nIdentifier = rObject.GetObjIdentifier(); | ||||||||
1729 | bool bIsTextObj = dynamic_cast< const SdrTextObj *>( &rObject ) != nullptr; | ||||||||
1730 | |||||||||
1731 | if ( nInventor == SdrInventor::Default ) | ||||||||
1732 | { | ||||||||
1733 | if ( nIdentifier == OBJ_GRUP ) | ||||||||
1734 | eElement = vcl::PDFWriter::Section; | ||||||||
1735 | else if ( nIdentifier == OBJ_TITLETEXT ) | ||||||||
1736 | eElement = vcl::PDFWriter::Heading; | ||||||||
1737 | else if ( nIdentifier == OBJ_OUTLINETEXT ) | ||||||||
1738 | eElement = vcl::PDFWriter::Division; | ||||||||
1739 | else if ( !bIsTextObj || !static_cast<SdrTextObj&>(rObject).HasText() ) | ||||||||
1740 | eElement = vcl::PDFWriter::Figure; | ||||||||
1741 | } | ||||||||
1742 | } | ||||||||
1743 | |||||||||
1744 | return eElement; | ||||||||
1745 | } | ||||||||
1746 | |||||||||
1747 | drawinglayer::primitive2d::Primitive2DContainer ImplRenderPaintProc::createRedirectedPrimitive2DSequence( | ||||||||
1748 | const sdr::contact::ViewObjectContact& rOriginal, | ||||||||
1749 | const sdr::contact::DisplayInfo& rDisplayInfo) | ||||||||
1750 | { | ||||||||
1751 | SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject(); | ||||||||
1752 | |||||||||
1753 | if(pObject) | ||||||||
1754 | { | ||||||||
1755 | drawinglayer::primitive2d::Primitive2DContainer xRetval; | ||||||||
1756 | |||||||||
1757 | if(pObject->getSdrPageFromSdrObject()) | ||||||||
1758 | { | ||||||||
1759 | if(pObject->getSdrPageFromSdrObject()->checkVisibility(rOriginal, rDisplayInfo, false)) | ||||||||
1760 | { | ||||||||
1761 | if(IsVisible(pObject) && IsPrintable(pObject)) | ||||||||
1762 | { | ||||||||
1763 | const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject )); | ||||||||
1764 | const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement); | ||||||||
1765 | |||||||||
1766 | xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); | ||||||||
1767 | |||||||||
1768 | if(!xRetval.empty() && bTagUsed) | ||||||||
1769 | { | ||||||||
1770 | // embed Primitive2DSequence in a structure tag element for | ||||||||
1771 | // exactly this purpose (StructureTagPrimitive2D) | ||||||||
1772 | |||||||||
1773 | const SdrPage* pSdrPage(pObject->getSdrPageFromSdrObject()); | ||||||||
1774 | const bool bBackground(nullptr != pSdrPage && pSdrPage->IsMasterPage()); | ||||||||
1775 | const bool bImage(pObject->GetObjIdentifier() == OBJ_GRAF); | ||||||||
1776 | |||||||||
1777 | const drawinglayer::primitive2d::Primitive2DReference xReference( | ||||||||
1778 | new drawinglayer::primitive2d::StructureTagPrimitive2D( | ||||||||
1779 | eElement, | ||||||||
1780 | bBackground, | ||||||||
1781 | bImage, | ||||||||
1782 | xRetval)); | ||||||||
1783 | |||||||||
1784 | xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference }; | ||||||||
1785 | } | ||||||||
1786 | } | ||||||||
1787 | } | ||||||||
1788 | } | ||||||||
1789 | |||||||||
1790 | return xRetval; | ||||||||
1791 | } | ||||||||
1792 | else | ||||||||
1793 | { | ||||||||
1794 | // not an object, maybe a page | ||||||||
1795 | return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); | ||||||||
1796 | } | ||||||||
1797 | } | ||||||||
1798 | |||||||||
1799 | bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const | ||||||||
1800 | { | ||||||||
1801 | bool bVisible = true; | ||||||||
1802 | SdrLayerID nLayerId = pObj->GetLayer(); | ||||||||
1803 | if( pSdrPageView ) | ||||||||
1804 | { | ||||||||
1805 | const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId ); | ||||||||
1806 | if ( pSdrLayer ) | ||||||||
1807 | { | ||||||||
1808 | const OUString& aLayerName = pSdrLayer->GetName(); | ||||||||
1809 | bVisible = pSdrPageView->IsLayerVisible( aLayerName ); | ||||||||
1810 | } | ||||||||
1811 | } | ||||||||
1812 | return bVisible; | ||||||||
1813 | } | ||||||||
1814 | bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const | ||||||||
1815 | { | ||||||||
1816 | bool bPrintable = true; | ||||||||
1817 | SdrLayerID nLayerId = pObj->GetLayer(); | ||||||||
1818 | if( pSdrPageView ) | ||||||||
1819 | { | ||||||||
1820 | const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId ); | ||||||||
1821 | if ( pSdrLayer ) | ||||||||
1822 | { | ||||||||
1823 | const OUString& aLayerName = pSdrLayer->GetName(); | ||||||||
1824 | bPrintable = pSdrPageView->IsLayerPrintable( aLayerName ); | ||||||||
1825 | } | ||||||||
1826 | } | ||||||||
1827 | return bPrintable; | ||||||||
1828 | |||||||||
1829 | } | ||||||||
1830 | |||||||||
1831 | namespace | ||||||||
1832 | { | ||||||||
1833 | sal_Int16 CalcOutputPageNum(vcl::PDFExtOutDevData const * pPDFExtOutDevData, SdDrawDocument const *pDoc, sal_Int16 nPageNumber) | ||||||||
1834 | { | ||||||||
1835 | //export all pages, simple one to one case | ||||||||
1836 | if (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) | ||||||||
1837 | return nPageNumber-1; | ||||||||
1838 | //check all preceding pages, and only count non-hidden ones | ||||||||
1839 | sal_Int16 nRet = 0; | ||||||||
1840 | for (sal_Int16 i = 0; i < nPageNumber-1; ++i) | ||||||||
1841 | { | ||||||||
1842 | if (!pDoc->GetSdPage(i, PageKind::Standard)->IsExcluded()) | ||||||||
1843 | ++nRet; | ||||||||
1844 | } | ||||||||
1845 | return nRet; | ||||||||
1846 | } | ||||||||
1847 | } | ||||||||
1848 | |||||||||
1849 | void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection, | ||||||||
1850 | const uno::Sequence< beans::PropertyValue >& rxOptions ) | ||||||||
1851 | { | ||||||||
1852 | ::SolarMutexGuard aGuard; | ||||||||
1853 | |||||||||
1854 | if( nullptr == mpDoc ) | ||||||||
1855 | throw lang::DisposedException(); | ||||||||
1856 | |||||||||
1857 | if (!mpDocShell) | ||||||||
1858 | return; | ||||||||
1859 | |||||||||
1860 | uno::Reference< awt::XDevice > xRenderDevice; | ||||||||
1861 | const sal_Int32 nPageNumber = nRenderer + 1; | ||||||||
1862 | PageKind ePageKind = PageKind::Standard; | ||||||||
1863 | bool bExportNotesPages = false; | ||||||||
1864 | |||||||||
1865 | for( const auto& rOption : rxOptions ) | ||||||||
1866 | { | ||||||||
1867 | if ( rOption.Name == "RenderDevice" ) | ||||||||
1868 | rOption.Value >>= xRenderDevice; | ||||||||
1869 | else if ( rOption.Name == "ExportNotesPages" ) | ||||||||
1870 | { | ||||||||
1871 | rOption.Value >>= bExportNotesPages; | ||||||||
1872 | if ( bExportNotesPages ) | ||||||||
1873 | ePageKind = PageKind::Notes; | ||||||||
1874 | } | ||||||||
1875 | } | ||||||||
1876 | |||||||||
1877 | if( !(xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) )) ) | ||||||||
1878 | return; | ||||||||
1879 | |||||||||
1880 | VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>( xRenderDevice ); | ||||||||
1881 | VclPtr< OutputDevice> pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >(); | ||||||||
1882 | |||||||||
1883 | if( !pOut ) | ||||||||
1884 | return; | ||||||||
1885 | |||||||||
1886 | vcl::PDFExtOutDevData* pPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData* >( pOut->GetExtOutDevData() ); | ||||||||
1887 | |||||||||
1888 | if ( mpDoc->GetSdPage(static_cast<sal_Int16>(nPageNumber)-1, PageKind::Standard)->IsExcluded() && | ||||||||
1889 | !(pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) ) | ||||||||
1890 | return; | ||||||||
1891 | |||||||||
1892 | if (pPDFExtOutDevData) | ||||||||
1893 | { | ||||||||
1894 | // Calculate the page number in the PDF output, which may be smaller than the page number in | ||||||||
1895 | // case of hidden slides. | ||||||||
1896 | sal_Int32 nOutputPageNum = CalcOutputPageNum(pPDFExtOutDevData, mpDoc, nPageNumber); | ||||||||
1897 | pPDFExtOutDevData->SetCurrentPageNumber(nOutputPageNum); | ||||||||
1898 | } | ||||||||
1899 | |||||||||
1900 | std::unique_ptr<::sd::ClientView> pView( new ::sd::ClientView( mpDocShell, pOut ) ); | ||||||||
1901 | ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->GetSize() ); | ||||||||
1902 | vcl::Region aRegion( aVisArea ); | ||||||||
1903 | |||||||||
1904 | ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell(); | ||||||||
1905 | ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : nullptr; | ||||||||
1906 | |||||||||
1907 | if ( pOldSdView ) | ||||||||
1908 | pOldSdView->SdrEndTextEdit(); | ||||||||
1909 | |||||||||
1910 | pView->SetHlplVisible( false ); | ||||||||
1911 | pView->SetGridVisible( false ); | ||||||||
1912 | pView->SetBordVisible( false ); | ||||||||
1913 | pView->SetPageVisible( false ); | ||||||||
1914 | pView->SetGlueVisible( false ); | ||||||||
1915 | |||||||||
1916 | pOut->SetMapMode(MapMode(MapUnit::Map100thMM)); | ||||||||
1917 | pOut->IntersectClipRegion( aVisArea ); | ||||||||
1918 | |||||||||
1919 | uno::Reference< frame::XModel > xModel; | ||||||||
1920 | rSelection >>= xModel; | ||||||||
1921 | |||||||||
1922 | if( xModel == mpDocShell->GetModel() ) | ||||||||
1923 | { | ||||||||
1924 | pView->ShowSdrPage( mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )); | ||||||||
1925 | SdrPageView* pPV = pView->GetSdrPageView(); | ||||||||
1926 | |||||||||
1927 | if( pOldSdView ) | ||||||||
1928 | { | ||||||||
1929 | SdrPageView* pOldPV = pOldSdView->GetSdrPageView(); | ||||||||
1930 | if( pPV && pOldPV ) | ||||||||
1931 | { | ||||||||
1932 | pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() ); | ||||||||
1933 | pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() ); | ||||||||
1934 | } | ||||||||
1935 | } | ||||||||
1936 | |||||||||
1937 | ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(), | ||||||||
1938 | pPV, pPDFExtOutDevData ); | ||||||||
1939 | |||||||||
1940 | // background color for outliner :o | ||||||||
1941 | SdPage* pPage = pPV ? static_cast<SdPage*>(pPV->GetPage()) : nullptr; | ||||||||
1942 | if( pPage ) | ||||||||
1943 | { | ||||||||
1944 | SdrOutliner& rOutl = mpDoc->GetDrawOutliner(); | ||||||||
1945 | bool bScreenDisplay(true); | ||||||||
1946 | |||||||||
1947 | // #i75566# printing; suppress AutoColor BackgroundColor generation | ||||||||
1948 | // for visibility reasons by giving GetPageBackgroundColor() | ||||||||
1949 | // the needed hint | ||||||||
1950 | // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see printing) | ||||||||
1951 | if (pOut && ((OUTDEV_PRINTER == pOut->GetOutDevType()) | ||||||||
1952 | || (OUTDEV_PDF == pOut->GetOutDevType()))) | ||||||||
1953 | bScreenDisplay = false; | ||||||||
1954 | |||||||||
1955 | // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and | ||||||||
1956 | // hint value if screen display. Only then the AutoColor mechanisms shall be applied | ||||||||
1957 | rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) ); | ||||||||
1958 | } | ||||||||
1959 | pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc ); | ||||||||
1960 | |||||||||
1961 | if ( pPDFExtOutDevData && pPage ) | ||||||||
1962 | { | ||||||||
1963 | try | ||||||||
1964 | { | ||||||||
1965 | uno::Any aAny; | ||||||||
1966 | uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) ); | ||||||||
1967 | if ( xPage.is() ) | ||||||||
1968 | { | ||||||||
1969 | if ( pPDFExtOutDevData->GetIsExportNotes() ) | ||||||||
1970 | ImplPDFExportComments( xPage, *pPDFExtOutDevData ); | ||||||||
1971 | uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY ); | ||||||||
1972 | if( xPagePropSet.is() ) | ||||||||
1973 | { | ||||||||
1974 | // exporting object interactions to pdf | ||||||||
1975 | |||||||||
1976 | // if necessary, the master page interactions will be exported first | ||||||||
1977 | bool bIsBackgroundObjectsVisible = false; // #i39428# IsBackgroundObjectsVisible not available for Draw | ||||||||
1978 | if ( mbImpressDoc && xPagePropSet->getPropertySetInfo()->hasPropertyByName( "IsBackgroundObjectsVisible" ) ) | ||||||||
1979 | xPagePropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bIsBackgroundObjectsVisible; | ||||||||
1980 | if ( bIsBackgroundObjectsVisible && !pPDFExtOutDevData->GetIsExportNotesPages() ) | ||||||||
1981 | { | ||||||||
1982 | uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY ); | ||||||||
1983 | if ( xMasterPageTarget.is() ) | ||||||||
1984 | { | ||||||||
1985 | uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage(); | ||||||||
1986 | if ( xMasterPage.is() ) | ||||||||
1987 | { | ||||||||
1988 | sal_Int32 i, nCount = xMasterPage->getCount(); | ||||||||
1989 | for ( i = 0; i < nCount; i++ ) | ||||||||
1990 | { | ||||||||
1991 | aAny = xMasterPage->getByIndex( i ); | ||||||||
1992 | uno::Reference< drawing::XShape > xShape; | ||||||||
1993 | if ( aAny >>= xShape ) | ||||||||
1994 | ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData ); | ||||||||
1995 | } | ||||||||
1996 | } | ||||||||
1997 | } | ||||||||
1998 | } | ||||||||
1999 | |||||||||
2000 | // exporting slide page object interactions | ||||||||
2001 | sal_Int32 i, nCount = xPage->getCount(); | ||||||||
2002 | for ( i = 0; i < nCount; i++ ) | ||||||||
2003 | { | ||||||||
2004 | aAny = xPage->getByIndex( i ); | ||||||||
2005 | uno::Reference< drawing::XShape > xShape; | ||||||||
2006 | if ( aAny >>= xShape ) | ||||||||
2007 | ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData ); | ||||||||
2008 | } | ||||||||
2009 | |||||||||
2010 | // exporting transition effects to pdf | ||||||||
2011 | if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && pPDFExtOutDevData->GetIsExportTransitionEffects() ) | ||||||||
2012 | { | ||||||||
2013 | const OUString sEffect( "Effect" ); | ||||||||
2014 | const OUString sSpeed ( "Speed" ); | ||||||||
2015 | sal_Int32 nTime = 800; | ||||||||
2016 | presentation::AnimationSpeed aAs; | ||||||||
2017 | if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) ) | ||||||||
2018 | { | ||||||||
2019 | aAny = xPagePropSet->getPropertyValue( sSpeed ); | ||||||||
2020 | if ( aAny >>= aAs ) | ||||||||
2021 | { | ||||||||
2022 | switch( aAs ) | ||||||||
2023 | { | ||||||||
2024 | case presentation::AnimationSpeed_SLOW : nTime = 1500; break; | ||||||||
2025 | case presentation::AnimationSpeed_FAST : nTime = 300; break; | ||||||||
2026 | default: | ||||||||
2027 | case presentation::AnimationSpeed_MEDIUM : nTime = 800; | ||||||||
2028 | } | ||||||||
2029 | } | ||||||||
2030 | } | ||||||||
2031 | presentation::FadeEffect eFe; | ||||||||
2032 | vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::PageTransition::Regular; | ||||||||
2033 | if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) ) | ||||||||
2034 | { | ||||||||
2035 | aAny = xPagePropSet->getPropertyValue( sEffect ); | ||||||||
2036 | if ( aAny >>= eFe ) | ||||||||
2037 | { | ||||||||
2038 | switch( eFe ) | ||||||||
2039 | { | ||||||||
2040 | case presentation::FadeEffect_HORIZONTAL_LINES : | ||||||||
2041 | case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD : | ||||||||
2042 | case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::PageTransition::BlindsHorizontal; break; | ||||||||
2043 | |||||||||
2044 | case presentation::FadeEffect_VERTICAL_LINES : | ||||||||
2045 | case presentation::FadeEffect_VERTICAL_CHECKERBOARD : | ||||||||
2046 | case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::PageTransition::BlindsVertical; break; | ||||||||
2047 | |||||||||
2048 | case presentation::FadeEffect_UNCOVER_TO_RIGHT : | ||||||||
2049 | case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT : | ||||||||
2050 | case presentation::FadeEffect_ROLL_FROM_LEFT : | ||||||||
2051 | case presentation::FadeEffect_FADE_FROM_UPPERLEFT : | ||||||||
2052 | case presentation::FadeEffect_MOVE_FROM_UPPERLEFT : | ||||||||
2053 | case presentation::FadeEffect_FADE_FROM_LEFT : | ||||||||
2054 | case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::PageTransition::WipeLeftToRight; break; | ||||||||
2055 | |||||||||
2056 | case presentation::FadeEffect_UNCOVER_TO_BOTTOM : | ||||||||
2057 | case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT : | ||||||||
2058 | case presentation::FadeEffect_ROLL_FROM_TOP : | ||||||||
2059 | case presentation::FadeEffect_FADE_FROM_UPPERRIGHT : | ||||||||
2060 | case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT : | ||||||||
2061 | case presentation::FadeEffect_FADE_FROM_TOP : | ||||||||
2062 | case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::PageTransition::WipeTopToBottom; break; | ||||||||
2063 | |||||||||
2064 | case presentation::FadeEffect_UNCOVER_TO_LEFT : | ||||||||
2065 | case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT : | ||||||||
2066 | case presentation::FadeEffect_ROLL_FROM_RIGHT : | ||||||||
2067 | |||||||||
2068 | case presentation::FadeEffect_FADE_FROM_LOWERRIGHT : | ||||||||
2069 | case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT : | ||||||||
2070 | case presentation::FadeEffect_FADE_FROM_RIGHT : | ||||||||
2071 | case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::PageTransition::WipeRightToLeft; break; | ||||||||
2072 | |||||||||
2073 | case presentation::FadeEffect_UNCOVER_TO_TOP : | ||||||||
2074 | case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT : | ||||||||
2075 | case presentation::FadeEffect_ROLL_FROM_BOTTOM : | ||||||||
2076 | case presentation::FadeEffect_FADE_FROM_LOWERLEFT : | ||||||||
2077 | case presentation::FadeEffect_MOVE_FROM_LOWERLEFT : | ||||||||
2078 | case presentation::FadeEffect_FADE_FROM_BOTTOM : | ||||||||
2079 | case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::PageTransition::WipeBottomToTop; break; | ||||||||
2080 | |||||||||
2081 | case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::PageTransition::SplitHorizontalInward; break; | ||||||||
2082 | case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::PageTransition::SplitHorizontalOutward; break; | ||||||||
2083 | |||||||||
2084 | case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::PageTransition::SplitVerticalInward; break; | ||||||||
2085 | case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::PageTransition::SplitVerticalOutward; break; | ||||||||
2086 | |||||||||
2087 | case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::PageTransition::BoxInward; break; | ||||||||
2088 | case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::PageTransition::BoxOutward; break; | ||||||||
2089 | |||||||||
2090 | case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::PageTransition::Regular; break; | ||||||||
2091 | |||||||||
2092 | case presentation::FadeEffect_RANDOM : | ||||||||
2093 | case presentation::FadeEffect_DISSOLVE : | ||||||||
2094 | default: eType = vcl::PDFWriter::PageTransition::Dissolve; break; | ||||||||
2095 | } | ||||||||
2096 | } | ||||||||
2097 | } | ||||||||
2098 | |||||||||
2099 | if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) || | ||||||||
2100 | xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) ) | ||||||||
2101 | { | ||||||||
2102 | pPDFExtOutDevData->SetPageTransition( eType, nTime ); | ||||||||
2103 | } | ||||||||
2104 | } | ||||||||
2105 | } | ||||||||
2106 | } | ||||||||
2107 | |||||||||
2108 | Size aPageSize( mpDoc->GetSdPage( 0, PageKind::Standard )->GetSize() ); | ||||||||
2109 | Point aPoint( 0, 0 ); | ||||||||
2110 | ::tools::Rectangle aPageRect( aPoint, aPageSize ); | ||||||||
2111 | |||||||||
2112 | // resolving links found in this page by the method ImpEditEngine::Paint | ||||||||
2113 | std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks(); | ||||||||
2114 | for ( const auto& rBookmark : rBookmarks ) | ||||||||
2115 | { | ||||||||
2116 | sal_Int32 nPage = ImplPDFGetBookmarkPage( rBookmark.aBookmark, *mpDoc ); | ||||||||
2117 | if ( nPage != -1 ) | ||||||||
2118 | { | ||||||||
2119 | if ( rBookmark.nLinkId != -1 ) | ||||||||
2120 | pPDFExtOutDevData->SetLinkDest( rBookmark.nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ) ); | ||||||||
2121 | else | ||||||||
2122 | pPDFExtOutDevData->DescribeRegisteredDest( rBookmark.nDestId, aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ); | ||||||||
2123 | } | ||||||||
2124 | else | ||||||||
2125 | pPDFExtOutDevData->SetLinkURL( rBookmark.nLinkId, rBookmark.aBookmark ); | ||||||||
2126 | } | ||||||||
2127 | rBookmarks.clear(); | ||||||||
2128 | //---> #i56629, #i40318 | ||||||||
2129 | //get the page name, will be used as outline element in PDF bookmark pane | ||||||||
2130 | OUString aPageName = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1 , PageKind::Standard )->GetName(); | ||||||||
2131 | if( !aPageName.isEmpty() ) | ||||||||
2132 | { | ||||||||
2133 | // Destination PageNum | ||||||||
2134 | const sal_Int32 nDestPageNum = CalcOutputPageNum(pPDFExtOutDevData, mpDoc, nPageNumber); | ||||||||
2135 | |||||||||
2136 | // insert the bookmark to this page into the NamedDestinations | ||||||||
2137 | if( pPDFExtOutDevData->GetIsExportNamedDestinations() ) | ||||||||
2138 | pPDFExtOutDevData->CreateNamedDest(aPageName, aPageRect, nDestPageNum); | ||||||||
2139 | |||||||||
2140 | // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx | ||||||||
2141 | // issue #i40318. | ||||||||
2142 | |||||||||
2143 | if( pPDFExtOutDevData->GetIsExportBookmarks() ) | ||||||||
2144 | { | ||||||||
2145 | // Destination Export | ||||||||
2146 | const sal_Int32 nDestId = | ||||||||
2147 | pPDFExtOutDevData->CreateDest(aPageRect , nDestPageNum); | ||||||||
2148 | |||||||||
2149 | // Create a new outline item: | ||||||||
2150 | pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId ); | ||||||||
2151 | } | ||||||||
2152 | } | ||||||||
2153 | //<--- #i56629, #i40318 | ||||||||
2154 | } | ||||||||
2155 | catch (const uno::Exception&) | ||||||||
2156 | { | ||||||||
2157 | } | ||||||||
2158 | |||||||||
2159 | } | ||||||||
2160 | } | ||||||||
2161 | else | ||||||||
2162 | { | ||||||||
2163 | uno::Reference< drawing::XShapes > xShapes; | ||||||||
2164 | rSelection >>= xShapes; | ||||||||
2165 | |||||||||
2166 | if( xShapes.is() && xShapes->getCount() ) | ||||||||
2167 | { | ||||||||
2168 | SdrPageView* pPV = nullptr; | ||||||||
2169 | |||||||||
2170 | ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(), | ||||||||
2171 | pOldSdView ? pOldSdView->GetSdrPageView() : nullptr, pPDFExtOutDevData ); | ||||||||
2172 | |||||||||
2173 | for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ ) | ||||||||
2174 | { | ||||||||
2175 | uno::Reference< drawing::XShape > xShape; | ||||||||
2176 | xShapes->getByIndex( i ) >>= xShape; | ||||||||
2177 | |||||||||
2178 | if( xShape.is() ) | ||||||||
2179 | { | ||||||||
2180 | SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShape ); | ||||||||
2181 | |||||||||
2182 | if( pShape ) | ||||||||
2183 | { | ||||||||
2184 | SdrObject* pObj = pShape->GetSdrObject(); | ||||||||
2185 | if( pObj && pObj->getSdrPageFromSdrObject() | ||||||||
2186 | && aImplRenderPaintProc.IsVisible( pObj ) | ||||||||
2187 | && aImplRenderPaintProc.IsPrintable( pObj ) ) | ||||||||
2188 | { | ||||||||
2189 | if( !pPV ) | ||||||||
2190 | pPV = pView->ShowSdrPage( pObj->getSdrPageFromSdrObject() ); | ||||||||
2191 | |||||||||
2192 | if( pPV ) | ||||||||
2193 | pView->MarkObj( pObj, pPV ); | ||||||||
2194 | } | ||||||||
2195 | } | ||||||||
2196 | } | ||||||||
2197 | } | ||||||||
2198 | pView->DrawMarkedObj(*pOut); | ||||||||
2199 | } | ||||||||
2200 | } | ||||||||
2201 | } | ||||||||
2202 | |||||||||
2203 | DrawViewShell* SdXImpressDocument::GetViewShell() | ||||||||
2204 | { | ||||||||
2205 | DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell()); | ||||||||
2206 | if (!pViewSh) | ||||||||
2207 | { | ||||||||
2208 | SAL_WARN("sd", "DrawViewShell not available!")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2208" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2208" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2208" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2208" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||
2209 | return nullptr; | ||||||||
2210 | } | ||||||||
2211 | return pViewSh; | ||||||||
2212 | } | ||||||||
2213 | |||||||||
2214 | void SdXImpressDocument::paintTile( VirtualDevice& rDevice, | ||||||||
2215 | int nOutputWidth, int nOutputHeight, | ||||||||
2216 | int nTilePosX, int nTilePosY, | ||||||||
2217 | long nTileWidth, long nTileHeight ) | ||||||||
2218 | { | ||||||||
2219 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2220 | if (!pViewSh) | ||||||||
2221 | return; | ||||||||
2222 | |||||||||
2223 | // Scaling. Must convert from pixels to twips. We know | ||||||||
2224 | // that VirtualDevices use a DPI of 96. | ||||||||
2225 | // We specifically calculate these scales first as we're still | ||||||||
2226 | // in TWIPs, and might as well minimize the number of conversions. | ||||||||
2227 | Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440) / | ||||||||
2228 | Fraction( nTileWidth); | ||||||||
2229 | Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440) / | ||||||||
2230 | Fraction( nTileHeight); | ||||||||
2231 | |||||||||
2232 | // svx seems to be the only component that works natively in | ||||||||
2233 | // 100th mm rather than TWIP. It makes most sense just to | ||||||||
2234 | // convert here and in getDocumentSize, and leave the tiled | ||||||||
2235 | // rendering API working in TWIPs. | ||||||||
2236 | long nTileWidthHMM = convertTwipToMm100( nTileWidth ); | ||||||||
2237 | long nTileHeightHMM = convertTwipToMm100( nTileHeight ); | ||||||||
2238 | int nTilePosXHMM = convertTwipToMm100( nTilePosX ); | ||||||||
2239 | int nTilePosYHMM = convertTwipToMm100( nTilePosY ); | ||||||||
2240 | |||||||||
2241 | MapMode aMapMode = rDevice.GetMapMode(); | ||||||||
2242 | aMapMode.SetMapUnit( MapUnit::Map100thMM ); | ||||||||
2243 | aMapMode.SetOrigin( Point( -nTilePosXHMM, | ||||||||
2244 | -nTilePosYHMM) ); | ||||||||
2245 | aMapMode.SetScaleX( scaleX ); | ||||||||
2246 | aMapMode.SetScaleY( scaleY ); | ||||||||
2247 | |||||||||
2248 | rDevice.SetMapMode( aMapMode ); | ||||||||
2249 | |||||||||
2250 | rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) ); | ||||||||
2251 | |||||||||
2252 | Point aPoint(nTilePosXHMM, nTilePosYHMM); | ||||||||
2253 | Size aSize(nTileWidthHMM, nTileHeightHMM); | ||||||||
2254 | ::tools::Rectangle aRect(aPoint, aSize); | ||||||||
2255 | |||||||||
2256 | pViewSh->GetView()->CompleteRedraw(&rDevice, vcl::Region(aRect)); | ||||||||
2257 | |||||||||
2258 | LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight, | ||||||||
2259 | nTilePosX, nTilePosY, nTileWidth, nTileHeight); | ||||||||
2260 | } | ||||||||
2261 | |||||||||
2262 | void SdXImpressDocument::selectPart(int nPart, int nSelect) | ||||||||
2263 | { | ||||||||
2264 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2265 | if (!pViewSh) | ||||||||
2266 | return; | ||||||||
2267 | |||||||||
2268 | pViewSh->SelectPage(nPart, nSelect); | ||||||||
2269 | } | ||||||||
2270 | |||||||||
2271 | void SdXImpressDocument::moveSelectedParts(int nPosition, bool bDuplicate) | ||||||||
2272 | { | ||||||||
2273 | // Duplicating is currently unsupported. | ||||||||
2274 | if (!bDuplicate) | ||||||||
2275 | mpDoc->MovePages(nPosition); | ||||||||
2276 | } | ||||||||
2277 | |||||||||
2278 | OUString SdXImpressDocument::getPartInfo(int nPart) | ||||||||
2279 | { | ||||||||
2280 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2281 | if (!pViewSh) | ||||||||
2282 | return OUString(); | ||||||||
2283 | |||||||||
2284 | const bool bIsVisible = pViewSh->IsVisible(nPart); | ||||||||
2285 | const bool bIsSelected = pViewSh->IsSelected(nPart); | ||||||||
2286 | |||||||||
2287 | OUString aPartInfo = "{ \"visible\": \"" + | ||||||||
2288 | OUString::number(static_cast<unsigned int>(bIsVisible)) + | ||||||||
2289 | "\", \"selected\": \"" + | ||||||||
2290 | OUString::number(static_cast<unsigned int>(bIsSelected)) + | ||||||||
2291 | "\" }"; | ||||||||
2292 | return aPartInfo; | ||||||||
2293 | } | ||||||||
2294 | |||||||||
2295 | void SdXImpressDocument::setPart( int nPart ) | ||||||||
2296 | { | ||||||||
2297 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2298 | if (!pViewSh) | ||||||||
2299 | return; | ||||||||
2300 | |||||||||
2301 | pViewSh->SwitchPage( nPart ); | ||||||||
2302 | } | ||||||||
2303 | |||||||||
2304 | int SdXImpressDocument::getParts() | ||||||||
2305 | { | ||||||||
2306 | // TODO: master pages? | ||||||||
2307 | // Read: drviews1.cxx | ||||||||
2308 | return mpDoc->GetSdPageCount(PageKind::Standard); | ||||||||
2309 | } | ||||||||
2310 | |||||||||
2311 | int SdXImpressDocument::getPart() | ||||||||
2312 | { | ||||||||
2313 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2314 | if (!pViewSh) | ||||||||
2315 | return 0; | ||||||||
2316 | |||||||||
2317 | return pViewSh->GetViewShellBase().getPart(); | ||||||||
2318 | } | ||||||||
2319 | |||||||||
2320 | OUString SdXImpressDocument::getPartName( int nPart ) | ||||||||
2321 | { | ||||||||
2322 | SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard ); | ||||||||
2323 | if (!pPage) | ||||||||
2324 | { | ||||||||
2325 | SAL_WARN("sd", "DrawViewShell not available!")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2325" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2325" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2325" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2325" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||
2326 | return OUString(); | ||||||||
2327 | } | ||||||||
2328 | |||||||||
2329 | return pPage->GetName(); | ||||||||
2330 | } | ||||||||
2331 | |||||||||
2332 | OUString SdXImpressDocument::getPartHash( int nPart ) | ||||||||
2333 | { | ||||||||
2334 | SdPage* pPage = mpDoc->GetSdPage( nPart, PageKind::Standard ); | ||||||||
2335 | if (!pPage) | ||||||||
2336 | { | ||||||||
2337 | SAL_WARN("sd", "DrawViewShell not available!")do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN , "sd")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2337" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2337" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL : if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart () << "DrawViewShell not available!") == 1) { ::sal_detail_log ( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2337" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "DrawViewShell not available!"), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "DrawViewShell not available!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sd"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2337" ": "), sal_detail_stream, 0); }; std::abort(); break ; } } } while (false); | ||||||||
2338 | return OUString(); | ||||||||
2339 | } | ||||||||
2340 | |||||||||
2341 | return OUString::number(pPage->GetHashCode()); | ||||||||
2342 | } | ||||||||
2343 | |||||||||
2344 | VclPtr<vcl::Window> SdXImpressDocument::getDocWindow() | ||||||||
2345 | { | ||||||||
2346 | SolarMutexGuard aGuard; | ||||||||
2347 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2348 | VclPtr<vcl::Window> pWindow; | ||||||||
2349 | if (pViewShell
| ||||||||
2350 | pWindow = pViewShell->GetActiveWindow(); | ||||||||
2351 | |||||||||
2352 | LokChartHelper aChartHelper(pViewShell->GetViewShell()); | ||||||||
2353 | VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow(); | ||||||||
2354 | if (pChartWindow) | ||||||||
2355 | pWindow = pChartWindow; | ||||||||
2356 | |||||||||
2357 | return pWindow; | ||||||||
2358 | } | ||||||||
2359 | |||||||||
2360 | void SdXImpressDocument::setPartMode( int nPartMode ) | ||||||||
2361 | { | ||||||||
2362 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2363 | if (!pViewSh) | ||||||||
2364 | return; | ||||||||
2365 | |||||||||
2366 | PageKind aPageKind( PageKind::Standard ); | ||||||||
2367 | switch ( nPartMode ) | ||||||||
2368 | { | ||||||||
2369 | case LOK_PARTMODE_SLIDES: | ||||||||
2370 | break; | ||||||||
2371 | case LOK_PARTMODE_NOTES: | ||||||||
2372 | aPageKind = PageKind::Notes; | ||||||||
2373 | break; | ||||||||
2374 | } | ||||||||
2375 | pViewSh->SetPageKind( aPageKind ); | ||||||||
2376 | } | ||||||||
2377 | |||||||||
2378 | Size SdXImpressDocument::getDocumentSize() | ||||||||
2379 | { | ||||||||
2380 | DrawViewShell* pViewSh = GetViewShell(); | ||||||||
2381 | if (!pViewSh) | ||||||||
2382 | return Size(); | ||||||||
2383 | |||||||||
2384 | SdrView *pSdrView = pViewSh->GetView(); | ||||||||
2385 | if (!pSdrView) | ||||||||
2386 | return Size(); | ||||||||
2387 | |||||||||
2388 | SdrPageView* pCurPageView = pSdrView->GetSdrPageView(); | ||||||||
2389 | if (!pCurPageView) | ||||||||
2390 | return Size(); | ||||||||
2391 | |||||||||
2392 | Size aSize = pCurPageView->GetPageRect().GetSize(); | ||||||||
2393 | // Convert the size in 100th mm to TWIP | ||||||||
2394 | // See paintTile above for further info. | ||||||||
2395 | return Size(convertMm100ToTwip(aSize.getWidth()), convertMm100ToTwip(aSize.getHeight())); | ||||||||
2396 | } | ||||||||
2397 | |||||||||
2398 | void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter) | ||||||||
2399 | { | ||||||||
2400 | auto commentsNode = rJsonWriter.startNode("comments"); | ||||||||
2401 | // Return annotations on master pages too ? | ||||||||
2402 | const sal_uInt16 nMaxPages = mpDoc->GetPageCount(); | ||||||||
2403 | SdPage* pPage; | ||||||||
2404 | for (sal_uInt16 nPage = 0; nPage < nMaxPages; ++nPage) | ||||||||
2405 | { | ||||||||
2406 | pPage = static_cast<SdPage*>(mpDoc->GetPage(nPage)); | ||||||||
2407 | const sd::AnnotationVector& aPageAnnotations = pPage->getAnnotations(); | ||||||||
2408 | |||||||||
2409 | for (const uno::Reference<office::XAnnotation>& xAnnotation : aPageAnnotations) | ||||||||
2410 | { | ||||||||
2411 | sal_uInt32 nID = sd::getAnnotationId(xAnnotation); | ||||||||
2412 | OString nodeName = "comment" + OString::number(nID); | ||||||||
2413 | auto commentNode = rJsonWriter.startNode(nodeName.getStr()); | ||||||||
2414 | rJsonWriter.put("id", nID); | ||||||||
2415 | rJsonWriter.put("author", xAnnotation->getAuthor()); | ||||||||
2416 | rJsonWriter.put("dateTime", utl::toISO8601(xAnnotation->getDateTime())); | ||||||||
2417 | uno::Reference<text::XText> xText(xAnnotation->getTextRange()); | ||||||||
2418 | rJsonWriter.put("text", xText->getString()); | ||||||||
2419 | rJsonWriter.put("parthash", pPage->GetHashCode()); | ||||||||
2420 | geometry::RealPoint2D const & rPoint = xAnnotation->getPosition(); | ||||||||
2421 | geometry::RealSize2D const & rSize = xAnnotation->getSize(); | ||||||||
2422 | ::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0)); | ||||||||
2423 | aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); | ||||||||
2424 | OString sRectangle = aRectangle.toString(); | ||||||||
2425 | rJsonWriter.put("rectangle", sRectangle.getStr()); | ||||||||
2426 | } | ||||||||
2427 | } | ||||||||
2428 | } | ||||||||
2429 | |||||||||
2430 | void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) | ||||||||
2431 | { | ||||||||
2432 | SolarMutexGuard aGuard; | ||||||||
2433 | |||||||||
2434 | if (DrawViewShell* pViewShell = GetViewShell()) | ||||||||
2435 | { | ||||||||
2436 | DrawView* pDrawView = pViewShell->GetDrawView(); | ||||||||
2437 | for (const beans::PropertyValue& rValue : rArguments) | ||||||||
2438 | { | ||||||||
2439 | if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>()) | ||||||||
2440 | pDrawView->SetPageShadowVisible(rValue.Value.get<bool>()); | ||||||||
2441 | else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>()) | ||||||||
2442 | pDrawView->SetAuthor(rValue.Value.get<OUString>()); | ||||||||
2443 | } | ||||||||
2444 | |||||||||
2445 | // Disable comments if requested | ||||||||
2446 | SdOptions* pOptions = SD_MOD()( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule ::Draw)) )->GetSdOptions(mpDoc->GetDocumentType()); | ||||||||
2447 | pOptions->SetShowComments(comphelper::LibreOfficeKit::isTiledAnnotations()); | ||||||||
2448 | |||||||||
2449 | pViewShell->SetRuler(false); | ||||||||
2450 | pViewShell->SetScrollBarsVisible(false); | ||||||||
2451 | |||||||||
2452 | if (sd::Window* pWindow = pViewShell->GetActiveWindow()) | ||||||||
2453 | { | ||||||||
2454 | // get the full page size in pixels | ||||||||
2455 | pWindow->EnableMapMode(); | ||||||||
2456 | Size aSize(pWindow->LogicToPixel(pDrawView->GetSdrPageView()->GetPage()->GetSize())); | ||||||||
2457 | // Disable map mode, so that it's possible to send mouse event | ||||||||
2458 | // coordinates in logic units | ||||||||
2459 | pWindow->EnableMapMode(false); | ||||||||
2460 | |||||||||
2461 | // arrange UI elements again with new view size | ||||||||
2462 | pViewShell->GetParentWindow()->SetSizePixel(aSize); | ||||||||
2463 | pViewShell->Resize(); | ||||||||
2464 | } | ||||||||
2465 | |||||||||
2466 | // Forces all images to be swapped in synchronously, this | ||||||||
2467 | // ensures that images are available when paintTile is called | ||||||||
2468 | // (whereas with async loading images start being loaded after | ||||||||
2469 | // we have painted the tile, resulting in an invalidate, followed | ||||||||
2470 | // by the tile being rerendered - which is wasteful and ugly). | ||||||||
2471 | pDrawView->SetSwapAsynchron(false); | ||||||||
2472 | } | ||||||||
2473 | |||||||||
2474 | // when the "This document may contain formatting or content that cannot | ||||||||
2475 | // be saved..." dialog appears, it is auto-cancelled with tiled rendering, | ||||||||
2476 | // causing 'Save' being disabled; so let's always save to the original | ||||||||
2477 | // format | ||||||||
2478 | SvtSaveOptions().SetWarnAlienFormat(false); | ||||||||
2479 | |||||||||
2480 | if (!getenv("LO_TESTNAME")) | ||||||||
2481 | SvtSlideSorterBarOptions().SetVisibleImpressView(true); | ||||||||
2482 | } | ||||||||
2483 | |||||||||
2484 | void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode) | ||||||||
2485 | { | ||||||||
2486 | SolarMutexGuard aGuard; | ||||||||
2487 | SfxLokHelper::postKeyEventAsync(getDocWindow(), nType, nCharCode, nKeyCode); | ||||||||
| |||||||||
2488 | } | ||||||||
2489 | |||||||||
2490 | void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) | ||||||||
2491 | { | ||||||||
2492 | SolarMutexGuard aGuard; | ||||||||
2493 | |||||||||
2494 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2495 | if (!pViewShell) | ||||||||
2496 | return; | ||||||||
2497 | |||||||||
2498 | double fScale = 1.0/TWIPS_PER_PIXEL15; | ||||||||
2499 | |||||||||
2500 | // check if user hit a chart which is being edited by him | ||||||||
2501 | LokChartHelper aChartHelper(pViewShell->GetViewShell()); | ||||||||
2502 | if (aChartHelper.postMouseEvent(nType, nX, nY, | ||||||||
2503 | nCount, nButtons, nModifier, | ||||||||
2504 | fScale, fScale)) | ||||||||
2505 | return; | ||||||||
2506 | |||||||||
2507 | // check if the user hit a chart which is being edited by someone else | ||||||||
2508 | // and, if so, skip current mouse event | ||||||||
2509 | if (nType != LOK_MOUSEEVENT_MOUSEMOVE) | ||||||||
2510 | { | ||||||||
2511 | if (LokChartHelper::HitAny(Point(nX, nY))) | ||||||||
2512 | return; | ||||||||
2513 | } | ||||||||
2514 | |||||||||
2515 | const Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY))); | ||||||||
2516 | LokMouseEventData aMouseEventData(nType, aPos, nCount, MouseEventModifiers::SIMPLECLICK, | ||||||||
2517 | nButtons, nModifier); | ||||||||
2518 | SfxLokHelper::postMouseEventAsync(pViewShell->GetActiveWindow(), aMouseEventData); | ||||||||
2519 | } | ||||||||
2520 | |||||||||
2521 | void SdXImpressDocument::setTextSelection(int nType, int nX, int nY) | ||||||||
2522 | { | ||||||||
2523 | SolarMutexGuard aGuard; | ||||||||
2524 | |||||||||
2525 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2526 | if (!pViewShell) | ||||||||
2527 | return; | ||||||||
2528 | |||||||||
2529 | LokChartHelper aChartHelper(pViewShell->GetViewShell()); | ||||||||
2530 | if (aChartHelper.setTextSelection(nType, nX, nY)) | ||||||||
2531 | return; | ||||||||
2532 | |||||||||
2533 | Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY)); | ||||||||
2534 | switch (nType) | ||||||||
2535 | { | ||||||||
2536 | case LOK_SETTEXTSELECTION_START: | ||||||||
2537 | pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/false, /*bClearMark=*/false); | ||||||||
2538 | break; | ||||||||
2539 | case LOK_SETTEXTSELECTION_END: | ||||||||
2540 | pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/true, /*bClearMark=*/false); | ||||||||
2541 | break; | ||||||||
2542 | case LOK_SETTEXTSELECTION_RESET: | ||||||||
2543 | pViewShell->SetCursorMm100Position(aPoint, /*bPoint=*/true, /*bClearMark=*/true); | ||||||||
2544 | break; | ||||||||
2545 | default: | ||||||||
2546 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" , 2546, __extension__ __PRETTY_FUNCTION__)); | ||||||||
2547 | break; | ||||||||
2548 | } | ||||||||
2549 | } | ||||||||
2550 | |||||||||
2551 | uno::Reference<datatransfer::XTransferable> SdXImpressDocument::getSelection() | ||||||||
2552 | { | ||||||||
2553 | SolarMutexGuard aGuard; | ||||||||
2554 | |||||||||
2555 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2556 | if (!pViewShell) | ||||||||
2557 | return uno::Reference<datatransfer::XTransferable>(); | ||||||||
2558 | |||||||||
2559 | return pViewShell->GetSelectionTransferrable(); | ||||||||
2560 | } | ||||||||
2561 | |||||||||
2562 | void SdXImpressDocument::setGraphicSelection(int nType, int nX, int nY) | ||||||||
2563 | { | ||||||||
2564 | SolarMutexGuard aGuard; | ||||||||
2565 | |||||||||
2566 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2567 | if (!pViewShell) | ||||||||
2568 | return; | ||||||||
2569 | |||||||||
2570 | double fScale = 1.0/TWIPS_PER_PIXEL15; | ||||||||
2571 | |||||||||
2572 | LokChartHelper aChartHelper(pViewShell->GetViewShell()); | ||||||||
2573 | if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale)) | ||||||||
2574 | return; | ||||||||
2575 | |||||||||
2576 | Point aPoint(convertTwipToMm100(nX), convertTwipToMm100(nY)); | ||||||||
2577 | switch (nType) | ||||||||
2578 | { | ||||||||
2579 | case LOK_SETGRAPHICSELECTION_START: | ||||||||
2580 | pViewShell->SetGraphicMm100Position(/*bStart=*/true, aPoint); | ||||||||
2581 | break; | ||||||||
2582 | case LOK_SETGRAPHICSELECTION_END: | ||||||||
2583 | pViewShell->SetGraphicMm100Position(/*bStart=*/false, aPoint); | ||||||||
2584 | break; | ||||||||
2585 | default: | ||||||||
2586 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" , 2586, __extension__ __PRETTY_FUNCTION__)); | ||||||||
2587 | break; | ||||||||
2588 | } | ||||||||
2589 | } | ||||||||
2590 | |||||||||
2591 | void SdXImpressDocument::resetSelection() | ||||||||
2592 | { | ||||||||
2593 | SolarMutexGuard aGuard; | ||||||||
2594 | |||||||||
2595 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2596 | if (!pViewShell) | ||||||||
2597 | return; | ||||||||
2598 | |||||||||
2599 | SdrView* pSdrView = pViewShell->GetView(); | ||||||||
2600 | if (!pSdrView) | ||||||||
2601 | return; | ||||||||
2602 | |||||||||
2603 | if (pSdrView->IsTextEdit()) | ||||||||
2604 | { | ||||||||
2605 | // Reset the editeng selection. | ||||||||
2606 | pSdrView->UnmarkAll(); | ||||||||
2607 | // Finish editing. | ||||||||
2608 | pSdrView->SdrEndTextEdit(); | ||||||||
2609 | } | ||||||||
2610 | // Reset graphic selection. | ||||||||
2611 | pSdrView->UnmarkAll(); | ||||||||
2612 | } | ||||||||
2613 | |||||||||
2614 | void SdXImpressDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard) | ||||||||
2615 | { | ||||||||
2616 | SolarMutexGuard aGuard; | ||||||||
2617 | |||||||||
2618 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2619 | if (!pViewShell) | ||||||||
2620 | return; | ||||||||
2621 | |||||||||
2622 | pViewShell->GetActiveWindow()->SetClipboard(xClipboard); | ||||||||
2623 | } | ||||||||
2624 | |||||||||
2625 | bool SdXImpressDocument::isMimeTypeSupported() | ||||||||
2626 | { | ||||||||
2627 | SolarMutexGuard aGuard; | ||||||||
2628 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2629 | if (!pViewShell) | ||||||||
2630 | return false; | ||||||||
2631 | |||||||||
2632 | TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(pViewShell->GetActiveWindow())); | ||||||||
2633 | return EditEngine::HasValidData(aDataHelper.GetTransferable()); | ||||||||
2634 | } | ||||||||
2635 | |||||||||
2636 | PointerStyle SdXImpressDocument::getPointer() | ||||||||
2637 | { | ||||||||
2638 | SolarMutexGuard aGuard; | ||||||||
2639 | DrawViewShell* pViewShell = GetViewShell(); | ||||||||
2640 | if (!pViewShell) | ||||||||
2641 | return PointerStyle::Arrow; | ||||||||
2642 | |||||||||
2643 | Window* pWindow = pViewShell->GetActiveWindow(); | ||||||||
2644 | if (!pWindow) | ||||||||
2645 | return PointerStyle::Arrow; | ||||||||
2646 | |||||||||
2647 | return pWindow->GetPointer(); | ||||||||
2648 | } | ||||||||
2649 | |||||||||
2650 | uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable() | ||||||||
2651 | { | ||||||||
2652 | uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbiddenCharacters); | ||||||||
2653 | |||||||||
2654 | if( !xForb.is() ) | ||||||||
2655 | mxForbiddenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc ); | ||||||||
2656 | |||||||||
2657 | return xForb; | ||||||||
2658 | } | ||||||||
2659 | |||||||||
2660 | void SdXImpressDocument::initializeDocument() | ||||||||
2661 | { | ||||||||
2662 | if( mbClipBoard ) | ||||||||
2663 | return; | ||||||||
2664 | |||||||||
2665 | switch( mpDoc->GetPageCount() ) | ||||||||
2666 | { | ||||||||
2667 | case 1: | ||||||||
2668 | { | ||||||||
2669 | // nasty hack to detect clipboard document | ||||||||
2670 | mbClipBoard = true; | ||||||||
2671 | break; | ||||||||
2672 | } | ||||||||
2673 | case 0: | ||||||||
2674 | { | ||||||||
2675 | mpDoc->CreateFirstPages(); | ||||||||
2676 | mpDoc->StopWorkStartupDelay(); | ||||||||
2677 | break; | ||||||||
2678 | } | ||||||||
2679 | } | ||||||||
2680 | } | ||||||||
2681 | |||||||||
2682 | SdrModel& SdXImpressDocument::getSdrModelFromUnoModel() const | ||||||||
2683 | { | ||||||||
2684 | OSL_ENSURE(GetDoc(), "No SdrModel in draw/Impress, should not happen")do { if (true && (!(GetDoc()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "2684" ": "), "%s", "No SdrModel in draw/Impress, should not happen" ); } } while (false); | ||||||||
2685 | return *GetDoc(); // TTTT should be reference | ||||||||
2686 | } | ||||||||
2687 | |||||||||
2688 | void SAL_CALL SdXImpressDocument::dispose() | ||||||||
2689 | { | ||||||||
2690 | if( mbDisposed ) | ||||||||
2691 | return; | ||||||||
2692 | |||||||||
2693 | ::SolarMutexGuard aGuard; | ||||||||
2694 | |||||||||
2695 | if( mpDoc ) | ||||||||
2696 | { | ||||||||
2697 | EndListening( *mpDoc ); | ||||||||
2698 | mpDoc = nullptr; | ||||||||
2699 | } | ||||||||
2700 | |||||||||
2701 | // Call the base class dispose() before setting the mbDisposed flag | ||||||||
2702 | // to true. The reason for this is that if close() has not yet been | ||||||||
2703 | // called this is done in SfxBaseModel::dispose(). At the end of | ||||||||
2704 | // that dispose() is called again. It is important to forward this | ||||||||
2705 | // second dispose() to the base class, too. | ||||||||
2706 | // As a consequence the following code has to be able to be run twice. | ||||||||
2707 | SfxBaseModel::dispose(); | ||||||||
2708 | mbDisposed = true; | ||||||||
2709 | |||||||||
2710 | uno::Reference< container::XNameAccess > xLinks( mxLinks ); | ||||||||
2711 | if( xLinks.is() ) | ||||||||
2712 | { | ||||||||
2713 | uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY ); | ||||||||
2714 | if( xComp.is() ) | ||||||||
2715 | xComp->dispose(); | ||||||||
2716 | |||||||||
2717 | xLinks = nullptr; | ||||||||
2718 | } | ||||||||
2719 | |||||||||
2720 | uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess ); | ||||||||
2721 | if( xDrawPagesAccess.is() ) | ||||||||
2722 | { | ||||||||
2723 | uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY ); | ||||||||
2724 | if( xComp.is() ) | ||||||||
2725 | xComp->dispose(); | ||||||||
2726 | |||||||||
2727 | xDrawPagesAccess = nullptr; | ||||||||
2728 | } | ||||||||
2729 | |||||||||
2730 | uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess ); | ||||||||
2731 | if( xDrawPagesAccess.is() ) | ||||||||
2732 | { | ||||||||
2733 | uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY ); | ||||||||
2734 | if( xComp.is() ) | ||||||||
2735 | xComp->dispose(); | ||||||||
2736 | |||||||||
2737 | xDrawPagesAccess = nullptr; | ||||||||
2738 | } | ||||||||
2739 | |||||||||
2740 | uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager ); | ||||||||
2741 | if( xLayerManager.is() ) | ||||||||
2742 | { | ||||||||
2743 | uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY ); | ||||||||
2744 | if( xComp.is() ) | ||||||||
2745 | xComp->dispose(); | ||||||||
2746 | |||||||||
2747 | xLayerManager = nullptr; | ||||||||
2748 | } | ||||||||
2749 | |||||||||
2750 | uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess ); | ||||||||
2751 | if( xCustomPresentationAccess.is() ) | ||||||||
2752 | { | ||||||||
2753 | uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY ); | ||||||||
2754 | if( xComp.is() ) | ||||||||
2755 | xComp->dispose(); | ||||||||
2756 | |||||||||
2757 | xCustomPresentationAccess = nullptr; | ||||||||
2758 | } | ||||||||
2759 | |||||||||
2760 | mxDashTable = nullptr; | ||||||||
2761 | mxGradientTable = nullptr; | ||||||||
2762 | mxHatchTable = nullptr; | ||||||||
2763 | mxBitmapTable = nullptr; | ||||||||
2764 | mxTransGradientTable = nullptr; | ||||||||
2765 | mxMarkerTable = nullptr; | ||||||||
2766 | mxDrawingPool = nullptr; | ||||||||
2767 | } | ||||||||
2768 | |||||||||
2769 | |||||||||
2770 | SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel ) throw() | ||||||||
2771 | : mpModel( &rMyModel) | ||||||||
2772 | { | ||||||||
2773 | } | ||||||||
2774 | |||||||||
2775 | SdDrawPagesAccess::~SdDrawPagesAccess() throw() | ||||||||
2776 | { | ||||||||
2777 | } | ||||||||
2778 | |||||||||
2779 | // XIndexAccess | ||||||||
2780 | sal_Int32 SAL_CALL SdDrawPagesAccess::getCount() | ||||||||
2781 | { | ||||||||
2782 | ::SolarMutexGuard aGuard; | ||||||||
2783 | |||||||||
2784 | if( nullptr == mpModel ) | ||||||||
2785 | throw lang::DisposedException(); | ||||||||
2786 | |||||||||
2787 | return mpModel->mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
2788 | } | ||||||||
2789 | |||||||||
2790 | uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index ) | ||||||||
2791 | { | ||||||||
2792 | ::SolarMutexGuard aGuard; | ||||||||
2793 | |||||||||
2794 | if( nullptr == mpModel ) | ||||||||
2795 | throw lang::DisposedException(); | ||||||||
2796 | |||||||||
2797 | uno::Any aAny; | ||||||||
2798 | |||||||||
2799 | if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PageKind::Standard ) ) ) | ||||||||
2800 | throw lang::IndexOutOfBoundsException(); | ||||||||
2801 | |||||||||
2802 | SdPage* pPage = mpModel->mpDoc->GetSdPage( static_cast<sal_uInt16>(Index), PageKind::Standard ); | ||||||||
2803 | if( pPage ) | ||||||||
2804 | { | ||||||||
2805 | uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
2806 | aAny <<= xDrawPage; | ||||||||
2807 | } | ||||||||
2808 | |||||||||
2809 | return aAny; | ||||||||
2810 | } | ||||||||
2811 | |||||||||
2812 | // XNameAccess | ||||||||
2813 | uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) | ||||||||
2814 | { | ||||||||
2815 | ::SolarMutexGuard aGuard; | ||||||||
2816 | |||||||||
2817 | if( nullptr == mpModel ) | ||||||||
2818 | throw lang::DisposedException(); | ||||||||
2819 | |||||||||
2820 | if( !aName.isEmpty() ) | ||||||||
2821 | { | ||||||||
2822 | const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
2823 | sal_uInt16 nPage; | ||||||||
2824 | for( nPage = 0; nPage < nCount; nPage++ ) | ||||||||
2825 | { | ||||||||
2826 | SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard ); | ||||||||
2827 | if(nullptr == pPage) | ||||||||
2828 | continue; | ||||||||
2829 | |||||||||
2830 | if( aName == SdDrawPage::getPageApiName( pPage ) ) | ||||||||
2831 | { | ||||||||
2832 | uno::Any aAny; | ||||||||
2833 | uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
2834 | aAny <<= xDrawPage; | ||||||||
2835 | return aAny; | ||||||||
2836 | } | ||||||||
2837 | } | ||||||||
2838 | } | ||||||||
2839 | |||||||||
2840 | throw container::NoSuchElementException(); | ||||||||
2841 | } | ||||||||
2842 | |||||||||
2843 | uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() | ||||||||
2844 | { | ||||||||
2845 | ::SolarMutexGuard aGuard; | ||||||||
2846 | |||||||||
2847 | if( nullptr == mpModel ) | ||||||||
2848 | throw lang::DisposedException(); | ||||||||
2849 | |||||||||
2850 | const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
2851 | uno::Sequence< OUString > aNames( nCount ); | ||||||||
2852 | OUString* pNames = aNames.getArray(); | ||||||||
2853 | |||||||||
2854 | sal_uInt16 nPage; | ||||||||
2855 | for( nPage = 0; nPage < nCount; nPage++ ) | ||||||||
2856 | { | ||||||||
2857 | SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard ); | ||||||||
2858 | *pNames++ = SdDrawPage::getPageApiName( pPage ); | ||||||||
2859 | } | ||||||||
2860 | |||||||||
2861 | return aNames; | ||||||||
2862 | } | ||||||||
2863 | |||||||||
2864 | sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) | ||||||||
2865 | { | ||||||||
2866 | ::SolarMutexGuard aGuard; | ||||||||
2867 | |||||||||
2868 | if( nullptr == mpModel ) | ||||||||
2869 | throw lang::DisposedException(); | ||||||||
2870 | |||||||||
2871 | const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
2872 | sal_uInt16 nPage; | ||||||||
2873 | for( nPage = 0; nPage < nCount; nPage++ ) | ||||||||
2874 | { | ||||||||
2875 | SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PageKind::Standard ); | ||||||||
2876 | if(nullptr == pPage) | ||||||||
2877 | continue; | ||||||||
2878 | |||||||||
2879 | if( aName == SdDrawPage::getPageApiName( pPage ) ) | ||||||||
2880 | return true; | ||||||||
2881 | } | ||||||||
2882 | |||||||||
2883 | return false; | ||||||||
2884 | } | ||||||||
2885 | |||||||||
2886 | // XElementAccess | ||||||||
2887 | uno::Type SAL_CALL SdDrawPagesAccess::getElementType() | ||||||||
2888 | { | ||||||||
2889 | return cppu::UnoType<drawing::XDrawPage>::get(); | ||||||||
2890 | } | ||||||||
2891 | |||||||||
2892 | sal_Bool SAL_CALL SdDrawPagesAccess::hasElements() | ||||||||
2893 | { | ||||||||
2894 | return getCount() > 0; | ||||||||
2895 | } | ||||||||
2896 | |||||||||
2897 | // XDrawPages | ||||||||
2898 | |||||||||
2899 | /** | ||||||||
2900 | * Creates a new page with model at the specified position. | ||||||||
2901 | * @returns corresponding SdDrawPage | ||||||||
2902 | */ | ||||||||
2903 | uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex ) | ||||||||
2904 | { | ||||||||
2905 | ::SolarMutexGuard aGuard; | ||||||||
2906 | comphelper::ProfileZone aZone("insertNewByIndex"); | ||||||||
2907 | |||||||||
2908 | if( nullptr == mpModel ) | ||||||||
2909 | throw lang::DisposedException(); | ||||||||
2910 | |||||||||
2911 | if( mpModel->mpDoc ) | ||||||||
2912 | { | ||||||||
2913 | SdPage* pPage = mpModel->InsertSdPage( static_cast<sal_uInt16>(nIndex), false ); | ||||||||
2914 | if( pPage ) | ||||||||
2915 | { | ||||||||
2916 | uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
2917 | return xDrawPage; | ||||||||
2918 | } | ||||||||
2919 | } | ||||||||
2920 | uno::Reference< drawing::XDrawPage > xDrawPage; | ||||||||
2921 | return xDrawPage; | ||||||||
2922 | } | ||||||||
2923 | |||||||||
2924 | /** | ||||||||
2925 | * Removes the specified SdDrawPage from the model and the internal list. It | ||||||||
2926 | * only works, if there is at least one *normal* page in the model after | ||||||||
2927 | * removing this page. | ||||||||
2928 | */ | ||||||||
2929 | void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) | ||||||||
2930 | { | ||||||||
2931 | ::SolarMutexGuard aGuard; | ||||||||
2932 | |||||||||
2933 | if( nullptr == mpModel || mpModel->mpDoc == nullptr ) | ||||||||
2934 | throw lang::DisposedException(); | ||||||||
2935 | |||||||||
2936 | SdDrawDocument& rDoc = *mpModel->mpDoc; | ||||||||
2937 | |||||||||
2938 | sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard ); | ||||||||
2939 | if( nPageCount > 1 ) | ||||||||
2940 | { | ||||||||
2941 | // get pPage from xPage and determine the Id (nPos ) afterwards | ||||||||
2942 | SdDrawPage* pSvxPage = comphelper::getUnoTunnelImplementation<SdDrawPage>( xPage ); | ||||||||
2943 | if( pSvxPage ) | ||||||||
2944 | { | ||||||||
2945 | SdPage* pPage = static_cast<SdPage*>(pSvxPage->GetSdrPage()); | ||||||||
2946 | if(pPage && ( pPage->GetPageKind() == PageKind::Standard ) ) | ||||||||
2947 | { | ||||||||
2948 | sal_uInt16 nPage = pPage->GetPageNum(); | ||||||||
2949 | |||||||||
2950 | SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) ); | ||||||||
2951 | |||||||||
2952 | bool bUndo = rDoc.IsUndoEnabled(); | ||||||||
2953 | if( bUndo ) | ||||||||
2954 | { | ||||||||
2955 | // Add undo actions and delete the pages. The order of adding | ||||||||
2956 | // the undo actions is important. | ||||||||
2957 | rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGESreinterpret_cast<char const *>("STR_UNDO_DELETEPAGES" "\004" u8"Delete slides") ) ); | ||||||||
2958 | rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage)); | ||||||||
2959 | rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage)); | ||||||||
2960 | } | ||||||||
2961 | |||||||||
2962 | rDoc.RemovePage( nPage ); // the page | ||||||||
2963 | rDoc.RemovePage( nPage ); // the notes page | ||||||||
2964 | |||||||||
2965 | if( bUndo ) | ||||||||
2966 | { | ||||||||
2967 | rDoc.EndUndo(); | ||||||||
2968 | } | ||||||||
2969 | else | ||||||||
2970 | { | ||||||||
2971 | delete pNotesPage; | ||||||||
2972 | delete pPage; | ||||||||
2973 | } | ||||||||
2974 | } | ||||||||
2975 | } | ||||||||
2976 | } | ||||||||
2977 | |||||||||
2978 | mpModel->SetModified(); | ||||||||
2979 | } | ||||||||
2980 | |||||||||
2981 | // XServiceInfo | ||||||||
2982 | |||||||||
2983 | OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) | ||||||||
2984 | { | ||||||||
2985 | return "SdDrawPagesAccess"; | ||||||||
2986 | } | ||||||||
2987 | |||||||||
2988 | sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) | ||||||||
2989 | { | ||||||||
2990 | return cppu::supportsService(this, ServiceName); | ||||||||
2991 | } | ||||||||
2992 | |||||||||
2993 | uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) | ||||||||
2994 | { | ||||||||
2995 | return { "com.sun.star.drawing.DrawPages" }; | ||||||||
2996 | } | ||||||||
2997 | |||||||||
2998 | // XComponent | ||||||||
2999 | void SAL_CALL SdDrawPagesAccess::dispose( ) | ||||||||
3000 | { | ||||||||
3001 | mpModel = nullptr; | ||||||||
3002 | } | ||||||||
3003 | |||||||||
3004 | void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3005 | { | ||||||||
3006 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3006" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3007 | } | ||||||||
3008 | |||||||||
3009 | void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3010 | { | ||||||||
3011 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3011" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3012 | } | ||||||||
3013 | |||||||||
3014 | |||||||||
3015 | SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw() | ||||||||
3016 | : mpModel(&rMyModel) | ||||||||
3017 | { | ||||||||
3018 | } | ||||||||
3019 | |||||||||
3020 | SdMasterPagesAccess::~SdMasterPagesAccess() throw() | ||||||||
3021 | { | ||||||||
3022 | } | ||||||||
3023 | |||||||||
3024 | // XComponent | ||||||||
3025 | void SAL_CALL SdMasterPagesAccess::dispose( ) | ||||||||
3026 | { | ||||||||
3027 | mpModel = nullptr; | ||||||||
3028 | } | ||||||||
3029 | |||||||||
3030 | void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3031 | { | ||||||||
3032 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3032" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3033 | } | ||||||||
3034 | |||||||||
3035 | void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3036 | { | ||||||||
3037 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3037" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3038 | } | ||||||||
3039 | |||||||||
3040 | // XIndexAccess | ||||||||
3041 | sal_Int32 SAL_CALL SdMasterPagesAccess::getCount() | ||||||||
3042 | { | ||||||||
3043 | ::SolarMutexGuard aGuard; | ||||||||
3044 | |||||||||
3045 | if( nullptr == mpModel->mpDoc ) | ||||||||
3046 | throw lang::DisposedException(); | ||||||||
3047 | |||||||||
3048 | return mpModel->mpDoc->GetMasterSdPageCount(PageKind::Standard); | ||||||||
3049 | } | ||||||||
3050 | |||||||||
3051 | /** | ||||||||
3052 | * Provides a drawing::XDrawPage interface for accessing the Masterpage at the | ||||||||
3053 | * specified position in the model. | ||||||||
3054 | */ | ||||||||
3055 | uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index ) | ||||||||
3056 | { | ||||||||
3057 | ::SolarMutexGuard aGuard; | ||||||||
3058 | comphelper::ProfileZone aZone("SdMasterPagesAccess::getByIndex"); | ||||||||
3059 | |||||||||
3060 | if( nullptr == mpModel ) | ||||||||
3061 | throw lang::DisposedException(); | ||||||||
3062 | |||||||||
3063 | uno::Any aAny; | ||||||||
3064 | |||||||||
3065 | if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PageKind::Standard ) ) ) | ||||||||
3066 | throw lang::IndexOutOfBoundsException(); | ||||||||
3067 | |||||||||
3068 | SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( static_cast<sal_uInt16>(Index), PageKind::Standard ); | ||||||||
3069 | if( pPage ) | ||||||||
3070 | { | ||||||||
3071 | uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
3072 | aAny <<= xDrawPage; | ||||||||
3073 | } | ||||||||
3074 | |||||||||
3075 | return aAny; | ||||||||
3076 | } | ||||||||
3077 | |||||||||
3078 | // XElementAccess | ||||||||
3079 | uno::Type SAL_CALL SdMasterPagesAccess::getElementType() | ||||||||
3080 | { | ||||||||
3081 | return cppu::UnoType<drawing::XDrawPage>::get(); | ||||||||
3082 | } | ||||||||
3083 | |||||||||
3084 | sal_Bool SAL_CALL SdMasterPagesAccess::hasElements() | ||||||||
3085 | { | ||||||||
3086 | return getCount() > 0; | ||||||||
3087 | } | ||||||||
3088 | |||||||||
3089 | // XDrawPages | ||||||||
3090 | uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos ) | ||||||||
3091 | { | ||||||||
3092 | ::SolarMutexGuard aGuard; | ||||||||
3093 | |||||||||
3094 | if( nullptr == mpModel ) | ||||||||
3095 | throw lang::DisposedException(); | ||||||||
3096 | |||||||||
3097 | uno::Reference< drawing::XDrawPage > xDrawPage; | ||||||||
3098 | |||||||||
3099 | SdDrawDocument* pDoc = mpModel->mpDoc; | ||||||||
3100 | if( pDoc ) | ||||||||
3101 | { | ||||||||
3102 | // calculate internal index and check for range errors | ||||||||
3103 | const sal_Int32 nMPageCount = pDoc->GetMasterPageCount(); | ||||||||
3104 | nInsertPos = nInsertPos * 2 + 1; | ||||||||
3105 | if( nInsertPos < 0 || nInsertPos > nMPageCount ) | ||||||||
3106 | nInsertPos = nMPageCount; | ||||||||
3107 | |||||||||
3108 | // now generate a unique name for the new masterpage | ||||||||
3109 | const OUString aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAMEreinterpret_cast<char const *>("STR_LAYOUT_DEFAULT_NAME" "\004" u8"Default")) ); | ||||||||
3110 | OUString aPrefix( aStdPrefix ); | ||||||||
3111 | |||||||||
3112 | bool bUnique = true; | ||||||||
3113 | |||||||||
3114 | std::vector<OUString> aPageNames; | ||||||||
3115 | for (sal_Int32 nMaster = 1; nMaster < nMPageCount; ++nMaster) | ||||||||
3116 | { | ||||||||
3117 | const SdPage* pPage = static_cast<const SdPage*>(pDoc->GetMasterPage(static_cast<sal_uInt16>(nMaster))); | ||||||||
3118 | if (!pPage) | ||||||||
3119 | continue; | ||||||||
3120 | aPageNames.push_back(pPage->GetName()); | ||||||||
3121 | if (aPageNames.back() == aPrefix) | ||||||||
3122 | bUnique = false; | ||||||||
3123 | } | ||||||||
3124 | |||||||||
3125 | sal_Int32 i = 0; | ||||||||
3126 | while (!bUnique) | ||||||||
3127 | { | ||||||||
3128 | aPrefix = aStdPrefix + " " + OUString::number(++i); | ||||||||
3129 | bUnique = std::find(aPageNames.begin(), aPageNames.end(), aPrefix) == aPageNames.end(); | ||||||||
3130 | } | ||||||||
3131 | |||||||||
3132 | OUString aLayoutName = aPrefix + SD_LT_SEPARATOR"~LT~" STR_LAYOUT_OUTLINE"Gliederung"; | ||||||||
3133 | |||||||||
3134 | // create styles | ||||||||
3135 | static_cast<SdStyleSheetPool*>(pDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix ); | ||||||||
3136 | |||||||||
3137 | // get the first page for initial size and border settings | ||||||||
3138 | SdPage* pPage = mpModel->mpDoc->GetSdPage( sal_uInt16(0), PageKind::Standard ); | ||||||||
3139 | SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( sal_uInt16(0), PageKind::Notes); | ||||||||
3140 | |||||||||
3141 | // create and insert new draw masterpage | ||||||||
3142 | SdPage* pMPage = mpModel->mpDoc->AllocSdPage(true); | ||||||||
3143 | pMPage->SetSize( pPage->GetSize() ); | ||||||||
3144 | pMPage->SetBorder( pPage->GetLeftBorder(), | ||||||||
3145 | pPage->GetUpperBorder(), | ||||||||
3146 | pPage->GetRightBorder(), | ||||||||
3147 | pPage->GetLowerBorder() ); | ||||||||
3148 | pMPage->SetLayoutName( aLayoutName ); | ||||||||
3149 | pDoc->InsertMasterPage(pMPage, static_cast<sal_uInt16>(nInsertPos)); | ||||||||
3150 | |||||||||
3151 | { | ||||||||
3152 | // ensure default MasterPage fill | ||||||||
3153 | pMPage->EnsureMasterPageDefaultBackground(); | ||||||||
3154 | } | ||||||||
3155 | |||||||||
3156 | xDrawPage.set( pMPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
3157 | |||||||||
3158 | // create and insert new notes masterpage | ||||||||
3159 | SdPage* pMNotesPage = mpModel->mpDoc->AllocSdPage(true); | ||||||||
3160 | pMNotesPage->SetSize( pRefNotesPage->GetSize() ); | ||||||||
3161 | pMNotesPage->SetPageKind(PageKind::Notes); | ||||||||
3162 | pMNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(), | ||||||||
3163 | pRefNotesPage->GetUpperBorder(), | ||||||||
3164 | pRefNotesPage->GetRightBorder(), | ||||||||
3165 | pRefNotesPage->GetLowerBorder() ); | ||||||||
3166 | pMNotesPage->SetLayoutName( aLayoutName ); | ||||||||
3167 | pDoc->InsertMasterPage(pMNotesPage, static_cast<sal_uInt16>(nInsertPos) + 1); | ||||||||
3168 | pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true); | ||||||||
3169 | mpModel->SetModified(); | ||||||||
3170 | } | ||||||||
3171 | |||||||||
3172 | return xDrawPage; | ||||||||
3173 | } | ||||||||
3174 | |||||||||
3175 | /** | ||||||||
3176 | * Removes the specified SdMasterPage from the model and the internal list. It | ||||||||
3177 | * only works, if there is no *normal* page using this page as MasterPage in | ||||||||
3178 | * the model. | ||||||||
3179 | */ | ||||||||
3180 | void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) | ||||||||
3181 | { | ||||||||
3182 | ::SolarMutexGuard aGuard; | ||||||||
3183 | |||||||||
3184 | if( nullptr == mpModel || mpModel->mpDoc == nullptr ) | ||||||||
3185 | throw lang::DisposedException(); | ||||||||
3186 | |||||||||
3187 | SdMasterPage* pSdPage = comphelper::getUnoTunnelImplementation<SdMasterPage>( xPage ); | ||||||||
3188 | if(pSdPage == nullptr) | ||||||||
3189 | return; | ||||||||
3190 | |||||||||
3191 | SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage()); | ||||||||
3192 | |||||||||
3193 | DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?")do { if (true && (!(pPage && pPage->IsMasterPage ()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.tools" ), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3193" ": "), "%s", "SdMasterPage is not masterpage?"); } } while (false); | ||||||||
3194 | |||||||||
3195 | if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0)) | ||||||||
3196 | return; //Todo: this should be excepted | ||||||||
3197 | |||||||||
3198 | // only standard pages can be removed directly | ||||||||
3199 | if( pPage->GetPageKind() != PageKind::Standard ) | ||||||||
3200 | return; | ||||||||
3201 | |||||||||
3202 | sal_uInt16 nPage = pPage->GetPageNum(); | ||||||||
3203 | |||||||||
3204 | SdDrawDocument& rDoc = *mpModel->mpDoc; | ||||||||
3205 | |||||||||
3206 | SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) ); | ||||||||
3207 | |||||||||
3208 | bool bUndo = rDoc.IsUndoEnabled(); | ||||||||
3209 | if( bUndo ) | ||||||||
3210 | { | ||||||||
3211 | // Add undo actions and delete the pages. The order of adding | ||||||||
3212 | // the undo actions is important. | ||||||||
3213 | rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGESreinterpret_cast<char const *>("STR_UNDO_DELETEPAGES" "\004" u8"Delete slides") ) ); | ||||||||
3214 | rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage)); | ||||||||
3215 | rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage)); | ||||||||
3216 | } | ||||||||
3217 | |||||||||
3218 | // remove both pages | ||||||||
3219 | rDoc.RemoveMasterPage( nPage ); | ||||||||
3220 | rDoc.RemoveMasterPage( nPage ); | ||||||||
3221 | |||||||||
3222 | if( bUndo ) | ||||||||
3223 | { | ||||||||
3224 | rDoc.EndUndo(); | ||||||||
3225 | } | ||||||||
3226 | else | ||||||||
3227 | { | ||||||||
3228 | delete pNotesPage; | ||||||||
3229 | delete pPage; | ||||||||
3230 | } | ||||||||
3231 | } | ||||||||
3232 | |||||||||
3233 | // XServiceInfo | ||||||||
3234 | |||||||||
3235 | OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) | ||||||||
3236 | { | ||||||||
3237 | return "SdMasterPagesAccess"; | ||||||||
3238 | } | ||||||||
3239 | |||||||||
3240 | sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) | ||||||||
3241 | { | ||||||||
3242 | return cppu::supportsService(this, ServiceName); | ||||||||
3243 | } | ||||||||
3244 | |||||||||
3245 | uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) | ||||||||
3246 | { | ||||||||
3247 | return { "com.sun.star.drawing.MasterPages" }; | ||||||||
3248 | } | ||||||||
3249 | |||||||||
3250 | |||||||||
3251 | SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw() | ||||||||
3252 | : mpModel( &rMyModel ) | ||||||||
3253 | { | ||||||||
3254 | } | ||||||||
3255 | |||||||||
3256 | SdDocLinkTargets::~SdDocLinkTargets() throw() | ||||||||
3257 | { | ||||||||
3258 | } | ||||||||
3259 | |||||||||
3260 | // XComponent | ||||||||
3261 | void SAL_CALL SdDocLinkTargets::dispose( ) | ||||||||
3262 | { | ||||||||
3263 | mpModel = nullptr; | ||||||||
3264 | } | ||||||||
3265 | |||||||||
3266 | void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3267 | { | ||||||||
3268 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3268" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3269 | } | ||||||||
3270 | |||||||||
3271 | void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >& ) | ||||||||
3272 | { | ||||||||
3273 | OSL_FAIL( "not implemented!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sd/source/ui/unoidl/unomodel.cxx" ":" "3273" ": "), "%s", "not implemented!"); } } while (false ); | ||||||||
3274 | } | ||||||||
3275 | |||||||||
3276 | // XNameAccess | ||||||||
3277 | uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName ) | ||||||||
3278 | { | ||||||||
3279 | ::SolarMutexGuard aGuard; | ||||||||
3280 | |||||||||
3281 | if( nullptr == mpModel ) | ||||||||
3282 | throw lang::DisposedException(); | ||||||||
3283 | |||||||||
3284 | SdPage* pPage = FindPage( aName ); | ||||||||
3285 | |||||||||
3286 | if( pPage == nullptr ) | ||||||||
3287 | throw container::NoSuchElementException(); | ||||||||
3288 | |||||||||
3289 | uno::Any aAny; | ||||||||
3290 | |||||||||
3291 | uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY ); | ||||||||
3292 | if( xProps.is() ) | ||||||||
3293 | aAny <<= xProps; | ||||||||
3294 | |||||||||
3295 | return aAny; | ||||||||
3296 | } | ||||||||
3297 | |||||||||
3298 | uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames() | ||||||||
3299 | { | ||||||||
3300 | ::SolarMutexGuard aGuard; | ||||||||
3301 | |||||||||
3302 | if( nullptr == mpModel ) | ||||||||
3303 | throw lang::DisposedException(); | ||||||||
3304 | |||||||||
3305 | SdDrawDocument* pDoc = mpModel->GetDoc(); | ||||||||
3306 | if( pDoc == nullptr ) | ||||||||
3307 | { | ||||||||
3308 | return { }; | ||||||||
3309 | } | ||||||||
3310 | |||||||||
3311 | if( pDoc->GetDocumentType() == DocumentType::Draw ) | ||||||||
3312 | { | ||||||||
3313 | const sal_uInt16 nMaxPages = pDoc->GetSdPageCount( PageKind::Standard ); | ||||||||
3314 | const sal_uInt16 nMaxMasterPages = pDoc->GetMasterSdPageCount( PageKind::Standard ); | ||||||||
3315 | |||||||||
3316 | uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages ); | ||||||||
3317 | OUString* pStr = aSeq.getArray(); | ||||||||
3318 | |||||||||
3319 | sal_uInt16 nPage; | ||||||||
3320 | // standard pages | ||||||||
3321 | for( nPage = 0; nPage < nMaxPages; nPage++ ) | ||||||||
3322 | *pStr++ = pDoc->GetSdPage( nPage, PageKind::Standard )->GetName(); | ||||||||
3323 | |||||||||
3324 | // master pages | ||||||||
3325 | for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) | ||||||||
3326 | *pStr++ = pDoc->GetMasterSdPage( nPage, PageKind::Standard )->GetName(); | ||||||||
3327 | return aSeq; | ||||||||
3328 | } | ||||||||
3329 | else | ||||||||
3330 | { | ||||||||
3331 | const sal_uInt16 nMaxPages = pDoc->GetPageCount(); | ||||||||
3332 | const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount(); | ||||||||
3333 | |||||||||
3334 | uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages ); | ||||||||
3335 | OUString* pStr = aSeq.getArray(); | ||||||||
3336 | |||||||||
3337 | sal_uInt16 nPage; | ||||||||
3338 | // standard pages | ||||||||
3339 | for( nPage = 0; nPage < nMaxPages; nPage++ ) | ||||||||
3340 | *pStr++ = static_cast<SdPage*>(pDoc->GetPage( nPage ))->GetName(); | ||||||||
3341 | |||||||||
3342 | // master pages | ||||||||
3343 | for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) | ||||||||
3344 | *pStr++ = static_cast<SdPage*>(pDoc->GetMasterPage( nPage ))->GetName(); | ||||||||
3345 | return aSeq; | ||||||||
3346 | } | ||||||||
3347 | } | ||||||||
3348 | |||||||||
3349 | sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName ) | ||||||||
3350 | { | ||||||||
3351 | ::SolarMutexGuard aGuard; | ||||||||
3352 | |||||||||
3353 | if( nullptr == mpModel ) | ||||||||
3354 | throw lang::DisposedException(); | ||||||||
3355 | |||||||||
3356 | return FindPage( aName ) != nullptr; | ||||||||
3357 | } | ||||||||
3358 | |||||||||
3359 | // container::XElementAccess | ||||||||
3360 | uno::Type SAL_CALL SdDocLinkTargets::getElementType() | ||||||||
3361 | { | ||||||||
3362 | return cppu::UnoType<beans::XPropertySet>::get(); | ||||||||
3363 | } | ||||||||
3364 | |||||||||
3365 | sal_Bool SAL_CALL SdDocLinkTargets::hasElements() | ||||||||
3366 | { | ||||||||
3367 | ::SolarMutexGuard aGuard; | ||||||||
3368 | |||||||||
3369 | if( nullptr == mpModel ) | ||||||||
3370 | throw lang::DisposedException(); | ||||||||
3371 | |||||||||
3372 | return mpModel->GetDoc() != nullptr; | ||||||||
3373 | } | ||||||||
3374 | |||||||||
3375 | SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const | ||||||||
3376 | { | ||||||||
3377 | SdDrawDocument* pDoc = mpModel->GetDoc(); | ||||||||
3378 | if( pDoc == nullptr ) | ||||||||
3379 | return nullptr; | ||||||||
3380 | |||||||||
3381 | const sal_uInt16 nMaxPages = pDoc->GetPageCount(); | ||||||||
3382 | const sal_uInt16 nMaxMasterPages = pDoc->GetMasterPageCount(); | ||||||||
3383 | |||||||||
3384 | sal_uInt16 nPage; | ||||||||
3385 | SdPage* pPage; | ||||||||
3386 | |||||||||
3387 | const bool bDraw = pDoc->GetDocumentType() == DocumentType::Draw; | ||||||||
3388 | |||||||||
3389 | // standard pages | ||||||||
3390 | for( nPage = 0; nPage < nMaxPages; nPage++ ) | ||||||||
3391 | { | ||||||||
3392 | pPage = static_cast<SdPage*>(pDoc->GetPage( nPage )); | ||||||||
3393 | if( (pPage->GetName() == rName) && (!bDraw || (pPage->GetPageKind() == PageKind::Standard)) ) | ||||||||
3394 | return pPage; | ||||||||
3395 | } | ||||||||
3396 | |||||||||
3397 | // master pages | ||||||||
3398 | for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) | ||||||||
3399 | { | ||||||||
3400 | pPage = static_cast<SdPage*>(pDoc->GetMasterPage( nPage )); | ||||||||
3401 | if( (pPage->GetName() == rName) && (!bDraw || (pPage->GetPageKind() == PageKind::Standard)) ) | ||||||||
3402 | return pPage; | ||||||||
3403 | } | ||||||||
3404 | |||||||||
3405 | return nullptr; | ||||||||
3406 | } | ||||||||
3407 | |||||||||
3408 | // XServiceInfo | ||||||||
3409 | OUString SAL_CALL SdDocLinkTargets::getImplementationName() | ||||||||
3410 | { | ||||||||
3411 | return "SdDocLinkTargets"; | ||||||||
3412 | } | ||||||||
3413 | |||||||||
3414 | sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName ) | ||||||||
3415 | { | ||||||||
3416 | return cppu::supportsService( this, ServiceName ); | ||||||||
3417 | } | ||||||||
3418 | |||||||||
3419 | uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames() | ||||||||
3420 | { | ||||||||
3421 | return { "com.sun.star.document.LinkTargets" }; | ||||||||
3422 | } | ||||||||
3423 | |||||||||
3424 | rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument const & rDocument ) | ||||||||
3425 | { | ||||||||
3426 | rtl::Reference< SdXImpressDocument > xRet; | ||||||||
3427 | ::sd::DrawDocShell* pDocShell(rDocument.GetDocSh()); | ||||||||
3428 | if( pDocShell ) | ||||||||
3429 | { | ||||||||
3430 | uno::Reference<frame::XModel> xModel(pDocShell->GetModel()); | ||||||||
3431 | |||||||||
3432 | xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) ); | ||||||||
3433 | } | ||||||||
3434 | |||||||||
3435 | return xRet; | ||||||||
3436 | } | ||||||||
3437 | |||||||||
3438 | void NotifyDocumentEvent( SdDrawDocument const & rDocument, const OUString& rEventName ) | ||||||||
3439 | { | ||||||||
3440 | rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( rDocument ) ); | ||||||||
3441 | |||||||||
3442 | if( xModel.is() ) | ||||||||
3443 | { | ||||||||
3444 | uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) ); | ||||||||
3445 | css::document::EventObject aEvent( xSource, rEventName ); | ||||||||
3446 | xModel->notifyEvent(aEvent ); | ||||||||
3447 | } | ||||||||
3448 | } | ||||||||
3449 | |||||||||
3450 | void NotifyDocumentEvent( SdDrawDocument const & rDocument, const OUString& rEventName, const uno::Reference< uno::XInterface >& xSource ) | ||||||||
3451 | { | ||||||||
3452 | rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( rDocument ) ); | ||||||||
3453 | |||||||||
3454 | if( xModel.is() ) | ||||||||
3455 | { | ||||||||
3456 | css::document::EventObject aEvent( xSource, rEventName ); | ||||||||
3457 | xModel->notifyEvent(aEvent ); | ||||||||
3458 | } | ||||||||
3459 | } | ||||||||
3460 | |||||||||
3461 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||||||||||
2 | /* | ||||||||||||||||
3 | * This file is part of the LibreOffice project. | ||||||||||||||||
4 | * | ||||||||||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||||||||||
8 | * | ||||||||||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||||||||||
10 | * | ||||||||||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||||||||||
13 | * with this work for additional information regarding copyright | ||||||||||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||||||||||
18 | */ | ||||||||||||||||
19 | |||||||||||||||||
20 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||||||||||
22 | |||||||||||||||||
23 | #include "sal/config.h" | ||||||||||||||||
24 | |||||||||||||||||
25 | #include <cassert> | ||||||||||||||||
26 | #include <cstddef> | ||||||||||||||||
27 | #include <functional> | ||||||||||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||
29 | #include <type_traits> | ||||||||||||||||
30 | #endif | ||||||||||||||||
31 | |||||||||||||||||
32 | #include "sal/types.h" | ||||||||||||||||
33 | |||||||||||||||||
34 | namespace rtl | ||||||||||||||||
35 | { | ||||||||||||||||
36 | |||||||||||||||||
37 | /** Template reference class for reference type. | ||||||||||||||||
38 | */ | ||||||||||||||||
39 | template <class reference_type> | ||||||||||||||||
40 | class Reference | ||||||||||||||||
41 | { | ||||||||||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||||||||||
43 | */ | ||||||||||||||||
44 | reference_type * m_pBody; | ||||||||||||||||
45 | |||||||||||||||||
46 | |||||||||||||||||
47 | public: | ||||||||||||||||
48 | /** Constructor... | ||||||||||||||||
49 | */ | ||||||||||||||||
50 | Reference() | ||||||||||||||||
51 | : m_pBody (NULL__null) | ||||||||||||||||
52 | {} | ||||||||||||||||
53 | |||||||||||||||||
54 | |||||||||||||||||
55 | /** Constructor... | ||||||||||||||||
56 | */ | ||||||||||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||||||||||
58 | : m_pBody (pBody) | ||||||||||||||||
59 | { | ||||||||||||||||
60 | } | ||||||||||||||||
61 | |||||||||||||||||
62 | /** Constructor... | ||||||||||||||||
63 | */ | ||||||||||||||||
64 | Reference (reference_type * pBody) | ||||||||||||||||
65 | : m_pBody (pBody) | ||||||||||||||||
66 | { | ||||||||||||||||
67 | if (m_pBody) | ||||||||||||||||
68 | m_pBody->acquire(); | ||||||||||||||||
69 | } | ||||||||||||||||
70 | |||||||||||||||||
71 | /** Copy constructor... | ||||||||||||||||
72 | */ | ||||||||||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||||||||||
75 | { | ||||||||||||||||
76 | if (m_pBody) | ||||||||||||||||
77 | m_pBody->acquire(); | ||||||||||||||||
78 | } | ||||||||||||||||
79 | |||||||||||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||
81 | /** Move constructor... | ||||||||||||||||
82 | */ | ||||||||||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||||||||||
85 | { | ||||||||||||||||
86 | handle.m_pBody = nullptr; | ||||||||||||||||
87 | } | ||||||||||||||||
88 | #endif | ||||||||||||||||
89 | |||||||||||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||||||||||
92 | |||||||||||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||||||||||
94 | |||||||||||||||||
95 | @param rRef another reference | ||||||||||||||||
96 | */ | ||||||||||||||||
97 | template< class derived_type > | ||||||||||||||||
98 | inline Reference( | ||||||||||||||||
99 | const Reference< derived_type > & rRef, | ||||||||||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||||||||||
101 | : m_pBody (rRef.get()) | ||||||||||||||||
102 | { | ||||||||||||||||
103 | if (m_pBody) | ||||||||||||||||
104 | m_pBody->acquire(); | ||||||||||||||||
105 | } | ||||||||||||||||
106 | #endif | ||||||||||||||||
107 | |||||||||||||||||
108 | /** Destructor... | ||||||||||||||||
109 | */ | ||||||||||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||||||||||
111 | { | ||||||||||||||||
112 | if (m_pBody
| ||||||||||||||||
113 | m_pBody->release(); | ||||||||||||||||
| |||||||||||||||||
114 | } | ||||||||||||||||
115 | |||||||||||||||||
116 | /** Set... | ||||||||||||||||
117 | Similar to assignment. | ||||||||||||||||
118 | */ | ||||||||||||||||
119 | Reference<reference_type> & | ||||||||||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||||||||||
121 | { | ||||||||||||||||
122 | if (pBody) | ||||||||||||||||
123 | pBody->acquire(); | ||||||||||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||||||||||
125 | m_pBody = pBody; | ||||||||||||||||
126 | if (pOld) | ||||||||||||||||
127 | pOld->release(); | ||||||||||||||||
128 | return *this; | ||||||||||||||||
129 | } | ||||||||||||||||
130 | |||||||||||||||||
131 | /** Assignment. | ||||||||||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||||||||||
133 | bind it to the body represented by the handle. | ||||||||||||||||
134 | */ | ||||||||||||||||
135 | Reference<reference_type> & | ||||||||||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||||||||||
137 | { | ||||||||||||||||
138 | return set( handle.m_pBody ); | ||||||||||||||||
139 | } | ||||||||||||||||
140 | |||||||||||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||||||||||
142 | /** Assignment. | ||||||||||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||||||||||
144 | * bind it to the body represented by the handle, and | ||||||||||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||||||||||
146 | */ | ||||||||||||||||
147 | Reference<reference_type> & | ||||||||||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||||||||||
149 | { | ||||||||||||||||
150 | // self-movement guts ourself | ||||||||||||||||
151 | if (m_pBody) | ||||||||||||||||
152 | m_pBody->release(); | ||||||||||||||||
153 | m_pBody = handle.m_pBody; | ||||||||||||||||
154 | handle.m_pBody = nullptr; | ||||||||||||||||
155 | return *this; | ||||||||||||||||
156 | } | ||||||||||||||||
157 | #endif | ||||||||||||||||
158 | |||||||||||||||||
159 | /** Assignment... | ||||||||||||||||
160 | */ | ||||||||||||||||
161 | Reference<reference_type> & | ||||||||||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||||||||||
163 | { | ||||||||||||||||
164 | return set( pBody ); | ||||||||||||||||
165 | } | ||||||||||||||||
166 | |||||||||||||||||
167 | /** Unbind the body from this handle. | ||||||||||||||||
168 | Note that for a handle representing a large body, | ||||||||||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||||||||||
171 | since in the second case two large objects exist in memory | ||||||||||||||||
172 | (the old body and the new body). | ||||||||||||||||
173 | */ | ||||||||||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||||||||||
175 | { | ||||||||||||||||
176 | if (m_pBody) | ||||||||||||||||
177 | { | ||||||||||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||||||||||
179 | m_pBody = NULL__null; | ||||||||||||||||
180 | pOld->release(); | ||||||||||||||||
181 | } | ||||||||||||||||
182 | return *this; | ||||||||||||||||
183 | } | ||||||||||||||||
184 | |||||||||||||||||
185 | |||||||||||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||||||||||
188 | are the same. | ||||||||||||||||
189 | */ | ||||||||||||||||
190 | reference_type * SAL_CALL get() const | ||||||||||||||||
191 | { | ||||||||||||||||
192 | return m_pBody; | ||||||||||||||||
193 | } | ||||||||||||||||
194 | |||||||||||||||||
195 | |||||||||||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||||||||||
197 | */ | ||||||||||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||||||||||
199 | { | ||||||||||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||||||
201 | return m_pBody; | ||||||||||||||||
202 | } | ||||||||||||||||
203 | |||||||||||||||||
204 | |||||||||||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||||||||||
206 | */ | ||||||||||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||||||||||
208 | { | ||||||||||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||||||||||
210 | return *m_pBody; | ||||||||||||||||
211 | } | ||||||||||||||||
212 | |||||||||||||||||
213 | |||||||||||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||||||||||
215 | */ | ||||||||||||||||
216 | bool SAL_CALL is() const | ||||||||||||||||
217 | { | ||||||||||||||||
218 | return (m_pBody != NULL__null); | ||||||||||||||||
219 | } | ||||||||||||||||
220 | |||||||||||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||||||||||
223 | */ | ||||||||||||||||
224 | explicit operator bool() const | ||||||||||||||||
225 | { | ||||||||||||||||
226 | return is(); | ||||||||||||||||
227 | } | ||||||||||||||||
228 | #endif | ||||||||||||||||
229 | |||||||||||||||||
230 | /** Returns True if this points to pBody. | ||||||||||||||||
231 | */ | ||||||||||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||||||||||
233 | { | ||||||||||||||||
234 | return (m_pBody == pBody); | ||||||||||||||||
235 | } | ||||||||||||||||
236 | |||||||||||||||||
237 | |||||||||||||||||
238 | /** Returns True if handle points to the same body. | ||||||||||||||||
239 | */ | ||||||||||||||||
240 | bool | ||||||||||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||||||||||
242 | { | ||||||||||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||||||||||
244 | } | ||||||||||||||||
245 | |||||||||||||||||
246 | |||||||||||||||||
247 | /** Needed to place References into STL collection. | ||||||||||||||||
248 | */ | ||||||||||||||||
249 | bool | ||||||||||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||||||||||
251 | { | ||||||||||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||||||||||
253 | } | ||||||||||||||||
254 | |||||||||||||||||
255 | |||||||||||||||||
256 | /** Needed to place References into STL collection. | ||||||||||||||||
257 | */ | ||||||||||||||||
258 | bool | ||||||||||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||||||||||
260 | { | ||||||||||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||||||||||
262 | } | ||||||||||||||||
263 | |||||||||||||||||
264 | |||||||||||||||||
265 | /** Needed to place References into STL collection. | ||||||||||||||||
266 | */ | ||||||||||||||||
267 | bool | ||||||||||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||||||||||
269 | { | ||||||||||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||||||||||
271 | } | ||||||||||||||||
272 | }; | ||||||||||||||||
273 | |||||||||||||||||
274 | } // namespace rtl | ||||||||||||||||
275 | |||||||||||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||||||||||
277 | namespace std | ||||||||||||||||
278 | { | ||||||||||||||||
279 | |||||||||||||||||
280 | /// @cond INTERNAL | ||||||||||||||||
281 | /** | ||||||||||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||||||||||
283 | |||||||||||||||||
284 | @since LibreOffice 6.3 | ||||||||||||||||
285 | */ | ||||||||||||||||
286 | template<typename T> | ||||||||||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||||||||||
288 | { | ||||||||||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||||||||||
290 | { return std::size_t(s.get()); } | ||||||||||||||||
291 | }; | ||||||||||||||||
292 | /// @endcond | ||||||||||||||||
293 | |||||||||||||||||
294 | } | ||||||||||||||||
295 | |||||||||||||||||
296 | #endif | ||||||||||||||||
297 | |||||||||||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||||||||||
299 | |||||||||||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |