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