LibreOffice Module sd (master) 1
sdxfer.hxx
Go to the documentation of this file.
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
30class SdDrawDocument;
31class SdrObject;
32class ImageMap;
33class VirtualDevice;
34
35namespace sd {
36class DrawDocShell;
37class View;
38}
39
40class SAL_DLLPUBLIC_RTTI SdTransferable : public TransferDataContainer, public SfxListener
41{
42public:
43
44 SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, bool bInitOnGetData );
45 virtual ~SdTransferable() override;
46
47 void SetDocShell( const SfxObjectShellRef& rRef ) { maDocShellRef = rRef; }
48 const SfxObjectShellRef& GetDocShell() const { return maDocShellRef; }
49
50 void SetWorkDocument( const SdDrawDocument* pWorkDoc ) { mpSdDrawDocument = mpSdDrawDocumentIntern = const_cast<SdDrawDocument*>(pWorkDoc); }
51 const SdDrawDocument* GetWorkDocument() const { return mpSdDrawDocument; }
52
53 void SetView(const ::sd::View* pView);
54 const ::sd::View* GetView() const { return mpSdView; }
55
56 void SetObjectDescriptor( std::unique_ptr<TransferableObjectDescriptor> pObjDesc );
57
58 void SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; }
59 const Point& GetStartPos() const { return maStartPos; }
60
61 void SetInternalMove( bool bSet ) { mbInternalMove = bSet; }
62 bool IsInternalMove() const { return mbInternalMove; }
63
64 bool HasSourceDoc( const SdDrawDocument* pDoc ) const { return( mpSourceDoc == pDoc ); }
65
66 void SetPageBookmarks( std::vector<OUString>&& rPageBookmarks, bool bPersistent );
67 bool IsPageTransferable() const { return mbPageTransferable; }
68 bool HasPageBookmarks() const { return( mpPageDocShell && ( !maPageBookmarks.empty() ) ); }
69 const std::vector<OUString>& GetPageBookmarks() const { return maPageBookmarks; }
70 ::sd::DrawDocShell* GetPageDocShell() const { return mpPageDocShell; }
71
72 bool SetTableRTF( SdDrawDocument* );
73
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;
80 SdDrawDocument* GetSourceDoc() const { return mpSourceDoc;}
81
87 class UserData {public:virtual~UserData(){}};
88
92 void AddUserData (const std::shared_ptr<UserData>& rpData);
93
96 sal_Int32 GetUserDataCount() const;
97
102 std::shared_ptr<UserData> GetUserData (const sal_Int32 nIndex) const;
103
104protected:
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
111private:
112
113 SfxObjectShellRef maDocShellRef;
114 ::sd::DrawDocShell* mpPageDocShell;
115 std::vector<OUString> maPageBookmarks;
116 std::unique_ptr<TransferableDataHelper> mpOLEDataHelper;
117 std::unique_ptr<TransferableObjectDescriptor> mpObjDesc;
118 const ::sd::View* mpSdView;
119 ::sd::View* mpSdViewIntern;
120 SdDrawDocument* mpSdDrawDocument;
121 SdDrawDocument* mpSdDrawDocumentIntern;
122 SdDrawDocument* mpSourceDoc;
124 std::optional<INetBookmark> moBookmark;
125 std::optional<Graphic> moGraphic;
126 std::unique_ptr<ImageMap> mpImageMap;
127 ::tools::Rectangle maVisArea;
128 Point maStartPos;
129 bool mbInternalMove : 1;
130 bool mbOwnDocument : 1;
131 bool mbOwnView : 1;
132 bool mbLateInit : 1;
133 bool mbPageTransferable : 1;
134 bool mbPageTransferablePersistent : 1;
135 ::std::vector<std::shared_ptr<UserData> > maUserData;
136
137 SdTransferable( const SdTransferable& ) = delete;
138 SdTransferable& operator=( const SdTransferable& ) = delete;
139
140 void CreateObjectReplacement( SdrObject* pObj );
141 void CreateData();
142
143};
144
145/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
User data objects can be used to store information temporarily at the transferable.
Definition: sdxfer.hxx:87
const SfxObjectShellRef & GetDocShell() const
Definition: sdxfer.hxx:48
bool IsPageTransferable() const
Definition: sdxfer.hxx:67
void SetStartPos(const Point &rStartPos)
Definition: sdxfer.hxx:58
const ::sd::View * GetView() const
Definition: sdxfer.hxx:54
void SetInternalMove(bool bSet)
Definition: sdxfer.hxx:61
void SetWorkDocument(const SdDrawDocument *pWorkDoc)
Definition: sdxfer.hxx:50
const Point & GetStartPos() const
Definition: sdxfer.hxx:59
bool HasPageBookmarks() const
Definition: sdxfer.hxx:68
void SetDocShell(const SfxObjectShellRef &rRef)
Definition: sdxfer.hxx:47
::sd::DrawDocShell * GetPageDocShell() const
Definition: sdxfer.hxx:70
const std::vector< OUString > & GetPageBookmarks() const
Definition: sdxfer.hxx:69
const SdDrawDocument * GetWorkDocument() const
Definition: sdxfer.hxx:51
bool IsInternalMove() const
Definition: sdxfer.hxx:62
SdDrawDocument * GetSourceDoc() const
Definition: sdxfer.hxx:80
bool HasSourceDoc(const SdDrawDocument *pDoc) const
Definition: sdxfer.hxx:64
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
virtual void DragFinished(sal_Int8 nDropAction) override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
virtual void AddSupportedFormats() override
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
virtual void ObjectReleased()
signed char sal_Int8