cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / unopage.hxx
blobf27b79ad4ce86cafb71dffe7c8c3f645bec8b30b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
22 #include <com/sun/star/container/XNamed.hpp>
23 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
24 #include <com/sun/star/drawing/XShapeCombiner.hpp>
25 #include <com/sun/star/drawing/XShapeBinder.hpp>
26 #include <com/sun/star/presentation/XPresentationPage.hpp>
27 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
28 #include <com/sun/star/beans/XMultiPropertySet.hpp>
29 #include <com/sun/star/office/XAnnotationAccess.hpp>
31 #include <svx/unopage.hxx>
33 #include <comphelper/servicehelper.hxx>
34 #include <cppuhelper/implbase.hxx>
36 #include "unosrch.hxx"
37 #include <sdpage.hxx>
39 class SdrObject;
40 class SdXImpressDocument;
41 class SdMasterPage;
43 class SdGenericDrawPage : public SvxDrawPage,
44 public SdUnoSearchReplaceShape,
45 public css::drawing::XShapeCombiner,
46 public css::drawing::XShapeBinder,
47 public css::container::XNamed,
48 public css::beans::XPropertySet,
49 public css::beans::XMultiPropertySet,
50 public css::animations::XAnimationNodeSupplier,
51 public css::office::XAnnotationAccess,
52 public css::document::XLinkTargetSupplier
54 private:
55 SdXImpressDocument* mpDocModel;
56 SdrModel* mpSdrModel;
57 bool mbIsImpressDocument;
58 sal_Int16 mnTempPageNumber; // for printing handouts
59 css::uno::Any mSlideLayout; // import slide layout pptx
60 const SvxItemPropertySet* mpPropSet;
62 void UpdateModel();
64 protected:
65 friend class SdXImpressDocument;
67 /// @throws css::lang::IllegalArgumentException
68 virtual void setBackground( const css::uno::Any& rValue );
69 /// @throws std::exception
70 virtual void getBackground( css::uno::Any& rValue );
72 OUString getBookmarkURL() const;
73 void setBookmarkURL( std::u16string_view rURL );
75 void SetLeftBorder( sal_Int32 nValue );
76 void SetRightBorder( sal_Int32 nValue );
77 void SetUpperBorder( sal_Int32 nValue );
78 void SetLowerBorder( sal_Int32 nValue );
80 void SetWidth( sal_Int32 nWidth );
81 void SetHeight( sal_Int32 nHeight );
83 bool IsImpressDocument() const;
85 virtual void disposing() noexcept override;
87 css::uno::Any getNavigationOrder();
88 void setNavigationOrder( const css::uno::Any& rValue );
90 /// @throws css::uno::RuntimeException
91 void throwIfDisposed() const;
93 public:
94 SdGenericDrawPage(SdXImpressDocument* pModel, SdPage* pInPage, const SvxItemPropertySet* pSet);
95 virtual ~SdGenericDrawPage() noexcept override;
97 // internal
98 bool isValid() const { return (SvxDrawPage::mpPage != nullptr) && (mpModel != nullptr); }
100 SdPage* GetPage() const { return static_cast<SdPage*>(SvxDrawPage::mpPage); }
101 SdXImpressDocument* GetModel() const;
103 static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept;
104 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
106 // this is called whenever a SdrObject must be created for an empty api shape wrapper
107 virtual rtl::Reference<SdrObject> CreateSdrObject_( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
109 // SvxDrawPage
110 virtual css::uno::Reference<css::drawing::XShape> CreateShape(SdrObject *pObj) const override;
112 // XInterface
113 virtual void SAL_CALL acquire() noexcept override { SvxDrawPage::acquire(); }
114 virtual void SAL_CALL release() noexcept override { SvxDrawPage::release(); }
115 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
117 // XShapeCombiner
118 virtual css::uno::Reference< css::drawing::XShape > SAL_CALL combine( const css::uno::Reference< css::drawing::XShapes >& xShapes ) override;
119 virtual void SAL_CALL split( const css::uno::Reference< css::drawing::XShape >& xGroup ) override;
121 // XShapeBinder
122 virtual css::uno::Reference< css::drawing::XShape > SAL_CALL bind( const css::uno::Reference< css::drawing::XShapes >& xShapes ) override;
123 virtual void SAL_CALL unbind( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
125 // XPropertySet
126 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
127 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
128 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
129 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
130 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
131 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
132 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
134 // XMultiPropertySet
135 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
136 virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
137 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
138 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
139 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
141 // XLinkTargetSupplier
142 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks( ) override;
144 // XServiceInfo
145 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
147 // XAnimationNodeSupplier
148 virtual css::uno::Reference< css::animations::XAnimationNode > SAL_CALL getAnimationNode( ) override;
150 // XAnnotationAccess:
151 virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL createAndInsertAnnotation() override;
152 virtual void SAL_CALL removeAnnotation(const css::uno::Reference< css::office::XAnnotation > & annotation) override;
153 virtual css::uno::Reference< css::office::XAnnotationEnumeration > SAL_CALL createAnnotationEnumeration() override;
156 /***********************************************************************
158 ***********************************************************************/
160 class SdDrawPage final : public css::drawing::XMasterPageTarget,
161 public css::presentation::XPresentationPage,
162 public SdGenericDrawPage
164 private:
165 css::uno::Sequence< css::uno::Type > maTypeSequence;
167 virtual void setBackground( const css::uno::Any& rValue ) override;
168 virtual void getBackground( css::uno::Any& rValue ) override;
169 public:
170 SdDrawPage(SdXImpressDocument* pModel, SdPage* pInPage);
171 virtual ~SdDrawPage() noexcept override;
173 UNO3_GETIMPLEMENTATION_DECL( SdDrawPage )
175 static OUString getPageApiName( SdPage const * pPage );
176 static OUString getPageApiNameFromUiName( const OUString& rUIName );
177 static OUString getUiNameFromPageApiName( const OUString& rApiName );
179 // XInterface
180 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
181 virtual void SAL_CALL acquire() noexcept override;
182 virtual void SAL_CALL release() noexcept override;
184 // XTypeProvider
185 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
186 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
188 // XServiceInfo
189 virtual OUString SAL_CALL getImplementationName() override;
190 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
191 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
193 // XMasterPageTarget
194 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getMasterPage( ) override;
195 virtual void SAL_CALL setMasterPage( const css::uno::Reference< css::drawing::XDrawPage >& xMasterPage ) override;
197 // XPresentationPage
198 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getNotesPage( ) override;
200 // XNamed
201 virtual OUString SAL_CALL getName( ) override;
202 virtual void SAL_CALL setName( const OUString& aName ) override;
204 // XIndexAccess
205 virtual sal_Int32 SAL_CALL getCount() override ;
206 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
208 // XElementAccess
209 virtual css::uno::Type SAL_CALL getElementType() override;
210 virtual sal_Bool SAL_CALL hasElements() override;
212 // XShapes
213 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
214 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
216 SdMasterPage* getSdMasterPage();
219 /***********************************************************************
221 ***********************************************************************/
223 class SdMasterPage final : public css::presentation::XPresentationPage,
224 public SdGenericDrawPage
226 private:
227 css::uno::Sequence< css::uno::Type > maTypeSequence;
229 virtual void setBackground( const css::uno::Any& rValue ) override;
230 virtual void getBackground( css::uno::Any& rValue ) override;
232 public:
233 SdMasterPage(SdXImpressDocument* pModel, SdPage* pInPage);
234 virtual ~SdMasterPage() noexcept override;
236 UNO3_GETIMPLEMENTATION_DECL(SdMasterPage)
238 // XInterface
239 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
240 virtual void SAL_CALL acquire() noexcept override;
241 virtual void SAL_CALL release() noexcept override;
243 // XTypeProvider
244 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
245 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
247 // XServiceInfo
248 virtual OUString SAL_CALL getImplementationName() override;
249 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
250 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
252 // XIndexAccess
253 virtual sal_Int32 SAL_CALL getCount() override ;
254 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
256 // XElementAccess
257 virtual css::uno::Type SAL_CALL getElementType() override;
258 virtual sal_Bool SAL_CALL hasElements() override;
260 // XPresentationPage
261 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getNotesPage( ) override;
263 // XNamed
264 virtual OUString SAL_CALL getName( ) override;
265 virtual void SAL_CALL setName( const OUString& aName ) override;
267 // XShapes
268 virtual void SAL_CALL add( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
269 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XShape >& xShape ) override;
272 /***********************************************************************
274 ***********************************************************************/
276 class SdPageLinkTargets final : public ::cppu::WeakImplHelper< css::container::XNameAccess,
277 css::lang::XServiceInfo >
279 private:
280 rtl::Reference< SdGenericDrawPage > mxPage;
282 public:
283 SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) noexcept;
284 virtual ~SdPageLinkTargets() noexcept override;
286 // internal
287 SdrObject* FindObject( std::u16string_view rName ) const noexcept;
289 // XServiceInfo
290 virtual OUString SAL_CALL getImplementationName() override;
291 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
292 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
294 // XNameAccess
295 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
296 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
297 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
299 // XElementAccess
300 virtual css::uno::Type SAL_CALL getElementType() override;
301 virtual sal_Bool SAL_CALL hasElements() override;
304 OUString getUiNameFromPageApiNameImpl( const OUString& rApiName );
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */