Line data Source code
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 _SWDTFLVR_HXX
20 : #define _SWDTFLVR_HXX
21 :
22 : #include <sfx2/objsh.hxx>
23 :
24 : #include <svtools/transfer.hxx>
25 : #include <vcl/graph.hxx>
26 : #include <sfx2/lnkbase.hxx>
27 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
28 :
29 : class Graphic;
30 : class ImageMap;
31 : class INetBookmark;
32 : class INetImage;
33 : class SwDoc;
34 : class SwDocFac;
35 : class SwTextBlocks;
36 : class SwWrtShell;
37 : class SvxClipboardFmtItem;
38 : class ViewShell;
39 : class SwView_Impl;
40 :
41 : typedef sal_uInt16 TransferBufferType;
42 : namespace nsTransferBufferType
43 : {
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!
53 : }
54 :
55 :
56 : class SwTransferable : public TransferableHelper
57 : {
58 : friend class SwView_Impl;
59 : SfxObjectShellLock aDocShellRef;
60 : TransferableDataHelper aOleData;
61 : TransferableObjectDescriptor aObjDesc;
62 : ::sfx2::SvBaseLinkRef refDdeLink;
63 :
64 : SwWrtShell *pWrtShell;
65 : /* #96392# Added pCreatorView to distinguish SwFrameShell from
66 : SwWrtShell. */
67 : const ViewShell *pCreatorView;
68 : SwDocFac *pClpDocFac;
69 : Graphic *pClpGraphic, *pClpBitmap, *pOrigGrf;
70 : INetBookmark *pBkmk; // URL and description!
71 : ImageMap *pImageMap;
72 : INetImage *pTargetURL;
73 :
74 : TransferBufferType eBufferType;
75 :
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)
78 :
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();
83 :
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 );
91 :
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 );
98 :
99 : static int _PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
100 : sal_Bool bReReadGrf, sal_Bool bMsg );
101 :
102 : static int _PasteSdrFormat( TransferableDataHelper& rData,
103 : SwWrtShell& rSh, sal_uInt16 nAction,
104 : const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste);
105 :
106 : static int _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
107 : sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
108 : sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste);
109 :
110 : static int _PasteImageMap( TransferableDataHelper& rData,
111 : SwWrtShell& rSh );
112 :
113 : static int _PasteAsHyperlink( TransferableDataHelper& rData,
114 : SwWrtShell& rSh, sal_uLong nFmt );
115 :
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 );
119 :
120 : static int _PasteDBData( TransferableDataHelper& rData, SwWrtShell& rSh,
121 : sal_uLong nFmt, sal_Bool bLink, const Point* pDragPt,
122 : sal_Bool bMsg );
123 :
124 : static int _PasteFileList( TransferableDataHelper& rData,
125 : SwWrtShell& rSh, sal_Bool bLink,
126 : const Point* pPt, sal_Bool bMsg );
127 :
128 : int PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, sal_Bool bMove,
129 : sal_Bool bIsXSelection );
130 : int PrivatePaste( SwWrtShell& rShell );
131 :
132 : void SetDataForDragAndDrop( const Point& rSttPos );
133 :
134 : // not available
135 : SwTransferable();
136 : SwTransferable( const SwTransferable& );
137 : SwTransferable& operator=( const SwTransferable& );
138 :
139 : protected:
140 : virtual void AddSupportedFormats();
141 : virtual sal_Bool GetData( const css::datatransfer::DataFlavor& rFlavor );
142 : virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm,
143 : void* pUserObject,
144 : sal_uInt32 nUserObjectId,
145 : const css::datatransfer::DataFlavor& rFlavor );
146 : virtual void DragFinished( sal_Int8 nDropAction );
147 : virtual void ObjectReleased();
148 :
149 : using TransferableHelper::StartDrag;
150 :
151 : public:
152 : SwTransferable( SwWrtShell& );
153 : virtual ~SwTransferable();
154 :
155 : static sal_uInt16 GetSotDestination( const SwWrtShell& rSh, const Point* = 0 );
156 :
157 : // set properties on the document, like PageMargin, VisArea.
158 : // And set real Size
159 : static void InitOle( SfxObjectShell* pDoc, SwDoc& rDoc );
160 :
161 : // copy - methods and helper methods for the copy
162 : int Cut();
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 );
167 :
168 : // remove the DDE-Link format promise
169 : void RemoveDDELinkFormat( const Window& rWin );
170 :
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,
177 : sal_Bool bIsDefault,
178 : const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
179 : sal_Bool bPasteSelection = sal_False );
180 :
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,
186 : sal_uLong nFormat );
187 :
188 : static void FillClipFmtItem( const SwWrtShell& rSh,
189 : const TransferableDataHelper& rData,
190 : SvxClipboardFmtItem & rToFill );
191 :
192 : // Interfaces for Drag & Drop
193 : void StartDrag( Window* pWin, const Point& rPos );
194 :
195 0 : SwWrtShell* GetShell() { return pWrtShell; }
196 0 : void SetCleanUp( sal_Bool bFlag ) { bCleanUp = bFlag; }
197 :
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 );
204 :
205 : // the related SwView is being closed and the SwTransferable is invalid now
206 2 : void Invalidate() {pWrtShell = 0;}
207 : static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
208 :
209 : virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) throw( css::uno::RuntimeException );
210 : };
211 :
212 :
213 : #endif
214 :
215 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|