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