CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / source / ui / inc / sdtreelb.hxx
blob9681e9ba423013f3cc64054bf482ecc9c0b64835
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _SDTREELB_HXX
29 #define _SDTREELB_HXX
31 #include <svtools/transfer.hxx>
33 #ifndef _SD_SDRESID_HXX
34 #include "sdresid.hxx"
35 #endif
36 #include "pres.hxx"
37 #include "sddllapi.h"
38 #include <tools/string.hxx>
39 #include <svtools/svtreebx.hxx>
40 #include <svl/urlbmk.hxx>
41 #include <tools/ref.hxx>
42 #include "sdxfer.hxx"
44 class SdDrawDocument;
45 class SfxMedium;
46 class SfxViewFrame;
47 class SdNavigatorWin;
48 class SdrObject;
49 class SdrObjList;
50 class SdPage;
51 class SvLBoxEntry;
53 namespace sd {
54 class DrawDocShell;
55 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
56 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
57 SV_DECL_REF(DrawDocShell)
58 #endif
61 /*************************************************************************
63 |* Effekte-Tab-Dialog
65 \************************************************************************/
67 class SD_DLLPUBLIC SdPageObjsTLB : public SvTreeListBox
69 private:
71 static sal_Bool SD_DLLPRIVATE bIsInDrag; // static, falls der Navigator im ExecuteDrag geloescht wird
73 public:
75 // nested class to implement the TransferableHelper
76 class SdPageObjsTransferable : public SdTransferable
78 public:
79 SdPageObjsTransferable(
80 SdPageObjsTLB& rParent,
81 const INetBookmark& rBookmark,
82 ::sd::DrawDocShell& rDocShell,
83 NavigatorDragType eDragType,
84 const ::com::sun::star::uno::Any& rTreeListBoxData );
85 ::sd::DrawDocShell& GetDocShell() const;
86 NavigatorDragType GetDragType() const;
88 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
89 static SdPageObjsTransferable* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
90 /** Return a temporary transferable data flavor that is used
91 internally in the navigator for reordering entries. Its
92 lifetime ends with the office application.
94 static sal_uInt32 GetListBoxDropFormatId (void);
96 private:
97 /** Temporary drop flavor id that is used internally in the
98 navigator.
100 static sal_uInt32 mnListBoxDropFormatId;
102 SdPageObjsTLB& mrParent;
103 INetBookmark maBookmark;
104 ::sd::DrawDocShell& mrDocShell;
105 NavigatorDragType meDragType;
106 const ::com::sun::star::uno::Any maTreeListBoxData;
108 SD_DLLPRIVATE virtual ~SdPageObjsTransferable();
110 SD_DLLPRIVATE virtual void AddSupportedFormats();
111 SD_DLLPRIVATE virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
112 SD_DLLPRIVATE virtual void DragFinished( sal_Int8 nDropAction );
114 SD_DLLPRIVATE virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
117 friend class SdPageObjsTLB::SdPageObjsTransferable;
119 /** Determine whether the specified page belongs to the current show
120 which is either the standard show or a custom show.
121 @param pPage
122 Pointer to the page for which to check whether it belongs to the
123 show.
124 @return
125 Returns <FALSE/> if there is no custom show or if the current
126 show does not contain the specified page at least once.
128 bool PageBelongsToCurrentShow (const SdPage* pPage) const;
130 protected:
132 Window* mpParent;
133 const SdDrawDocument* mpDoc;
134 SdDrawDocument* mpBookmarkDoc;
135 SfxMedium* mpMedium;
136 SfxMedium* mpOwnMedium;
137 Image maImgOle;
138 Image maImgGraphic;
139 Image maImgOleH;
140 Image maImgGraphicH;
141 sal_Bool mbLinkableSelected;
142 sal_Bool mbDragEnabled;
143 String maDocName;
144 ::sd::DrawDocShellRef mxBookmarkDocShRef; // Zum Laden von Bookmarks
145 ::sd::DrawDocShell* mpDropDocSh;
146 SdNavigatorWin* mpDropNavWin;
147 SfxViewFrame* mpFrame;
149 // DragSourceHelper
150 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
152 // DropTargetHelper
153 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
154 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
156 virtual void RequestingChilds( SvLBoxEntry* pParent );
158 void DoDrag();
159 void OnDragFinished( sal_uInt8 nDropAction );
161 /** Return the name of the object. When the object has no user supplied
162 name and the bCreate flag is <TRUE/> then a name is created
163 automatically. Additionally the mbShowAllShapes flag is taken into
164 account when there is no user supplied name. When this flag is
165 <FALSE/> then no name is created.
166 @param pObject
167 When this is NULL then an empty string is returned, regardless
168 of the value of bCreate.
169 @param bCreate
170 This flag controls for objects without user supplied name
171 whether a name is created. When a name is created then this
172 name is not stored in the object.
174 String GetObjectName (
175 const SdrObject* pObject,
176 const bool bCreate = true) const;
177 void CloseBookmarkDoc();
178 DECL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*);
180 /** Handle the reordering of entries in the navigator. This method
181 reorders both the involved shapes in their page as well as the
182 associated list box entries.
184 virtual sal_Bool NotifyMoving(
185 SvLBoxEntry* pTarget,
186 SvLBoxEntry* pEntry,
187 SvLBoxEntry*& rpNewParent,
188 sal_uLong& rNewChildPos);
190 using Window::GetDropTarget;
191 virtual SvLBoxEntry* GetDropTarget (const Point& rLocation);
193 public:
195 SdPageObjsTLB( Window* pParent, const SdResId& rSdResId );
196 ~SdPageObjsTLB();
198 virtual void SelectHdl();
199 virtual void KeyInput( const KeyEvent& rKEvt );
201 void SetViewFrame( SfxViewFrame* pViewFrame ) { mpFrame = pViewFrame; }
202 SfxViewFrame* GetViewFrame() const { return mpFrame; }
204 void Fill( const SdDrawDocument*, sal_Bool bAllPages, const String& rDocName );
205 void Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const String& rDocName );
206 void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
207 bool GetShowAllShapes (void) const;
208 sal_Bool IsEqualToDoc( const SdDrawDocument* pInDoc = NULL );
209 sal_Bool HasSelectedChilds( const String& rName );
210 sal_Bool SelectEntry( const String& rName );
211 String GetSelectEntry();
212 List* GetSelectEntryList( sal_uInt16 nDepth );
213 SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = NULL);
214 ::sd::DrawDocShell* GetDropDocSh() { return(mpDropDocSh); }
216 sal_Bool IsLinkableSelected() const { return mbLinkableSelected; }
218 static sal_Bool IsInDrag();
219 using SvLBox::ExecuteDrop;
221 using SvTreeListBox::SelectEntry;
222 private:
223 /** This flag controls whether all shapes are shown as children of pages
224 and group shapes or only the named shapes.
226 bool mbShowAllShapes;
227 /** This flag controls whether to show all pages.
229 bool mbShowAllPages;
231 /** Return <TRUE/> when the current transferable may be dropped at the
232 given list box entry.
234 bool IsDropAllowed (SvLBoxEntry* pEntry);
236 /** This inner class is defined in sdtreelb.cxx and is basically a
237 container for the icons used in the list box for the entries.
239 class IconProvider;
241 /** Add one list box entry for the parent of the given shapes and one child entry for
242 each of the given shapes.
243 @param rList
244 The container of shapes that are to be inserted.
245 @param pShape
246 The parent shape or NULL when the parent is a page.
247 @param rsName
248 The name to be displayed for the new parent node.
249 @param bIsExcluded
250 Some pages can be excluded (from the show?).
251 @param pParentEntry
252 The parent entry of the new parent entry.
253 @param rIconProvider
254 Icons used to visualize the different shape and page types.
256 void AddShapeList (
257 const SdrObjList& rList,
258 SdrObject* pShape,
259 const ::rtl::OUString& rsName,
260 const bool bIsExcluded,
261 SvLBoxEntry* pParentEntry,
262 const IconProvider& rIconProvider);
264 /** Add the given object to a transferable object so that the object can
265 be dragged and dropped without having a name.
267 void AddShapeToTransferable (
268 SdTransferable& rTransferable,
269 SdrObject& rObject) const;
272 #endif // _SDTREELB_HXX