xref: /AOO41X/main/sd/source/ui/inc/sdtreelb.hxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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 <vector>
40 using namespace std;
41 #include <boost/scoped_ptr.hpp>
42 #include <boost/function.hpp>
43 
44 class SdDrawDocument;
45 class SfxMedium;
46 class SfxViewFrame;
47 class SdNavigatorWin;
48 class SdrObject;
49 class SdrObjList;
50 class SdPage;
51 class SvLBoxEntry;
52 
53 namespace sd {
54 class ViewShell;
55 
56 class DrawDocShell;
57 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
58 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
59 SV_DECL_REF(DrawDocShell)
60 #endif
61 }
62 
63 /*************************************************************************
64 |*
65 |* Effekte-Tab-Dialog
66 |*
67 \************************************************************************/
68 
69 class SD_DLLPUBLIC SdPageObjsTLB : public SvTreeListBox
70 {
71 private:
72 
73     static sal_Bool  SD_DLLPRIVATE bIsInDrag;      // static, falls der Navigator im ExecuteDrag geloescht wird
74 
75     //Solution: set contenttree in SdNavigatorWin
76     sal_Bool                           bisInSdNavigatorWin;
77 public:
78 
79     // nested class to implement the TransferableHelper
80     class SdPageObjsTransferable : public SdTransferable
81     {
82     public:
83         SdPageObjsTransferable(
84             SdPageObjsTLB& rParent,
85             const INetBookmark& rBookmark,
86             ::sd::DrawDocShell& rDocShell,
87             NavigatorDragType eDragType,
88             const ::com::sun::star::uno::Any& rTreeListBoxData );
89         ::sd::DrawDocShell&     GetDocShell() const;
90         NavigatorDragType   GetDragType() const;
91 
92         static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
93         static SdPageObjsTransferable* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
94         /** Return a temporary transferable data flavor that is used
95             internally in the navigator for reordering entries.  Its
96             lifetime ends with the office application.
97         */
98         static sal_uInt32 GetListBoxDropFormatId (void);
99 
100     private:
101         /** Temporary drop flavor id that is used internally in the
102             navigator.
103         */
104         static sal_uInt32 mnListBoxDropFormatId;
105 
106         SdPageObjsTLB&      mrParent;
107         INetBookmark        maBookmark;
108         ::sd::DrawDocShell&     mrDocShell;
109         NavigatorDragType   meDragType;
110         const ::com::sun::star::uno::Any maTreeListBoxData;
111         SD_DLLPRIVATE virtual               ~SdPageObjsTransferable();
112 
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 );
116 
117         SD_DLLPRIVATE virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
118     };
119 
120     friend class SdPageObjsTLB::SdPageObjsTransferable;
121 
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.
130     */
131     bool PageBelongsToCurrentShow (const SdPage* pPage) const;
132 
133 protected:
134 
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     sal_Bool                    mbLinkableSelected;
145     sal_Bool                    mbDragEnabled;
146     String                  maDocName;
147     ::sd::DrawDocShellRef       mxBookmarkDocShRef; // Zum Laden von Bookmarks
148     ::sd::DrawDocShell*         mpDropDocSh;
149     SdNavigatorWin*         mpDropNavWin;
150     SfxViewFrame*           mpFrame;
151     vector<String>          maTreeItem;
152     sal_Bool                    mbSaveTreeItemState;
153     String                  maSelectionEntryText;
154 
155     // DragSourceHelper
156     virtual void            StartDrag( sal_Int8 nAction, const Point& rPosPixel );
157 
158     // DropTargetHelper
159     virtual sal_Int8        AcceptDrop( const AcceptDropEvent& rEvt );
160     virtual sal_Int8        ExecuteDrop( const ExecuteDropEvent& rEvt );
161 
162     virtual void            RequestingChilds( SvLBoxEntry* pParent );
163 
164     void                    DoDrag();
165     void                    OnDragFinished( sal_uInt8 nDropAction );
166 
167     /** Return the name of the object.  When the object has no user supplied
168         name and the bCreate flag is <TRUE/> then a name is created
169         automatically.  Additionally the mbShowAllShapes flag is taken into
170         account when there is no user supplied name.  When this flag is
171         <FALSE/> then no name is created.
172         @param pObject
173             When this is NULL then an empty string is returned, regardless
174             of the value of bCreate.
175         @param bCreate
176             This flag controls for objects without user supplied name
177             whether a name is created.  When a name is created then this
178             name is not stored in the object.
179     */
180     String GetObjectName (
181         const SdrObject* pObject,
182         const bool bCreate = true) const;
183     void                    CloseBookmarkDoc();
184                             DECL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*);
185 
186     /** Handle the reordering of entries in the navigator.  This method
187         reorders both the involved shapes in their page as well as the
188         associated list box entries.
189     */
190     virtual sal_Bool NotifyMoving(
191         SvLBoxEntry*  pTarget,
192         SvLBoxEntry*  pEntry,
193         SvLBoxEntry*& rpNewParent,
194         sal_uLong&        rNewChildPos);
195 
196     using Window::GetDropTarget;
197     virtual SvLBoxEntry* GetDropTarget (const Point& rLocation);
198     virtual void    InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind );
199 
200 public:
201 
202                             SdPageObjsTLB( Window* pParent, const SdResId& rSdResId );
203                             ~SdPageObjsTLB();
204    // helper function for   GetEntryAltText and GetEntryLongDescription
205     String          getAltLongDescText( SvLBoxEntry* pEntry , sal_Bool isAltText) const;
206     String          GetEntryAltText( SvLBoxEntry* pEntry ) const;
207     String          GetEntryLongDescription( SvLBoxEntry* pEntry ) const;
208     virtual void            SelectHdl();
209     virtual void            KeyInput( const KeyEvent& rKEvt );
210 
SetViewFrame(SfxViewFrame * pViewFrame)211     void                    SetViewFrame( SfxViewFrame* pViewFrame ) { mpFrame = pViewFrame; }
GetViewFrame() const212     SfxViewFrame*           GetViewFrame() const { return mpFrame; }
213 
214     void                    Fill( const SdDrawDocument*, sal_Bool bAllPages, const String& rDocName );
215     void                    Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const String& rDocName );
216     void                    SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
217     bool                    GetShowAllShapes (void) const;
218     sal_Bool                    IsEqualToDoc( const SdDrawDocument* pInDoc = NULL );
219     sal_Bool                    HasSelectedChilds( const String& rName );
220     sal_Bool                    SelectEntry( const String& rName );
221     String                  GetSelectEntry();
222     //Solution: Mark Current Entry
223     void                    MarkCurEntry( const String& rName );
SetSdNavigatorWinFlag(sal_Bool isInSdNavigatorWin)224     void                    SetSdNavigatorWinFlag(sal_Bool isInSdNavigatorWin){bisInSdNavigatorWin =isInSdNavigatorWin;};
225     void                    FreshCurEntry();
226 
227     void                    Clear();
SetSaveTreeItemStateFlag(sal_Bool bState)228     void                    SetSaveTreeItemStateFlag(sal_Bool bState){mbSaveTreeItemState = bState;}
229     void                    SaveExpandedTreeItemState(SvLBoxEntry* pEntry, vector<String>& vectTreeItem);
230     List*                   GetSelectEntryList( sal_uInt16 nDepth );
231     SdDrawDocument*         GetBookmarkDoc(SfxMedium* pMedium = NULL);
GetDropDocSh()232     ::sd::DrawDocShell*         GetDropDocSh() { return(mpDropDocSh); }
233 
IsLinkableSelected() const234     sal_Bool                    IsLinkableSelected() const { return mbLinkableSelected; }
235 
236     static sal_Bool             IsInDrag();
237     using SvLBox::ExecuteDrop;
238 
239     using SvTreeListBox::SelectEntry;
240 
241     /** Return the view shell that is linked to the given doc shell.
242         Call this method when the there is a chance that the doc shell
243         has been disconnected from the view shell (but not the other
244         way round.)
245         @return
246             May return <NULL/> when the link between view shell and
247             doc shell has been severed.
248     */
249     static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
250 
251 private:
252     /** This flag controls whether all shapes are shown as children of pages
253         and group shapes or only the named shapes.
254     */
255     bool mbShowAllShapes;
256     /** This flag controls whether to show all pages.
257     */
258     bool mbShowAllPages;
259 
260     /** Return <TRUE/> when the current transferable may be dropped at the
261         given list box entry.
262     */
263     bool IsDropAllowed (SvLBoxEntry* pEntry);
264 
265     /** This inner class is defined in sdtreelb.cxx and is basically a
266         container for the icons used in the list box for the entries.
267     */
268     class IconProvider;
269 
270     /** Add one list box entry for the parent of the given shapes and one child entry for
271         each of the given shapes.
272         @param rList
273             The container of shapes that are to be inserted.
274         @param pShape
275             The parent shape or NULL when the parent is a page.
276         @param rsName
277             The name to be displayed for the new parent node.
278         @param bIsExcluded
279             Some pages can be excluded (from the show?).
280         @param pParentEntry
281             The parent entry of the new parent entry.
282         @param rIconProvider
283             Icons used to visualize the different shape and page types.
284     */
285     void AddShapeList (
286         const SdrObjList& rList,
287         SdrObject* pShape,
288         const ::rtl::OUString& rsName,
289         const bool bIsExcluded,
290         SvLBoxEntry* pParentEntry,
291         const IconProvider& rIconProvider);
292 
293     /** Add the given object to a transferable object so that the object can
294         be dragged and dropped without having a name.
295     */
296     void AddShapeToTransferable (
297         SdTransferable& rTransferable,
298         SdrObject& rObject) const;
299 };
300 
301 #endif      // _SDTREELB_HXX
302