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