1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <sfx2/objsh.hxx>
24 #include <svtools/transfer.hxx>
25 #include <vcl/graph.hxx>
26 #include <sfx2/lnkbase.hxx>
27 #include <com/sun/star/embed/XEmbeddedObject.hpp>
37 class SvxClipboardFmtItem
;
41 typedef sal_uInt16 TransferBufferType
;
42 namespace nsTransferBufferType
44 const sal_uInt16 TRNSFR_NONE
= 0x0000;
45 const sal_uInt16 TRNSFR_DOCUMENT
= 0x0001;
46 const sal_uInt16 TRNSFR_DOCUMENT_WORD
= 0x0002;
47 const sal_uInt16 TRNSFR_GRAPHIC
= 0x0004;
48 const sal_uInt16 TRNSFR_TABELLE
= 0x0008;
49 const sal_uInt16 TRNSFR_DDELINK
= 0x0010;
50 const sal_uInt16 TRNSFR_OLE
= 0x0020;
51 const sal_uInt16 TRNSFR_INETFLD
= 0x0040;
52 const sal_uInt16 TRNSFR_DRAWING
= 0x0081; // drawing is internal too!
56 class SwTransferable
: public TransferableHelper
58 friend class SwView_Impl
;
59 SfxObjectShellLock aDocShellRef
;
60 TransferableDataHelper aOleData
;
61 TransferableObjectDescriptor aObjDesc
;
62 ::sfx2::SvBaseLinkRef refDdeLink
;
64 SwWrtShell
*pWrtShell
;
65 /* #96392# Added pCreatorView to distinguish SwFrameShell from
67 const ViewShell
*pCreatorView
;
69 Graphic
*pClpGraphic
, *pClpBitmap
, *pOrigGrf
;
70 INetBookmark
*pBkmk
; // URL and description!
72 INetImage
*pTargetURL
;
74 TransferBufferType eBufferType
;
76 sal_Bool bOldIdle
:1; //D&D Idle flag from the viewsettings
77 sal_Bool bCleanUp
:1; //D&D cleanup after Drop (not by internal Drop)
79 // helper methods for the copy
80 css::uno::Reference
< css::embed::XEmbeddedObject
> FindOLEObj( sal_Int64
& nAspect
) const;
81 const Graphic
* FindOLEReplacementGraphic() const;
82 void DeleteSelection();
84 // helper methods for the paste
85 static SwTransferable
* GetSwTransferable( const TransferableDataHelper
& rData
);
86 static void SetSelInShell( SwWrtShell
& , sal_Bool
, const Point
* );
87 static sal_Bool
_CheckForURLOrLNKFile( TransferableDataHelper
& rData
,
88 String
& rFileName
, String
* pTitle
= 0 );
89 static int _TestAllowedFormat( const TransferableDataHelper
& rData
,
90 sal_uLong nFormat
, sal_uInt16 nDestination
);
92 static int _PasteFileContent( TransferableDataHelper
&,
93 SwWrtShell
& rSh
, sal_uLong nFmt
, sal_Bool bMsg
);
94 static int _PasteOLE( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
95 sal_uLong nFmt
, sal_uInt8 nActionFlags
, sal_Bool bMsg
);
96 static int _PasteTargetURL( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
97 sal_uInt16 nAction
, const Point
* pPt
, sal_Bool bInsertGRF
);
99 static int _PasteDDE( TransferableDataHelper
& rData
, SwWrtShell
& rWrtShell
,
100 sal_Bool bReReadGrf
, sal_Bool bMsg
);
102 static int _PasteSdrFormat( TransferableDataHelper
& rData
,
103 SwWrtShell
& rSh
, sal_uInt16 nAction
,
104 const Point
* pPt
, sal_uInt8 nActionFlags
);
106 static int _PasteGrf( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
107 sal_uLong nFmt
, sal_uInt16 nAction
, const Point
* pPt
,
108 sal_uInt8 nActionFlags
, sal_Bool bMsg
);
110 static int _PasteImageMap( TransferableDataHelper
& rData
,
113 static int _PasteAsHyperlink( TransferableDataHelper
& rData
,
114 SwWrtShell
& rSh
, sal_uLong nFmt
);
116 static int _PasteFileName( TransferableDataHelper
& rData
,
117 SwWrtShell
& rSh
, sal_uLong nFmt
, sal_uInt16 nAction
,
118 const Point
* pPt
, sal_uInt8 nActionFlags
, sal_Bool bMsg
);
120 static int _PasteDBData( TransferableDataHelper
& rData
, SwWrtShell
& rSh
,
121 sal_uLong nFmt
, sal_Bool bLink
, const Point
* pDragPt
,
124 static int _PasteFileList( TransferableDataHelper
& rData
,
125 SwWrtShell
& rSh
, sal_Bool bLink
,
126 const Point
* pPt
, sal_Bool bMsg
);
128 int PrivateDrop( SwWrtShell
& rSh
, const Point
& rDragPt
, sal_Bool bMove
,
129 sal_Bool bIsXSelection
);
130 int PrivatePaste( SwWrtShell
& rShell
);
132 void SetDataForDragAndDrop( const Point
& rSttPos
);
136 SwTransferable( const SwTransferable
& );
137 SwTransferable
& operator=( const SwTransferable
& );
140 virtual void AddSupportedFormats();
141 virtual sal_Bool
GetData( const css::datatransfer::DataFlavor
& rFlavor
);
142 virtual sal_Bool
WriteObject( SotStorageStreamRef
& rxOStm
,
144 sal_uInt32 nUserObjectId
,
145 const css::datatransfer::DataFlavor
& rFlavor
);
146 virtual void DragFinished( sal_Int8 nDropAction
);
147 virtual void ObjectReleased();
149 using TransferableHelper::StartDrag
;
152 SwTransferable( SwWrtShell
& );
153 virtual ~SwTransferable();
155 static sal_uInt16
GetSotDestination( const SwWrtShell
& rSh
, const Point
* = 0 );
157 // set properties on the document, like PageMargin, VisArea.
159 static void InitOle( SfxObjectShell
* pDoc
, SwDoc
& rDoc
);
161 // copy - methods and helper methods for the copy
163 int Copy( sal_Bool bIsCut
= sal_False
);
164 int PrepareForCopy( sal_Bool bIsCut
= sal_False
);
165 int CalculateAndCopy(); // special for Calculator
166 int CopyGlossary( SwTextBlocks
& rGlossary
, const String
& rStr
);
168 // remove the DDE-Link format promise
169 void RemoveDDELinkFormat( const Window
& rWin
);
171 // paste - methods and helper methods for the paste
172 static sal_Bool
IsPaste( const SwWrtShell
&, const TransferableDataHelper
& );
173 static int Paste( SwWrtShell
&, TransferableDataHelper
& );
174 static int PasteData( TransferableDataHelper
& rData
,
175 SwWrtShell
& rSh
, sal_uInt16 nAction
, sal_uLong nFormat
,
176 sal_uInt16 nDestination
, sal_Bool bIsPasteFmt
,
178 const Point
* pDDPos
= 0, sal_Int8 nDropAction
= 0,
179 sal_Bool bPasteSelection
= sal_False
);
181 static sal_Bool
IsPasteSpecial( const SwWrtShell
& rWrtShell
,
182 const TransferableDataHelper
& );
183 static int PasteUnformatted( SwWrtShell
& rSh
, TransferableDataHelper
& );
184 static int PasteSpecial( SwWrtShell
& rSh
, TransferableDataHelper
&, sal_uLong
& rFormatUsed
);
185 static int PasteFormat( SwWrtShell
& rSh
, TransferableDataHelper
& rData
,
188 static void FillClipFmtItem( const SwWrtShell
& rSh
,
189 const TransferableDataHelper
& rData
,
190 SvxClipboardFmtItem
& rToFill
);
192 // Interfaces for Drag & Drop
193 void StartDrag( Window
* pWin
, const Point
& rPos
);
195 SwWrtShell
* GetShell() { return pWrtShell
; }
196 void SetCleanUp( sal_Bool bFlag
) { bCleanUp
= bFlag
; }
198 // Interfaces for Selection
199 /* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
200 static void CreateSelection( SwWrtShell
& rSh
,
201 const ViewShell
* pCreator
= NULL
);
202 static void ClearSelection( SwWrtShell
& rSh
,
203 const ViewShell
* pCreator
= NULL
);
205 // the related SwView is being closed and the SwTransferable is invalid now
206 void Invalidate() {pWrtShell
= 0;}
207 static const css::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
209 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& rId
) throw( css::uno::RuntimeException
);
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */