LibreOffice Module sd (master) 1
sdtreelb.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <pres.hxx>
23#include <sddllapi.h>
24#include <vcl/weld.hxx>
25#include <svl/urlbmk.hxx>
26#include <tools/ref.hxx>
27#include "sdxfer.hxx"
28#include <memory>
29#include <vector>
30
31class SdrView;
32class SdDrawDocument;
33class SfxMedium;
34class SfxViewFrame;
35class SdNavigatorWin;
36class SdrObject;
37class SdrObjList;
38class SdPage;
39struct ImplSVEvent;
40
41namespace sd {
42class ViewShell;
43
44class DrawDocShell;
45#ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
46#define SV_DECL_DRAW_DOC_SHELL_DEFINED
47typedef ::tools::SvRef<DrawDocShell> DrawDocShellRef;
48#endif
49}
50namespace svt {
51 class AcceleratorExecute;
52}
53
54class SdPageObjsTLVDropTarget final : public DropTargetHelper
55{
56private:
59 bool m_bOrderFrontToBack = false;
60
61 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
62 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
63
64public:
66
67 void SetDrawView(SdrView* pSdrView) { m_pSdrView = pSdrView; }
68 void SetOrderFrontToBack(bool bSet) { m_bOrderFrontToBack = bSet; }
69};
70
72{
73private:
74 static bool SAL_DLLPRIVATE bIsInDrag;
75
76 std::unique_ptr<weld::TreeView> m_xTreeView;
77 std::unique_ptr<weld::TreeIter> m_xScratchIter;
78 std::unique_ptr<SdPageObjsTLVDropTarget> m_xDropTargetHelper;
79 std::unique_ptr<::svt::AcceleratorExecute> m_xAccel;
88
92
98
104
105 bool m_bEditing = false;
106
108
111
112 OUString m_aDocName;
119
133 OUString GetObjectName (
134 const SdrObject* pObject,
135 const bool bCreate = true) const;
136
137 void CloseBookmarkDoc();
138
139 DECL_DLLPRIVATE_LINK(RequestingChildrenHdl, const weld::TreeIter&, bool);
141 DECL_DLLPRIVATE_LINK(AsyncSelectHdl, void*, void);
142 DECL_DLLPRIVATE_LINK(RowActivatedHdl, weld::TreeView&, bool);
143 DECL_DLLPRIVATE_LINK(AsyncRowActivatedHdl, void*, void);
144 DECL_DLLPRIVATE_LINK(DragBeginHdl, bool&, bool);
145 DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
146
147 DECL_LINK(EditingEntryHdl, const weld::TreeIter&, bool);
148 typedef std::pair<const weld::TreeIter&, OUString> IterString;
149 DECL_LINK(EditedEntryHdl, const IterString&, bool);
150 DECL_LINK(EditEntryAgain, void*, void);
151
152 DECL_LINK(CommandHdl, const CommandEvent&, bool);
153
163 bool PageBelongsToCurrentShow (const SdPage* pPage) const;
164
165 bool DoDrag();
166 static void OnDragFinished();
167
168 // DragSourceHelper
169 bool StartDrag();
170
171public:
172
173 SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeview);
175
176 bool IsEditingActive() const {return m_bEditing;}
177
179 {
180 std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
181 if (m_xTreeView->get_cursor(xIter.get()))
182 {
183 m_xTreeView->start_editing(*xIter);
184 }
185 }
186
187 void set_sensitive(bool bSensitive)
188 {
189 m_xTreeView->set_sensitive(bSensitive);
190 }
191
192 void hide()
193 {
194 m_xTreeView->hide();
195 }
196
197 void show()
198 {
199 m_xTreeView->show();
200 }
201
203 {
204 m_xTreeView->grab_focus();
205 }
206
207 void set_size_request(int nWidth, int nHeight)
208 {
209 m_xTreeView->set_size_request(nWidth, nHeight);
210 }
211
213 {
214 return m_xTreeView->get_approximate_digit_width();
215 }
216
217 DECL_LINK(MousePressHdl, const MouseEvent&, bool);
218 DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool);
219
220 void Select();
221
222 int get_height_rows(int nRows) const
223 {
224 return m_xTreeView->get_height_rows(nRows);
225 }
226
228 {
229 m_eSelectionMode = eMode;
230 m_xTreeView->set_selection_mode(eMode);
231 }
232
234 {
235 return m_eSelectionMode;
236 }
237
239 {
240 m_aRowActivatedHdl = rLink;
241 }
242
244 {
245 m_aKeyPressHdl = rLink;
246 }
247
249 {
250 m_aMouseReleaseHdl = rLink;
251 }
252
254 {
255 m_aPopupMenuHdl = rLink;
256 }
257
258 bool HasSelectedChildren(std::u16string_view rName);
259 bool SelectEntry(std::u16string_view rName);
260 void SelectEntry(const SdrObject* pObj);
261
262 OUString get_selected_text() const
263 {
264 return m_xTreeView->get_selected_text();
265 }
266
267 bool get_selected() const
268 {
269 return m_xTreeView->get_selected(nullptr);
270 }
271
273 {
274 return m_xTreeView->count_selected_rows();
275 }
276
278 {
279 m_aChangeHdl = rLink;
280 }
281
282 bool is_selected(const weld::TreeIter& rIter) const
283 {
284 return m_xTreeView->is_selected(rIter);
285 }
286
288 {
289 return m_xTreeView->get_iter_first(rIter);
290 }
291
293 {
294 return *m_xTreeView;
295 }
296
297 std::unique_ptr<weld::TreeIter> make_iterator()
298 {
299 return m_xTreeView->make_iterator();
300 }
301
302 bool get_visible() const
303 {
304 return m_xTreeView->get_visible();
305 }
306
308 {
309 m_xTreeView->unselect_all();
310 }
311
312 OUString get_cursor_text() const
313 {
314 std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
315 if (m_xTreeView->get_cursor(xIter.get()))
316 return m_xTreeView->get_text(*xIter);
317 return OUString();
318 }
319
320 OUString get_cursor_id() const
321 {
322 std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
323 if (m_xTreeView->get_cursor(xIter.get()))
324 return m_xTreeView->get_id(*xIter);
325 return OUString();
326 }
327
328 void SetViewFrame(const SfxViewFrame* pViewFrame);
329
330 void Fill(const SdDrawDocument*, bool bAllPages, const OUString& rDocName);
331 void Fill(const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName);
332
333 void SetShowAllShapes (const bool bShowAllShapes, const bool bFill);
334 bool GetShowAllShapes() const { return m_bShowAllShapes; }
335
336 void SetOrderFrontToBack (const bool bOrderFrontToBack);
337 bool GetOrderFrontToBack() const { return m_bOrderFrontToBack; }
338
339 bool IsNavigationGrabsFocus() const { return m_bNavigationGrabsFocus; }
340 bool IsEqualToDoc(const SdDrawDocument* pInDoc);
342 bool IsEqualToShapeList(std::unique_ptr<weld::TreeIter>& rEntry, const SdrObjList& rList,
343 std::u16string_view rListName);
344
345 static bool IsInDrag();
346
355 static ::sd::ViewShell* GetViewShellForDocShell (::sd::DrawDocShell &rDocShell);
356
370 void AddShapeList (
371 const SdrObjList& rList,
372 const SdrObject* pShape,
373 const OUString& rsName,
374 const bool bIsExcluded,
375 const weld::TreeIter* pParentEntry);
376
380 void AddShapeToTransferable (
381 SdTransferable& rTransferable,
382 const SdrObject& rObject) const;
383
388 std::vector<OUString> GetSelectEntryList(const int nDepth) const;
389
390 std::vector<OUString> GetSelectedEntryIds() const;
391
392 SdDrawDocument* GetBookmarkDoc(SfxMedium* pMedium = nullptr);
393
394 bool IsLinkableSelected() const { return m_bLinkableSelected; }
395
396 void InsertEntry(const OUString &rName, const OUString &rExpander)
397 {
398 m_xTreeView->insert(nullptr, -1, &rName, nullptr, nullptr, nullptr, false, m_xScratchIter.get());
399 m_xTreeView->set_image(*m_xScratchIter, rExpander);
400 }
401
402 void InsertEntry(const weld::TreeIter* pParent, const OUString& rId, const OUString &rName, const OUString &rExpander, weld::TreeIter* pEntry = nullptr)
403 {
404 if (pParent)
405 m_xTreeView->insert(pParent, m_bOrderFrontToBack ? 0 : -1, &rName, &rId, nullptr,
406 nullptr, false, m_xScratchIter.get());
407 else
408 // always append page/slide entry
409 m_xTreeView->insert(nullptr, -1, &rName, &rId, nullptr, nullptr, false, m_xScratchIter.get());
410 m_xTreeView->set_image(*m_xScratchIter, rExpander);
411 if (pEntry)
412 m_xTreeView->copy_iterator(*m_xScratchIter, *pEntry);
413 }
414
415 //Mark Current Entry
416 void SetSdNavigator(SdNavigatorWin* pNavigator);
417
418 void clear()
419 {
420 m_xTreeView->clear();
421 }
422
423 // nested class to implement the TransferableHelper
424 class SAL_DLLPRIVATE SdPageObjsTransferable final : public SdTransferable
425 {
426 public:
428 INetBookmark aBookmark,
429 ::sd::DrawDocShell& rDocShell,
430 NavigatorDragType eDragType );
431 ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
432 NavigatorDragType GetDragType() const { return meDragType;}
433
434 static SdPageObjsTransferable* getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData ) noexcept;
439 static SotClipboardFormatId GetListBoxDropFormatId();
440
441 private:
446
450 virtual ~SdPageObjsTransferable() override;
451
452 virtual void AddSupportedFormats() override;
453 virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
454 virtual void DragFinished( sal_Int8 nDropAction ) override;
455 };
456
458
459private:
461};
462
463/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
ExecuteDrop-Event.
Definition: sdtreelb.cxx:546
SdPageObjsTLVDropTarget(weld::TreeView &rTreeView)
Definition: sdtreelb.cxx:487
weld::TreeView & m_rTreeView
Definition: sdtreelb.hxx:57
void SetDrawView(SdrView *pSdrView)
Definition: sdtreelb.hxx:67
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
AcceptDrop-Event.
Definition: sdtreelb.cxx:497
void SetOrderFrontToBack(bool bSet)
Definition: sdtreelb.hxx:68
NavigatorDragType const meDragType
Definition: sdtreelb.hxx:449
NavigatorDragType GetDragType() const
Definition: sdtreelb.hxx:432
::sd::DrawDocShell & GetDocShell() const
Definition: sdtreelb.hxx:431
static SotClipboardFormatId mnListBoxDropFormatId
Temporary drop flavor id that is used internally in the navigator.
Definition: sdtreelb.hxx:445
void unselect_all()
Definition: sdtreelb.hxx:307
::sd::DrawDocShellRef m_xBookmarkDocShRef
for the loading of bookmarks
Definition: sdtreelb.hxx:113
SdDrawDocument * m_pBookmarkDoc
Definition: sdtreelb.hxx:82
void connect_popup_menu(const Link< const CommandEvent &, bool > &rLink)
Definition: sdtreelb.hxx:253
bool get_iter_first(weld::TreeIter &rIter) const
Definition: sdtreelb.hxx:287
bool GetOrderFrontToBack() const
Definition: sdtreelb.hxx:337
void InsertEntry(const weld::TreeIter *pParent, const OUString &rId, const OUString &rName, const OUString &rExpander, weld::TreeIter *pEntry=nullptr)
Definition: sdtreelb.hxx:402
std::unique_ptr< weld::TreeView > m_xTreeView
Definition: sdtreelb.hxx:76
DECL_DLLPRIVATE_LINK(RowActivatedHdl, weld::TreeView &, bool)
OUString get_cursor_text() const
Definition: sdtreelb.hxx:312
bool get_visible() const
Definition: sdtreelb.hxx:302
bool IsEditingActive() const
Definition: sdtreelb.hxx:176
SfxMedium * m_pMedium
Definition: sdtreelb.hxx:83
DECL_DLLPRIVATE_LINK(DragBeginHdl, bool &, bool)
DECL_LINK(MousePressHdl, const MouseEvent &, bool)
std::unique_ptr< weld::TreeIter > make_iterator()
Definition: sdtreelb.hxx:297
void grab_focus()
Definition: sdtreelb.hxx:202
void connect_changed(const Link< weld::TreeView &, void > &rLink)
Definition: sdtreelb.hxx:277
const SdDrawDocument * m_pDoc
Definition: sdtreelb.hxx:81
DECL_DLLPRIVATE_LINK(AsyncRowActivatedHdl, void *, void)
DECL_DLLPRIVATE_LINK(AsyncSelectHdl, void *, void)
DECL_DLLPRIVATE_LINK(RequestingChildrenHdl, const weld::TreeIter &, bool)
void connect_key_press(const Link< const KeyEvent &, bool > &rLink)
Definition: sdtreelb.hxx:243
weld::TreeView & get_treeview()
Definition: sdtreelb.hxx:292
SdNavigatorWin * m_pNavigator
Definition: sdtreelb.hxx:80
SelectionMode get_selection_mode() const
Definition: sdtreelb.hxx:233
Link< const CommandEvent &, bool > m_aPopupMenuHdl
Definition: sdtreelb.hxx:118
void set_size_request(int nWidth, int nHeight)
Definition: sdtreelb.hxx:207
void connect_mouse_release(const Link< const MouseEvent &, bool > &rLink)
Definition: sdtreelb.hxx:248
DECL_LINK(MouseReleaseHdl, const MouseEvent &, bool)
DECL_LINK(EditEntryAgain, void *, void)
bool m_bNavigationGrabsFocus
If navigation should not only select the relevant shape but also change focus to it.
Definition: sdtreelb.hxx:103
bool get_selected() const
Definition: sdtreelb.hxx:267
float get_approximate_digit_width() const
Definition: sdtreelb.hxx:212
OUString m_aDocName
Definition: sdtreelb.hxx:112
void clear()
Definition: sdtreelb.hxx:418
ImplSVEvent * m_nRowActivateEventId
Definition: sdtreelb.hxx:110
DECL_DLLPRIVATE_LINK(SelectHdl, weld::TreeView &, void)
DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent &, bool)
DECL_LINK(EditedEntryHdl, const IterString &, bool)
int count_selected_rows() const
Definition: sdtreelb.hxx:272
std::unique_ptr<::svt::AcceleratorExecute > m_xAccel
Definition: sdtreelb.hxx:79
bool m_bShowAllShapes
Definition: sdtreelb.hxx:86
bool m_bOrderFrontToBack
Definition: sdtreelb.hxx:87
static bool SAL_DLLPRIVATE bIsInDrag
static, in the case the navigator is deleted in ExecuteDrag
Definition: sdtreelb.hxx:74
std::unique_ptr< weld::TreeIter > m_xScratchIter
Definition: sdtreelb.hxx:77
void connect_row_activated(const Link< weld::TreeView &, bool > &rLink)
Definition: sdtreelb.hxx:238
void InsertEntry(const OUString &rName, const OUString &rExpander)
Definition: sdtreelb.hxx:396
OUString get_cursor_id() const
Definition: sdtreelb.hxx:320
bool GetShowAllShapes() const
Definition: sdtreelb.hxx:334
Link< weld::TreeView &, bool > m_aRowActivatedHdl
Definition: sdtreelb.hxx:115
bool IsNavigationGrabsFocus() const
Definition: sdtreelb.hxx:339
std::unique_ptr< SdPageObjsTLVDropTarget > m_xDropTargetHelper
Definition: sdtreelb.hxx:78
bool m_bSelectionHandlerNavigates
If changing the selection should also result in navigating to the relevant shape.
Definition: sdtreelb.hxx:97
bool is_selected(const weld::TreeIter &rIter) const
Definition: sdtreelb.hxx:282
ImplSVEvent * m_nSelectEventId
Definition: sdtreelb.hxx:109
OUString get_selected_text() const
Definition: sdtreelb.hxx:262
DECL_LINK(EditingEntryHdl, const weld::TreeIter &, bool)
SfxMedium * m_pOwnMedium
Definition: sdtreelb.hxx:84
DECL_LINK(CommandHdl, const CommandEvent &, bool)
bool IsLinkableSelected() const
Definition: sdtreelb.hxx:394
bool m_bShowAllPages
This flag controls whether to show all pages.
Definition: sdtreelb.hxx:91
int get_height_rows(int nRows) const
Definition: sdtreelb.hxx:222
SelectionMode m_eSelectionMode
Definition: sdtreelb.hxx:107
rtl::Reference< SdPageObjsTransferable > m_xHelper
Definition: sdtreelb.hxx:460
std::pair< const weld::TreeIter &, OUString > IterString
Definition: sdtreelb.hxx:148
void start_editing()
Definition: sdtreelb.hxx:178
Link< weld::TreeView &, void > m_aChangeHdl
Definition: sdtreelb.hxx:114
Link< const KeyEvent &, bool > m_aKeyPressHdl
Definition: sdtreelb.hxx:116
Link< const MouseEvent &, bool > m_aMouseReleaseHdl
Definition: sdtreelb.hxx:117
void set_sensitive(bool bSensitive)
Definition: sdtreelb.hxx:187
bool m_bLinkableSelected
Definition: sdtreelb.hxx:85
void set_selection_mode(SelectionMode eMode)
Definition: sdtreelb.hxx:227
SotClipboardFormatId
Mode eMode
Fill
::tools::SvRef< DrawDocShell > DrawDocShellRef
NavigatorDragType
Definition: pres.hxx:65
#define SD_DLLPUBLIC
Definition: sddllapi.h:27
signed char sal_Int8
SelectionMode