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