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