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 INCLUDED_SW_SOURCE_UI_INC_SWDTFLVR_HXX
20 : #define INCLUDED_SW_SOURCE_UI_INC_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 SwViewShell;
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 : class SW_DLLPUBLIC SwTransferable : public TransferableHelper
56 : {
57 : friend class SwView_Impl;
58 : SfxObjectShellLock aDocShellRef;
59 : TransferableDataHelper aOleData;
60 : TransferableObjectDescriptor aObjDesc;
61 : ::sfx2::SvBaseLinkRef refDdeLink;
62 :
63 : SwWrtShell *pWrtShell;
64 : /* #96392# Added pCreatorView to distinguish SwFrameShell from
65 : SwWrtShell. */
66 : const SwViewShell *pCreatorView;
67 : SwDocFac *pClpDocFac;
68 : Graphic *pClpGraphic, *pClpBitmap, *pOrigGrf;
69 : INetBookmark *pBkmk; // URL and description!
70 : ImageMap *pImageMap;
71 : INetImage *pTargetURL;
72 :
73 : TransferBufferType eBufferType;
74 :
75 : sal_Bool bOldIdle :1; //D&D Idle flag from the viewsettings
76 : sal_Bool bCleanUp :1; //D&D cleanup after Drop (not by internal Drop)
77 :
78 : // helper methods for the copy
79 : css::uno::Reference < css::embed::XEmbeddedObject > FindOLEObj( sal_Int64& nAspect ) const;
80 : const Graphic* FindOLEReplacementGraphic() const;
81 : void DeleteSelection();
82 :
83 : // helper methods for the paste
84 : static SwTransferable* GetSwTransferable( const TransferableDataHelper& rData );
85 : static void SetSelInShell( SwWrtShell& , sal_Bool , const Point* );
86 : static sal_Bool _CheckForURLOrLNKFile( TransferableDataHelper& rData,
87 : OUString& rFileName, OUString* pTitle = 0 );
88 : static bool _TestAllowedFormat( const TransferableDataHelper& rData,
89 : sal_uLong nFormat, sal_uInt16 nDestination );
90 :
91 : static bool _PasteFileContent( TransferableDataHelper&,
92 : SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg );
93 : static bool _PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
94 : sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg );
95 : static bool _PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
96 : sal_uInt16 nAction, const Point* pPt, sal_Bool bInsertGRF );
97 :
98 : static bool _PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
99 : sal_Bool bReReadGrf, sal_Bool bMsg );
100 :
101 : static bool _PasteSdrFormat( TransferableDataHelper& rData,
102 : SwWrtShell& rSh, sal_uInt16 nAction,
103 : const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste);
104 :
105 : static bool _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
106 : sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
107 : sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste);
108 :
109 : static bool _PasteImageMap( TransferableDataHelper& rData,
110 : SwWrtShell& rSh );
111 :
112 : static bool _PasteAsHyperlink( TransferableDataHelper& rData,
113 : SwWrtShell& rSh, sal_uLong nFmt );
114 :
115 : static bool _PasteFileName( TransferableDataHelper& rData,
116 : SwWrtShell& rSh, sal_uLong nFmt, sal_uInt16 nAction,
117 : const Point* pPt, sal_uInt8 nActionFlags, sal_Bool bMsg, bool * graphicInserted );
118 :
119 : static bool _PasteDBData( TransferableDataHelper& rData, SwWrtShell& rSh,
120 : sal_uLong nFmt, sal_Bool bLink, const Point* pDragPt,
121 : sal_Bool bMsg );
122 :
123 : static bool _PasteFileList( TransferableDataHelper& rData,
124 : SwWrtShell& rSh, sal_Bool bLink,
125 : const Point* pPt, sal_Bool bMsg );
126 :
127 : bool PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, sal_Bool bMove,
128 : sal_Bool bIsXSelection );
129 : bool PrivatePaste( SwWrtShell& rShell );
130 :
131 : void SetDataForDragAndDrop( const Point& rSttPos );
132 :
133 : // not available
134 : SwTransferable();
135 : SwTransferable( const SwTransferable& );
136 : SwTransferable& operator=( const SwTransferable& );
137 :
138 : protected:
139 : virtual void AddSupportedFormats() SAL_OVERRIDE;
140 : virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
141 : virtual bool WriteObject( SotStorageStreamRef& rxOStm,
142 : void* pUserObject,
143 : sal_uInt32 nUserObjectId,
144 : const css::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
145 : virtual void DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE;
146 : virtual void ObjectReleased() SAL_OVERRIDE;
147 :
148 : using TransferableHelper::StartDrag;
149 :
150 : public:
151 : SwTransferable( SwWrtShell& );
152 : virtual ~SwTransferable();
153 :
154 : static sal_uInt16 GetSotDestination( const SwWrtShell& rSh, const Point* = 0 );
155 :
156 : // set properties on the document, like PageMargin, VisArea.
157 : // And set real Size
158 : static void InitOle( SfxObjectShell* pDoc, SwDoc& rDoc );
159 :
160 : // copy - methods and helper methods for the copy
161 : int Cut();
162 : int Copy( sal_Bool bIsCut = sal_False );
163 : int PrepareForCopy( sal_Bool bIsCut = sal_False );
164 : int CalculateAndCopy(); // special for Calculator
165 : int CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr );
166 :
167 : // remove the DDE-Link format promise
168 : void RemoveDDELinkFormat( const Window& rWin );
169 :
170 : // paste - methods and helper methods for the paste
171 : static sal_Bool IsPaste( const SwWrtShell&, const TransferableDataHelper& );
172 : static bool Paste( SwWrtShell&, TransferableDataHelper& );
173 : static bool PasteData( TransferableDataHelper& rData,
174 : SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
175 : sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
176 : sal_Bool bIsDefault,
177 : const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
178 : sal_Bool bPasteSelection = sal_False );
179 :
180 : static sal_Bool IsPasteSpecial( const SwWrtShell& rWrtShell,
181 : const TransferableDataHelper& );
182 : static bool PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
183 : static bool PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, sal_uLong& rFormatUsed );
184 : static bool PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
185 : sal_uLong nFormat );
186 :
187 : static void FillClipFmtItem( const SwWrtShell& rSh,
188 : const TransferableDataHelper& rData,
189 : SvxClipboardFmtItem & rToFill );
190 :
191 : // Interfaces for Drag & Drop
192 : void StartDrag( Window* pWin, const Point& rPos );
193 :
194 0 : SwWrtShell* GetShell() { return pWrtShell; }
195 0 : void SetCleanUp( sal_Bool bFlag ) { bCleanUp = bFlag; }
196 :
197 : // Interfaces for Selection
198 : /* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
199 : static void CreateSelection( SwWrtShell & rSh,
200 : const SwViewShell * pCreator = NULL );
201 : static void ClearSelection( SwWrtShell& rSh,
202 : const SwViewShell * pCreator = NULL );
203 :
204 : // the related SwView is being closed and the SwTransferable is invalid now
205 0 : void Invalidate() {pWrtShell = 0;}
206 : static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId();
207 :
208 : virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
209 : };
210 :
211 : #endif
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|