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