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