xref: /aoo41x/main/sd/source/ui/inc/sdxfer.hxx (revision 67e470da)
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 
24 #ifndef _SD_SDXFER_HXX
25 #define _SD_SDXFER_HXX
26 
27 #include <svtools/transfer.hxx>
28 #include <vcl/graph.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <svl/lstner.hxx>
31 
32 // ------------------
33 // - SdTransferable -
34 // ------------------
35 
36 class SdDrawDocument;
37 class SdrObject;
38 class INetBookmark;
39 class ImageMap;
40 class VirtualDevice;
41 
42 namespace sd {
43 class DrawDocShell;
44 class View;
45 }
46 
47 class SfxObjectShellRef;
48 class SdTransferable : public TransferableHelper, public SfxListener
49 {
50 public:
51 
52 									SdTransferable( SdDrawDocument* pSrcDoc, ::sd::View* pWorkView, sal_Bool bInitOnGetData );
53 									~SdTransferable();
54 
SetDocShell(const SfxObjectShellRef & rRef)55     void                            SetDocShell( const SfxObjectShellRef& rRef ) { maDocShellRef = rRef; }
GetDocShell() const56     const SfxObjectShellRef&        GetDocShell() const { return maDocShellRef; }
57 
SetWorkDocument(const SdDrawDocument * pWorkDoc)58     void							SetWorkDocument( const SdDrawDocument* pWorkDoc ) { mpSdDrawDocument = mpSdDrawDocumentIntern = (SdDrawDocument*) pWorkDoc; }
GetWorkDocument() const59 	const SdDrawDocument*			GetWorkDocument() const { return mpSdDrawDocument; }
60 
SetView(const::sd::View * pView)61 	void							SetView( const ::sd::View* pView ) { mpSdView = pView; }
GetView() const62 	const ::sd::View*					GetView() const { return mpSdView; }
63 
64 	void							SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc );
65 
SetStartPos(const Point & rStartPos)66 	void							SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; }
GetStartPos() const67 	const Point&					GetStartPos() const { return maStartPos; }
68 
SetInternalMove(sal_Bool bSet)69 	void							SetInternalMove( sal_Bool bSet ) { mbInternalMove = bSet; }
IsInternalMove() const70 	sal_Bool							IsInternalMove() const { return mbInternalMove; }
71 
HasSourceDoc(const SdDrawDocument * pDoc) const72 	sal_Bool							HasSourceDoc( const SdDrawDocument* pDoc ) const { return( mpSourceDoc == pDoc ); }
73 
74 	void							SetPageBookmarks( const List& rPageBookmarks, sal_Bool bPersistent );
IsPageTransferable() const75     sal_Bool                            IsPageTransferable() const { return mbPageTransferable; }
HasPageBookmarks() const76     sal_Bool                            HasPageBookmarks() const { return( mpPageDocShell && ( maPageBookmarks.Count() > 0 ) ); }
GetPageBookmarks() const77     const List&                     GetPageBookmarks() const { return maPageBookmarks; }
GetPageDocShell() const78 	::sd::DrawDocShell*         		GetPageDocShell() const { return mpPageDocShell; }
79 
80 	sal_Bool						SetTableRTF( SdDrawDocument*, const ::com::sun::star::datatransfer::DataFlavor& );
81 
82 	static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
83     static SdTransferable*          getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
84 
85 	// SfxListener
86 	virtual void			Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
87 
88     virtual void					DragFinished( sal_Int8 nDropAction );
89     SdDrawDocument*					GetSourceDoc (void) const;
90 
91     /** User data objects can be used to store information temporarily
92         at the transferable.  The slide sorter uses this to store
93         previews of the slides that are referenced by the
94         transferable.
95     */
~UserData()96     class UserData {public:virtual~UserData(){}};
97 
98     /** Add a user data object.  When it was added before (and not
99         removed) then this call is ignored.
100     */
101     void AddUserData (const ::boost::shared_ptr<UserData>& rpData);
102 
103     /** Remove a previously added user data object.  When the object
104         was never added or removed before then this call is ignored.
105     */
106     void RemoveUserData (const ::boost::shared_ptr<UserData>& rpData);
107 
108     /** Return the number of user data objects.
109     */
110     sal_Int32 GetUserDataCount (void) const;
111 
112     /** Return the specified user data object.  When the index is not
113         valid, ie not in the range [0,count) then an empty pointer is
114         returned.
115     */
116     ::boost::shared_ptr<UserData> GetUserData (const sal_Int32 nIndex) const;
117 
118 protected:
119 
120 	virtual void					AddSupportedFormats();
121 	virtual sal_Bool				GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
122 	virtual sal_Bool				WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
123 	virtual void					ObjectReleased();
124 
125     virtual sal_Int64 SAL_CALL      getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
126 
127 private:
128 
129     SfxObjectShellRef				maDocShellRef;
130     ::sd::DrawDocShell*				mpPageDocShell;
131     List                            maPageBookmarks;
132 	TransferableDataHelper*			mpOLEDataHelper;
133 	TransferableObjectDescriptor*	mpObjDesc;
134 	const ::sd::View*				mpSdView;
135 	::sd::View*						mpSdViewIntern;
136 	SdDrawDocument* 				mpSdDrawDocument;
137 	SdDrawDocument* 				mpSdDrawDocumentIntern;
138 	SdDrawDocument* 				mpSourceDoc;
139 	VirtualDevice*					mpVDev;
140 	INetBookmark*	  				mpBookmark;
141 	Graphic*						mpGraphic;
142 	ImageMap*						mpImageMap;
143 	Rectangle						maVisArea;
144 	Point							maStartPos;
145 	sal_Bool							mbInternalMove               : 1;
146 	sal_Bool							mbOwnDocument                : 1;
147 	sal_Bool							mbOwnView                    : 1;
148 	sal_Bool							mbLateInit                   : 1;
149     sal_Bool                            mbPageTransferable           : 1;
150     sal_Bool                            mbPageTransferablePersistent : 1;
151 	bool							mbIsUnoObj					: 1;
152     ::std::vector<boost::shared_ptr<UserData> > maUserData;
153 
154 									// not available
155 									SdTransferable();
156 									SdTransferable( const SdTransferable& );
157 	SdTransferable&					operator=( const SdTransferable& );
158 
159 	void							CreateObjectReplacement( SdrObject* pObj );
160 	void							CreateData();
161 
162 };
163 
164 #endif // _SD_SDXFER_HXX
165