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