1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SD_SOURCE_UI_INC_UNOMODEL_HXX
20 #define INCLUDED_SD_SOURCE_UI_INC_UNOMODEL_HXX
22 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
23 #include <com/sun/star/document/XLinkTargetSupplier.hpp>
24 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
25 #include <com/sun/star/drawing/XDrawPageDuplicator.hpp>
26 #include <com/sun/star/drawing/XLayerSupplier.hpp>
27 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
28 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
29 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/drawing/XDrawPages.hpp>
32 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
33 #include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
34 #include <com/sun/star/view/XRenderable.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <rtl/ref.hxx>
39 #include <sfx2/sfxbasemodel.hxx>
40 #include <svx/fmdmod.hxx>
42 #include <vcl/ITiledRenderable.hxx>
44 #include <comphelper/servicehelper.hxx>
45 #include <cppuhelper/implbase.hxx>
46 #include <cppuhelper/weakref.hxx>
49 namespace com
{ namespace sun
{ namespace star
{ namespace container
{ class XNameContainer
; } } } }
50 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{ class XForbiddenCharacters
; } } } }
51 namespace com
{ namespace sun
{ namespace star
{ namespace presentation
{ class XPresentation
; } } } }
55 class SvxItemPropertySet
;
62 extern OUString
getPageApiName( SdPage
const * pPage
);
63 extern OUString
getPageApiNameFromUiName( const OUString
& rUIName
);
65 class SD_DLLPUBLIC SdXImpressDocument
: public SfxBaseModel
, // implements SfxListener, OWEAKOBJECT & other
66 public SvxFmMSFactory
,
67 public css::drawing::XDrawPageDuplicator
,
68 public css::drawing::XLayerSupplier
,
69 public css::drawing::XMasterPagesSupplier
,
70 public css::drawing::XDrawPagesSupplier
,
71 public css::presentation::XPresentationSupplier
,
72 public css::presentation::XCustomPresentationSupplier
,
73 public css::document::XLinkTargetSupplier
,
74 public css::beans::XPropertySet
,
75 public css::style::XStyleFamiliesSupplier
,
76 public css::lang::XServiceInfo
,
77 public css::ucb::XAnyCompareFactory
,
78 public css::presentation::XHandoutMasterSupplier
,
79 public css::view::XRenderable
,
80 public vcl::ITiledRenderable
82 friend class SdDrawPagesAccess
;
83 friend class SdMasterPagesAccess
;
84 friend class SdLayerManager
;
87 ::sd::DrawDocShell
* mpDocShell
;
88 SdDrawDocument
* mpDoc
;
91 css::uno::Reference
<css::uno::XInterface
> create(
92 OUString
const & aServiceSpecifier
, OUString
const & referer
);
94 /// @throws css::uno::RuntimeException
95 SdPage
* InsertSdPage( sal_uInt16 nPage
, bool bDuplicate
);
97 const bool mbImpressDoc
;
100 css::uno::WeakReference
< css::drawing::XDrawPages
> mxDrawPagesAccess
;
101 css::uno::WeakReference
< css::drawing::XDrawPages
> mxMasterPagesAccess
;
102 css::uno::WeakReference
< css::container::XNameAccess
> mxLayerManager
;
103 css::uno::WeakReference
< css::container::XNameContainer
> mxCustomPresentationAccess
;
104 css::uno::WeakReference
< css::i18n::XForbiddenCharacters
> mxForbiddenCharacters
;
105 css::uno::Reference
< css::container::XNameAccess
> mxLinks
;
107 css::uno::Reference
< css::uno::XInterface
> mxDashTable
;
108 css::uno::Reference
< css::uno::XInterface
> mxGradientTable
;
109 css::uno::Reference
< css::uno::XInterface
> mxHatchTable
;
110 css::uno::Reference
< css::uno::XInterface
> mxBitmapTable
;
111 css::uno::Reference
< css::uno::XInterface
> mxTransGradientTable
;
112 css::uno::Reference
< css::uno::XInterface
> mxMarkerTable
;
113 css::uno::Reference
< css::uno::XInterface
> mxDrawingPool
;
115 const SvxItemPropertySet
* mpPropSet
;
117 css::uno::Sequence
< css::uno::Type
> maTypeSequence
;
121 void initializeDocument();
123 sd::DrawViewShell
* GetViewShell();
126 /** abstract SdrModel provider */
127 virtual SdrModel
& getSdrModelFromUnoModel() const override
;
130 SdXImpressDocument(::sd::DrawDocShell
* pShell
, bool bClipBoard
);
131 SdXImpressDocument(SdDrawDocument
* pDoc
, bool bClipBoard
);
132 virtual ~SdXImpressDocument() throw() override
;
134 static rtl::Reference
< SdXImpressDocument
> GetModel( SdDrawDocument
const & rDoc
);
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() throw();
146 css::uno::Reference
< css::i18n::XForbiddenCharacters
> getForbiddenCharsTable();
149 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
151 UNO3_GETIMPLEMENTATION_DECL(SdXImpressDocument
)
154 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
155 virtual void SAL_CALL
acquire() throw() override
;
156 virtual void SAL_CALL
release() throw() override
;
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
;
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
;
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
;
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
;
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
;
227 virtual void paintTile( VirtualDevice
& rDevice
,
233 long nTileHeight
) override
;
234 virtual Size
getDocumentSize() override
;
235 virtual void setPart( int nPart
) 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
;
242 virtual void setPartMode( int nPartMode
) override
;
244 /// @see vcl::ITiledRenderable::initializeForTiledRendering().
245 virtual void initializeForTiledRendering(const css::uno::Sequence
<css::beans::PropertyValue
>& rArguments
) override
;
246 /// @see vcl::ITiledRenderable::postKeyEvent().
247 virtual void postKeyEvent(int nType
, int nCharCode
, int nKeyCode
) override
;
248 /// @see vcl::ITiledRenderable::postMouseEvent().
249 virtual void postMouseEvent(int nType
, int nX
, int nY
, int nCount
, int nButtons
, int nModifier
) override
;
250 /// @see vcl::ITiledRenderable::setTextSelection().
251 virtual void setTextSelection(int nType
, int nX
, int nY
) override
;
252 /// @see vcl::ITiledRenderable::getTextSelection().
253 virtual OString
getTextSelection(const char* pMimeType
, OString
& rUsedMimeType
) override
;
254 /// @see vcl::ITiledRenderable::setGraphicSelection().
255 virtual void setGraphicSelection(int nType
, int nX
, int nY
) override
;
256 /// @see lok::Document::resetSelection().
257 virtual void resetSelection() override
;
258 /// @see vcl::ITiledRenderable::setClipboard().
259 virtual void setClipboard(const css::uno::Reference
<css::datatransfer::clipboard::XClipboard
>& xClipboard
) override
;
260 /// @see vcl::ITiledRenderable::isMimeTypeSupported().
261 virtual bool isMimeTypeSupported() override
;
262 /// @see vcl::ITiledRenderable::getPointer().
263 virtual PointerStyle
getPointer() override
;
264 /// @see vcl::ITiledRenderable::getPostIts().
265 virtual OUString
getPostIts() override
;
269 /** This dispose implementation releases the resources held by the
270 called object and forwards the call to its base class.
271 When close() has not yet been called then this is done first. As a
272 consequence the implementation has to cope with being called twice
273 and still has to forward the second call to the base class.
274 See also comments of issue 27847.
276 virtual void SAL_CALL
dispose() override
;
279 /***********************************************************************
281 ***********************************************************************/
283 class SdDrawPagesAccess
: public ::cppu::WeakImplHelper
< css::drawing::XDrawPages
, css::container::XNameAccess
, css::lang::XServiceInfo
, css::lang::XComponent
>
286 SdXImpressDocument
* mpModel
;
289 SdDrawPagesAccess( SdXImpressDocument
& rMyModel
) throw();
290 virtual ~SdDrawPagesAccess() throw() override
;
293 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
insertNewByIndex( sal_Int32 nIndex
) override
;
294 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XDrawPage
>& xPage
) override
;
297 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
298 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
299 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
302 virtual sal_Int32 SAL_CALL
getCount() override
;
303 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
306 virtual css::uno::Type SAL_CALL
getElementType() override
;
307 virtual sal_Bool SAL_CALL
hasElements() override
;
310 virtual OUString SAL_CALL
getImplementationName( ) override
;
311 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
312 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
315 virtual void SAL_CALL
dispose( ) override
;
316 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
317 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
320 /***********************************************************************
322 ***********************************************************************/
324 class SdMasterPagesAccess
: public ::cppu::WeakImplHelper
< css::drawing::XDrawPages
, css::lang::XServiceInfo
, css::lang::XComponent
>
327 SdXImpressDocument
* mpModel
;
330 SdMasterPagesAccess( SdXImpressDocument
& rMyModel
) throw();
331 virtual ~SdMasterPagesAccess() throw() override
;
334 virtual css::uno::Reference
< css::drawing::XDrawPage
> SAL_CALL
insertNewByIndex( sal_Int32 nIndex
) override
;
335 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XDrawPage
>& xPage
) override
;
338 virtual sal_Int32 SAL_CALL
getCount() override
;
339 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
342 virtual css::uno::Type SAL_CALL
getElementType() override
;
343 virtual sal_Bool SAL_CALL
hasElements() override
;
346 virtual OUString SAL_CALL
getImplementationName( ) override
;
347 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
348 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
351 virtual void SAL_CALL
dispose( ) override
;
352 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
353 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
356 /***********************************************************************
358 ***********************************************************************/
360 class SdDocLinkTargets
: public ::cppu::WeakImplHelper
< css::container::XNameAccess
,
361 css::lang::XServiceInfo
, css::lang::XComponent
>
364 SdXImpressDocument
* mpModel
;
367 SdDocLinkTargets( SdXImpressDocument
& rMyModel
) throw();
368 virtual ~SdDocLinkTargets() throw() override
;
371 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
372 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
373 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
376 virtual css::uno::Type SAL_CALL
getElementType() override
;
377 virtual sal_Bool SAL_CALL
hasElements() override
;
380 virtual OUString SAL_CALL
getImplementationName() override
;
381 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
382 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
385 virtual void SAL_CALL
dispose( ) override
;
386 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
387 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
390 /// @throws std::exception
391 SdPage
* FindPage( const OUString
& rName
) const;
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */