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 #pragma once 21 22 #include <vcl/transfer.hxx> 23 #include <vcl/vclptr.hxx> 24 #include <sfx2/objsh.hxx> 25 #include <svl/lstner.hxx> 26 27 // SdTransferable 28 class SdDrawDocument; 29 class SdrObject; 30 class INetBookmark; 31 class ImageMap; 32 class VirtualDevice; 33 34 namespace sd { 35 class DrawDocShell; 36 class View; 37 } 38 39 class SAL_DLLPUBLIC_RTTI SdTransferable : public TransferDataContainer, public SfxListener 40 { 41 public: 42 43 SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, bool bInitOnGetData ); 44 virtual ~SdTransferable() override; 45 SetDocShell(const SfxObjectShellRef & rRef)46 void SetDocShell( const SfxObjectShellRef& rRef ) { maDocShellRef = rRef; } GetDocShell() const47 const SfxObjectShellRef& GetDocShell() const { return maDocShellRef; } 48 SetWorkDocument(const SdDrawDocument * pWorkDoc)49 void SetWorkDocument( const SdDrawDocument* pWorkDoc ) { mpSdDrawDocument = mpSdDrawDocumentIntern = const_cast<SdDrawDocument*>(pWorkDoc); } GetWorkDocument() const50 const SdDrawDocument* GetWorkDocument() const { return mpSdDrawDocument; } 51 52 void SetView(const ::sd::View* pView); GetView() const53 const ::sd::View* GetView() const { return mpSdView; } 54 55 void SetObjectDescriptor( std::unique_ptr<TransferableObjectDescriptor> pObjDesc ); 56 SetStartPos(const Point & rStartPos)57 void SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; } GetStartPos() const58 const Point& GetStartPos() const { return maStartPos; } 59 SetInternalMove(bool bSet)60 void SetInternalMove( bool bSet ) { mbInternalMove = bSet; } IsInternalMove() const61 bool IsInternalMove() const { return mbInternalMove; } 62 HasSourceDoc(const SdDrawDocument * pDoc) const63 bool HasSourceDoc( const SdDrawDocument* pDoc ) const { return( mpSourceDoc == pDoc ); } 64 65 void SetPageBookmarks( const std::vector<OUString>& rPageBookmarks, bool bPersistent ); IsPageTransferable() const66 bool IsPageTransferable() const { return mbPageTransferable; } HasPageBookmarks() const67 bool HasPageBookmarks() const { return( mpPageDocShell && ( !maPageBookmarks.empty() ) ); } GetPageBookmarks() const68 const std::vector<OUString>& GetPageBookmarks() const { return maPageBookmarks; } GetPageDocShell() const69 ::sd::DrawDocShell* GetPageDocShell() const { return mpPageDocShell; } 70 71 bool SetTableRTF( SdDrawDocument* ); 72 73 static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 74 static SdTransferable* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) noexcept; 75 76 // SfxListener 77 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; 78 79 virtual void DragFinished( sal_Int8 nDropAction ) override; GetSourceDoc() const80 SdDrawDocument* GetSourceDoc() const { return mpSourceDoc;} 81 82 /** User data objects can be used to store information temporarily 83 at the transferable. The slide sorter uses this to store 84 previews of the slides that are referenced by the 85 transferable. 86 */ ~UserData()87 class UserData {public:virtual~UserData(){}}; 88 89 /** Add a user data object. When it was added before (and not 90 removed) then this call is ignored. 91 */ 92 void AddUserData (const std::shared_ptr<UserData>& rpData); 93 94 /** Return the number of user data objects. 95 */ 96 sal_Int32 GetUserDataCount() const; 97 98 /** Return the specified user data object. When the index is not 99 valid, ie not in the range [0,count) then an empty pointer is 100 returned. 101 */ 102 std::shared_ptr<UserData> GetUserData (const sal_Int32 nIndex) const; 103 104 protected: 105 106 virtual void AddSupportedFormats() override; 107 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; 108 virtual bool WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override; 109 virtual void ObjectReleased() override final; 110 111 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override; 112 113 private: 114 115 SfxObjectShellRef maDocShellRef; 116 ::sd::DrawDocShell* mpPageDocShell; 117 std::vector<OUString> maPageBookmarks; 118 std::unique_ptr<TransferableDataHelper> mpOLEDataHelper; 119 std::unique_ptr<TransferableObjectDescriptor> mpObjDesc; 120 const ::sd::View* mpSdView; 121 ::sd::View* mpSdViewIntern; 122 SdDrawDocument* mpSdDrawDocument; 123 SdDrawDocument* mpSdDrawDocumentIntern; 124 SdDrawDocument* mpSourceDoc; 125 VclPtr<VirtualDevice> mpVDev; 126 std::unique_ptr<INetBookmark> mpBookmark; 127 std::unique_ptr<Graphic> mpGraphic; 128 std::unique_ptr<ImageMap> mpImageMap; 129 ::tools::Rectangle maVisArea; 130 Point maStartPos; 131 bool mbInternalMove : 1; 132 bool mbOwnDocument : 1; 133 bool mbOwnView : 1; 134 bool mbLateInit : 1; 135 bool mbPageTransferable : 1; 136 bool mbPageTransferablePersistent : 1; 137 ::std::vector<std::shared_ptr<UserData> > maUserData; 138 139 SdTransferable( const SdTransferable& ) = delete; 140 SdTransferable& operator=( const SdTransferable& ) = delete; 141 142 void CreateObjectReplacement( SdrObject* pObj ); 143 void CreateData(); 144 145 }; 146 147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 148