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