xref: /AOO41X/main/sd/source/ui/inc/sdtreelb.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SDTREELB_HXX
29*cdf0e10cSrcweir #define _SDTREELB_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <svtools/transfer.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifndef _SD_SDRESID_HXX
34*cdf0e10cSrcweir #include "sdresid.hxx"
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #include "pres.hxx"
37*cdf0e10cSrcweir #include "sddllapi.h"
38*cdf0e10cSrcweir #include <tools/string.hxx>
39*cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
40*cdf0e10cSrcweir #include <svl/urlbmk.hxx>
41*cdf0e10cSrcweir #include <tools/ref.hxx>
42*cdf0e10cSrcweir #include "sdxfer.hxx"
43*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
44*cdf0e10cSrcweir #include <boost/function.hpp>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir class SdDrawDocument;
47*cdf0e10cSrcweir class SfxMedium;
48*cdf0e10cSrcweir class SfxViewFrame;
49*cdf0e10cSrcweir class SdNavigatorWin;
50*cdf0e10cSrcweir class SdrObject;
51*cdf0e10cSrcweir class SdrObjList;
52*cdf0e10cSrcweir class SdPage;
53*cdf0e10cSrcweir class SvLBoxEntry;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir namespace sd {
56*cdf0e10cSrcweir class ViewShell;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir class DrawDocShell;
59*cdf0e10cSrcweir #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
60*cdf0e10cSrcweir #define SV_DECL_DRAW_DOC_SHELL_DEFINED
61*cdf0e10cSrcweir SV_DECL_REF(DrawDocShell)
62*cdf0e10cSrcweir #endif
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir /*************************************************************************
66*cdf0e10cSrcweir |*
67*cdf0e10cSrcweir |* Effekte-Tab-Dialog
68*cdf0e10cSrcweir |*
69*cdf0e10cSrcweir \************************************************************************/
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir class SD_DLLPUBLIC SdPageObjsTLB : public SvTreeListBox
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir private:
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	static sal_Bool  SD_DLLPRIVATE bIsInDrag;      // static, falls der Navigator im ExecuteDrag geloescht wird
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir public:
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	// nested class to implement the TransferableHelper
80*cdf0e10cSrcweir 	class SdPageObjsTransferable : public SdTransferable
81*cdf0e10cSrcweir 	{
82*cdf0e10cSrcweir 	public:
83*cdf0e10cSrcweir         SdPageObjsTransferable(
84*cdf0e10cSrcweir             SdPageObjsTLB& rParent,
85*cdf0e10cSrcweir             const INetBookmark& rBookmark,
86*cdf0e10cSrcweir             ::sd::DrawDocShell& rDocShell,
87*cdf0e10cSrcweir             NavigatorDragType eDragType,
88*cdf0e10cSrcweir             const ::com::sun::star::uno::Any& rTreeListBoxData );
89*cdf0e10cSrcweir 	    ::sd::DrawDocShell&     GetDocShell() const;
90*cdf0e10cSrcweir 	    NavigatorDragType   GetDragType() const;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     	static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
93*cdf0e10cSrcweir         static SdPageObjsTransferable* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
94*cdf0e10cSrcweir         /** Return a temporary transferable data flavor that is used
95*cdf0e10cSrcweir             internally in the navigator for reordering entries.  Its
96*cdf0e10cSrcweir             lifetime ends with the office application.
97*cdf0e10cSrcweir         */
98*cdf0e10cSrcweir         static sal_uInt32 GetListBoxDropFormatId (void);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 	private:
101*cdf0e10cSrcweir         /** Temporary drop flavor id that is used internally in the
102*cdf0e10cSrcweir             navigator.
103*cdf0e10cSrcweir         */
104*cdf0e10cSrcweir         static sal_uInt32 mnListBoxDropFormatId;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 		SdPageObjsTLB&		mrParent;
107*cdf0e10cSrcweir 		INetBookmark		maBookmark;
108*cdf0e10cSrcweir 		::sd::DrawDocShell&     mrDocShell;
109*cdf0e10cSrcweir 		NavigatorDragType   meDragType;
110*cdf0e10cSrcweir         const ::com::sun::star::uno::Any maTreeListBoxData;
111*cdf0e10cSrcweir 		SD_DLLPRIVATE virtual				~SdPageObjsTransferable();
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 		SD_DLLPRIVATE virtual void		AddSupportedFormats();
114*cdf0e10cSrcweir 		SD_DLLPRIVATE virtual sal_Bool	GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
115*cdf0e10cSrcweir 		SD_DLLPRIVATE virtual void		DragFinished( sal_Int8 nDropAction );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir         SD_DLLPRIVATE virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
118*cdf0e10cSrcweir 	};
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	friend class SdPageObjsTLB::SdPageObjsTransferable;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     /** Determine whether the specified page belongs to the current show
123*cdf0e10cSrcweir         which is either the standard show or a custom show.
124*cdf0e10cSrcweir         @param pPage
125*cdf0e10cSrcweir             Pointer to the page for which to check whether it belongs to the
126*cdf0e10cSrcweir             show.
127*cdf0e10cSrcweir         @return
128*cdf0e10cSrcweir             Returns <FALSE/> if there is no custom show or if the current
129*cdf0e10cSrcweir             show does not contain the specified page at least once.
130*cdf0e10cSrcweir     */
131*cdf0e10cSrcweir     bool PageBelongsToCurrentShow (const SdPage* pPage) const;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir protected:
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	Window* 				mpParent;
136*cdf0e10cSrcweir 	const SdDrawDocument*	mpDoc;
137*cdf0e10cSrcweir 	SdDrawDocument* 		mpBookmarkDoc;
138*cdf0e10cSrcweir 	SfxMedium*				mpMedium;
139*cdf0e10cSrcweir 	SfxMedium*				mpOwnMedium;
140*cdf0e10cSrcweir 	Image					maImgOle;
141*cdf0e10cSrcweir 	Image					maImgGraphic;
142*cdf0e10cSrcweir 	Image					maImgOleH;
143*cdf0e10cSrcweir 	Image					maImgGraphicH;
144*cdf0e10cSrcweir 	sal_Bool                    mbLinkableSelected;
145*cdf0e10cSrcweir 	sal_Bool					mbDragEnabled;
146*cdf0e10cSrcweir 	String					maDocName;
147*cdf0e10cSrcweir 	::sd::DrawDocShellRef		mxBookmarkDocShRef;	// Zum Laden von Bookmarks
148*cdf0e10cSrcweir 	::sd::DrawDocShell* 		mpDropDocSh;
149*cdf0e10cSrcweir 	SdNavigatorWin*			mpDropNavWin;
150*cdf0e10cSrcweir 	SfxViewFrame*           mpFrame;
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	// DragSourceHelper
153*cdf0e10cSrcweir 	virtual void			StartDrag( sal_Int8 nAction, const Point& rPosPixel );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	// DropTargetHelper
156*cdf0e10cSrcweir 	virtual sal_Int8		AcceptDrop( const AcceptDropEvent& rEvt );
157*cdf0e10cSrcweir 	virtual	sal_Int8		ExecuteDrop( const ExecuteDropEvent& rEvt );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	virtual void			RequestingChilds( SvLBoxEntry* pParent );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     void                    DoDrag();
162*cdf0e10cSrcweir 	void					OnDragFinished( sal_uInt8 nDropAction );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     /** Return the name of the object.  When the object has no user supplied
165*cdf0e10cSrcweir         name and the bCreate flag is <TRUE/> then a name is created
166*cdf0e10cSrcweir         automatically.  Additionally the mbShowAllShapes flag is taken into
167*cdf0e10cSrcweir         account when there is no user supplied name.  When this flag is
168*cdf0e10cSrcweir         <FALSE/> then no name is created.
169*cdf0e10cSrcweir         @param pObject
170*cdf0e10cSrcweir             When this is NULL then an empty string is returned, regardless
171*cdf0e10cSrcweir             of the value of bCreate.
172*cdf0e10cSrcweir         @param bCreate
173*cdf0e10cSrcweir             This flag controls for objects without user supplied name
174*cdf0e10cSrcweir             whether a name is created.  When a name is created then this
175*cdf0e10cSrcweir             name is not stored in the object.
176*cdf0e10cSrcweir     */
177*cdf0e10cSrcweir     String GetObjectName (
178*cdf0e10cSrcweir         const SdrObject* pObject,
179*cdf0e10cSrcweir         const bool bCreate = true) const;
180*cdf0e10cSrcweir     void                    CloseBookmarkDoc();
181*cdf0e10cSrcweir 							DECL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     /** Handle the reordering of entries in the navigator.  This method
184*cdf0e10cSrcweir         reorders both the involved shapes in their page as well as the
185*cdf0e10cSrcweir         associated list box entries.
186*cdf0e10cSrcweir     */
187*cdf0e10cSrcweir 	virtual sal_Bool NotifyMoving(
188*cdf0e10cSrcweir 		SvLBoxEntry*  pTarget,
189*cdf0e10cSrcweir 		SvLBoxEntry*  pEntry,
190*cdf0e10cSrcweir 		SvLBoxEntry*& rpNewParent,
191*cdf0e10cSrcweir 		sal_uLong&		  rNewChildPos);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     using Window::GetDropTarget;
194*cdf0e10cSrcweir     virtual SvLBoxEntry* GetDropTarget (const Point& rLocation);
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir public:
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 							SdPageObjsTLB( Window* pParent, const SdResId& rSdResId );
199*cdf0e10cSrcweir 							~SdPageObjsTLB();
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	virtual void			SelectHdl();
202*cdf0e10cSrcweir 	virtual void			KeyInput( const KeyEvent& rKEvt );
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	void					SetViewFrame( SfxViewFrame* pViewFrame ) { mpFrame = pViewFrame; }
205*cdf0e10cSrcweir 	SfxViewFrame*			GetViewFrame() const { return mpFrame; }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	void					Fill( const SdDrawDocument*, sal_Bool bAllPages, const String& rDocName );
208*cdf0e10cSrcweir 	void					Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const String& rDocName );
209*cdf0e10cSrcweir     void                    SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
210*cdf0e10cSrcweir     bool                    GetShowAllShapes (void) const;
211*cdf0e10cSrcweir 	sal_Bool					IsEqualToDoc( const SdDrawDocument* pInDoc = NULL );
212*cdf0e10cSrcweir 	sal_Bool					HasSelectedChilds( const String& rName );
213*cdf0e10cSrcweir 	sal_Bool					SelectEntry( const String& rName );
214*cdf0e10cSrcweir 	String					GetSelectEntry();
215*cdf0e10cSrcweir 	List*					GetSelectEntryList( sal_uInt16 nDepth );
216*cdf0e10cSrcweir 	SdDrawDocument*			GetBookmarkDoc(SfxMedium* pMedium = NULL);
217*cdf0e10cSrcweir 	::sd::DrawDocShell*			GetDropDocSh() { return(mpDropDocSh); }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	sal_Bool                    IsLinkableSelected() const { return mbLinkableSelected; }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir 	static sal_Bool				IsInDrag();
222*cdf0e10cSrcweir 	using SvLBox::ExecuteDrop;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     using SvTreeListBox::SelectEntry;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     /** Return the view shell that is linked to the given doc shell.
227*cdf0e10cSrcweir         Call this method when the there is a chance that the doc shell
228*cdf0e10cSrcweir         has been disconnected from the view shell (but not the other
229*cdf0e10cSrcweir         way round.)
230*cdf0e10cSrcweir         @return
231*cdf0e10cSrcweir             May return <NULL/> when the link between view shell and
232*cdf0e10cSrcweir             doc shell has been severed.
233*cdf0e10cSrcweir     */
234*cdf0e10cSrcweir     static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir private:
237*cdf0e10cSrcweir     /** This flag controls whether all shapes are shown as children of pages
238*cdf0e10cSrcweir         and group shapes or only the named shapes.
239*cdf0e10cSrcweir     */
240*cdf0e10cSrcweir     bool mbShowAllShapes;
241*cdf0e10cSrcweir     /** This flag controls whether to show all pages.
242*cdf0e10cSrcweir     */
243*cdf0e10cSrcweir     bool mbShowAllPages;
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir     /** Return <TRUE/> when the current transferable may be dropped at the
246*cdf0e10cSrcweir         given list box entry.
247*cdf0e10cSrcweir     */
248*cdf0e10cSrcweir     bool IsDropAllowed (SvLBoxEntry* pEntry);
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir     /** This inner class is defined in sdtreelb.cxx and is basically a
251*cdf0e10cSrcweir         container for the icons used in the list box for the entries.
252*cdf0e10cSrcweir     */
253*cdf0e10cSrcweir     class IconProvider;
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     /** Add one list box entry for the parent of the given shapes and one child entry for
256*cdf0e10cSrcweir         each of the given shapes.
257*cdf0e10cSrcweir         @param rList
258*cdf0e10cSrcweir             The container of shapes that are to be inserted.
259*cdf0e10cSrcweir         @param pShape
260*cdf0e10cSrcweir             The parent shape or NULL when the parent is a page.
261*cdf0e10cSrcweir         @param rsName
262*cdf0e10cSrcweir             The name to be displayed for the new parent node.
263*cdf0e10cSrcweir         @param bIsExcluded
264*cdf0e10cSrcweir             Some pages can be excluded (from the show?).
265*cdf0e10cSrcweir         @param pParentEntry
266*cdf0e10cSrcweir             The parent entry of the new parent entry.
267*cdf0e10cSrcweir         @param rIconProvider
268*cdf0e10cSrcweir             Icons used to visualize the different shape and page types.
269*cdf0e10cSrcweir     */
270*cdf0e10cSrcweir     void AddShapeList (
271*cdf0e10cSrcweir         const SdrObjList& rList,
272*cdf0e10cSrcweir         SdrObject* pShape,
273*cdf0e10cSrcweir         const ::rtl::OUString& rsName,
274*cdf0e10cSrcweir         const bool bIsExcluded,
275*cdf0e10cSrcweir         SvLBoxEntry* pParentEntry,
276*cdf0e10cSrcweir         const IconProvider& rIconProvider);
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     /** Add the given object to a transferable object so that the object can
279*cdf0e10cSrcweir         be dragged and dropped without having a name.
280*cdf0e10cSrcweir     */
281*cdf0e10cSrcweir     void AddShapeToTransferable (
282*cdf0e10cSrcweir         SdTransferable& rTransferable,
283*cdf0e10cSrcweir         SdrObject& rObject) const;
284*cdf0e10cSrcweir };
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir #endif		// _SDTREELB_HXX
287