Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX
22 :
23 : #include <svtools/transfer.hxx>
24 :
25 : #include "sdresid.hxx"
26 : #include "pres.hxx"
27 : #include "sddllapi.h"
28 : #include <svtools/treelistbox.hxx>
29 : #include <svl/urlbmk.hxx>
30 : #include <tools/ref.hxx>
31 : #include "sdxfer.hxx"
32 : #include <vector>
33 : #include <boost/scoped_ptr.hpp>
34 : #include <boost/function.hpp>
35 :
36 : class SdDrawDocument;
37 : class SfxMedium;
38 : class SfxViewFrame;
39 : class SdNavigatorWin;
40 : class SdrObject;
41 : class SdrObjList;
42 : class SdPage;
43 : class SvTreeListEntry;
44 :
45 : namespace sd {
46 : class ViewShell;
47 :
48 : class DrawDocShell;
49 : #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
50 : #define SV_DECL_DRAW_DOC_SHELL_DEFINED
51 : typedef ::tools::SvRef<DrawDocShell> DrawDocShellRef;
52 : #endif
53 : }
54 :
55 : /**
56 : * Effect-Tab-Dialog
57 : */
58 : class SD_DLLPUBLIC SdPageObjsTLB : public SvTreeListBox
59 : {
60 : private:
61 :
62 : static bool SAL_DLLPRIVATE bIsInDrag; ///< static, in the case the navigator is deleted in ExecuteDrag
63 :
64 : // set contenttree in SdNavigatorWin
65 : bool bisInSdNavigatorWin;
66 : public:
67 :
68 : // nested class to implement the TransferableHelper
69 : class SdPageObjsTransferable : public SdTransferable
70 : {
71 : public:
72 : SdPageObjsTransferable(
73 : SdPageObjsTLB& rParent,
74 : const INetBookmark& rBookmark,
75 : ::sd::DrawDocShell& rDocShell,
76 : NavigatorDragType eDragType,
77 : const ::com::sun::star::uno::Any& rTreeListBoxData );
78 0 : ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
79 0 : NavigatorDragType GetDragType() const { return meDragType;}
80 :
81 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
82 : static SdPageObjsTransferable* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
83 : /** Return a temporary transferable data flavor that is used
84 : internally in the navigator for reordering entries. Its
85 : lifetime ends with the office application.
86 : */
87 : static sal_uInt32 GetListBoxDropFormatId (void);
88 :
89 : private:
90 : /** Temporary drop flavor id that is used internally in the
91 : navigator.
92 : */
93 : static sal_uInt32 mnListBoxDropFormatId;
94 :
95 : SdPageObjsTLB& mrParent;
96 : INetBookmark maBookmark;
97 : ::sd::DrawDocShell& mrDocShell;
98 : NavigatorDragType meDragType;
99 : const ::com::sun::star::uno::Any maTreeListBoxData;
100 : SAL_DLLPRIVATE virtual ~SdPageObjsTransferable();
101 :
102 : SAL_DLLPRIVATE virtual void AddSupportedFormats() SAL_OVERRIDE;
103 : SAL_DLLPRIVATE virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE;
104 : SAL_DLLPRIVATE virtual void DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE;
105 :
106 : SAL_DLLPRIVATE virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
107 : };
108 :
109 : friend class SdPageObjsTLB::SdPageObjsTransferable;
110 :
111 : /** Determine whether the specified page belongs to the current show
112 : which is either the standard show or a custom show.
113 : @param pPage
114 : Pointer to the page for which to check whether it belongs to the
115 : show.
116 : @return
117 : Returns <FALSE/> if there is no custom show or if the current
118 : show does not contain the specified page at least once.
119 : */
120 : bool PageBelongsToCurrentShow (const SdPage* pPage) const;
121 :
122 : protected:
123 :
124 : vcl::Window* mpParent;
125 : const SdDrawDocument* mpDoc;
126 : SdDrawDocument* mpBookmarkDoc;
127 : SfxMedium* mpMedium;
128 : SfxMedium* mpOwnMedium;
129 : Image maImgOle;
130 : Image maImgGraphic;
131 : bool mbLinkableSelected;
132 : OUString maDocName;
133 : ::sd::DrawDocShellRef mxBookmarkDocShRef; ///< for the loading of bookmarks
134 : SdNavigatorWin* mpDropNavWin;
135 : SfxViewFrame* mpFrame;
136 : std::vector<OUString> maTreeItem;
137 : bool mbSaveTreeItemState;
138 : OUString maSelectionEntryText;
139 :
140 : // DragSourceHelper
141 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
142 :
143 : // DropTargetHelper
144 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
145 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
146 :
147 : virtual void RequestingChildren( SvTreeListEntry* pParent ) SAL_OVERRIDE;
148 :
149 : void DoDrag();
150 : void OnDragFinished( sal_uInt8 nDropAction );
151 :
152 : /** Return the name of the object. When the object has no user supplied
153 : name and the bCreate flag is <TRUE/> then a name is created
154 : automatically. Additionally the mbShowAllShapes flag is taken into
155 : account when there is no user supplied name. When this flag is
156 : <FALSE/> then no name is created.
157 : @param pObject
158 : When this is NULL then an empty string is returned, regardless
159 : of the value of bCreate.
160 : @param bCreate
161 : This flag controls for objects without user supplied name
162 : whether a name is created. When a name is created then this
163 : name is not stored in the object.
164 : */
165 : OUString GetObjectName (
166 : const SdrObject* pObject,
167 : const bool bCreate = true) const;
168 : void CloseBookmarkDoc();
169 : DECL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*);
170 :
171 : /** Handle the reordering of entries in the navigator. This method
172 : reorders both the involved shapes in their page as well as the
173 : associated list box entries.
174 : */
175 : virtual TriState NotifyMoving(
176 : SvTreeListEntry* pTarget,
177 : SvTreeListEntry* pEntry,
178 : SvTreeListEntry*& rpNewParent,
179 : sal_uLong& rNewChildPos) SAL_OVERRIDE;
180 :
181 : using Window::GetDropTarget;
182 : virtual SvTreeListEntry* GetDropTarget (const Point& rLocation) SAL_OVERRIDE;
183 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&,SvLBoxButtonKind) SAL_OVERRIDE;
184 :
185 : public:
186 :
187 : SdPageObjsTLB( vcl::Window* pParent, const SdResId& rSdResId );
188 : SdPageObjsTLB( vcl::Window* pParent, WinBits nStyle );
189 : virtual ~SdPageObjsTLB();
190 :
191 : // helper function for GetEntryAltText and GetEntryLongDescription
192 : OUString getAltLongDescText( SvTreeListEntry* pEntry , bool isAltText) const;
193 : OUString GetEntryAltText( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
194 : OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
195 : virtual void SelectHdl() SAL_OVERRIDE;
196 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
197 :
198 2 : void SetViewFrame( SfxViewFrame* pViewFrame ) { mpFrame = pViewFrame; }
199 : SfxViewFrame* GetViewFrame() const { return mpFrame; }
200 :
201 : void Fill( const SdDrawDocument*, bool bAllPages, const OUString& rDocName );
202 : void Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName );
203 : void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
204 0 : bool GetShowAllShapes (void) const { return mbShowAllShapes;}
205 : bool IsEqualToDoc( const SdDrawDocument* pInDoc = NULL );
206 : bool HasSelectedChildren( const OUString& rName );
207 : bool SelectEntry( const OUString& rName );
208 : OUString GetSelectEntry();
209 :
210 : //Mark Current Entry
211 : void MarkCurEntry( const OUString& rName );
212 2 : void SetSdNavigatorWinFlag(bool isInSdNavigatorWin){bisInSdNavigatorWin =isInSdNavigatorWin;};
213 : void FreshCurEntry();
214 :
215 : void Clear();
216 0 : void SetSaveTreeItemStateFlag(bool bState){mbSaveTreeItemState = bState;}
217 : void SaveExpandedTreeItemState(SvTreeListEntry* pEntry, std::vector<OUString>& vectTreeItem);
218 :
219 : /** return selected entries
220 : nDepth == 0 -> pages
221 : nDepth == 1 -> objects */
222 :
223 : std::vector<OUString> GetSelectEntryList (const sal_uInt16 nDepth) const;
224 :
225 : SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = NULL);
226 :
227 0 : bool IsLinkableSelected() const { return mbLinkableSelected; }
228 :
229 : static bool IsInDrag();
230 : using SvTreeListBox::ExecuteDrop;
231 :
232 : using SvTreeListBox::SelectEntry;
233 :
234 : /** Return the view shell that is linked to the given doc shell.
235 : Call this method when the there is a chance that the doc shell
236 : has been disconnected from the view shell (but not the other
237 : way round.)
238 : @return
239 : May return <NULL/> when the link between view shell and
240 : doc shell has been severed.
241 : */
242 : static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
243 :
244 : private:
245 : /** This flag controls whether all shapes are shown as children of pages
246 : and group shapes or only the named shapes.
247 : */
248 : bool mbShowAllShapes;
249 : /** This flag controls whether to show all pages.
250 : */
251 : bool mbShowAllPages;
252 :
253 : /** Return <TRUE/> when the current transferable may be dropped at the
254 : given list box entry.
255 : */
256 : bool IsDropAllowed (SvTreeListEntry* pEntry);
257 :
258 : /** This inner class is defined in sdtreelb.cxx and is basically a
259 : container for the icons used in the list box for the entries.
260 : */
261 : class IconProvider;
262 :
263 : /** Add one list box entry for the parent of the given shapes and one child entry for
264 : each of the given shapes.
265 : @param rList
266 : The container of shapes that are to be inserted.
267 : @param pShape
268 : The parent shape or NULL when the parent is a page.
269 : @param rsName
270 : The name to be displayed for the new parent node.
271 : @param bIsExcluded
272 : Some pages can be excluded (from the show?).
273 : @param pParentEntry
274 : The parent entry of the new parent entry.
275 : @param rIconProvider
276 : Icons used to visualize the different shape and page types.
277 : */
278 : void AddShapeList (
279 : const SdrObjList& rList,
280 : SdrObject* pShape,
281 : const OUString& rsName,
282 : const bool bIsExcluded,
283 : SvTreeListEntry* pParentEntry,
284 : const IconProvider& rIconProvider);
285 :
286 : /** Add the given object to a transferable object so that the object can
287 : be dragged and dropped without having a name.
288 : */
289 : void AddShapeToTransferable (
290 : SdTransferable& rTransferable,
291 : SdrObject& rObject) const;
292 : };
293 :
294 : #endif // INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX
295 :
296 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|