xref: /trunk/main/sd/source/ui/inc/sdxfer.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SD_SDXFER_HXX
29 #define _SD_SDXFER_HXX
30 
31 #include <svtools/transfer.hxx>
32 #include <vcl/graph.hxx>
33 #include <sfx2/objsh.hxx>
34 #include <svl/lstner.hxx>
35 
36 // ------------------
37 // - SdTransferable -
38 // ------------------
39 
40 class SdDrawDocument;
41 class SdrObject;
42 class INetBookmark;
43 class ImageMap;
44 class VirtualDevice;
45 
46 namespace sd {
47 class DrawDocShell;
48 class View;
49 }
50 
51 class SfxObjectShellRef;
52 class SdTransferable : public TransferableHelper, public SfxListener
53 {
54 public:
55 
56 									SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, sal_Bool bInitOnGetData );
57 									~SdTransferable();
58 
59     void                            SetDocShell( const SfxObjectShellRef& rRef ) { maDocShellRef = rRef; }
60     const SfxObjectShellRef&        GetDocShell() const { return maDocShellRef; }
61 
62     void							SetWorkDocument( const SdDrawDocument* pWorkDoc ) { mpSdDrawDocument = mpSdDrawDocumentIntern = (SdDrawDocument*) pWorkDoc; }
63 	const SdDrawDocument*			GetWorkDocument() const { return mpSdDrawDocument; }
64 
65 	void							SetView( const ::sd::View* pView ) { mpSdView = pView; }
66 	const ::sd::View*					GetView() const { return mpSdView; }
67 
68 	void							SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc );
69 
70 	void							SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; }
71 	const Point&					GetStartPos() const { return maStartPos; }
72 
73 	void							SetInternalMove( sal_Bool bSet ) { mbInternalMove = bSet; }
74 	sal_Bool							IsInternalMove() const { return mbInternalMove; }
75 
76 	sal_Bool							HasSourceDoc( const SdDrawDocument* pDoc ) const { return( mpSourceDoc == pDoc ); }
77 
78 	void							SetPageBookmarks( const List& rPageBookmarks, sal_Bool bPersistent );
79     sal_Bool                            IsPageTransferable() const { return mbPageTransferable; }
80     sal_Bool                            HasPageBookmarks() const { return( mpPageDocShell && ( maPageBookmarks.Count() > 0 ) ); }
81     const List&                     GetPageBookmarks() const { return maPageBookmarks; }
82 	::sd::DrawDocShell*         		GetPageDocShell() const { return mpPageDocShell; }
83 
84 	sal_Bool						SetTableRTF( SdDrawDocument*, const ::com::sun::star::datatransfer::DataFlavor& );
85 
86 	static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
87     static SdTransferable*          getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
88 
89 	// SfxListener
90 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
91 
92     virtual void					DragFinished( sal_Int8 nDropAction );
93     SdDrawDocument*					GetSourceDoc (void) const;
94 
95     /** User data objects can be used to store information temporarily
96         at the transferable.  The slide sorter uses this to store
97         previews of the slides that are referenced by the
98         transferable.
99     */
100     class UserData {public:virtual~UserData(){}};
101 
102     /** Add a user data object.  When it was added before (and not
103         removed) then this call is ignored.
104     */
105     void AddUserData (const ::boost::shared_ptr<UserData>& rpData);
106 
107     /** Remove a previously added user data object.  When the object
108         was never added or removed before then this call is ignored.
109     */
110     void RemoveUserData (const ::boost::shared_ptr<UserData>& rpData);
111 
112     /** Return the number of user data objects.
113     */
114     sal_Int32 GetUserDataCount (void) const;
115 
116     /** Return the specified user data object.  When the index is not
117         valid, ie not in the range [0,count) then an empty pointer is
118         returned.
119     */
120     ::boost::shared_ptr<UserData> GetUserData (const sal_Int32 nIndex) const;
121 
122 protected:
123 
124 	virtual void					AddSupportedFormats();
125 	virtual sal_Bool				GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
126 	virtual sal_Bool				WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
127 	virtual void					ObjectReleased();
128 
129     virtual sal_Int64 SAL_CALL      getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
130 
131 private:
132 
133     SfxObjectShellRef				maDocShellRef;
134     ::sd::DrawDocShell*				mpPageDocShell;
135     List                            maPageBookmarks;
136 	TransferableDataHelper*			mpOLEDataHelper;
137 	TransferableObjectDescriptor*	mpObjDesc;
138 	const ::sd::View*				mpSdView;
139 	::sd::View*						mpSdViewIntern;
140 	SdDrawDocument* 				mpSdDrawDocument;
141 	SdDrawDocument* 				mpSdDrawDocumentIntern;
142 	SdDrawDocument* 				mpSourceDoc;
143 	VirtualDevice*					mpVDev;
144 	INetBookmark*	  				mpBookmark;
145 	Graphic*						mpGraphic;
146 	ImageMap*						mpImageMap;
147 	Rectangle						maVisArea;
148 	Point							maStartPos;
149 	sal_Bool							mbInternalMove               : 1;
150 	sal_Bool							mbOwnDocument                : 1;
151 	sal_Bool							mbOwnView                    : 1;
152 	sal_Bool							mbLateInit                   : 1;
153     sal_Bool                            mbPageTransferable           : 1;
154     sal_Bool                            mbPageTransferablePersistent : 1;
155 	bool							mbIsUnoObj					: 1;
156     ::std::vector<boost::shared_ptr<UserData> > maUserData;
157 
158 									// not available
159 									SdTransferable();
160 									SdTransferable( const SdTransferable& );
161 	SdTransferable&					operator=( const SdTransferable& );
162 
163 	void							CreateObjectReplacement( SdrObject* pObj );
164 	void							CreateData();
165 
166 };
167 
168 #endif // _SD_SDXFER_HXX
169