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