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 SwPaM;
44 class SwTextBlocks;
45 class SwWrtShell;
47 class SwFrameShell;
48 class SwView_Impl;
49 class SwPasteContext;
50 enum class SwPasteSdr;
51 
52 enum 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 };
63 namespace o3tl {
64  template<> struct typed_flags<TransferBufferType> : is_typed_flags<TransferBufferType, 0x00ef> {};
65 }
66 // paste table into a table
67 enum class PasteTableType
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( 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( 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( TransferableDataHelper& rData, SwWrtShell& rSh,
117  SwPasteSdr nAction, const Point* pPt, bool bInsertGRF );
118 
119  static bool PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
120  bool bReReadGrf, bool bMsg );
121 
122  static bool PasteSdrFormat( TransferableDataHelper& rData,
123  SwWrtShell& rSh, SwPasteSdr nAction,
124  const Point* pPt, SotExchangeActionFlags nActionFlags, bool bNeedToSelectBeforePaste);
125 
126  static bool PasteGrf( 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( TransferableDataHelper& rData,
131  SwWrtShell& rSh );
132 
133  static bool PasteAsHyperlink( 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( TransferableDataHelper& rData, SwWrtShell& rSh,
141  SotClipboardFormatId nFormat, bool bLink, const Point* pDragPt,
142  bool bMsg );
143 
144  static bool PasteFileList( TransferableDataHelper& rData,
145  SwWrtShell& rSh, bool bLink,
146  const Point* pPt, bool bMsg );
147 
148  bool PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, bool bMove,
149  bool bIsXSelection );
150 
151  bool PrivatePaste( SwWrtShell& rShell, SwPasteContext* pContext = nullptr, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT );
152 
153  void SetDataForDragAndDrop( const Point& rSttPos );
154 
155  SwTransferable( const SwTransferable& ) = delete;
156  SwTransferable& operator=( const SwTransferable& ) = delete;
157 
158  virtual void AddSupportedFormats() override;
159  virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
160  virtual bool WriteObject( tools::SvRef<SotTempStream>& 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 PrepareForCopyTextRange(SwPaM & rPaM);
185  void CalculateAndCopy(); // special for Calculator
186  bool CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr );
187 
188  // remove the DDE-Link format promise
189  void RemoveDDELinkFormat(vcl::Window& rWin);
190 
191  // paste - methods and helper methods for the paste
192  static bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
193  static bool Paste( SwWrtShell&, TransferableDataHelper&, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
194  bool bIgnoreComments = false, PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT );
195  static bool PasteData( TransferableDataHelper& rData,
196  SwWrtShell& rSh, sal_uInt8 nAction, SotExchangeActionFlags nActionFlags,
197  SotClipboardFormatId nFormat,
198  SotExchangeDest nDestination, bool bIsPasteFormat,
199  bool bIsDefault,
200  const Point* pDDPos = nullptr, sal_Int8 nDropAction = 0,
201  bool bPasteSelection = false, RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA,
202  bool bIgnoreComments = false,
203  SwPasteContext* pContext = nullptr,
205 
206  static bool IsPasteSpecial( const SwWrtShell& rWrtShell,
207  const TransferableDataHelper& );
208  static bool IsPasteOwnFormat( const TransferableDataHelper& );
209  static bool PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
215  static void PrePasteSpecial( const SwWrtShell& rSh, TransferableDataHelper&, const VclPtr<SfxAbstractPasteDialog>& pDlg );
216  static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
217  SotClipboardFormatId nFormat );
218 
219  static void FillClipFormatItem( const SwWrtShell& rSh,
220  const TransferableDataHelper& rData,
221  SvxClipboardFormatItem & rToFill );
222 
223  // Interfaces for Drag & Drop
224  void StartDrag( vcl::Window* pWin, const Point& rPos );
225 
226  SwWrtShell* GetShell() { return m_pWrtShell; }
227  void SetCleanUp( bool bFlag ) { m_bCleanUp = bFlag; }
228 
229  // Interfaces for Selection
230  /* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
231  static void CreateSelection( SwWrtShell & rSh,
232  const SwFrameShell * pCreator = nullptr );
233  static void ClearSelection( SwWrtShell& rSh,
234  const SwFrameShell * pCreator = nullptr );
235 
236  // the related SwView is being closed and the SwTransferable is invalid now
237  void Invalidate() {m_pWrtShell = nullptr;}
238  static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
239 
240  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) override;
241 
242  static void SelectPasteFormat(TransferableDataHelper& rData, sal_uInt8& nAction,
243  SotClipboardFormatId& nFormat);
244 };
245 
246 #endif
247 
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwWrtShell * GetShell()
Definition: swdtflvr.hxx:226
TransferableObjectDescriptor m_aObjDesc
Definition: swdtflvr.hxx:79
tools::SvRef< sfx2::SvBaseLink > m_xDdeLink
Definition: swdtflvr.hxx:80
virtual void AddSupportedFormats()=0
signed char sal_Int8
Definition: doc.hxx:188
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:93
Graphic * m_pOrigGraphic
Definition: swdtflvr.hxx:89
TransferBufferType m_eBufferType
Definition: swdtflvr.hxx:94
SwPasteSdr
Definition: fesh.hxx:157
virtual bool WriteObject(tools::SvRef< SotTempStream > &rxOStm, void *pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor &rFlavor)
SotClipboardFormatId
std::unique_ptr< SwDocFac, o3tl::default_delete< SwDocFac > > m_pClpDocFac
Definition: swdtflvr.hxx:86
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
std::unique_ptr< Graphic > m_pClpBitmap
Definition: swdtflvr.hxx:88
TransferBufferType
Definition: swdtflvr.hxx:52
const SwFrameShell * m_pCreatorView
Definition: swdtflvr.hxx:85
SotExchangeActionFlags
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
unsigned char sal_Bool
void StartDrag(vcl::Window *pWindow, sal_Int8 nDragSourceActions)
#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:90
void Invalidate()
Definition: swdtflvr.hxx:237
SwWrtShell * m_pWrtShell
Definition: swdtflvr.hxx:82
unsigned char sal_uInt8
void SetCleanUp(bool bFlag)
Definition: swdtflvr.hxx:227
Tracks the boundaries of pasted content and notifies listeners.
Definition: swdtflvr.cxx:208
virtual void ObjectReleased()
PasteTableType
Definition: swdtflvr.hxx:67
RndStdIds
std::unique_ptr< INetImage > m_pTargetURL
Definition: swdtflvr.hxx:92
SfxObjectShellLock m_aDocShellRef
Definition: swdtflvr.hxx:78
std::unique_ptr< ImageMap > m_pImageMap
Definition: swdtflvr.hxx:91
std::unique_ptr< Graphic > m_pClpGraphic
Definition: swdtflvr.hxx:87
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc)=0