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