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 #pragma once 20 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> 35 36 #include <rtl/ref.hxx> 37 38 #include <sfx2/sfxbasemodel.hxx> 39 #include <svx/fmdmod.hxx> 40 41 #include <vcl/ITiledRenderable.hxx> 42 43 #include <comphelper/servicehelper.hxx> 44 #include <cppuhelper/implbase.hxx> 45 #include <cppuhelper/weakref.hxx> 46 #include <sddllapi.h> 47 48 namespace com::sun::star::container { class XNameContainer; } 49 namespace com::sun::star::i18n { class XForbiddenCharacters; } 50 namespace com::sun::star::presentation { class XPresentation; } 51 52 class SdDrawDocument; 53 class SdPage; 54 class SvxItemPropertySet; 55 56 namespace sd { 57 class DrawDocShell; 58 class DrawViewShell; 59 } 60 61 extern OUString getPageApiName( SdPage const * pPage ); 62 extern OUString getPageApiNameFromUiName( const OUString& rUIName ); 63 64 class SD_DLLPUBLIC SdXImpressDocument : 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 80 { 81 friend class SdDrawPagesAccess; 82 friend class SdMasterPagesAccess; 83 friend class SdLayerManager; 84 85 private: 86 ::sd::DrawDocShell* mpDocShell; 87 SdDrawDocument* mpDoc; 88 bool mbDisposed; 89 90 css::uno::Reference<css::uno::XInterface> create( 91 OUString const & aServiceSpecifier, OUString const & referer); 92 93 /// @throws css::uno::RuntimeException 94 SdPage* InsertSdPage( sal_uInt16 nPage, bool bDuplicate ); 95 96 const bool mbImpressDoc; 97 bool mbClipBoard; 98 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; 105 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; 113 114 const SvxItemPropertySet* mpPropSet; 115 116 css::uno::Sequence< css::uno::Type > maTypeSequence; 117 118 OUString maBuildId; 119 120 void initializeDocument(); 121 122 sd::DrawViewShell* GetViewShell(); 123 124 protected: 125 /** abstract SdrModel provider */ 126 virtual SdrModel& getSdrModelFromUnoModel() const override; 127 128 public: 129 SdXImpressDocument(::sd::DrawDocShell* pShell, bool bClipBoard); 130 SdXImpressDocument(SdDrawDocument* pDoc, bool bClipBoard); 131 virtual ~SdXImpressDocument() noexcept override; 132 133 static rtl::Reference< SdXImpressDocument > GetModel( SdDrawDocument const & rDoc ); 134 135 // intern operator ==(const SdXImpressDocument & rModel) const136 bool operator==( const SdXImpressDocument& rModel ) const { return mpDoc == rModel.mpDoc; } operator !=(const SdXImpressDocument & rModel) const137 bool operator!=( const SdXImpressDocument& rModel ) const { return mpDoc != rModel.mpDoc; } 138 GetDocShell() const139 ::sd::DrawDocShell* GetDocShell() const { return mpDocShell; } GetDoc() const140 SdDrawDocument* GetDoc() const { return mpDoc; } IsImpressDocument() const141 bool IsImpressDocument() const { return mbImpressDoc; } 142 143 void SetModified() noexcept; 144 145 css::uno::Reference< css::i18n::XForbiddenCharacters > getForbiddenCharsTable(); 146 147 // SfxListener 148 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; 149 150 UNO3_GETIMPLEMENTATION_DECL(SdXImpressDocument) 151 152 // XInterface 153 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; 154 virtual void SAL_CALL acquire() noexcept override; 155 virtual void SAL_CALL release() noexcept override; 156 157 // XModel 158 virtual void SAL_CALL lockControllers( ) override; 159 virtual void SAL_CALL unlockControllers( ) override; 160 virtual sal_Bool SAL_CALL hasControllersLocked( ) override; 161 virtual css::uno::Reference < css::container::XIndexAccess > SAL_CALL getViewData() override; 162 virtual void SAL_CALL setViewData( const css::uno::Reference < css::container::XIndexAccess >& aData ) override; 163 164 // XTypeProvider 165 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; 166 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; 167 168 // XDrawPageDuplicator 169 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL duplicate( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override; 170 171 // XDrawPagesSupplier 172 virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getDrawPages( ) override; 173 174 // XMasterPagesSupplier 175 virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getMasterPages( ) override; 176 177 // XLayerManagerSupplier 178 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLayerManager( ) override; 179 180 // XCustomPresentationSupplier 181 virtual css::uno::Reference< css::container::XNameContainer > SAL_CALL getCustomPresentations( ) override; 182 183 // XHandoutMasterSupplier 184 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getHandoutMasterPage( ) override; 185 186 // XPresentationSupplier 187 virtual css::uno::Reference< css::presentation::XPresentation > SAL_CALL getPresentation( ) override; 188 189 // XMultiServiceFactory ( SvxFmMSFactory ) 190 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; 191 virtual css::uno::Reference<css::uno::XInterface> SAL_CALL 192 createInstanceWithArguments( 193 OUString const & ServiceSpecifier, 194 css::uno::Sequence<css::uno::Any> const & Arguments) override; 195 virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames( ) override; 196 197 // XServiceInfo 198 virtual OUString SAL_CALL getImplementationName() override; 199 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 200 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 201 202 // XPropertySet 203 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; 204 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; 205 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; 206 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; 207 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; 208 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 209 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 210 211 // XLinkTargetSupplier 212 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks( ) override; 213 214 // XStyleFamiliesSupplier 215 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies( ) override; 216 217 // XAnyCompareFactory 218 virtual css::uno::Reference< css::ucb::XAnyCompare > SAL_CALL createAnyCompareByName( const OUString& PropertyName ) override; 219 220 // XRenderable 221 virtual sal_Int32 SAL_CALL getRendererCount( const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override; 222 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; 223 virtual void SAL_CALL render( sal_Int32 nRenderer, const css::uno::Any& aSelection, const css::uno::Sequence< css::beans::PropertyValue >& xOptions ) override; 224 225 // ITiledRenderable 226 virtual void paintTile( VirtualDevice& rDevice, 227 int nOutputWidth, 228 int nOutputHeight, 229 int nTilePosX, 230 int nTilePosY, 231 tools::Long nTileWidth, 232 tools::Long nTileHeight ) override; 233 virtual Size getDocumentSize() override; 234 virtual void setPart( int nPart, bool bAllowChangeFocus = true ) override; 235 virtual int getPart() override; 236 virtual int getParts() override; 237 virtual OUString getPartName( int nPart ) override; 238 virtual OUString getPartHash( int nPart ) override; 239 virtual VclPtr<vcl::Window> getDocWindow() override; 240 241 virtual void setPartMode( int nPartMode ) override; 242 243 /// @see vcl::ITiledRenderable::initializeForTiledRendering(). 244 virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) override; 245 /// @see vcl::ITiledRenderable::postKeyEvent(). 246 virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) override; 247 /// @see vcl::ITiledRenderable::postMouseEvent(). 248 virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; 249 /// @see vcl::ITiledRenderable::setTextSelection(). 250 virtual void setTextSelection(int nType, int nX, int nY) override; 251 /// @see vcl::ITiledRenderable::getSelection(). 252 virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; 253 /// @see vcl::ITiledRenderable::setGraphicSelection(). 254 virtual void setGraphicSelection(int nType, int nX, int nY) override; 255 /// @see lok::Document::resetSelection(). 256 virtual void resetSelection() override; 257 /// @see vcl::ITiledRenderable::setClientVisibleArea(). 258 virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override; 259 /// @see vcl::ITiledRenderable::setClipboard(). 260 virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; 261 /// @see vcl::ITiledRenderable::isMimeTypeSupported(). 262 virtual bool isMimeTypeSupported() override; 263 /// @see vcl::ITiledRenderable::getPointer(). 264 virtual PointerStyle getPointer() override; 265 /// @see vcl::ITiledRenderable::getPostIts(). 266 virtual void getPostIts(tools::JsonWriter& /*rJsonWriter*/) override; 267 /// @see vcl::ITiledRenderable::selectPart(). 268 virtual void selectPart(int nPart, int nSelect) override; 269 /// @see vcl::ITiledRenderable::moveSelectedParts(). 270 virtual void moveSelectedParts(int nPosition, bool bDuplicate) override; 271 /// @see vcl::ITiledRenderable::getPartInfo(). 272 virtual OUString getPartInfo(int nPart) override; 273 /// @see vcl::ITiledRenderable::isDisposed(). isDisposed() const274 virtual bool isDisposed() const override 275 { 276 return mbDisposed; 277 } 278 279 // XComponent 280 281 /** This dispose implementation releases the resources held by the 282 called object and forwards the call to its base class. 283 When close() has not yet been called then this is done first. As a 284 consequence the implementation has to cope with being called twice 285 and still has to forward the second call to the base class. 286 See also comments of issue 27847. 287 */ 288 virtual void SAL_CALL dispose() override; 289 }; 290 291 /*********************************************************************** 292 * * 293 ***********************************************************************/ 294 295 class SdDrawPagesAccess : public ::cppu::WeakImplHelper< css::drawing::XDrawPages, css::container::XNameAccess, css::lang::XServiceInfo, css::lang::XComponent > 296 { 297 private: 298 SdXImpressDocument* mpModel; 299 300 public: 301 SdDrawPagesAccess( SdXImpressDocument& rMyModel ) noexcept; 302 virtual ~SdDrawPagesAccess() noexcept override; 303 304 // XDrawPages 305 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) override; 306 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override; 307 308 // XNameAccess 309 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; 310 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; 311 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; 312 313 // XIndexAccess 314 virtual sal_Int32 SAL_CALL getCount() override ; 315 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; 316 317 // XElementAccess 318 virtual css::uno::Type SAL_CALL getElementType() override; 319 virtual sal_Bool SAL_CALL hasElements() override; 320 321 // XServiceInfo 322 virtual OUString SAL_CALL getImplementationName( ) override; 323 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 324 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; 325 326 // XComponent 327 virtual void SAL_CALL dispose( ) override; 328 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; 329 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; 330 }; 331 332 /*********************************************************************** 333 * * 334 ***********************************************************************/ 335 336 class SdMasterPagesAccess : public ::cppu::WeakImplHelper< css::drawing::XDrawPages, css::lang::XServiceInfo, css::lang::XComponent > 337 { 338 private: 339 SdXImpressDocument* mpModel; 340 341 public: 342 SdMasterPagesAccess( SdXImpressDocument& rMyModel ) noexcept; 343 virtual ~SdMasterPagesAccess() noexcept override; 344 345 // XDrawPages 346 virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) override; 347 virtual void SAL_CALL remove( const css::uno::Reference< css::drawing::XDrawPage >& xPage ) override; 348 349 // XIndexAccess 350 virtual sal_Int32 SAL_CALL getCount() override ; 351 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; 352 353 // XElementAccess 354 virtual css::uno::Type SAL_CALL getElementType() override; 355 virtual sal_Bool SAL_CALL hasElements() override; 356 357 // XServiceInfo 358 virtual OUString SAL_CALL getImplementationName( ) override; 359 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 360 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; 361 362 // XComponent 363 virtual void SAL_CALL dispose( ) override; 364 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; 365 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; 366 }; 367 368 /*********************************************************************** 369 * * 370 ***********************************************************************/ 371 372 class SdDocLinkTargets : public ::cppu::WeakImplHelper< css::container::XNameAccess, 373 css::lang::XServiceInfo , css::lang::XComponent > 374 { 375 private: 376 SdXImpressDocument* mpModel; 377 378 public: 379 SdDocLinkTargets( SdXImpressDocument& rMyModel ) noexcept; 380 virtual ~SdDocLinkTargets() noexcept override; 381 382 // XNameAccess 383 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; 384 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; 385 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; 386 387 // XElementAccess 388 virtual css::uno::Type SAL_CALL getElementType() override; 389 virtual sal_Bool SAL_CALL hasElements() override; 390 391 // XServiceInfo 392 virtual OUString SAL_CALL getImplementationName() override; 393 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 394 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 395 396 // XComponent 397 virtual void SAL_CALL dispose( ) override; 398 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; 399 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; 400 401 // intern 402 /// @throws std::exception 403 SdPage* FindPage( std::u16string_view rName ) const; 404 }; 405 406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 407