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