xref: /aoo42x/main/sw/source/ui/inc/swdtflvr.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SWDTFLVR_HXX
28 #define _SWDTFLVR_HXX
29 
30 #include <sfx2/objsh.hxx>
31 
32 #include <svtools/transfer.hxx>
33 #include <vcl/graph.hxx>
34 #include <sfx2/lnkbase.hxx>
35 #include <com/sun/star/embed/XEmbeddedObject.hpp>
36 
37 class Graphic;
38 class ImageMap;
39 class INetBookmark;
40 class INetImage;
41 class SwDoc;
42 class SwDocFac;
43 class SwTextBlocks;
44 class SwWrtShell;
45 class SvxClipboardFmtItem;
46 class ViewShell;
47 class SwView_Impl;
48 
49 typedef sal_uInt16 TransferBufferType;
50 namespace nsTransferBufferType
51 {
52 	const sal_uInt16 TRNSFR_NONE 			= 0x0000;
53 	const sal_uInt16 TRNSFR_DOCUMENT		= 0x0001;
54 	const sal_uInt16 TRNSFR_DOCUMENT_WORD	= 0x0002;
55 	const sal_uInt16 TRNSFR_GRAPHIC			= 0x0004;
56 	const sal_uInt16 TRNSFR_TABELLE			= 0x0008;
57 	const sal_uInt16 TRNSFR_DDELINK			= 0x0010;
58 	const sal_uInt16 TRNSFR_OLE				= 0x0020;
59 	const sal_uInt16 TRNSFR_INETFLD			= 0x0040;
60 	const sal_uInt16 TRNSFR_DRAWING			= 0x0081;	//Drawing ist auch intern!
61 }
62 
63 #define DATA_FLAVOR 	::com::sun::star::datatransfer::DataFlavor
64 
65 class SwTransferable : public TransferableHelper
66 {
67     friend class SwView_Impl;
68     SfxObjectShellLock             aDocShellRef;
69 	TransferableDataHelper			aOleData;
70 	TransferableObjectDescriptor	aObjDesc;
71     ::sfx2::SvBaseLinkRef            refDdeLink;
72 
73 	SwWrtShell 		*pWrtShell;
74 	/* #96392# Added pCreatorView to distinguish SwFrameShell from
75        SwWrtShell. */
76 	const ViewShell       *pCreatorView;
77 	SwDocFac		*pClpDocFac;
78 	Graphic			*pClpGraphic, *pClpBitmap, *pOrigGrf;
79 	INetBookmark	*pBkmk;		// URL und Beschreibung!
80 	ImageMap		*pImageMap;
81 	INetImage		*pTargetURL;
82 
83 	TransferBufferType eBufferType;
84 
85 	sal_Bool bOldIdle	:1; //D&D Idle flag from the viewsettings
86 	sal_Bool bCleanUp 	:1; //D&D cleanup after Drop (not by internal Drop)
87 
88 	// helper methods for the copy
89     com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > FindOLEObj( sal_Int64& nAspect ) const;
90 	Graphic* FindOLEReplacementGraphic() const;
91 	void DeleteSelection();
92 
93 	// helper methods for the paste
94 	static SwTransferable* GetSwTransferable( const TransferableDataHelper& rData );
95 	static void SetSelInShell( SwWrtShell& , sal_Bool , const Point* );
96 	static sal_Bool _CheckForURLOrLNKFile( TransferableDataHelper& rData,
97 								String& rFileName, String* pTitle = 0 );
98 	static int _TestAllowedFormat( const TransferableDataHelper& rData,
99 										sal_uLong nFormat, sal_uInt16 nDestination );
100 
101 	static int _PasteFileContent( TransferableDataHelper&,
102 									SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg );
103 	static int _PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
104 							sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg );
105 	static int _PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
106 						sal_uInt16 nAction, const Point* pPt, sal_Bool bInsertGRF );
107 
108 	static int _PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
109 							sal_Bool bReReadGrf, sal_Bool bMsg );
110 
111 	static int _PasteSdrFormat(  TransferableDataHelper& rData,
112 									SwWrtShell& rSh, sal_uInt16 nAction,
113 									const Point* pPt, sal_uInt8 nActionFlags );
114 
115 	static int _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
116 								sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
117 								sal_uInt8 nActionFlags, sal_Bool bMsg );
118 
119 	static int _PasteImageMap( TransferableDataHelper& rData,
120 									SwWrtShell& rSh );
121 
122 	static int _PasteAsHyperlink( TransferableDataHelper& rData,
123 										SwWrtShell& rSh, sal_uLong nFmt );
124 
125 	static int _PasteFileName( TransferableDataHelper& rData,
126 							SwWrtShell& rSh, sal_uLong nFmt, sal_uInt16 nAction,
127 							const Point* pPt, sal_uInt8 nActionFlags, sal_Bool bMsg );
128 
129 	static int _PasteDBData( TransferableDataHelper& rData, SwWrtShell& rSh,
130 							sal_uLong nFmt, sal_Bool bLink, const Point* pDragPt,
131 							sal_Bool bMsg );
132 
133 	static int _PasteFileList( TransferableDataHelper& rData,
134 								SwWrtShell& rSh, sal_Bool bLink,
135 								const Point* pPt, sal_Bool bMsg );
136 
137 	int PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, sal_Bool bMove,
138 						sal_Bool bIsXSelection );
139 	int PrivatePaste( SwWrtShell& rShell );
140 
141 	void SetDataForDragAndDrop( const Point& rSttPos );
142 
143 									// not available
144 									SwTransferable();
145 									SwTransferable( const SwTransferable& );
146 	SwTransferable&					operator=( const SwTransferable& );
147 
148 protected:
149 	virtual void		AddSupportedFormats();
150 	virtual sal_Bool	GetData( const DATA_FLAVOR& rFlavor );
151 	virtual sal_Bool	WriteObject( SotStorageStreamRef& rxOStm,
152 										void* pUserObject,
153 										sal_uInt32 nUserObjectId,
154 										const DATA_FLAVOR& rFlavor );
155 	virtual void 		DragFinished( sal_Int8 nDropAction );
156 	virtual void		ObjectReleased();
157 
158     using TransferableHelper::StartDrag;
159 
160 public:
161 	SwTransferable( SwWrtShell& );
162 	virtual ~SwTransferable();
163 
164 	static sal_uInt16 GetSotDestination( const SwWrtShell& rSh, const Point* = 0 );
165 
166 	// set properties on the document, like PageMargin, VisArea.
167 	// And set real Size
168     static void InitOle( SfxObjectShell* pDoc, SwDoc& rDoc );
169 
170 	// copy - methods and helper methods for the copy
171 	int	 Cut();
172 	int	 Copy( sal_Bool bIsCut = sal_False );
173     int  PrepareForCopy( sal_Bool bIsCut = sal_False );
174 	int  CalculateAndCopy();				// special for Calculator
175 	int  CopyGlossary( SwTextBlocks& rGlossary, const String& rStr );
176 
177 	// remove the DDE-Link format promise
178 	void RemoveDDELinkFormat( const Window& rWin );
179 
180 	// paste - methods and helper methods for the paste
181 	static sal_Bool	IsPaste( const SwWrtShell&, const TransferableDataHelper& );
182 	static int Paste( SwWrtShell&, TransferableDataHelper& );
183 	static int PasteData( TransferableDataHelper& rData,
184 						  SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
185 						  sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
186                           sal_Bool bIsDefault,
187                           const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
188 						  sal_Bool bPasteSelection = sal_False );
189 
190 	static sal_Bool IsPasteSpecial( const SwWrtShell& rWrtShell,
191 								const TransferableDataHelper& );
192     static int PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
193     static int PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, sal_uLong& rFormatUsed );
194 	static int PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
195 							 sal_uLong nFormat );
196 
197 	static void FillClipFmtItem( const SwWrtShell& rSh,
198 								const TransferableDataHelper& rData,
199 								SvxClipboardFmtItem & rToFill );
200 
201 	// Interfaces for Drag & Drop
202 	void StartDrag( Window* pWin, const Point& rPos );
203 
204 	SwWrtShell* GetShell()				{ return pWrtShell; }
205 	void SetCleanUp( sal_Bool bFlag )		{ bCleanUp = bFlag; }
206 
207 	// Interfaces for Selection
208 	/* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
209 	static void CreateSelection( SwWrtShell & rSh,
210 								 const ViewShell * pCreator = NULL );
211 	static void ClearSelection( SwWrtShell& rSh,
212 								const ViewShell * pCreator = NULL );
213 
214     // the related SwView is being closed and the SwTransferable is invalid now
215     void    Invalidate() {pWrtShell = 0;}
216     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
217 
218     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
219 };
220 
221 
222 #endif
223