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