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