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 0 : ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
78 0 : NavigatorDragType GetDragType() const { return meDragType;}
79 :
80 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
81 : static SdPageObjsTransferable* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
82 : /** Return a temporary transferable data flavor that is used
83 : internally in the navigator for reordering entries. Its
84 : lifetime ends with the office application.
85 : */
86 : static SotClipboardFormatId GetListBoxDropFormatId();
87 :
88 : private:
89 : /** Temporary drop flavor id that is used internally in the
90 : navigator.
91 : */
92 : static SotClipboardFormatId mnListBoxDropFormatId;
93 :
94 : SdPageObjsTLB& mrParent;
95 : INetBookmark maBookmark;
96 : ::sd::DrawDocShell& mrDocShell;
97 : NavigatorDragType meDragType;
98 : SAL_DLLPRIVATE virtual ~SdPageObjsTransferable();
99 :
100 : SAL_DLLPRIVATE virtual void AddSupportedFormats() SAL_OVERRIDE;
101 : SAL_DLLPRIVATE virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE;
102 : SAL_DLLPRIVATE virtual void DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE;
103 :
104 : 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;
105 : };
106 :
107 : friend class SdPageObjsTLB::SdPageObjsTransferable;
108 :
109 : /** Determine whether the specified page belongs to the current show
110 : which is either the standard show or a custom show.
111 : @param pPage
112 : Pointer to the page for which to check whether it belongs to the
113 : show.
114 : @return
115 : Returns <FALSE/> if there is no custom show or if the current
116 : show does not contain the specified page at least once.
117 : */
118 : bool PageBelongsToCurrentShow (const SdPage* pPage) const;
119 :
120 : protected:
121 :
122 : VclPtr<vcl::Window> mpParent;
123 : const SdDrawDocument* mpDoc;
124 : SdDrawDocument* mpBookmarkDoc;
125 : SfxMedium* mpMedium;
126 : SfxMedium* mpOwnMedium;
127 : Image maImgOle;
128 : Image maImgGraphic;
129 : bool mbLinkableSelected;
130 : OUString maDocName;
131 : ::sd::DrawDocShellRef mxBookmarkDocShRef; ///< for the loading of bookmarks
132 : VclPtr<SdNavigatorWin> mpDropNavWin;
133 : SfxViewFrame* mpFrame;
134 : std::vector<OUString> maTreeItem;
135 : bool mbSaveTreeItemState;
136 : OUString maSelectionEntryText;
137 :
138 : // DragSourceHelper
139 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
140 :
141 : // DropTargetHelper
142 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
143 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
144 :
145 : virtual void RequestingChildren( SvTreeListEntry* pParent ) SAL_OVERRIDE;
146 :
147 : void DoDrag();
148 : void OnDragFinished( sal_uInt8 nDropAction );
149 :
150 : /** Return the name of the object. When the object has no user supplied
151 : name and the bCreate flag is <TRUE/> then a name is created
152 : automatically. Additionally the mbShowAllShapes flag is taken into
153 : account when there is no user supplied name. When this flag is
154 : <FALSE/> then no name is created.
155 : @param pObject
156 : When this is NULL then an empty string is returned, regardless
157 : of the value of bCreate.
158 : @param bCreate
159 : This flag controls for objects without user supplied name
160 : whether a name is created. When a name is created then this
161 : name is not stored in the object.
162 : */
163 : OUString GetObjectName (
164 : const SdrObject* pObject,
165 : const bool bCreate = true) const;
166 : void CloseBookmarkDoc();
167 : DECL_LINK(ExecDragHdl, void*);
168 :
169 : /** Handle the reordering of entries in the navigator. This method
170 : reorders both the involved shapes in their page as well as the
171 : associated list box entries.
172 : */
173 : virtual TriState NotifyMoving(
174 : SvTreeListEntry* pTarget,
175 : SvTreeListEntry* pEntry,
176 : SvTreeListEntry*& rpNewParent,
177 : sal_uLong& rNewChildPos) SAL_OVERRIDE;
178 :
179 : using Window::GetDropTarget;
180 : virtual SvTreeListEntry* GetDropTarget (const Point& rLocation) SAL_OVERRIDE;
181 : virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&,SvLBoxButtonKind) SAL_OVERRIDE;
182 :
183 : public:
184 :
185 : SdPageObjsTLB( vcl::Window* pParent, const SdResId& rSdResId );
186 : SdPageObjsTLB( vcl::Window* pParent, WinBits nStyle );
187 : virtual ~SdPageObjsTLB();
188 : virtual void dispose() SAL_OVERRIDE;
189 :
190 : // helper function for GetEntryAltText and GetEntryLongDescription
191 : OUString getAltLongDescText( SvTreeListEntry* pEntry , bool isAltText) const;
192 : OUString GetEntryAltText( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
193 : OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
194 : virtual void SelectHdl() SAL_OVERRIDE;
195 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
196 :
197 1 : void SetViewFrame( SfxViewFrame* pViewFrame ) { mpFrame = pViewFrame; }
198 : SfxViewFrame* GetViewFrame() const { return mpFrame; }
199 :
200 : void Fill( const SdDrawDocument*, bool bAllPages, const OUString& rDocName );
201 : void Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName );
202 : void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
203 0 : bool GetShowAllShapes() const { return mbShowAllShapes;}
204 : bool IsEqualToDoc( const SdDrawDocument* pInDoc = NULL );
205 : bool HasSelectedChildren( const OUString& rName );
206 : bool SelectEntry( const OUString& rName );
207 : OUString GetSelectEntry();
208 :
209 : //Mark Current Entry
210 : void MarkCurEntry( const OUString& rName );
211 1 : void SetSdNavigatorWinFlag(bool isInSdNavigatorWin){bisInSdNavigatorWin =isInSdNavigatorWin;};
212 : void FreshCurEntry();
213 :
214 : void Clear();
215 0 : void SetSaveTreeItemStateFlag(bool bState){mbSaveTreeItemState = bState;}
216 : void SaveExpandedTreeItemState(SvTreeListEntry* pEntry, std::vector<OUString>& vectTreeItem);
217 :
218 : /** return selected entries
219 : nDepth == 0 -> pages
220 : nDepth == 1 -> objects */
221 :
222 : std::vector<OUString> GetSelectEntryList (const sal_uInt16 nDepth) const;
223 :
224 : SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = NULL);
225 :
226 0 : bool IsLinkableSelected() const { return mbLinkableSelected; }
227 :
228 : static bool IsInDrag();
229 : using SvTreeListBox::ExecuteDrop;
230 :
231 : using SvTreeListBox::SelectEntry;
232 :
233 : /** Return the view shell that is linked to the given doc shell.
234 : Call this method when the there is a chance that the doc shell
235 : has been disconnected from the view shell (but not the other
236 : way round.)
237 : @return
238 : May return <NULL/> when the link between view shell and
239 : doc shell has been severed.
240 : */
241 : static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
242 :
243 : private:
244 : /** This flag controls whether all shapes are shown as children of pages
245 : and group shapes or only the named shapes.
246 : */
247 : bool mbShowAllShapes;
248 : /** This flag controls whether to show all pages.
249 : */
250 : bool mbShowAllPages;
251 :
252 : /** Return <TRUE/> when the current transferable may be dropped at the
253 : given list box entry.
254 : */
255 : bool IsDropAllowed (SvTreeListEntry* pEntry);
256 :
257 : /** This inner class is defined in sdtreelb.cxx and is basically a
258 : container for the icons used in the list box for the entries.
259 : */
260 : class IconProvider;
261 :
262 : /** Add one list box entry for the parent of the given shapes and one child entry for
263 : each of the given shapes.
264 : @param rList
265 : The container of shapes that are to be inserted.
266 : @param pShape
267 : The parent shape or NULL when the parent is a page.
268 : @param rsName
269 : The name to be displayed for the new parent node.
270 : @param bIsExcluded
271 : Some pages can be excluded (from the show?).
272 : @param pParentEntry
273 : The parent entry of the new parent entry.
274 : @param rIconProvider
275 : Icons used to visualize the different shape and page types.
276 : */
277 : void AddShapeList (
278 : const SdrObjList& rList,
279 : SdrObject* pShape,
280 : const OUString& rsName,
281 : const bool bIsExcluded,
282 : SvTreeListEntry* pParentEntry,
283 : const IconProvider& rIconProvider);
284 :
285 : /** Add the given object to a transferable object so that the object can
286 : be dragged and dropped without having a name.
287 : */
288 : void AddShapeToTransferable (
289 : SdTransferable& rTransferable,
290 : SdrObject& rObject) const;
291 : };
292 :
293 : #endif // INCLUDED_SD_SOURCE_UI_INC_SDTREELB_HXX
294 :
295 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|