xref: /aoo41x/main/sw/source/ui/inc/swdtflvr.hxx (revision 1cd65da9)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
101d2dbeb0SAndrew Rist  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
121d2dbeb0SAndrew Rist  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
191d2dbeb0SAndrew Rist  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SWDTFLVR_HXX
24cdf0e10cSrcweir #define _SWDTFLVR_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <sfx2/objsh.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svtools/transfer.hxx>
29cdf0e10cSrcweir #include <vcl/graph.hxx>
30cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
31cdf0e10cSrcweir #include <com/sun/star/embed/XEmbeddedObject.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class Graphic;
34cdf0e10cSrcweir class ImageMap;
35cdf0e10cSrcweir class INetBookmark;
36cdf0e10cSrcweir class INetImage;
37cdf0e10cSrcweir class SwDoc;
38cdf0e10cSrcweir class SwDocFac;
39cdf0e10cSrcweir class SwTextBlocks;
40cdf0e10cSrcweir class SwWrtShell;
41cdf0e10cSrcweir class SvxClipboardFmtItem;
42cdf0e10cSrcweir class ViewShell;
43cdf0e10cSrcweir class SwView_Impl;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir typedef sal_uInt16 TransferBufferType;
46cdf0e10cSrcweir namespace nsTransferBufferType
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_NONE 			= 0x0000;
49cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_DOCUMENT		= 0x0001;
50cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_DOCUMENT_WORD	= 0x0002;
51cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_GRAPHIC			= 0x0004;
52cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_TABELLE			= 0x0008;
53cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_DDELINK			= 0x0010;
54cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_OLE				= 0x0020;
55cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_INETFLD			= 0x0040;
56cdf0e10cSrcweir 	const sal_uInt16 TRNSFR_DRAWING			= 0x0081;	//Drawing ist auch intern!
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define DATA_FLAVOR 	::com::sun::star::datatransfer::DataFlavor
60cdf0e10cSrcweir 
61cdf0e10cSrcweir class SwTransferable : public TransferableHelper
62cdf0e10cSrcweir {
63cdf0e10cSrcweir     friend class SwView_Impl;
64cdf0e10cSrcweir     SfxObjectShellLock             aDocShellRef;
65cdf0e10cSrcweir 	TransferableDataHelper			aOleData;
66cdf0e10cSrcweir 	TransferableObjectDescriptor	aObjDesc;
67cdf0e10cSrcweir     ::sfx2::SvBaseLinkRef            refDdeLink;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	SwWrtShell 		*pWrtShell;
70cdf0e10cSrcweir 	/* #96392# Added pCreatorView to distinguish SwFrameShell from
71cdf0e10cSrcweir        SwWrtShell. */
72cdf0e10cSrcweir 	const ViewShell       *pCreatorView;
73cdf0e10cSrcweir 	SwDocFac		*pClpDocFac;
74cdf0e10cSrcweir 	Graphic			*pClpGraphic, *pClpBitmap, *pOrigGrf;
75cdf0e10cSrcweir 	INetBookmark	*pBkmk;		// URL und Beschreibung!
76cdf0e10cSrcweir 	ImageMap		*pImageMap;
77cdf0e10cSrcweir 	INetImage		*pTargetURL;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	TransferBufferType eBufferType;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	sal_Bool bOldIdle	:1; //D&D Idle flag from the viewsettings
82cdf0e10cSrcweir 	sal_Bool bCleanUp 	:1; //D&D cleanup after Drop (not by internal Drop)
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	// helper methods for the copy
85cdf0e10cSrcweir     com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > FindOLEObj( sal_Int64& nAspect ) const;
86cdf0e10cSrcweir 	Graphic* FindOLEReplacementGraphic() const;
87cdf0e10cSrcweir 	void DeleteSelection();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	// helper methods for the paste
90cdf0e10cSrcweir 	static SwTransferable* GetSwTransferable( const TransferableDataHelper& rData );
91cdf0e10cSrcweir 	static void SetSelInShell( SwWrtShell& , sal_Bool , const Point* );
92cdf0e10cSrcweir 	static sal_Bool _CheckForURLOrLNKFile( TransferableDataHelper& rData,
93cdf0e10cSrcweir 								String& rFileName, String* pTitle = 0 );
94cdf0e10cSrcweir 	static int _TestAllowedFormat( const TransferableDataHelper& rData,
95cdf0e10cSrcweir 										sal_uLong nFormat, sal_uInt16 nDestination );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	static int _PasteFileContent( TransferableDataHelper&,
98cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uLong nFmt, sal_Bool bMsg );
99cdf0e10cSrcweir 	static int _PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
100cdf0e10cSrcweir 							sal_uLong nFmt, sal_uInt8 nActionFlags, sal_Bool bMsg );
101cdf0e10cSrcweir 	static int _PasteTargetURL( TransferableDataHelper& rData, SwWrtShell& rSh,
102cdf0e10cSrcweir 						sal_uInt16 nAction, const Point* pPt, sal_Bool bInsertGRF );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	static int _PasteDDE( TransferableDataHelper& rData, SwWrtShell& rWrtShell,
105cdf0e10cSrcweir 							sal_Bool bReReadGrf, sal_Bool bMsg );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	static int _PasteSdrFormat(  TransferableDataHelper& rData,
108cdf0e10cSrcweir 									SwWrtShell& rSh, sal_uInt16 nAction,
109*1cd65da9SArmin Le Grand 									const Point* pPt, sal_uInt8 nActionFlags, bool bNeedToSelectBeforePaste);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	static int _PasteGrf( TransferableDataHelper& rData, SwWrtShell& rSh,
112cdf0e10cSrcweir 								sal_uLong nFmt, sal_uInt16 nAction, const Point* pPt,
113*1cd65da9SArmin Le Grand 								sal_uInt8 nActionFlags, sal_Int8 nDropAction, bool bNeedToSelectBeforePaste);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	static int _PasteImageMap( TransferableDataHelper& rData,
116cdf0e10cSrcweir 									SwWrtShell& rSh );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	static int _PasteAsHyperlink( TransferableDataHelper& rData,
119cdf0e10cSrcweir 										SwWrtShell& rSh, sal_uLong nFmt );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	static int _PasteFileName( TransferableDataHelper& rData,
122cdf0e10cSrcweir 							SwWrtShell& rSh, sal_uLong nFmt, sal_uInt16 nAction,
123cdf0e10cSrcweir 							const Point* pPt, sal_uInt8 nActionFlags, sal_Bool bMsg );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	static int _PasteDBData( TransferableDataHelper& rData, SwWrtShell& rSh,
126cdf0e10cSrcweir 							sal_uLong nFmt, sal_Bool bLink, const Point* pDragPt,
127cdf0e10cSrcweir 							sal_Bool bMsg );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	static int _PasteFileList( TransferableDataHelper& rData,
130cdf0e10cSrcweir 								SwWrtShell& rSh, sal_Bool bLink,
131cdf0e10cSrcweir 								const Point* pPt, sal_Bool bMsg );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	int PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, sal_Bool bMove,
134cdf0e10cSrcweir 						sal_Bool bIsXSelection );
135cdf0e10cSrcweir 	int PrivatePaste( SwWrtShell& rShell );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	void SetDataForDragAndDrop( const Point& rSttPos );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 									// not available
140cdf0e10cSrcweir 									SwTransferable();
141cdf0e10cSrcweir 									SwTransferable( const SwTransferable& );
142cdf0e10cSrcweir 	SwTransferable&					operator=( const SwTransferable& );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir protected:
145cdf0e10cSrcweir 	virtual void		AddSupportedFormats();
146cdf0e10cSrcweir 	virtual sal_Bool	GetData( const DATA_FLAVOR& rFlavor );
147cdf0e10cSrcweir 	virtual sal_Bool	WriteObject( SotStorageStreamRef& rxOStm,
148cdf0e10cSrcweir 										void* pUserObject,
149cdf0e10cSrcweir 										sal_uInt32 nUserObjectId,
150cdf0e10cSrcweir 										const DATA_FLAVOR& rFlavor );
151cdf0e10cSrcweir 	virtual void 		DragFinished( sal_Int8 nDropAction );
152cdf0e10cSrcweir 	virtual void		ObjectReleased();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     using TransferableHelper::StartDrag;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir public:
157cdf0e10cSrcweir 	SwTransferable( SwWrtShell& );
158cdf0e10cSrcweir 	virtual ~SwTransferable();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	static sal_uInt16 GetSotDestination( const SwWrtShell& rSh, const Point* = 0 );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	// set properties on the document, like PageMargin, VisArea.
163cdf0e10cSrcweir 	// And set real Size
164cdf0e10cSrcweir     static void InitOle( SfxObjectShell* pDoc, SwDoc& rDoc );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	// copy - methods and helper methods for the copy
167cdf0e10cSrcweir 	int	 Cut();
168cdf0e10cSrcweir 	int	 Copy( sal_Bool bIsCut = sal_False );
169cdf0e10cSrcweir     int  PrepareForCopy( sal_Bool bIsCut = sal_False );
170cdf0e10cSrcweir 	int  CalculateAndCopy();				// special for Calculator
171cdf0e10cSrcweir 	int  CopyGlossary( SwTextBlocks& rGlossary, const String& rStr );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	// remove the DDE-Link format promise
174cdf0e10cSrcweir 	void RemoveDDELinkFormat( const Window& rWin );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	// paste - methods and helper methods for the paste
177cdf0e10cSrcweir 	static sal_Bool	IsPaste( const SwWrtShell&, const TransferableDataHelper& );
178cdf0e10cSrcweir 	static int Paste( SwWrtShell&, TransferableDataHelper& );
179cdf0e10cSrcweir 	static int PasteData( TransferableDataHelper& rData,
180cdf0e10cSrcweir 						  SwWrtShell& rSh, sal_uInt16 nAction, sal_uLong nFormat,
181cdf0e10cSrcweir 						  sal_uInt16 nDestination, sal_Bool bIsPasteFmt,
182cdf0e10cSrcweir                           sal_Bool bIsDefault,
183cdf0e10cSrcweir                           const Point* pDDPos = 0, sal_Int8 nDropAction = 0,
184cdf0e10cSrcweir 						  sal_Bool bPasteSelection = sal_False );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	static sal_Bool IsPasteSpecial( const SwWrtShell& rWrtShell,
187cdf0e10cSrcweir 								const TransferableDataHelper& );
188cdf0e10cSrcweir     static int PasteUnformatted( SwWrtShell& rSh, TransferableDataHelper& );
189cdf0e10cSrcweir     static int PasteSpecial( SwWrtShell& rSh, TransferableDataHelper&, sal_uLong& rFormatUsed );
190cdf0e10cSrcweir 	static int PasteFormat( SwWrtShell& rSh, TransferableDataHelper& rData,
191cdf0e10cSrcweir 							 sal_uLong nFormat );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	static void FillClipFmtItem( const SwWrtShell& rSh,
194cdf0e10cSrcweir 								const TransferableDataHelper& rData,
195cdf0e10cSrcweir 								SvxClipboardFmtItem & rToFill );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 	// Interfaces for Drag & Drop
198cdf0e10cSrcweir 	void StartDrag( Window* pWin, const Point& rPos );
199cdf0e10cSrcweir 
GetShell()200cdf0e10cSrcweir 	SwWrtShell* GetShell()				{ return pWrtShell; }
SetCleanUp(sal_Bool bFlag)201cdf0e10cSrcweir 	void SetCleanUp( sal_Bool bFlag )		{ bCleanUp = bFlag; }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 	// Interfaces for Selection
204cdf0e10cSrcweir 	/* #96392# Added pCreator to distinguish SwFrameShell from SwWrtShell. */
205cdf0e10cSrcweir 	static void CreateSelection( SwWrtShell & rSh,
206cdf0e10cSrcweir 								 const ViewShell * pCreator = NULL );
207cdf0e10cSrcweir 	static void ClearSelection( SwWrtShell& rSh,
208cdf0e10cSrcweir 								const ViewShell * pCreator = NULL );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     // the related SwView is being closed and the SwTransferable is invalid now
Invalidate()211cdf0e10cSrcweir     void    Invalidate() {pWrtShell = 0;}
212cdf0e10cSrcweir     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
215cdf0e10cSrcweir };
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir #endif
219