Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / source / ui / inc / unomodel.hxx
blobf31d93b974208545094b04135b50edf8d776e9d7
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/style/XStyleFamiliesSupplier.hpp>
22 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
23 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
24 #include <com/sun/star/drawing/XDrawPageDuplicator.hpp>
25 #include <com/sun/star/drawing/XLayerSupplier.hpp>
26 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
27 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
28 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/drawing/XDrawPages.hpp>
31 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
32 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
33 #include <com/sun/star/view/XRenderable.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <rtl/ref.hxx>
38 #include <sfx2/sfxbasemodel.hxx>
39 #include <svx/fmdmod.hxx>
41 #include <vcl/ITiledRenderable.hxx>
43 #include <comphelper/servicehelper.hxx>
44 #include <cppuhelper/implbase.hxx>
45 #include <cppuhelper/weakref.hxx>
46 #include <sddllapi.h>
48 namespace com::sun::star::container { class XNameContainer; }
49 namespace com::sun::star::i18n { class XForbiddenCharacters; }
50 namespace com::sun::star::presentation { class XPresentation; }
52 class SdDrawDocument;
53 class SdPage;
54 class SvxItemPropertySet;
56 namespace sd {
57 class DrawDocShell;
58 class DrawViewShell;
61 extern OUString getPageApiName( SdPage const * pPage );
62 extern OUString getPageApiNameFromUiName( const OUString& rUIName );
64 class SD_DLLPUBLIC SdXImpressDocument final : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other
65 public SvxFmMSFactory,
66 public css::drawing::XDrawPageDuplicator,
67 public css::drawing::XLayerSupplier,
68 public css::drawing::XMasterPagesSupplier,
69 public css::drawing::XDrawPagesSupplier,
70 public css::presentation::XPresentationSupplier,
71 public css::presentation::XCustomPresentationSupplier,
72 public css::document::XLinkTargetSupplier,
73 public css::beans::XPropertySet,
74 public css::style::XStyleFamiliesSupplier,
75 public css::lang::XServiceInfo,
76 public css::ucb::XAnyCompareFactory,
77 public css::presentation::XHandoutMasterSupplier,
78 public css::view::XRenderable,
79 public vcl::ITiledRenderable
81 friend class SdDrawPagesAccess;
82 friend class SdMasterPagesAccess;
83 friend class SdLayerManager;
85 private:
86 ::sd::DrawDocShell* mpDocShell;
87 SdDrawDocument* mpDoc;
88 bool mbDisposed;
90 css::uno::Reference<css::uno::XInterface> create(
91 OUString const & aServiceSpecifier, OUString const & referer);
93 /// @throws css::uno::RuntimeException
94 SdPage* InsertSdPage( sal_uInt16 nPage, bool bDuplicate );
96 const bool mbImpressDoc;
97 bool mbClipBoard;
99 css::uno::WeakReference< css::drawing::XDrawPages > mxDrawPagesAccess;
100 css::uno::WeakReference< css::drawing::XDrawPages > mxMasterPagesAccess;
101 css::uno::WeakReference< css::container::XNameAccess > mxLayerManager;
102 css::uno::WeakReference< css::container::XNameContainer > mxCustomPresentationAccess;
103 css::uno::WeakReference< css::i18n::XForbiddenCharacters > mxForbiddenCharacters;
104 css::uno::Reference< css::container::XNameAccess > mxLinks;
106 css::uno::Reference< css::uno::XInterface > mxDashTable;
107 css::uno::Reference< css::uno::XInterface > mxGradientTable;
108 css::uno::Reference< css::uno::XInterface > mxHatchTable;
109 css::uno::Reference< css::uno::XInterface > mxBitmapTable;
110 css::uno::Reference< css::uno::XInterface > mxTransGradientTable;
111 css::uno::Reference< css::uno::XInterface > mxMarkerTable;
112 css::uno::Reference< css::uno::XInterface > mxDrawingPool;
114 const SvxItemPropertySet* mpPropSet;
116 css::uno::Sequence< css::uno::Type > maTypeSequence;
118 OUString maBuildId;
120 bool mbPaintTextEdit;
122 void initializeDocument();
124 sd::DrawViewShell* GetViewShell();
126 /** abstract SdrModel provider */
127 virtual SdrModel& getSdrModelFromUnoModel() const override;
129 public:
130 SdXImpressDocument(::sd::DrawDocShell* pShell, bool bClipBoard);
131 SdXImpressDocument(SdDrawDocument* pDoc, bool bClipBoard);
132 virtual ~SdXImpressDocument() noexcept override;
134 static rtl::Reference< SdXImpressDocument > GetModel( SdDrawDocument const & rDoc );
136 // internal
137 bool operator==( const SdXImpressDocument& rModel ) const { return mpDoc == rModel.mpDoc; }
138 bool operator!=( const SdXImpressDocument& rModel ) const { return mpDoc != rModel.mpDoc; }
140 ::sd::DrawDocShell* GetDocShell() const { return mpDocShell; }
141 SdDrawDocument* GetDoc() const { return mpDoc; }
142 bool IsImpressDocument() const { return mbImpressDoc; }
144 void SetModified() noexcept;
146 css::uno::Reference< css::i18n::XForbiddenCharacters > getForbiddenCharsTable();
148 // SfxListener
149 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
151 UNO3_GETIMPLEMENTATION_DECL(SdXImpressDocument)
153 // XInterface
154 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
155 virtual void SAL_CALL acquire() noexcept override;
156 virtual void SAL_CALL release() noexcept override;
158 // XModel
159 virtual void SAL_CALL lockControllers( ) override;
160 virtual void SAL_CALL unlockControllers( ) override;
161 virtual sal_Bool SAL_CALL hasControllersLocked( ) override;
162 virtual css::uno::Reference < css::container::XIndexAccess > SAL_CALL getViewData() override;
163 virtual void SAL_CALL setViewData( const css::uno::Reference < css::container::XIndexAccess >& aData ) override;
165 // XTypeProvider
166 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
167 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
169 // XDrawPageDuplicator
170 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL duplicate( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override;
172 // XDrawPagesSupplier
173 virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getDrawPages( ) override;
175 // XMasterPagesSupplier
176 virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getMasterPages( ) override;
178 // XLayerManagerSupplier
179 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLayerManager( ) override;
181 // XCustomPresentationSupplier
182 virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getCustomPresentations( ) override;
184 // XHandoutMasterSupplier
185 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getHandoutMasterPage( ) override;
187 // XPresentationSupplier
188 virtual css::uno::Reference< css::presentation::XPresentation > SAL_CALL getPresentation( ) override;
190 // XMultiServiceFactory ( SvxFmMSFactory )
191 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
192 virtual css::uno::Reference<css::uno::XInterface> SAL_CALL
193 createInstanceWithArguments(
194 OUString const & ServiceSpecifier,
195 css::uno::Sequence<css::uno::Any> const & Arguments) override;
196 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override;
198 // XServiceInfo
199 virtual OUString SAL_CALL getImplementationName() override;
200 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
201 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
203 // XPropertySet
204 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
205 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
206 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
207 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
208 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
209 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
210 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
212 // XLinkTargetSupplier
213 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks( ) override;
215 // XStyleFamiliesSupplier
216 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies( ) override;
218 // XAnyCompareFactory
219 virtual css::uno::Reference< css::ucb::XAnyCompare > SAL_CALL createAnyCompareByName( const OUString& PropertyName ) override;
221 // XRenderable
222 virtual sal_Int32 SAL_CALL getRendererCount( const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override;
223 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRenderer( sal_Int32 nRenderer, const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override;
224 virtual void SAL_CALL render( sal_Int32 nRenderer, const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override;
226 // ITiledRenderable
227 virtual void paintTile( VirtualDevice& rDevice,
228 int nOutputWidth,
229 int nOutputHeight,
230 int nTilePosX,
231 int nTilePosY,
232 tools::Long nTileWidth,
233 tools::Long nTileHeight ) override;
234 virtual Size getDocumentSize() override;
235 virtual void setPart( int nPart, bool bAllowChangeFocus = true ) override;
236 virtual int getPart() override;
237 virtual int getParts() override;
238 virtual OUString getPartName( int nPart ) override;
239 virtual OUString getPartHash( int nPart ) override;
240 virtual VclPtr<vcl::Window> getDocWindow() override;
241 bool isMasterViewMode();
243 /// @see vcl::ITiledRenderable::setPartMode().
244 virtual void setPartMode( int nPartMode ) override;
245 /// @see vcl::ITiledRenderable::getEditMode().
246 virtual int getEditMode() override;
247 /// @see vcl::ITiledRenderable::setEditMode().
248 virtual void setEditMode(int) override;
249 /// @see vcl::ITiledRenderable::initializeForTiledRendering().
250 virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override;
251 /// @see vcl::ITiledRenderable::postKeyEvent().
252 virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override;
253 /// @see vcl::ITiledRenderable::postMouseEvent().
254 virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override;
255 /// @see vcl::ITiledRenderable::setTextSelection().
256 virtual void setTextSelection(int nType, int nX, int nY) override;
257 /// @see vcl::ITiledRenderable::getSelection().
258 virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override;
259 /// @see vcl::ITiledRenderable::setGraphicSelection().
260 virtual void setGraphicSelection(int nType, int nX, int nY) override;
261 /// @see lok::Document::resetSelection().
262 virtual void resetSelection() override;
263 /// @see vcl::ITiledRenderable::setClientVisibleArea().
264 virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override;
265 /// @see vcl::ITiledRenderable::setClipboard().
266 virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
267 /// @see vcl::ITiledRenderable::isMimeTypeSupported().
268 virtual bool isMimeTypeSupported() override;
269 /// @see vcl::ITiledRenderable::getPointer().
270 virtual PointerStyle getPointer() override;
271 /// @see vcl::ITiledRenderable::getPostIts().
272 virtual void getPostIts(tools::JsonWriter& /*rJsonWriter*/) override;
273 /// @see vcl::ITiledRenderable::selectPart().
274 virtual void selectPart(int nPart, int nSelect) override;
275 /// @see vcl::ITiledRenderable::moveSelectedParts().
276 virtual void moveSelectedParts(int nPosition, bool bDuplicate) override;
277 /// @see vcl::ITiledRenderable::getPartInfo().
278 virtual OUString getPartInfo(int nPart) override;
279 /// @see vcl::ITiledRenderable::isDisposed().
280 virtual bool isDisposed() const override
282 return mbDisposed;
284 /// @see vcl::ITiledRenderable::setPaintTextEdit().
285 virtual void setPaintTextEdit(bool bPaint) override { mbPaintTextEdit = bPaint; }
287 /// @see vcl::ITiledRenderable::getViewRenderState().
288 OString getViewRenderState() override;
290 // XComponent
292 /** This dispose implementation releases the resources held by the
293 called object and forwards the call to its base class.
294 When close() has not yet been called then this is done first. As a
295 consequence the implementation has to cope with being called twice
296 and still has to forward the second call to the base class.
297 See also comments of issue 27847.
299 virtual void SAL_CALL dispose() override;
302 /***********************************************************************
304 ***********************************************************************/
306 class SdDrawPagesAccess final : public ::cppu::WeakImplHelper< css::drawing::XDrawPages, css::container::XNameAccess, css::lang::XServiceInfo, css::lang::XComponent >
308 private:
309 SdXImpressDocument* mpModel;
311 public:
312 SdDrawPagesAccess( SdXImpressDocument& rMyModel ) noexcept;
313 virtual ~SdDrawPagesAccess() noexcept override;
315 // XDrawPages
316 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) override;
317 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override;
319 // XNameAccess
320 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
321 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
322 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
324 // XIndexAccess
325 virtual sal_Int32 SAL_CALL getCount() override ;
326 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
328 // XElementAccess
329 virtual css::uno::Type SAL_CALL getElementType() override;
330 virtual sal_Bool SAL_CALL hasElements() override;
332 // XServiceInfo
333 virtual OUString SAL_CALL getImplementationName( ) override;
334 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
335 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
337 // XComponent
338 virtual void SAL_CALL dispose( ) override;
339 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
340 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
343 /***********************************************************************
345 ***********************************************************************/
347 class SdMasterPagesAccess final : public ::cppu::WeakImplHelper< css::drawing::XDrawPages, css::lang::XServiceInfo, css::lang::XComponent >
349 private:
350 SdXImpressDocument* mpModel;
352 public:
353 SdMasterPagesAccess( SdXImpressDocument& rMyModel ) noexcept;
354 virtual ~SdMasterPagesAccess() noexcept override;
356 // XDrawPages
357 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) override;
358 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override;
360 // XIndexAccess
361 virtual sal_Int32 SAL_CALL getCount() override ;
362 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
364 // XElementAccess
365 virtual css::uno::Type SAL_CALL getElementType() override;
366 virtual sal_Bool SAL_CALL hasElements() override;
368 // XServiceInfo
369 virtual OUString SAL_CALL getImplementationName( ) override;
370 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
371 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
373 // XComponent
374 virtual void SAL_CALL dispose( ) override;
375 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
376 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
379 /***********************************************************************
381 ***********************************************************************/
383 class SdDocLinkTargets final : public ::cppu::WeakImplHelper< css::container::XNameAccess,
384 css::lang::XServiceInfo , css::lang::XComponent >
386 private:
387 SdXImpressDocument* mpModel;
389 public:
390 SdDocLinkTargets( SdXImpressDocument& rMyModel ) noexcept;
391 virtual ~SdDocLinkTargets() noexcept override;
393 // XNameAccess
394 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
395 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
396 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
398 // XElementAccess
399 virtual css::uno::Type SAL_CALL getElementType() override;
400 virtual sal_Bool SAL_CALL hasElements() override;
402 // XServiceInfo
403 virtual OUString SAL_CALL getImplementationName() override;
404 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
405 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
407 // XComponent
408 virtual void SAL_CALL dispose( ) override;
409 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
410 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
412 // internal
413 /// @throws std::exception
414 SdPage* FindPage( std::u16string_view rName ) const;
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */