LibreOffice Module sw (master) 1
swdtflvr.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#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWDTFLVR_HXX
20#define INCLUDED_SW_SOURCE_UIBASE_INC_SWDTFLVR_HXX
21
22#include <sfx2/objsh.hxx>
23
24#include <vcl/transfer.hxx>
25#include <vcl/graph.hxx>
26#include <vcl/vclptr.hxx>
27#include <sfx2/lnkbase.hxx>
28#include <com/sun/star/embed/XEmbeddedObject.hpp>
29#include <o3tl/deleter.hxx>
31#include <svx/swframetypes.hxx>
32#include <svl/urlbmk.hxx>
33#include <memory>
34#include <optional>
35
36#include <swdllapi.h>
37
38class Graphic;
39class ImageMap;
40class INetImage;
42class SwDoc;
43class SwDocFac;
44class SwPaM;
45class SwTextBlocks;
46class SwWrtShell;
48class SwFrameShell;
49class SwView_Impl;
50class SwPasteContext;
51enum class SwPasteSdr;
52
53enum class TransferBufferType : sal_uInt16
54{
55 NONE = 0x0000,
56 Document = 0x0001,
57 DocumentWord = 0x0002,
58 Graphic = 0x0004,
59 Table = 0x0008,
60 Ole = 0x0020,
61 InetField = 0x0040,
62 Drawing = 0x0081, // drawing is internal too!
63};
64namespace o3tl {
65 template<> struct typed_flags<TransferBufferType> : is_typed_flags<TransferBufferType, 0x00ef> {};
66}
67// paste table into a table
69{
70 PASTE_DEFAULT, // paste table by overwriting table cells
71 PASTE_ROW, // paste table as rows above
72 PASTE_COLUMN, // paste table as columns before
73 PASTE_TABLE // paste table as nested table
74};
75
77{
78 friend class SwView_Impl;
82
84 /* #96392# Added pCreatorView to distinguish SwFrameShell from
85 SwWrtShell. */
87 std::unique_ptr<SwDocFac, o3tl::default_delete<SwDocFac>> m_pClpDocFac;
88 std::optional<Graphic> m_oClpGraphic;
89 std::optional<Graphic> m_oClpBitmap;
91 std::optional<INetBookmark> m_oBookmark; // URL and description!
92 std::unique_ptr<ImageMap> m_pImageMap;
93 std::unique_ptr<INetImage> m_pTargetURL;
94
96
97 bool m_bOldIdle :1; //D&D Idle flag from the viewsettings
98 bool m_bCleanUp :1; //D&D cleanup after Drop (not by internal Drop)
99
100 // helper methods for the copy
101 css::uno::Reference < css::embed::XEmbeddedObject > FindOLEObj( sal_Int64& nAspect ) const;
102 const Graphic* FindOLEReplacementGraphic() const;
103 void DeleteSelection();
104
105 // helper methods for the paste
106 static SwTransferable* GetSwTransferable( const TransferableDataHelper& rData );
107 static void SetSelInShell( SwWrtShell& , bool , const Point* );
108 static bool CheckForURLOrLNKFile( const TransferableDataHelper& rData,
109 OUString& rFileName, OUString* pTitle = nullptr );
110 static bool TestAllowedFormat( const TransferableDataHelper& rData,
111 SotClipboardFormatId nFormat, SotExchangeDest nDestination );
112
113 static bool PasteFileContent( const TransferableDataHelper&,
114 SwWrtShell& rSh, SotClipboardFormatId nFormat, bool bMsg, bool bIgnoreComments = false );
115 static bool PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
116 SotClipboardFormatId nFormat, SotExchangeActionFlags nActionFlags, bool bMsg );
117 static bool PasteTargetURL( const TransferableDataHelper& rData, SwWrtShell& rSh,
118 SwPasteSdr nAction, const Point* pPt, bool bInsertGRF );
119
120 static bool PasteDDE( const TransferableDataHelper& rData, SwWrtShell& rWrtShell,
121 bool bReReadGrf, bool bMsg );
122
123 static bool PasteSdrFormat( const TransferableDataHelper& rData,
124 SwWrtShell& rSh, SwPasteSdr nAction,
125 const Point* pPt, SotExchangeActionFlags nActionFlags, bool bNeedToSelectBeforePaste);
126
127 static bool PasteGrf( const TransferableDataHelper& rData, SwWrtShell& rSh,
128 SotClipboardFormatId nFormat, SwPasteSdr nAction, const Point* pPt,
129 SotExchangeActionFlags nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA );
130
131 static bool PasteImageMap( const TransferableDataHelper& rData,
132 SwWrtShell& rSh );
133
134 static bool PasteAsHyperlink( const TransferableDataHelper& rData,
135 SwWrtShell& rSh, SotClipboardFormatId nFormat );
136
137 static bool PasteFileName( TransferableDataHelper& rData,
138 SwWrtShell& rSh, SotClipboardFormatId nFormat, SwPasteSdr nAction,
139 const Point* pPt, SotExchangeActionFlags nActionFlags, bool * graphicInserted );
140
141 static bool PasteDBData( const TransferableDataHelper& rData, SwWrtShell& rSh,
142 SotClipboardFormatId nFormat, bool bLink, const Point* pDragPt,
143 bool bMsg );
144
145 static bool PasteFileList( const TransferableDataHelper& rData,
146 SwWrtShell& rSh, bool bLink,
147 const Point* pPt, bool bMsg );
148
149 bool PrivatePaste( SwWrtShell& rShell, SwPasteContext* pContext = nullptr, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT );
150
151 void SetDataForDragAndDrop( const Point& rSttPos );
152
153 SwTransferable( const SwTransferable& ) = delete;
155
156 virtual void AddSupportedFormats() override;
157 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
158 virtual bool WriteObject( tools::SvRef<SotTempStream>& rxOStm,
159 void* pUserObject,
160 sal_uInt32 nUserObjectId,
161 const css::datatransfer::DataFlavor& rFlavor ) override;
162 virtual void DragFinished( sal_Int8 nDropAction ) override;
163 virtual void ObjectReleased() override;
164 virtual sal_Bool SAL_CALL isComplex() override;
165
167
168public:
170 virtual ~SwTransferable() override;
171
172 static SotExchangeDest GetSotDestination( const SwWrtShell& rSh );
173
174 // set properties on the document, like PageMargin, VisArea.
175 // And set real Size
176 static void InitOle( SfxObjectShell* pDoc );
177
178 // copy - methods and helper methods for the copy
179 int Cut();
180 int Copy( bool bIsCut = false );
181 int PrepareForCopy( bool bIsCut = false );
182 void PrepareForCopyTextRange(SwPaM & rPaM);
183 void CalculateAndCopy(); // special for Calculator
184 bool CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr );
185
186 // remove the DDE-Link format promise
187 void RemoveDDELinkFormat(vcl::Window& rWin);
188
189 // paste - methods and helper methods for the paste
190 static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
191 static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
192 bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT );
193 static bool PasteData( TransferableDataHelper& rData,
194 SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags,
195 SotClipboardFormatId nFormat,
196 SotExchangeDest nDestination, bool bIsPasteFormat,
197 bool bIsDefault,
198 const Point* pDDPos = nullptr, sal_Int8 nDropAction = 0,
199 bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
200 bool bIgnoreComments = false,
201 SwPasteContext* pContext = nullptr,
203
204 static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
205 const TransferableDataHelper& );
206 static bool IsPasteOwnFormat( const TransferableDataHelper& );
207 static bool PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
213 static void PrePasteSpecial( const SwWrtShell& rSh, TransferableDataHelper&, const VclPtr<SfxAbstractPasteDialog>& pDlg );
214 static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
215 SotClipboardFormatId nFormat );
216
217 static void FillClipFormatItem( const SwWrtShell& rSh,
218 const TransferableDataHelper& rData,
219 SvxClipboardFormatItem & rToFill );
220
221 // Interfaces for Drag & Drop
222 void StartDrag( vcl::Window* pWin, const Point& rPos );
223
224 SwWrtShell* GetShell() { return m_pWrtShell; }
225 void SetCleanUp( bool bFlag ) { m_bCleanUp = bFlag; }
226
227 // public only for testing
228 bool PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, bool bMove,
229 bool bIsXSelection );
230
231 // Interfaces for Selection
232 /* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
233 static void CreateSelection( SwWrtShell & rSh,
234 const SwFrameShell * pCreator = nullptr );
235 static void ClearSelection( const SwWrtShell& rSh,
236 const SwFrameShell * pCreator = nullptr );
237
238 // the related SwView is being closed and the SwTransferable is invalid now
239 void Invalidate() {m_pWrtShell = nullptr;}
240
241 static void SelectPasteFormat(TransferableDataHelper& rData, sal_uInt8& nAction,
242 SotClipboardFormatId& nFormat);
243};
244
245#endif
246
247/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:197
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Tracks the boundaries of pasted content and notifies listeners.
Definition: swdtflvr.cxx:211
SwTransferable & operator=(const SwTransferable &)=delete
SwWrtShell * GetShell()
Definition: swdtflvr.hxx:224
TransferableObjectDescriptor m_aObjDesc
Definition: swdtflvr.hxx:80
std::unique_ptr< INetImage > m_pTargetURL
Definition: swdtflvr.hxx:93
std::unique_ptr< SwDocFac, o3tl::default_delete< SwDocFac > > m_pClpDocFac
Definition: swdtflvr.hxx:87
tools::SvRef< sfx2::SvBaseLink > m_xDdeLink
Definition: swdtflvr.hxx:81
std::optional< INetBookmark > m_oBookmark
Definition: swdtflvr.hxx:91
const SwFrameShell * m_pCreatorView
Definition: swdtflvr.hxx:86
TransferBufferType m_eBufferType
Definition: swdtflvr.hxx:95
void Invalidate()
Definition: swdtflvr.hxx:239
std::unique_ptr< ImageMap > m_pImageMap
Definition: swdtflvr.hxx:92
Graphic * m_pOrigGraphic
Definition: swdtflvr.hxx:90
SfxObjectShellLock m_aDocShellRef
Definition: swdtflvr.hxx:79
void SetCleanUp(bool bFlag)
Definition: swdtflvr.hxx:225
std::optional< Graphic > m_oClpGraphic
Definition: swdtflvr.hxx:88
SwWrtShell * m_pWrtShell
Definition: swdtflvr.hxx:83
std::optional< Graphic > m_oClpBitmap
Definition: swdtflvr.hxx:89
SwTransferable(const SwTransferable &)=delete
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void StartDrag(vcl::Window *pWindow, sal_Int8 nDragSourceActions)
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
virtual void DragFinished(sal_Int8 nDropAction)
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc)=0
virtual void AddSupportedFormats()=0
virtual sal_Bool SAL_CALL isComplex() override
virtual void ObjectReleased()
SotExchangeActionFlags
SotExchangeDest
SwPasteSdr
Definition: fesh.hxx:159
SotClipboardFormatId
NONE
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
TransferBufferType
Definition: swdtflvr.hxx:54
PasteTableType
Definition: swdtflvr.hxx:69
RndStdIds
unsigned char sal_uInt8
unsigned char sal_Bool
signed char sal_Int8