LibreOffice Module sd (master) 1
sdtreelb.cxx
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#include <sal/log.hxx>
21#include <sal/types.h>
22#include <sot/formats.hxx>
23#include <utility>
24#include <vcl/weld.hxx>
25#include <svx/svditer.hxx>
26#include <sfx2/docfile.hxx>
27#include <svx/svdoole2.hxx>
28#include <vcl/svapp.hxx>
29#include <cusshow.hxx>
30
31#include <sfx2/viewfrm.hxx>
32
33#include <sdtreelb.hxx>
34#include <DrawDocShell.hxx>
35#include <drawdoc.hxx>
36#include <sdpage.hxx>
37#include <sdmod.hxx>
38#include <sdresid.hxx>
39#include <navigatr.hxx>
40#include <strings.hrc>
41
42#include <bitmaps.hlst>
43#include <customshowlist.hxx>
44#include <ViewShell.hxx>
45#include <DrawController.hxx>
46#include <ViewShellBase.hxx>
47
48#include <com/sun/star/embed/XEmbedPersist.hpp>
49#include <com/sun/star/embed/XEmbeddedObject.hpp>
50#include <com/sun/star/frame/Desktop.hpp>
55
56#include <vcl/commandevent.hxx>
57
58#include <svx/svdview.hxx>
59#include <DrawViewShell.hxx>
60
61using namespace com::sun::star;
62
63namespace {
64
65sd::DrawViewShell* lcl_getDrawViewShell(const SdDrawDocument* pDoc)
66{
67 if (!pDoc || !pDoc->GetDocSh())
68 return nullptr;
69 return static_cast<sd::DrawViewShell*>(pDoc->GetDocSh()->GetViewShell());
70}
71
72}
73
74bool SdPageObjsTLV::bIsInDrag = false;
75
77{
78 return bIsInDrag;
79}
80
82
84 INetBookmark aBookmark,
85 ::sd::DrawDocShell& rDocShell,
86 NavigatorDragType eDragType)
87 : SdTransferable(rDocShell.GetDoc(), nullptr, true),
88 maBookmark(std::move( aBookmark )),
89 mrDocShell( rDocShell ),
90 meDragType( eDragType )
91{
92}
93
95{
96}
97
99{
100 AddFormat(SotClipboardFormatId::NETSCAPE_BOOKMARK);
101 AddFormat(SotClipboardFormatId::TREELISTBOX);
102 AddFormat(GetListBoxDropFormatId());
103}
104
105bool SdPageObjsTLV::SdPageObjsTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
106{
107 SotClipboardFormatId nFormatId = SotExchange::GetFormat( rFlavor );
108 switch (nFormatId)
109 {
110 case SotClipboardFormatId::NETSCAPE_BOOKMARK:
111 SetINetBookmark( maBookmark, rFlavor );
112 return true;
113
114 case SotClipboardFormatId::TREELISTBOX:
115 {
116 css::uno::Any aTreeListBoxData; // empty for now
117 SetAny(aTreeListBoxData);
118 return true;
119 }
120
121 default:
122 return false;
123 }
124}
125
127{
129 SdTransferable::DragFinished(nDropAction);
130}
131
133 noexcept
134{
135 return dynamic_cast<SdPageObjsTLV::SdPageObjsTransferable*>(rxData.get());
136}
137
139{
140 if (mnListBoxDropFormatId == static_cast<SotClipboardFormatId>(SAL_MAX_UINT32))
141 mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType("application/x-openoffice-treelistbox-moveonly;windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\"");
142 return mnListBoxDropFormatId;
143}
144
148bool SdPageObjsTLV::HasSelectedChildren( std::u16string_view rName )
149{
150 bool bChildren = false;
151
152 if( !rName.empty() )
153 {
154 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
155 OUString aTmp;
156
157 if (m_xTreeView->get_iter_first(*xEntry))
158 {
159 do
160 {
161 aTmp = m_xTreeView->get_text(*xEntry);
162 if (aTmp == rName)
163 {
164
165 // see if any of the selected nodes are subchildren of this node
166 m_xTreeView->selected_foreach([this, &bChildren, &xEntry](weld::TreeIter& rEntry){
167 std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator(&rEntry));
168 while (!bChildren && m_xTreeView->iter_parent(*xParent))
169 bChildren = m_xTreeView->iter_compare(*xParent, *xEntry) == 0;
170 return bChildren;
171 });
172
173 break;
174 }
175 }
176 while (m_xTreeView->iter_next(*xEntry));
177 }
178 }
179
180 return bChildren;
181}
182
184 const bool bShowAllShapes,
185 const bool bFillList)
186{
187 m_bShowAllShapes = bShowAllShapes;
188 if (bFillList)
189 {
190 if (m_pMedium == nullptr)
192 else
194 }
195}
196
197void SdPageObjsTLV::SetOrderFrontToBack(const bool bOrderFrontToBack)
198{
199 m_bOrderFrontToBack = bOrderFrontToBack;
200}
201
202bool SdPageObjsTLV::IsEqualToShapeList(std::unique_ptr<weld::TreeIter>& rEntry, const SdrObjList& rList,
203 std::u16string_view rListName)
204{
205 if (!rEntry)
206 return false;
207 OUString aName = m_xTreeView->get_text(*rEntry);
208
209 if (rListName != aName)
210 return false;
211
212 if (!m_xTreeView->iter_next(*rEntry))
213 rEntry.reset();
214
215 SdrObjListIter aIter(&rList,
216 !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
217 SdrIterMode::Flat);
218
219 while (aIter.IsMore())
220 {
221 SdrObject* pObj = aIter.Next();
222
223 const OUString aObjectName(GetObjectName(pObj));
224
225 if (!aObjectName.isEmpty())
226 {
227 if (!rEntry)
228 return false;
229
230 aName = m_xTreeView->get_text(*rEntry);
231
232 if (aObjectName != aName)
233 return false;
234
235 if (pObj->IsGroupObject())
236 {
237 bool bRet = IsEqualToShapeList(rEntry, *pObj->GetSubList(), aObjectName);
238 if (!bRet)
239 return false;
240 }
241 else
242 {
243 if (!m_xTreeView->iter_next(*rEntry))
244 rEntry.reset();
245 }
246 }
247 }
248
249 return true;
250}
251
259{
260 if( pInDoc )
261 m_pDoc = pInDoc;
262
263 if( !m_pDoc )
264 return false;
265
266 sd::DrawViewShell* pDrawViewShell = lcl_getDrawViewShell(m_pDoc);
267 if (!pDrawViewShell)
268 return false;
269 PageKind eDrawViewShellPageKind = pDrawViewShell->GetPageKind();
270 if (eDrawViewShellPageKind != PageKind::Standard && eDrawViewShellPageKind != PageKind::Notes)
271 return false;
272
273 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
274 if (!m_xTreeView->get_iter_first(*xEntry))
275 xEntry.reset();
276
277 // compare all pages including the objects
278 sal_uInt16 nPage = 0;
279 const sal_uInt16 nMaxPages = m_pDoc->GetPageCount();
280
281 while( nPage < nMaxPages )
282 {
283 const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetPage( nPage ) );
284 if (pPage->GetPageKind() == eDrawViewShellPageKind)
285 {
286 bool bRet = IsEqualToShapeList(xEntry, *pPage, pPage->GetName());
287 if (!bRet)
288 return false;
289 }
290 nPage++;
291 }
292 // If there are still entries in the listbox,
293 // then objects (with names) or pages were deleted
294 return !xEntry;
295}
296
297IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent&, rCEvt, bool)
298{
299 if (IsEditingActive())
300 return false;
301
302 if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
303 {
304 m_xTreeView->grab_focus();
305
306 // select clicked entry
307 if (std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
308 rCEvt.IsMouseEvent() && m_xTreeView->get_dest_row_at_pos(
309 rCEvt.GetMousePosPixel(), xEntry.get(), false))
310 {
313 m_xTreeView->set_cursor(*xEntry);
314 Select();
315 }
316
317 return m_aPopupMenuHdl.Call(rCEvt);
318 }
319
320 return false;
321}
322
323IMPL_LINK(SdPageObjsTLV, KeyInputHdl, const KeyEvent&, rKEvt, bool)
324{
325 const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
326 if (m_xAccel->execute(rKeyCode))
327 {
328 m_bEditing = false;
329 // the accelerator consumed the event
330 return true;
331 }
332 if (rKeyCode.GetCode() == KEY_RETURN)
333 {
334 m_bEditing = false;
335 std::unique_ptr<weld::TreeIter> xCursor(m_xTreeView->make_iterator());
336 if (m_xTreeView->get_cursor(xCursor.get()) && m_xTreeView->iter_has_child(*xCursor))
337 {
338 if (m_xTreeView->get_row_expanded(*xCursor))
339 m_xTreeView->collapse_row(*xCursor);
340 else
341 m_xTreeView->expand_row(*xCursor);
342 }
346 return true;
347 }
348 bool bRet = m_aKeyPressHdl.Call(rKEvt);
349 // m_bEditing needs to be set after key press handler call back or x11 won't end editing on
350 // Esc key press. See SdNavigatorWin::KeyInputHdl.
351 m_bEditing = false;
352 return bRet;
353}
354
355IMPL_LINK(SdPageObjsTLV, MousePressHdl, const MouseEvent&, rMEvt, bool)
356{
357 m_bEditing = false;
358 m_bSelectionHandlerNavigates = rMEvt.GetClicks() == 1;
359 m_bNavigationGrabsFocus = rMEvt.GetClicks() != 1;
360 return false;
361}
362
363IMPL_LINK_NOARG(SdPageObjsTLV, MouseReleaseHdl, const MouseEvent&, bool)
364{
366 return false;
367
370 return false;
371}
372
373IMPL_LINK(SdPageObjsTLV, DragBeginHdl, bool&, rUnsetDragIcon, bool)
374{
375 rUnsetDragIcon = false;
376 return StartDrag();
377}
378
379namespace
380{
381 bool CanDragSource(const weld::TreeView& rTreeView)
382 {
383 std::unique_ptr<weld::TreeIter> xSource(rTreeView.make_iterator());
384 if (!rTreeView.get_selected(xSource.get()))
385 return false;
386
387 std::unique_ptr<weld::TreeIter> xSourceParent(rTreeView.make_iterator(xSource.get()));
388 bool bSourceHasParent = rTreeView.iter_parent(*xSourceParent);
389 // disallow root drag
390 if (!bSourceHasParent)
391 return false;
392
393 SdrObject* pSourceObject = weld::fromId<SdrObject*>(rTreeView.get_id(*xSource));
394 if (pSourceObject == reinterpret_cast<SdrObject*>(1))
395 pSourceObject = nullptr;
396
397 if (!pSourceObject)
398 return false;
399
400 SdrPage* pObjectList = pSourceObject->getSdrPageFromSdrObject();
401 if (!pObjectList)
402 return false;
403
404 return true;
405 }
406}
407
412{
413 return !CanDragSource(*m_xTreeView) || DoDrag();
414}
415
420{
421 if (!m_pNavigator)
422 return true;
423
424 if (!m_xHelper)
425 return true;
426
427 // Get the view.
428 ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
429 ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
430 if (pViewShell == nullptr)
431 {
432 OSL_ASSERT(pViewShell!=nullptr);
433 return true;
434 }
435 sd::View* pView = pViewShell->GetView();
436 if (pView == nullptr)
437 {
438 OSL_ASSERT(pView!=nullptr);
439 return true;
440 }
441
442 m_xDropTargetHelper->SetDrawView(pViewShell->GetDrawView());
443 m_xDropTargetHelper->SetOrderFrontToBack(m_bOrderFrontToBack);
444 bIsInDrag = true;
445
446 std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
447 bool bUserData = m_xTreeView->get_cursor(xEntry.get());
448
449 SdrObject* pObject = nullptr;
450 sal_Int64 nUserData = bUserData ? m_xTreeView->get_id(*xEntry).toInt64() : 0;
451 if (nUserData != 1)
452 pObject = reinterpret_cast<SdrObject*>(nUserData);
453 if (pObject != nullptr)
454 {
455 // For shapes without a user supplied name (the automatically
456 // created name does not count), a different drag and drop technique
457 // is used.
458 if (GetObjectName(pObject, false).isEmpty())
459 {
461 m_xHelper->SetView(pView);
462 SD_MOD()->pTransferDrag = m_xHelper.get();
463 }
464
465 // Unnamed shapes have to be selected to be recognized by the
466 // current drop implementation. In order to have a consistent
467 // behaviour for all shapes, every shape that is to be dragged is
468 // selected first.
469 SdrPageView* pPageView = pView->GetSdrPageView();
470 pView->UnmarkAllObj(pPageView);
471 pView->MarkObj(pObject, pPageView);
472 }
473 else
474 {
475 m_xHelper->SetView(pView);
476 SD_MOD()->pTransferDrag = m_xHelper.get();
477 }
478
479 return false;
480}
481
483{
484 bIsInDrag = false;
485}
486
488 : DropTargetHelper(rTreeView.get_drop_target())
489 , m_rTreeView(rTreeView)
490 , m_pSdrView(nullptr)
491{
492}
493
498{
500 // only dragging within the same widget allowed
501 if (!pSource || pSource != &m_rTreeView)
502 return DND_ACTION_NONE;
503
504 std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
505 if (!m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), true))
506 return DND_ACTION_NONE;
507
508 // disallow when root is drop target
510 return DND_ACTION_NONE;
511
512 // disallow if there is no source entry selected
513 std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
514 if (!m_rTreeView.get_selected(xSource.get()))
515 return DND_ACTION_NONE;
516
517 // disallow when root is source
518 if (m_rTreeView.get_iter_depth(*xSource) == 0)
519 return DND_ACTION_NONE;
520
521 // disallow when the source is the parent or ancestral parent of the target
522 std::unique_ptr<weld::TreeIter> xTargetParent(m_rTreeView.make_iterator(xTarget.get()));
523 while (m_rTreeView.get_iter_depth(*xTargetParent) > 1)
524 {
525 if (!m_rTreeView.iter_parent(*xTargetParent) ||
526 m_rTreeView.iter_compare(*xSource, *xTargetParent) == 0)
527 return DND_ACTION_NONE;
528 }
529
530 // disallow drop when source and target are not within the same page
531 std::unique_ptr<weld::TreeIter> xSourcePage(m_rTreeView.make_iterator(xSource.get()));
532 std::unique_ptr<weld::TreeIter> xTargetPage(m_rTreeView.make_iterator(xTarget.get()));
533 while (m_rTreeView.get_iter_depth(*xTargetPage))
534 m_rTreeView.iter_parent(*xTargetPage);
535 while (m_rTreeView.get_iter_depth(*xSourcePage))
536 m_rTreeView.iter_parent(*xSourcePage);
537 if (m_rTreeView.iter_compare(*xTargetPage, *xSourcePage) != 0)
538 return DND_ACTION_NONE;
539
540 return DND_ACTION_MOVE;
541}
542
547{
549 // only dragging within the same widget allowed
550 if (!pSource || pSource != &m_rTreeView)
551 return DND_ACTION_NONE;
552
553 std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
554 if (!m_rTreeView.get_selected(xSource.get()))
555 return DND_ACTION_NONE;
556
557 std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
558 if (!m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get(), false))
559 return DND_ACTION_NONE;
560
561 auto nIterCompare = m_rTreeView.iter_compare(*xSource, *xTarget);
562 if (nIterCompare == 0)
563 {
564 // drop position is the same as source position
565 return DND_ACTION_NONE;
566 }
567
568 SdrObject* pTargetObject = weld::fromId<SdrObject*>(m_rTreeView.get_id(*xTarget));
569 SdrObject* pSourceObject = weld::fromId<SdrObject*>(m_rTreeView.get_id(*xSource));
570 if (pSourceObject == reinterpret_cast<SdrObject*>(1))
571 pSourceObject = nullptr;
572 if (pTargetObject == reinterpret_cast<SdrObject*>(1))
573 pTargetObject = nullptr;
574
575 if (pTargetObject != nullptr && pSourceObject != nullptr && m_pSdrView)
576 {
577 SdrPage* pObjectList = pSourceObject->getSdrPageFromSdrObject();
578
579 std::unique_ptr<weld::TreeIter> xSourceParent(m_rTreeView.make_iterator(xSource.get()));
580 m_rTreeView.iter_parent(*xSourceParent);
581 std::unique_ptr<weld::TreeIter> xTargetParent(m_rTreeView.make_iterator(xTarget.get()));
582 m_rTreeView.iter_parent(*xTargetParent);
583
585
586 // Make the tree view what the model will be when it is changed below.
587 m_rTreeView.move_subtree(*xSource, xTargetParent.get(), nTargetPos);
590
591 // Remove and insert are required for moving objects into and out of groups.
592 // PutMarked... by itself would suffice if this wasn't allowed.
593
594 // Remove the source object from source parent list and insert it in the target parent list.
595 SdrObject* pSourceParentObject = weld::fromId<SdrObject*>(m_rTreeView.get_id(*xSourceParent));
596 SdrObject* pTargetParentObject = weld::fromId<SdrObject*>(m_rTreeView.get_id(*xTargetParent));
597
598 // Presumably there is need for a hard reference to hold on to the removed object so it is
599 // guaranteed to be valid for insert back into an object list.
600 rtl::Reference<SdrObject> rSourceObject;
601
602 // remove object
603 if (pSourceParentObject == reinterpret_cast<SdrObject*>(1))
604 {
605 rSourceObject = pObjectList->NbcRemoveObject(pSourceObject->GetOrdNum());
606 }
607 else
608 {
609 SdrObjList* pList = pSourceParentObject->GetSubList();
610 rSourceObject = pList->NbcRemoveObject(pSourceObject->GetOrdNum());
611 }
612
613 // insert object
614 if (pTargetParentObject == reinterpret_cast<SdrObject*>(1))
615 {
616 pObjectList->NbcInsertObject(rSourceObject.get());
617 }
618 else
619 {
620 SdrObjList* pList = pTargetParentObject->GetSubList();
621 pList->NbcInsertObject(rSourceObject.get());
622 }
623
625 m_pSdrView->PutMarkedBehindObj(pTargetObject);
626 }
627
628 return DND_ACTION_NONE;
629}
630
632 SdTransferable& rTransferable,
633 const SdrObject& rObject) const
634{
635 std::unique_ptr<TransferableObjectDescriptor> pObjectDescriptor(new TransferableObjectDescriptor);
636 bool bIsDescriptorFillingPending (true);
637
638 const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
639 if (pOleObject != nullptr && pOleObject->GetObjRef().is())
640 {
641 // If object has no persistence it must be copied as part of the document
642 try
643 {
644 uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
645 if (xPersObj.is() && xPersObj->hasEntry())
646 {
648 *pObjectDescriptor,
649 pOleObject->GetObjRef(),
650 pOleObject->GetGraphic(),
651 pOleObject->GetAspect());
652 bIsDescriptorFillingPending = false;
653 }
654 }
655 catch( uno::Exception& )
656 {
657 }
658 }
659
660 ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
661 if (bIsDescriptorFillingPending && pDocShell!=nullptr)
662 {
663 pDocShell->FillTransferableObjectDescriptor(*pObjectDescriptor);
664 }
665
666 Point aDragPos (rObject.GetCurrentBoundRect().Center());
667 pObjectDescriptor->maDragStartPos = aDragPos;
668 if (pDocShell != nullptr)
669 pObjectDescriptor->maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
670 else
671 pObjectDescriptor->maDisplayName.clear();
672
673 rTransferable.SetStartPos(aDragPos);
674 rTransferable.SetObjectDescriptor( std::move(pObjectDescriptor) );
675}
676
678{
679 {
680 ::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
681 if (pViewShell != nullptr)
682 return pViewShell;
683 }
684
685 try
686 {
687 // Get a component enumeration from the desktop and search it for documents.
688 uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext());
689
690 uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext);
691
692 if ( ! xDesktop.is())
693 return nullptr;
694
695 uno::Reference<container::XIndexAccess> xFrameAccess = xDesktop->getFrames();
696 if ( ! xFrameAccess.is())
697 return nullptr;
698
699 for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex)
700 {
701 uno::Reference<frame::XFrame> xFrame;
702 if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame))
703 continue;
704
705 auto xController = xFrame->getController();
706 ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xController.get());
707 if (pController == nullptr)
708 continue;
709 ::sd::ViewShellBase* pBase = pController->GetViewShellBase();
710 if (pBase == nullptr)
711 continue;
712 if (pBase->GetDocShell() != &rDocShell)
713 continue;
714
715 const std::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell());
716 if (pViewShell)
717 return pViewShell.get();
718 }
719 }
720 catch (uno::Exception &)
721 {
722 // When there is an exception then simply use the default value of
723 // bIsEnabled and disable the controls.
724 }
725 return nullptr;
726}
727
728SdPageObjsTLV::SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeView)
729 : m_xTreeView(std::move(xTreeView))
730 , m_xScratchIter(m_xTreeView->make_iterator())
731 , m_xDropTargetHelper(new SdPageObjsTLVDropTarget(*m_xTreeView))
732 , m_xAccel(::svt::AcceleratorExecute::createAcceleratorHelper())
733 , m_pNavigator(nullptr)
734 , m_pDoc(nullptr)
735 , m_pBookmarkDoc(nullptr)
736 , m_pMedium(nullptr)
737 , m_pOwnMedium(nullptr)
738 , m_bLinkableSelected(false)
739 , m_bShowAllShapes(false)
740 , m_bOrderFrontToBack(false)
741 , m_bShowAllPages(false)
742 , m_bSelectionHandlerNavigates(false)
743 , m_bNavigationGrabsFocus(true)
744 , m_eSelectionMode(SelectionMode::Single)
745 , m_nSelectEventId(nullptr)
746 , m_nRowActivateEventId(nullptr)
747{
748 m_xTreeView->connect_expanding(LINK(this, SdPageObjsTLV, RequestingChildrenHdl));
749 m_xTreeView->connect_changed(LINK(this, SdPageObjsTLV, SelectHdl));
750 m_xTreeView->connect_row_activated(LINK(this, SdPageObjsTLV, RowActivatedHdl));
751 m_xTreeView->connect_drag_begin(LINK(this, SdPageObjsTLV, DragBeginHdl));
752 m_xTreeView->connect_key_press(LINK(this, SdPageObjsTLV, KeyInputHdl));
753 m_xTreeView->connect_mouse_press(LINK(this, SdPageObjsTLV, MousePressHdl));
754 m_xTreeView->connect_mouse_release(LINK(this, SdPageObjsTLV, MouseReleaseHdl));
755 m_xTreeView->connect_editing(LINK(this, SdPageObjsTLV, EditingEntryHdl),
756 LINK(this, SdPageObjsTLV, EditedEntryHdl));
757 m_xTreeView->connect_popup_menu(LINK(this, SdPageObjsTLV, CommandHdl));
758
759 m_xTreeView->set_size_request(m_xTreeView->get_approximate_digit_width() * 28,
760 m_xTreeView->get_text_height() * 8);
761}
762
763IMPL_LINK(SdPageObjsTLV, EditEntryAgain, void*, p, void)
764{
765 m_xTreeView->grab_focus();
766 std::unique_ptr<weld::TreeIter> xEntry(static_cast<weld::TreeIter*>(p));
767 m_xTreeView->start_editing(*xEntry);
768 m_bEditing = true;
769}
770
771IMPL_LINK_NOARG(SdPageObjsTLV, EditingEntryHdl, const weld::TreeIter&, bool)
772{
773 m_bEditing = true;
774 return true;
775}
776
777IMPL_LINK(SdPageObjsTLV, EditedEntryHdl, const IterString&, rIterString, bool)
778{
779 m_bEditing = false;
780
781 // Did the name change?
782 if (m_xTreeView->get_text(rIterString.first) == rIterString.second)
783 return true;
784
785 // If the new name is empty or not unique, start editing again.
786 if (rIterString.second.isEmpty() || m_pDoc->GetObj(rIterString.second))
787 {
788 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator(&rIterString.first));
789 Application::PostUserEvent(LINK(this, SdPageObjsTLV, EditEntryAgain), xEntry.release());
790 return false;
791 }
792
793 // set the new name
794 const auto& rEntryId = m_xTreeView->get_id(rIterString.first);
795 if (rEntryId.toInt64() == 1)
796 {
797 // page name
798 if (::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh())
799 {
800 if (::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell))
801 {
802 SdPage* pPage = pViewShell->GetActualPage();
803 pPage->SetName(rIterString.second);
804 }
805 }
806 }
807 else if (SdrObject* pCursorEntryObject = weld::fromId<SdrObject*>(rEntryId))
808 {
809 // object name
810 pCursorEntryObject->SetName(rIterString.second);
811 }
812
813 return true;
814}
815
817{
818 if (m_nSelectEventId)
819 Application::RemoveUserEvent(m_nSelectEventId);
820 // post the event to process select event after mouse press event
821 m_nSelectEventId = Application::PostUserEvent(LINK(this, SdPageObjsTLV, AsyncSelectHdl));
822}
823
825{
826 if (m_nRowActivateEventId)
827 Application::RemoveUserEvent(m_nRowActivateEventId);
828 // post the event to process row activate after mouse press event
829 m_nRowActivateEventId = Application::PostUserEvent(LINK(this, SdPageObjsTLV, AsyncRowActivatedHdl));
830 return false;
831}
832
833IMPL_LINK_NOARG(SdPageObjsTLV, AsyncSelectHdl, void*, void)
834{
835 Select();
836}
837
839{
840 m_nSelectEventId = nullptr;
841
842 if (IsEditingActive())
843 return;
844
845 m_bLinkableSelected = true;
846
847 m_xTreeView->selected_foreach([this](weld::TreeIter& rEntry){
848 if (m_xTreeView->get_id(rEntry).toInt64() == 0)
849 m_bLinkableSelected = false;
850 return false;
851 });
852
854
857
858 if (!m_pNavigator)
859 {
860 m_xHelper.clear();
861 return;
862 }
863
864 ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
865 OUString aURL = INetURLObject(pDocShell->GetMedium()->GetPhysicalName(), INetProtocol::File).GetMainURL(INetURLObject::DecodeMechanism::NONE);
867
868 OUString sSelectedEntry = get_cursor_text(); // what about multiple selections?
869 aURL += "#" + sSelectedEntry;
870
871 INetBookmark aBookmark(aURL, sSelectedEntry);
872 sal_Int8 nDNDActions = DND_ACTION_COPYMOVE;
873
874 if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
875 nDNDActions = DND_ACTION_LINK; // Either COPY *or* LINK, never both!
877 {
878 // Can not move away the last slide in a document.
879 nDNDActions = DND_ACTION_COPY;
880 }
881
882 // object is destroyed by internal reference mechanism
883 m_xHelper.set(new SdPageObjsTLV::SdPageObjsTransferable(std::move(aBookmark), *pDocShell, eDragType));
885 m_xTreeView->enable_drag_source(xHelper, nDNDActions);
886}
887
888IMPL_LINK_NOARG(SdPageObjsTLV, AsyncRowActivatedHdl, void*, void)
889{
890 m_nRowActivateEventId = nullptr;
891 m_aRowActivatedHdl.Call(*m_xTreeView);
892}
893
895 const SdrObject* pObject,
896 const bool bCreate) const
897{
898 OUString aRet;
899
900 if ( pObject )
901 {
902 aRet = pObject->GetName();
903
904 if (aRet.isEmpty())
905 if (auto pOleObj = dynamic_cast<const SdrOle2Obj* >(pObject))
906 aRet = pOleObj->GetPersistName();
907 }
908
909 if (bCreate
911 && aRet.isEmpty()
912 && pObject!=nullptr)
913 {
914 aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME) + " (" + pObject->TakeObjNameSingul() +")";
915 aRet = aRet.replaceFirst("%1", OUString::number(pObject->GetOrdNum() + 1));
916 }
917
918 return aRet;
919}
920
921std::vector<OUString> SdPageObjsTLV::GetSelectEntryList(const int nDepth) const
922{
923 std::vector<OUString> aEntries;
924
925 m_xTreeView->selected_foreach([this, nDepth, &aEntries](weld::TreeIter& rEntry){
926 int nListDepth = m_xTreeView->get_iter_depth(rEntry);
927 if (nListDepth == nDepth)
928 aEntries.push_back(m_xTreeView->get_text(rEntry));
929 return false;
930 });
931
932 return aEntries;
933}
934
935std::vector<OUString> SdPageObjsTLV::GetSelectedEntryIds() const
936{
937 std::vector<OUString> vEntryIds;
938
939 m_xTreeView->selected_foreach([this, &vEntryIds](weld::TreeIter& rEntry){
940 vEntryIds.push_back(m_xTreeView->get_id(rEntry));
941 return false;
942 });
943
944 return vEntryIds;
945}
946
952{
953 if (
955 (pMed && (!m_pOwnMedium || m_pOwnMedium->GetName() != pMed->GetName()))
956 )
957 {
958 // create a new BookmarkDoc if now one exists or if a new Medium is provided
959 if (m_pOwnMedium != pMed)
960 {
962 }
963
964 if (pMed)
965 {
966 // it looks that it is undefined if a Medium was set by Fill() already
967 DBG_ASSERT( !m_pMedium, "SfxMedium confusion!" );
968 delete m_pMedium;
969 m_pMedium = nullptr;
970
971 // take over this Medium (currently used only be Navigator)
972 m_pOwnMedium = pMed;
973 }
974
975 DBG_ASSERT( m_pMedium || pMed, "No SfxMedium provided!" );
976
977 if( pMed )
978 {
979 // in this mode the document is also owned and controlled by this instance
980 m_xBookmarkDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::STANDARD, true, DocumentType::Impress);
981 if (m_xBookmarkDocShRef->DoLoad(pMed))
983 else
984 m_pBookmarkDoc = nullptr;
985 }
986 else if ( m_pMedium )
987 // in this mode the document is owned and controlled by the SdDrawDocument
988 // it can be released by calling the corresponding CloseBookmarkDoc method
989 // successful creation of a document makes this the owner of the medium
990 m_pBookmarkDoc = const_cast<SdDrawDocument*>(m_pDoc)->OpenBookmarkDoc(m_pMedium);
991
992 if ( !m_pBookmarkDoc )
993 {
994 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xTreeView.get(),
995 VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR)));
996 xErrorBox->run();
997 m_pMedium = nullptr; //On failure the SfxMedium is invalid
998 }
999 }
1000
1001 return m_pBookmarkDoc;
1002}
1003
1007IMPL_LINK(SdPageObjsTLV, RequestingChildrenHdl, const weld::TreeIter&, rFileEntry, bool)
1008{
1009 if (!m_xTreeView->iter_has_child(rFileEntry))
1010 {
1011 if (GetBookmarkDoc())
1012 {
1013 SdrObject* pObj = nullptr;
1014
1015 OUString sImgPage(BMP_PAGE);
1016 OUString sImgPageObjs(BMP_PAGEOBJS);
1017 OUString sImgObjects(BMP_OBJECTS);
1018 OUString sImgOle(BMP_OLE);
1019 OUString sImgGraphic(BMP_GRAPHIC);
1020
1021 // document name already inserted
1022
1023 // only insert all "normal" ? slides with objects
1024 sal_uInt16 nPage = 0;
1025 const sal_uInt16 nMaxPages = m_pBookmarkDoc->GetPageCount();
1026
1027 std::unique_ptr<weld::TreeIter> xPageEntry;
1028 while (nPage < nMaxPages)
1029 {
1030 SdPage* pPage = static_cast<SdPage*>(m_pBookmarkDoc->GetPage(nPage));
1031 if (pPage->GetPageKind() == PageKind::Standard)
1032 {
1033 OUString sId(OUString::number(1));
1034 m_xTreeView->insert(&rFileEntry, -1, &pPage->GetName(), &sId,
1035 nullptr, nullptr, false, m_xScratchIter.get());
1036 m_xTreeView->set_image(*m_xScratchIter, sImgPage);
1037
1038 if (!xPageEntry)
1039 {
1040 xPageEntry = m_xTreeView->make_iterator(&rFileEntry);
1041 (void)m_xTreeView->iter_children(*xPageEntry);
1042 }
1043 else
1044 (void)m_xTreeView->iter_next_sibling(*xPageEntry);
1045
1046 SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
1047
1048 while( aIter.IsMore() )
1049 {
1050 pObj = aIter.Next();
1051 OUString aStr( GetObjectName( pObj ) );
1052 if( !aStr.isEmpty() )
1053 {
1054 if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::OLE2 )
1055 {
1056 m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr,
1057 nullptr, nullptr, false, m_xScratchIter.get());
1058 m_xTreeView->set_image(*m_xScratchIter, sImgOle);
1059 }
1060 else if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::Graphic )
1061 {
1062 m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr,
1063 nullptr, nullptr, false, m_xScratchIter.get());
1064 m_xTreeView->set_image(*m_xScratchIter, sImgGraphic);
1065 }
1066 else
1067 {
1068 m_xTreeView->insert(xPageEntry.get(), -1, &aStr, nullptr,
1069 nullptr, nullptr, false, m_xScratchIter.get());
1070 m_xTreeView->set_image(*m_xScratchIter, sImgObjects);
1071 }
1072 }
1073 }
1074 if (m_xTreeView->iter_has_child(*xPageEntry))
1075 {
1076 m_xTreeView->set_image(*xPageEntry, sImgPageObjs);
1077 }
1078 }
1079 nPage++;
1080 }
1081 }
1082 }
1083 return true;
1084}
1085
1087{
1088 m_pNavigator = pNavigator;
1089}
1090
1092{
1094 std::shared_ptr<sd::ViewShell> xViewShell = pBase->GetMainViewShell();
1095 SAL_WARN_IF(!xViewShell, "sd", "null pBaseViewFrame");
1096 const css::uno::Reference< css::frame::XFrame > xFrame = xViewShell ? xViewShell->GetViewFrame()->GetFrame().GetFrameInterface() : nullptr;
1097 m_xAccel->init(::comphelper::getProcessComponentContext(), xFrame);
1098}
1099
1104{
1105 if (m_xBookmarkDocShRef.is())
1106 {
1107 m_xBookmarkDocShRef->DoClose();
1109
1110 // Medium is owned by document, so it's destroyed already
1111 m_pOwnMedium = nullptr;
1112 }
1113 else if (m_pBookmarkDoc)
1114 {
1115 DBG_ASSERT(!m_pOwnMedium, "SfxMedium confusion!");
1116 if (m_pDoc)
1117 {
1118 // The document owns the Medium, so the Medium will be invalid after closing the document
1119 const_cast<SdDrawDocument*>(m_pDoc)->CloseBookmarkDoc();
1120 m_pMedium = nullptr;
1121 }
1122 }
1123 else
1124 {
1125 // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc
1126 delete m_pOwnMedium;
1127 m_pOwnMedium = nullptr;
1128 }
1129
1130 m_pBookmarkDoc = nullptr;
1131}
1132
1134{
1135 // Return <TRUE/> as default when there is no custom show or when none
1136 // is used. The page does then belong to the standard show.
1137 bool bBelongsToShow = true;
1138
1140 {
1141 // Get the current custom show.
1142 SdCustomShow* pCustomShow = nullptr;
1143 SdCustomShowList* pShowList = const_cast<SdDrawDocument*>(m_pDoc)->GetCustomShowList();
1144 if (pShowList != nullptr)
1145 {
1146 sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
1147 pCustomShow = (*pShowList)[nCurrentShowIndex].get();
1148 }
1149
1150 // Check whether the given page is part of that custom show.
1151 if (pCustomShow != nullptr)
1152 {
1153 bBelongsToShow = false;
1154 size_t nPageCount = pCustomShow->PagesVector().size();
1155 for (size_t i=0; i<nPageCount && !bBelongsToShow; i++)
1156 if (pPage == pCustomShow->PagesVector()[i])
1157 bBelongsToShow = true;
1158 }
1159 }
1160
1161 return bBelongsToShow;
1162}
1163
1165 const SdrObjList& rList,
1166 const SdrObject* pShape,
1167 const OUString& rsName,
1168 const bool bIsExcluded,
1169 const weld::TreeIter* pParentEntry)
1170{
1171 OUString aIcon(BMP_PAGE);
1172 if (bIsExcluded)
1173 aIcon = BMP_PAGE_EXCLUDED;
1174 else if (pShape != nullptr)
1175 aIcon = BMP_GROUP;
1176
1177 OUString aUserData("1");
1178 if (pShape != nullptr)
1179 aUserData = weld::toId(pShape);
1180
1181 std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
1182 InsertEntry(pParentEntry, aUserData, rsName, aIcon, xEntry.get());
1183
1184 SdrObjListIter aIter(
1185 &rList,
1186 !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
1187 SdrIterMode::Flat);
1188
1189 while( aIter.IsMore() )
1190 {
1191 SdrObject* pObj = aIter.Next();
1192 OSL_ASSERT(pObj!=nullptr);
1193
1194 // Get the shape name.
1195 OUString aStr (GetObjectName( pObj ) );
1196 OUString sId(weld::toId(pObj));
1197
1198 if( !aStr.isEmpty() )
1199 {
1200 if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::OLE2 )
1201 {
1202 InsertEntry(xEntry.get(), sId, aStr, BMP_OLE);
1203 }
1204 else if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::Graphic )
1205 {
1206 InsertEntry(xEntry.get(), sId, aStr, BMP_GRAPHIC);
1207 }
1208 else if (pObj->IsGroupObject())
1209 {
1211 *pObj->GetSubList(),
1212 pObj,
1213 aStr,
1214 false,
1215 xEntry.get());
1216 }
1217 else
1218 {
1219 InsertEntry(xEntry.get(), sId, aStr, BMP_OBJECTS);
1220 }
1221 }
1222 }
1223
1224 if (!m_xTreeView->iter_has_child(*xEntry))
1225 return;
1226
1227 if (bIsExcluded)
1228 m_xTreeView->set_image(*xEntry, BMP_PAGEOBJS_EXCLUDED);
1229 else
1230 m_xTreeView->set_image(*xEntry, BMP_PAGEOBJS);
1231 m_xTreeView->expand_row(*xEntry);
1232}
1233
1237void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, bool bAllPages, const OUString& rDocName)
1238{
1239 OUString aSelection = m_xTreeView->get_selected_text();
1240 clear();
1241
1242 m_pDoc = pInDoc;
1243 m_aDocName = rDocName;
1244 m_bShowAllPages = bAllPages;
1245 m_pMedium = nullptr;
1246
1247 // first insert all pages including objects
1248 sal_uInt16 nPage = 0;
1249 const sal_uInt16 nMaxPages = m_pDoc->GetPageCount();
1250
1251 sd::DrawViewShell* pDrawViewShell = lcl_getDrawViewShell(m_pDoc);
1252 if (!pDrawViewShell)
1253 return;
1254 PageKind eDrawViewShellPageKind = pDrawViewShell->GetPageKind();
1255
1256 while( nPage < nMaxPages )
1257 {
1258 const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetPage( nPage ) );
1259 PageKind ePagePageKind = pPage->GetPageKind();
1260 if ((m_bShowAllPages ||
1261 (ePagePageKind == PageKind::Standard &&
1262 eDrawViewShellPageKind == PageKind::Standard) ||
1263 (ePagePageKind == PageKind::Notes &&
1264 eDrawViewShellPageKind == PageKind::Notes)) &&
1265 ePagePageKind != PageKind::Handout) //#94954# never list the normal handout page ( handout-masterpage is used instead )
1266 {
1267 bool bPageExcluded = pPage->IsExcluded();
1268
1269 bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
1270 bPageExcluded |= !bPageBelongsToShow;
1271
1272 AddShapeList(*pPage, nullptr, pPage->GetName(), bPageExcluded, nullptr);
1273 }
1274 nPage++;
1275 }
1276
1277 // then insert all master pages including objects
1278 if( m_bShowAllPages )
1279 {
1280 nPage = 0;
1281 const sal_uInt16 nMaxMasterPages = m_pDoc->GetMasterPageCount();
1282
1283 while( nPage < nMaxMasterPages )
1284 {
1285 const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetMasterPage( nPage ) );
1286 AddShapeList(*pPage, nullptr, pPage->GetName(), false, nullptr);
1287 nPage++;
1288 }
1289 }
1290 if (!aSelection.isEmpty())
1291 {
1292 m_xTreeView->all_foreach([this, &aSelection](weld::TreeIter& rEntry){
1293 if (m_xTreeView->get_text(rEntry) == aSelection)
1294 {
1295 m_xTreeView->select(rEntry);
1296 return true;
1297 }
1298 return false;
1299 });
1300 }
1301}
1302
1306void SdPageObjsTLV::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
1307 const OUString& rDocName )
1308{
1309 m_pDoc = pInDoc;
1310
1311 // this object now owns the Medium
1312 m_pMedium = pInMedium;
1313 m_aDocName = rDocName;
1314
1315 OUString sId(OUString::number(1));
1316 // insert document name
1317 m_xTreeView->insert(nullptr, -1, &m_aDocName, &sId, nullptr, nullptr, true, m_xScratchIter.get());
1318 m_xTreeView->set_image(*m_xScratchIter, BMP_DOC_OPEN);
1319}
1320
1324bool SdPageObjsTLV::SelectEntry( std::u16string_view rName )
1325{
1326 bool bFound = false;
1327
1328 if (!rName.empty())
1329 {
1330 std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
1331 OUString aTmp;
1332
1333 if (m_xTreeView->get_iter_first(*xEntry))
1334 {
1335 do
1336 {
1337 aTmp = m_xTreeView->get_text(*xEntry);
1338 if (aTmp == rName)
1339 {
1340 m_xTreeView->set_cursor(*xEntry);
1341 m_xTreeView->select(*xEntry);
1342 bFound = true;
1343 break;
1344 }
1345 }
1346 while (m_xTreeView->iter_next(*xEntry));
1347 }
1348 }
1349
1350 return bFound;
1351}
1352
1354{
1355 if (pObj)
1356 {
1357 m_xTreeView->all_foreach([this, &pObj](weld::TreeIter& rEntry){
1358 if (weld::fromId<SdrObject*>(m_xTreeView->get_id(rEntry)) == pObj)
1359 {
1360 // Only scroll to the row of the first selected. And only when the treeview
1361 // doesn't have the focus.
1362 if (!m_xTreeView->has_focus() && m_xTreeView->get_selected_rows().empty())
1363 m_xTreeView->set_cursor(rEntry);
1364 m_xTreeView->select(rEntry);
1365 return true;
1366 }
1367 return false;
1368 });
1369 }
1370}
1371
1373{
1374 if (m_nSelectEventId)
1378
1379 if (m_pBookmarkDoc)
1381 else
1382 {
1383 // no document was created from m_pMedium, so this object is still the owner of it
1384 delete m_pMedium;
1385 }
1386 m_xAccel.reset();
1387}
1388
1389/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
sal_uInt16 GetCurPos() const
PageVec & PagesVector()
Provides a direct access to the collection of the SdPage objects.
Definition: cusshow.hxx:52
SAL_DLLPRIVATE const sd::PresentationSettings & getPresentationSettings() const
Definition: drawdoc.hxx:400
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
NavigatorDragType GetNavigatorDragType()
DragType is set on dependence if a Drag is even possible.
Definition: navigatr.cxx:229
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
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
AcceptDrop-Event.
Definition: sdtreelb.cxx:497
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
Definition: sdtreelb.cxx:105
virtual ~SdPageObjsTransferable() override
Definition: sdtreelb.cxx:94
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: sdtreelb.cxx:126
SdPageObjsTransferable(INetBookmark aBookmark, ::sd::DrawDocShell &rDocShell, NavigatorDragType eDragType)
Definition: sdtreelb.cxx:83
static SdPageObjsTransferable * getImplementation(const css::uno::Reference< css::uno::XInterface > &rxData) noexcept
Definition: sdtreelb.cxx:132
virtual void AddSupportedFormats() override
Definition: sdtreelb.cxx:98
static SotClipboardFormatId GetListBoxDropFormatId()
Return a temporary transferable data flavor that is used internally in the navigator for reordering e...
Definition: sdtreelb.cxx:138
static SotClipboardFormatId mnListBoxDropFormatId
Temporary drop flavor id that is used internally in the navigator.
Definition: sdtreelb.hxx:445
bool IsEqualToDoc(const SdDrawDocument *pInDoc)
Checks if the pages (PageKind::Standard) of a doc and the objects on the pages are identical to the T...
Definition: sdtreelb.cxx:258
::sd::DrawDocShellRef m_xBookmarkDocShRef
for the loading of bookmarks
Definition: sdtreelb.hxx:113
SdDrawDocument * m_pBookmarkDoc
Definition: sdtreelb.hxx:82
std::unique_ptr< weld::TreeView > m_xTreeView
Definition: sdtreelb.hxx:76
void Fill(const SdDrawDocument *, bool bAllPages, const OUString &rDocName)
Fill TreeLB with pages and objects.
Definition: sdtreelb.cxx:1237
void SetShowAllShapes(const bool bShowAllShapes, const bool bFill)
Definition: sdtreelb.cxx:183
SdPageObjsTLV(std::unique_ptr< weld::TreeView > xTreeview)
Definition: sdtreelb.cxx:728
OUString get_cursor_text() const
Definition: sdtreelb.hxx:312
bool IsEditingActive() const
Definition: sdtreelb.hxx:176
SfxMedium * m_pMedium
Definition: sdtreelb.hxx:83
bool DoDrag()
Begin drag.
Definition: sdtreelb.cxx:419
void SetViewFrame(const SfxViewFrame *pViewFrame)
Definition: sdtreelb.cxx:1091
const SdDrawDocument * m_pDoc
Definition: sdtreelb.hxx:81
static bool IsInDrag()
Definition: sdtreelb.cxx:76
void AddShapeToTransferable(SdTransferable &rTransferable, const SdrObject &rObject) const
Add the given object to a transferable object so that the object can be dragged and dropped without h...
Definition: sdtreelb.cxx:631
bool StartDrag()
StartDrag-Request.
Definition: sdtreelb.cxx:411
SdNavigatorWin * m_pNavigator
Definition: sdtreelb.hxx:80
Link< const CommandEvent &, bool > m_aPopupMenuHdl
Definition: sdtreelb.hxx:118
bool m_bNavigationGrabsFocus
If navigation should not only select the relevant shape but also change focus to it.
Definition: sdtreelb.hxx:103
void SetSdNavigator(SdNavigatorWin *pNavigator)
Definition: sdtreelb.cxx:1086
bool PageBelongsToCurrentShow(const SdPage *pPage) const
Determine whether the specified page belongs to the current show which is either the standard show or...
Definition: sdtreelb.cxx:1133
OUString m_aDocName
Definition: sdtreelb.hxx:112
void clear()
Definition: sdtreelb.hxx:418
ImplSVEvent * m_nRowActivateEventId
Definition: sdtreelb.hxx:110
OUString GetObjectName(const SdrObject *pObject, const bool bCreate=true) const
Return the name of the object.
Definition: sdtreelb.cxx:894
std::unique_ptr<::svt::AcceleratorExecute > m_xAccel
Definition: sdtreelb.hxx:79
bool IsEqualToShapeList(std::unique_ptr< weld::TreeIter > &rEntry, const SdrObjList &rList, std::u16string_view rListName)
Visits rList recursively and tries to advance rEntry accordingly.
Definition: sdtreelb.cxx:202
void SetOrderFrontToBack(const bool bOrderFrontToBack)
Definition: sdtreelb.cxx:197
bool m_bShowAllShapes
Definition: sdtreelb.hxx:86
::sd::ViewShell * GetViewShellForDocShell(::sd::DrawDocShell &rDocShell)
Return the view shell that is linked to the given doc shell.
Definition: sdtreelb.cxx:677
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
static void OnDragFinished()
Definition: sdtreelb.cxx:482
void InsertEntry(const OUString &rName, const OUString &rExpander)
Definition: sdtreelb.hxx:396
std::vector< OUString > GetSelectedEntryIds() const
Definition: sdtreelb.cxx:935
Link< weld::TreeView &, bool > m_aRowActivatedHdl
Definition: sdtreelb.hxx:115
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
ImplSVEvent * m_nSelectEventId
Definition: sdtreelb.hxx:109
SfxMedium * m_pOwnMedium
Definition: sdtreelb.hxx:84
void Select()
Definition: sdtreelb.cxx:838
SdDrawDocument * GetBookmarkDoc(SfxMedium *pMedium=nullptr)
Checks if it is a draw file and opens the BookmarkDoc depending of the provided Docs.
Definition: sdtreelb.cxx:951
bool m_bShowAllPages
This flag controls whether to show all pages.
Definition: sdtreelb.hxx:91
void CloseBookmarkDoc()
Close and delete bookmark document.
Definition: sdtreelb.cxx:1103
rtl::Reference< SdPageObjsTransferable > m_xHelper
Definition: sdtreelb.hxx:460
std::vector< OUString > GetSelectEntryList(const int nDepth) const
return selected entries nDepth == 0 -> pages nDepth == 1 -> objects
Definition: sdtreelb.cxx:921
Link< weld::TreeView &, void > m_aChangeHdl
Definition: sdtreelb.hxx:114
Link< const KeyEvent &, bool > m_aKeyPressHdl
Definition: sdtreelb.hxx:116
bool HasSelectedChildren(std::u16string_view rName)
Definition: sdtreelb.cxx:148
void AddShapeList(const SdrObjList &rList, const SdrObject *pShape, const OUString &rsName, const bool bIsExcluded, const weld::TreeIter *pParentEntry)
Add one list box entry for the parent of the given shapes and one child entry for each of the given s...
Definition: sdtreelb.cxx:1164
Link< const MouseEvent &, bool > m_aMouseReleaseHdl
Definition: sdtreelb.hxx:117
bool SelectEntry(std::u16string_view rName)
select an entry in TreeLB
Definition: sdtreelb.cxx:1324
bool m_bLinkableSelected
Definition: sdtreelb.hxx:85
PageKind GetPageKind() const
Definition: sdpage.hxx:205
bool IsExcluded() const
Definition: sdpage.hxx:223
const OUString & GetName() const
Definition: sdpage.cxx:2505
void SetName(const OUString &rName)
Set the name of the page and broadcast a model change.
Definition: sdpage.cxx:2703
void SetStartPos(const Point &rStartPos)
Definition: sdxfer.hxx:58
virtual void DragFinished(sal_Int8 nDropAction) override
Definition: sdxfer.cxx:636
void SetObjectDescriptor(std::unique_ptr< TransferableObjectDescriptor > pObjDesc)
Definition: sdxfer.cxx:658
void PutMarkedBehindObj(const SdrObject *pRefObj)
void PutMarkedInFrontOfObj(const SdrObject *pRefObj)
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
const SdrPage * GetMasterPage(sal_uInt16 nPgNum) const
sal_uInt16 GetMasterPageCount() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
SdrObject * Next()
bool IsMore() const
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
bool HasObjectNavigationOrder() const
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum)
virtual SdrInventor GetObjInventor() const
sal_uInt32 GetOrdNum() const
virtual SdrObjList * GetSubList() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
bool IsGroupObject() const
virtual SdrObjKind GetObjIdentifier() const
SdrPage * getSdrPageFromSdrObject() const
sal_Int64 GetAspect() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
const Graphic * GetGraphic() const
SdrPageView * GetSdrPageView() const
const INetURLObject & GetURLObject() const
const OUString & GetName() const
const OUString & GetPhysicalName() const
void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc) const
SfxMedium * GetMedium() const
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId RegisterFormatMimeType(const OUString &rMimeType)
static void FillTransferableObjectDescriptor(TransferableObjectDescriptor &rDesc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, const Graphic *pGraphic, sal_Int64 nAspect)
The DrawController is the UNO controller for Impress and Draw.
ViewShellBase * GetViewShellBase()
Return a pointer to the ViewShellBase object that the DrawController is connected to.
sd::ViewShell * GetViewShell()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
PageKind GetPageKind() const
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
static ViewShellBase * GetViewShellBase(SfxViewFrame const *pFrame)
When given a view frame this static method returns the corresponding sd::ViewShellBase object.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
DrawDocShell * GetDocShell() const
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SdrView * GetDrawView() const
Definition: ViewShell.hxx:552
constexpr Point Center() const
bool is() const
sal_uInt16 GetCode() const
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const=0
virtual bool get_selected(TreeIter *pIter) const=0
virtual int get_iter_index_in_parent(const TreeIter &rIter) const=0
virtual TreeView * get_drag_source() const=0
virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter *pResult, bool bDnDMode, bool bAutoScroll=true)=0
virtual bool iter_parent(TreeIter &rIter) const=0
virtual int iter_compare(const TreeIter &a, const TreeIter &b) const=0
virtual bool iter_previous_sibling(TreeIter &rIter) const=0
virtual void set_cursor(int pos)=0
virtual int get_iter_depth(const TreeIter &rIter) const=0
virtual void move_subtree(TreeIter &rNode, const TreeIter *pNewParent, int nIndexInNewParent)=0
virtual OUString get_id(int pos) const=0
int nCount
#define DBG_ASSERT(sCon, aError)
URL aURL
ScXMLEditAttributeMap::Entry const aEntries[]
EmbeddedObjectRef * pObject
Reference< XInterface > xTarget
SotClipboardFormatId
sal_Int32 nIndex
OUString aName
void * p
constexpr sal_uInt16 KEY_RETURN
#define SAL_WARN_IF(condition, area, stream)
aStr
int i
OUString toId(const void *pValue)
NavigatorDragType
Definition: pres.hxx:65
@ NAVIGATOR_DRAGTYPE_LINK
Definition: pres.hxx:68
PageKind
Definition: pres.hxx:45
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
#define SD_MOD()
Definition: sdmod.hxx:184
IMPL_LINK_NOARG(SdPageObjsTLV, MouseReleaseHdl, const MouseEvent &, bool)
Definition: sdtreelb.cxx:363
IMPL_LINK(SdPageObjsTLV, CommandHdl, const CommandEvent &, rCEvt, bool)
Definition: sdtreelb.cxx:297
sal_uIntPtr sal_uLong
Reference< XController > xController
Reference< XFrame > xFrame
#define DND_ACTION_COPYMOVE
#define DND_ACTION_MOVE
#define DND_ACTION_COPY
#define DND_ACTION_LINK
#define DND_ACTION_NONE
signed char sal_Int8
#define SAL_MAX_UINT32
OUString sId
SelectionMode