LibreOffice Module sd (master) 1
navigatr.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 <memory>
21#include <sal/config.h>
22
23#include <osl/file.hxx>
24#include <tools/urlobj.hxx>
25#include <sfx2/fcontnr.hxx>
26#include <svl/stritem.hxx>
27#include <sfx2/docfile.hxx>
28#include <svl/intitem.hxx>
29#include <sfx2/dispatch.hxx>
30
31#include <sfx2/viewfrm.hxx>
32
33#include <pres.hxx>
34#include <navigatr.hxx>
35#include <pgjump.hxx>
36#include <app.hrc>
37
38#include <bitmaps.hlst>
39#include <drawdoc.hxx>
40#include <DrawDocShell.hxx>
41#include <ViewShell.hxx>
42#include <ViewShellBase.hxx>
43#include <slideshow.hxx>
44#include <FrameView.hxx>
45#include <Window.hxx>
46
47#include <DrawViewShell.hxx>
48#include <utility>
49
50#include <vcl/commandevent.hxx>
51#include <comphelper/lok.hxx>
52
57 : PanelLayout(pParent, "NavigatorPanel", "modules/simpress/ui/navigatorpanel.ui")
58 , mxToolbox(m_xBuilder->weld_toolbar("toolbox"))
59 , mxTlbObjects(new SdPageObjsTLV(m_xBuilder->weld_tree_view("tree")))
60 , mxLbDocs(m_xBuilder->weld_combo_box("documents"))
61 , mxDragModeMenu(m_xBuilder->weld_menu("dragmodemenu"))
62 , mxShapeMenu(m_xBuilder->weld_menu("shapemenu"))
63 , mxNavigatorDlg(pNavigatorDlg)
64 , mbDocImported ( false )
65 // On changes of the DragType: adjust SelectionMode of TLB!
66 , meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED )
67 , mpBindings ( pInBindings )
68{
69 mxTlbObjects->SetViewFrame( mpBindings->GetDispatcher()->GetFrame() );
70
71 mxTlbObjects->connect_row_activated(LINK(this, SdNavigatorWin, ClickObjectHdl));
72 mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
73 mxTlbObjects->connect_mouse_release(LINK(this, SdNavigatorWin, MouseReleaseHdl));
74 mxTlbObjects->connect_popup_menu(LINK(this, SdNavigatorWin, CommandHdl));
75
76 mxToolbox->connect_clicked(LINK(this, SdNavigatorWin, SelectToolboxHdl));
77 mxToolbox->connect_menu_toggled(LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl));
78
79 mxToolbox->set_item_menu("dragmode", mxDragModeMenu.get());
80 mxDragModeMenu->connect_activate(LINK(this, SdNavigatorWin, MenuSelectHdl));
81
82 // Shape filter drop down menu.
83 mxToolbox->set_item_menu("shapes", mxShapeMenu.get());
84 mxShapeMenu->connect_activate(LINK(this, SdNavigatorWin, ShapeFilterCallback));
85
86 mxTlbObjects->SetSdNavigator(this);
87
88 // DragTypeListBox
89 mxLbDocs->set_size_request(42, -1); // set a nominal width so it takes width of surroundings
90 mxLbDocs->connect_changed(LINK(this, SdNavigatorWin, SelectDocumentHdl));
91
93
94 mxToolbox->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl));
95 mxTlbObjects->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl));
96 mxLbDocs->connect_key_press(LINK(this, SdNavigatorWin, KeyInputHdl));
98 {
99 mxToolbox->hide();
100 mxLbDocs->hide();
101 }
102}
103
105{
106 // set focus to listbox, otherwise it is in the toolbox which is only useful
107 // for keyboard navigation
108 mxTlbObjects->grab_focus();
109}
110
112{
113 if (mxNavigatorDlg)
114 return mxNavigatorDlg->GetFrameWeld();
116}
117
119{
120 mpNavigatorCtrlItem.reset( new SdNavigatorControllerItem(SID_NAVIGATOR_STATE, this, mpBindings, rUpdateRequest) );
121 mpPageNameCtrlItem.reset( new SdPageNameControllerItem(SID_NAVIGATOR_PAGENAME, this, mpBindings) );
122
123 // InitTlb; is initiated over Slot
124 if (rUpdateRequest)
125 rUpdateRequest();
126}
127
129{
130 mpNavigatorCtrlItem.reset();
131 mpPageNameCtrlItem.reset();
132 mxDragModeMenu.reset();
133 mxShapeMenu.reset();
134 mxToolbox.reset();
135 mxTlbObjects.reset();
136 mxLbDocs.reset();
137}
138
139static void lcl_select_marked_object(const sd::ViewShell* pViewShell, SdPageObjsTLV* pTlbObjects)
140{
141 if (const SdrView* pView = pViewShell->GetDrawView())
142 {
143 auto vMarkedObjects = pView->GetMarkedObjects();
144 if (vMarkedObjects.size())
145 {
146 pTlbObjects->unselect_all();
147 for (auto rMarkedObject: vMarkedObjects)
148 pTlbObjects->SelectEntry(rMarkedObject);
149 }
150 else
151 pTlbObjects->SelectEntry(pViewShell->GetName());
152 }
153}
154
155//when object is marked , fresh the corresponding entry tree .
157{
158 SdDrawDocument* pNonConstDoc = const_cast<SdDrawDocument*>(pDoc); // const as const can...
159 sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
160 const OUString& aDocShName( pDocShell->GetName() );
161 OUString aDocName = pDocShell->GetMedium()->GetName();
162 if (!mxTlbObjects->IsEqualToDoc(pDoc))
163 {
164 mxTlbObjects->Fill( pDoc, false, aDocName ); // Only normal pages
166 mxLbDocs->set_active_text(aDocShName);
167 }
168 if (const sd::ViewShell* pViewShell = pDocShell->GetViewShell())
169 lcl_select_marked_object(pViewShell, mxTlbObjects.get());
170}
171
173{
174 SdDrawDocument* pNonConstDoc = const_cast<SdDrawDocument*>(pDoc); // const as const can...
175 ::sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
176 OUString aDocShName( pDocShell->GetName() );
177 ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
178
179 // Restore the 'ShowAllShapes' flag from the last time (in this session)
180 // that the navigator was shown.
181 if (pViewShell != nullptr)
182 {
183 ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
184 if (pFrameView != nullptr)
185 mxTlbObjects->SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
186 }
187
188 // Disable the shape filter drop down menu when there is a running slide
189 // show.
190 if (pViewShell!=nullptr && sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ))
191 mxToolbox->set_item_sensitive("shapes", false);
192 else
193 mxToolbox->set_item_sensitive("shapes", true);
194
195 if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
196 {
197 OUString aDocName = pDocShell->GetMedium()->GetName();
198 mxTlbObjects->clear();
199 mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
200
202 mxLbDocs->set_active_text(aDocShName);
203 }
204 else
205 {
206 mxLbDocs->set_active(-1);
207 mxLbDocs->set_active_text(aDocShName);
208
209// commented in order to fix 30246
210// if( mxLbDocs->get_active() == -1 )
211 {
213 mxLbDocs->set_active_text(aDocShName);
214 }
215 }
216
217 if (pViewShell)
218 lcl_select_marked_object(pViewShell, mxTlbObjects.get());
219
220 SfxViewFrame* pViewFrame = ( ( pViewShell && pViewShell->GetViewFrame() ) ? pViewShell->GetViewFrame() : SfxViewFrame::Current() );
221 if( pViewFrame )
222 pViewFrame->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME, true, true);
223}
224
230{
232 NavDocInfo* pInfo = GetDocInfo();
233
234 if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() ) )
236
237 return eDT;
238}
239
241{
242 return *mxTlbObjects;
243}
244
245IMPL_STATIC_LINK_NOARG(SdNavigatorWin, MouseReleaseHdl, const MouseEvent&, bool)
246{
247 return true;
248}
249
250IMPL_LINK(SdNavigatorWin, CommandHdl, const CommandEvent&, rCEvt, bool)
251{
252 if (rCEvt.GetCommand() != CommandEventId::ContextMenu)
253 return false;
254 weld::TreeView& rTreeView = GetObjects().get_treeview();
255 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&rTreeView,
256 "modules/sdraw/ui/navigatorcontextmenu.ui"));
257 std::unique_ptr<weld::Menu> xPop = xBuilder->weld_menu("navmenu");
258 OUString sCommand = xPop->popup_at_rect(&rTreeView,
259 tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1)));
260 if (!sCommand.isEmpty())
261 ExecuteContextMenuAction(sCommand);
262 return true;
263}
264
265void SdNavigatorWin::ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry)
266{
267 if (rSelectedPopupEntry == u"rename")
269}
270
271IMPL_LINK(SdNavigatorWin, SelectToolboxHdl, const OUString&, rCommand, void)
272{
273 PageJump ePage = PAGE_NONE;
274
275 if (rCommand == "first")
276 ePage = PAGE_FIRST;
277 else if (rCommand == "previous")
278 ePage = PAGE_PREVIOUS;
279 else if (rCommand == "next")
280 ePage = PAGE_NEXT;
281 else if (rCommand == "last")
282 ePage = PAGE_LAST;
283 else if (rCommand == "dragmode")
284 mxToolbox->set_menu_item_active("dragmode", !mxToolbox->get_menu_item_active("dragmode"));
285 else if (rCommand == "shapes")
286 mxToolbox->set_menu_item_active("shapes", !mxToolbox->get_menu_item_active("shapes"));
287
288 if (ePage != PAGE_NONE)
289 {
290 SfxUInt16Item aItem( SID_NAVIGATOR_PAGE, static_cast<sal_uInt16>(ePage) );
291 mpBindings->GetDispatcher()->ExecuteList(SID_NAVIGATOR_PAGE,
292 SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
293 }
294}
295
296IMPL_LINK(SdNavigatorWin, DropdownClickToolBoxHdl, const OUString&, rCommand, void)
297{
298 if (!mxToolbox->get_menu_item_active(rCommand))
299 return;
300
301 if (rCommand == "dragmode")
302 {
303 NavDocInfo* pInfo = GetDocInfo();
304 if( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() )
305 {
306 mxDragModeMenu->set_sensitive(OUString::number(NAVIGATOR_DRAGTYPE_LINK), false);
307 mxDragModeMenu->set_sensitive(OUString::number(NAVIGATOR_DRAGTYPE_URL), false);
308 meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
309 }
310
311 mxDragModeMenu->set_active(OUString::number(meDragType), true);
312 }
313 else if (rCommand == "shapes")
314 {
315 bool bAll = mxTlbObjects->GetShowAllShapes();
316 mxShapeMenu->set_active("named", !bAll);
317 mxShapeMenu->set_active("all", bAll);
318 bool bOrderFrontToBack = mxTlbObjects->GetOrderFrontToBack();
319 mxShapeMenu->set_active("fronttoback", bOrderFrontToBack);
320 mxShapeMenu->set_active("backtofront", !bOrderFrontToBack);
321 }
322}
323
325{
326 if( !mbDocImported || mxLbDocs->get_active() != 0 )
327 {
328 NavDocInfo* pInfo = GetDocInfo();
329
330 // if it is the active window, we jump to the page
331 if( pInfo && pInfo->IsActive() )
332 {
333 OUString aStr(mxTlbObjects->get_cursor_text());
334
335 if( !aStr.isEmpty() )
336 {
337 sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
338 if (!pDocShell)
339 return false;
340 sd::ViewShell* pViewShell = pDocShell->GetViewShell();
341 if (!pViewShell)
342 return false;
343 SdrView* pDrawView = pViewShell->GetDrawView();
344 if (!pDrawView)
345 return false;
346
347 // Save the selected tree entries re-mark the objects in the view after navigation.
348 auto vSelectedEntryIds = mxTlbObjects->GetSelectedEntryIds();
349
350 // Page entries in the tree have id value 1. Object entries have id value of
351 // the address of the pointer to the object.
352 const auto& rCursorEntryId = mxTlbObjects->get_cursor_id();
353 auto nCursorEntryId = rCursorEntryId.toInt64();
354 SdrObject* pCursorEntryObject = weld::fromId<SdrObject*>(rCursorEntryId);
355
356 bool bIsCursorEntrySelected(std::find(vSelectedEntryIds.begin(),
357 vSelectedEntryIds.end(),
358 rCursorEntryId) != vSelectedEntryIds.end());
359
360 if (bIsCursorEntrySelected)
361 {
362 // Set a temporary name, if need be, so the object can be navigated to.
363 bool bCursorEntryObjectHasEmptyName = false;
364 if (nCursorEntryId != 1 && pCursorEntryObject
365 && pCursorEntryObject->GetName().isEmpty())
366 {
367 bCursorEntryObjectHasEmptyName = true;
368 bool bUndo = pCursorEntryObject->getSdrModelFromSdrObject().IsUndoEnabled();
369 pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(false);
370 pCursorEntryObject->SetName(aStr, false);
371 pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(bUndo);
372 }
373
374 // All objects are unmarked when navigating to an object.
375 SfxStringItem aItem(SID_NAVIGATOR_OBJECT, aStr);
376 mpBindings->GetDispatcher()->ExecuteList(SID_NAVIGATOR_OBJECT,
377 SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
378
379 if (bCursorEntryObjectHasEmptyName)
380 {
381 bool bUndo = pCursorEntryObject->getSdrModelFromSdrObject().IsUndoEnabled();
382 pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(false);
383 pCursorEntryObject->SetName(OUString(), false);
384 pCursorEntryObject->getSdrModelFromSdrObject().EnableUndo(bUndo);
385 }
386
387 // re-mark the objects
388 if (bIsCursorEntrySelected)
389 {
390 // Mark the objects in the view that are selected in the Navigator tree.
391 for (auto& rEntryId: vSelectedEntryIds)
392 {
393 if (rEntryId != "1")
394 {
395 SdrObject* pEntryObject = weld::fromId<SdrObject*>(rEntryId);
396 if (pEntryObject)
397 pDrawView->MarkObj(pEntryObject, pDrawView->GetSdrPageView());
398 }
399 }
400 }
401 }
402 else if (nCursorEntryId != 1 && pCursorEntryObject)
403 {
404 // unmark
405 pDrawView->MarkObj(pCursorEntryObject, pDrawView->GetSdrPageView(), true);
406 }
407
408 // moved here from SetGetFocusHdl. Reset the
409 // focus only if something has been selected in the
410 // document.
412
413 if ( pCurSh )
414 {
415 vcl::Window* pShellWnd = pCurSh->GetWindow();
416 if ( pShellWnd )
417 pShellWnd->GrabFocus();
418 }
419
420 // We navigated to an object, but the current shell may be
421 // still the slide sorter. Explicitly try to grab the draw
422 // shell focus, so follow-up operations work with the object
423 // and not with the whole slide.
424 vcl::Window* pWindow = pViewShell->GetActiveWindow();
425 if (pWindow)
426 pWindow->GrabFocus();
427
428 if (!mxTlbObjects->IsNavigationGrabsFocus())
429 {
430 // This is the case when keyboard navigation inside the
431 // navigator should continue to work.
432 if (mxNavigatorDlg)
433 mxNavigatorDlg->GrabFocus();
434 mxTlbObjects->grab_focus();
435 }
436 }
437 }
438 }
439 return false;
440}
441
443{
444 OUString aStrLb = mxLbDocs->get_active_text();
445 tools::Long nPos = mxLbDocs->get_active();
446 bool bFound = false;
447 ::sd::DrawDocShell* pDocShell = nullptr;
448 NavDocInfo* pInfo = GetDocInfo();
449
450 // is it a dragged object?
451 if( mbDocImported && nPos == 0 )
452 {
453 // construct document in TLB
454 InsertFile( aStrLb );
455 }
456 else if (pInfo)
457 {
458 pDocShell = pInfo->mpDocShell;
459
460 bFound = true;
461 }
462
463 if( bFound )
464 {
465 SdDrawDocument* pDoc = pDocShell->GetDoc();
466 if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
467 {
468 SdDrawDocument* pNonConstDoc = pDoc; // const as const can...
469 ::sd::DrawDocShell* pNCDocShell = pNonConstDoc->GetDocSh();
470 OUString aDocName = pNCDocShell->GetMedium()->GetName();
471 mxTlbObjects->clear();
472 mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
473 }
474 }
475
476 // check if link or url is possible
477 if( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
478 {
479 meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
480 SetDragImage();
481 }
482}
483
487IMPL_LINK(SdNavigatorWin, MenuSelectHdl, const OUString&, rIdent, void)
488{
489 sal_uInt32 nMenuId = rIdent.toUInt32();
490
491 NavigatorDragType eDT = static_cast<NavigatorDragType>(nMenuId);
492 if( meDragType == eDT )
493 return;
494
495 meDragType = eDT;
496 SetDragImage();
497
498 if( meDragType == NAVIGATOR_DRAGTYPE_URL )
499 {
500 // patch, prevents endless loop
501 if (mxTlbObjects->count_selected_rows() > 1)
502 mxTlbObjects->unselect_all();
503
504 mxTlbObjects->set_selection_mode(SelectionMode::Single);
505 }
506 else
507 mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
508}
509
510IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, const OUString&, rIdent, void )
511{
512 bool bShowAllShapes(mxTlbObjects->GetShowAllShapes());
513 bool bOrderFrontToBack(mxTlbObjects->GetOrderFrontToBack());
514 if (rIdent == "named")
515 bShowAllShapes = false;
516 else if (rIdent == "all")
517 bShowAllShapes = true;
518 else if (rIdent == "fronttoback")
519 bOrderFrontToBack = true;
520 else if (rIdent == "backtofront")
521 bOrderFrontToBack = false;
522 else
523 OSL_FAIL("SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
524
525 mxTlbObjects->SetOrderFrontToBack(bOrderFrontToBack);
526 mxTlbObjects->SetShowAllShapes(bShowAllShapes, true);
527
528 // Remember the selection in the FrameView.
529 NavDocInfo* pInfo = GetDocInfo();
530 if (pInfo == nullptr)
531 return;
532
533 ::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
534 if (pDocShell != nullptr)
535 {
536 ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
537 if (pViewShell != nullptr)
538 {
539 ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
540 if (pFrameView != nullptr)
541 {
542 pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
543 }
544 lcl_select_marked_object(pViewShell, mxTlbObjects.get());
545 }
546 }
547}
548
549bool SdNavigatorWin::InsertFile(const OUString& rFileName)
550{
551 INetURLObject aURL( rFileName );
552
553 if( aURL.GetProtocol() == INetProtocol::NotValid )
554 {
555 OUString aURLStr;
556 osl::FileBase::getFileURLFromSystemPath( rFileName, aURLStr );
557 aURL = INetURLObject( aURLStr );
558 }
559
560 // get adjusted FileName
561 OUString aFileName( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
562
563 if (aFileName.isEmpty())
564 {
565 // show actual document again
566 maDropFileName = aFileName;
567 }
568 else
569 {
570 // show dragged-in document
571 std::shared_ptr<const SfxFilter> pFilter;
572 ErrCode nErr = ERRCODE_NONE;
573
574 if (aFileName != maDropFileName)
575 {
576 SfxMedium aMed(aFileName, (StreamMode::READ | StreamMode::SHARE_DENYNONE));
577 SfxFilterMatcher aMatch( "simpress" );
578 aMed.UseInteractionHandler( true );
579 nErr = aMatch.GuessFilter(aMed, pFilter);
580 }
581
582 if ((pFilter && !nErr) || aFileName == maDropFileName)
583 {
584 // The medium may be opened with READ/WRITE. Therefore, we first
585 // check if it contains a Storage.
586 std::unique_ptr<SfxMedium> xMedium(new SfxMedium(aFileName,
587 StreamMode::READ | StreamMode::NOCREATE));
588
589 if (xMedium->IsStorage())
590 {
591 // Now depending on mode:
592 // mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
593 // handover of ownership of xMedium;
594 SdDrawDocument* pDropDoc = mxTlbObjects->GetBookmarkDoc(xMedium.release());
595
596 if (pDropDoc)
597 {
598 mxTlbObjects->clear();
599 maDropFileName = aFileName;
600
601 if( !mxTlbObjects->IsEqualToDoc( pDropDoc ) )
602 {
603 // only normal pages
604 mxTlbObjects->Fill(pDropDoc, false, maDropFileName);
606 }
607 }
608 }
609 else
610 {
611 return false;
612 }
613 }
614 else
615 {
616 return false;
617 }
618 }
619
620 return true;
621}
622
623void SdNavigatorWin::RefreshDocumentLB( const OUString* pDocName )
624{
625 sal_Int32 nPos = 0;
626
627 if( pDocName )
628 {
629 if( mbDocImported )
630 mxLbDocs->remove(0);
631
632 mxLbDocs->insert_text(0, *pDocName);
633 mbDocImported = true;
634 }
635 else
636 {
637 nPos = mxLbDocs->get_active();
638 if (nPos == -1)
639 nPos = 0;
640
641 OUString aStr;
642 if( mbDocImported )
643 aStr = mxLbDocs->get_text(0);
644
645 mxLbDocs->clear();
646
647 // delete list of DocInfos
648 maDocList.clear();
649
650 if( mbDocImported )
651 mxLbDocs->insert_text(0, aStr);
652
653 ::sd::DrawDocShell* pCurrentDocShell =
654 dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
655 SfxObjectShell* pSfxDocShell = SfxObjectShell::GetFirst([](const SfxObjectShell*){return true;}, false);
656 while( pSfxDocShell )
657 {
658 ::sd::DrawDocShell* pDocShell = dynamic_cast< ::sd::DrawDocShell *>( pSfxDocShell );
659 if( pDocShell && !pDocShell->IsInDestruction() && ( pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) )
660 {
661 NavDocInfo aInfo ;
662 aInfo.mpDocShell = pDocShell;
663
664 SfxMedium *pMedium = pDocShell->GetMedium();
665 aStr = pMedium ? pMedium->GetName() : OUString();
666 if( !aStr.isEmpty() )
667 aInfo.SetName( true );
668 else
669 aInfo.SetName( false );
670 // at the moment, we use the name of the shell again (i.e.
671 // without path) since Koose thinks it is an error if the path
672 // is shown in url notation!
673 aStr = pDocShell->GetName();
674
675 mxLbDocs->append_text(aStr);
676
677 if( pDocShell == pCurrentDocShell )
678 aInfo.SetActive( true );
679 else
680 aInfo.SetActive( false );
681
682 maDocList.push_back( aInfo );
683 }
684 pSfxDocShell = SfxObjectShell::GetNext( *pSfxDocShell, [](const SfxObjectShell*){return true;}, false );
685 }
686 }
687 mxLbDocs->set_active(nPos);
688}
689
691{
692 switch( eDT )
693 {
695 return OUString();
697 return BMP_HYPERLINK;
699 return BMP_EMBEDDED;
701 return BMP_LINK;
702 default: OSL_FAIL( "No resource for DragType available!" );
703 }
704 return OUString();
705}
706
708{
709 sal_uInt32 nPos = mxLbDocs->get_active();
710
711 if( mbDocImported )
712 {
713 if( nPos == 0 )
714 {
715 return nullptr;
716 }
717 nPos--;
718 }
719
720 return nPos < maDocList.size() ? &(maDocList[ nPos ]) : nullptr;
721}
722
726IMPL_LINK(SdNavigatorWin, KeyInputHdl, const KeyEvent&, rKEvt, bool)
727{
728 bool bConsumed = false;
729
730 if (KEY_ESCAPE == rKEvt.GetKeyCode().GetCode())
731 {
732 // during drag'n'drop we just stop the drag but do not close the navigator
733 if (!SdPageObjsTLV::IsInDrag() && !GetObjects().IsEditingActive())
734 {
735 ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame());
736 if (pBase)
737 sd::SlideShow::Stop(*pBase);
738 bConsumed = true;
739 }
740 }
741
742 return bConsumed;
743}
744
746{
747 mxToolbox->set_item_icon_name("dragmode", GetDragTypeSdBmpId(meDragType));
748}
749
754 sal_uInt16 _nId,
755 SdNavigatorWin* pNavWin,
756 SfxBindings* _pBindings,
758 : SfxControllerItem( _nId, *_pBindings ),
759 pNavigatorWin( pNavWin ),
760 maUpdateRequest(std::move(aUpdateRequest))
761{
762}
763
765 SfxItemState eState, const SfxPoolItem* pItem )
766{
767 if( eState < SfxItemState::DEFAULT || nSId != SID_NAVIGATOR_STATE )
768 return;
769
770 // only if doc in LB is the active
772 if( !(pInfo && pInfo->IsActive()) )
773 return;
774
775 if (::sd::DrawDocShell* pDrawDocShell = pInfo->GetDrawDocShell())
776 {
777 const auto pDrawViewShell =
778 static_cast<::sd::DrawViewShell *>(pDrawDocShell->GetViewShell());
779 if (pDrawViewShell)
780 {
781 pNavigatorWin->FreshTree(pDrawDocShell->GetDoc());
782 bool bEditModePage(pDrawViewShell->GetEditMode() == EditMode::Page);
783 pNavigatorWin->mxToolbox->set_sensitive(bEditModePage);
784 pNavigatorWin->mxLbDocs->set_sensitive(bEditModePage);
785 pNavigatorWin->mxTlbObjects->set_sensitive(bEditModePage);
786 }
787 }
788
789 const SfxUInt32Item& rStateItem = dynamic_cast<const SfxUInt32Item&>(*pItem);
790 NavState nState = static_cast<NavState>(rStateItem.GetValue());
791
792 // First
794 !pNavigatorWin->mxToolbox->get_item_sensitive("first"))
795 pNavigatorWin->mxToolbox->set_item_sensitive("first", true);
797 pNavigatorWin->mxToolbox->get_item_sensitive("first"))
798 pNavigatorWin->mxToolbox->set_item_sensitive("first", false);
799
800 // Prev
802 !pNavigatorWin->mxToolbox->get_item_sensitive("previous"))
803 pNavigatorWin->mxToolbox->set_item_sensitive("previous", true);
805 pNavigatorWin->mxToolbox->get_item_sensitive("previous"))
806 pNavigatorWin->mxToolbox->set_item_sensitive("previous", false);
807
808 // Last
810 !pNavigatorWin->mxToolbox->get_item_sensitive("last"))
811 pNavigatorWin->mxToolbox->set_item_sensitive("last", true);
813 pNavigatorWin->mxToolbox->get_item_sensitive("last"))
814 pNavigatorWin->mxToolbox->set_item_sensitive("last", false);
815
816 // Next
818 !pNavigatorWin->mxToolbox->get_item_sensitive("next"))
819 pNavigatorWin->mxToolbox->set_item_sensitive("next", true);
821 pNavigatorWin->mxToolbox->get_item_sensitive("next"))
822 pNavigatorWin->mxToolbox->set_item_sensitive("next", false);
823
825 {
826 // InitTlb; is initiated by Slot
829 }
830}
831
836 sal_uInt16 _nId,
837 SdNavigatorWin* pNavWin,
838 SfxBindings* _pBindings)
839 : SfxControllerItem( _nId, *_pBindings ),
840 pNavigatorWin( pNavWin )
841{
842}
843
845 SfxItemState eState, const SfxPoolItem* pItem )
846{
847 if( eState < SfxItemState::DEFAULT || nSId != SID_NAVIGATOR_PAGENAME )
848 return;
849
850 // only if doc in LB is the active
852 if( !(pInfo && pInfo->IsActive()) )
853 return;
854
855 // Without a test for marked objects the page name entry is not selected when there are no
856 // marked objects. The HasSelectedChildren test is required when in 'Named Shapes' mode in
857 // order to select the page name when none of the marked objects have a name.
858 bool bDrawViewHasMarkedObjects = false;
859 if (pInfo->GetDrawDocShell() && pInfo->GetDrawDocShell()->GetViewShell())
860 {
861 const SdrView* pDrawView = pInfo->GetDrawDocShell()->GetViewShell()->GetDrawView();
862 if (pDrawView && pDrawView->GetMarkedObjectCount())
863 bDrawViewHasMarkedObjects = true;
864 }
865
866 const SfxStringItem& rStateItem = dynamic_cast<const SfxStringItem&>(*pItem);
867 const OUString& aPageName = rStateItem.GetValue();
868
869 if (!bDrawViewHasMarkedObjects || !pNavigatorWin->mxTlbObjects->HasSelectedChildren(aPageName))
870 {
871 if (pNavigatorWin->mxTlbObjects->get_selection_mode() == SelectionMode::Multiple)
872 {
873 // because otherwise it is always additional select
874 pNavigatorWin->mxTlbObjects->unselect_all();
875 }
876 pNavigatorWin->mxTlbObjects->SelectEntry( aPageName );
877 }
878}
879
880/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
sal_uInt32 GetValue() const
const OUString & GetValue() const
::sd::DrawDocShell * mpDocShell
Definition: navigatr.hxx:77
bool IsActive() const
Definition: navigatr.hxx:66
void SetName(bool bOn)
Definition: navigatr.hxx:68
bool HasName() const
Definition: navigatr.hxx:65
void SetActive(bool bOn)
Definition: navigatr.hxx:69
::sd::DrawDocShell * GetDrawDocShell()
Definition: navigatr.hxx:71
virtual weld::Window * GetFrameWeld() const
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem *pState) override
Definition: navigatr.cxx:764
SdNavigatorWin * pNavigatorWin
Definition: navigatr.hxx:189
SdNavigatorControllerItem(sal_uInt16, SdNavigatorWin *, SfxBindings *, SdNavigatorWin::UpdateRequestFunctor aUpdateRequest)
ControllerItem for Navigator.
Definition: navigatr.cxx:753
const SdNavigatorWin::UpdateRequestFunctor maUpdateRequest
Definition: navigatr.hxx:190
NavigatorDragType GetNavigatorDragType()
DragType is set on dependence if a Drag is even possible.
Definition: navigatr.cxx:229
void ExecuteContextMenuAction(std::u16string_view rSelectedPopupEntry)
Definition: navigatr.cxx:265
std::unique_ptr< weld::Menu > mxDragModeMenu
Definition: navigatr.hxx:133
void InitTreeLB(const SdDrawDocument *pDoc)
Definition: navigatr.cxx:172
std::unique_ptr< weld::Menu > mxShapeMenu
Definition: navigatr.hxx:134
virtual weld::Window * GetFrameWeld() const override
Definition: navigatr.cxx:111
std::vector< NavDocInfo > maDocList
Definition: navigatr.hxx:141
static OUString GetDragTypeSdBmpId(NavigatorDragType eDT)
This flag controls whether all shapes or only the named shapes are shown.
Definition: navigatr.cxx:690
SdPageObjsTLV & GetObjects()
Definition: navigatr.cxx:240
void SetDragImage()
Definition: navigatr.cxx:745
void FreshTree(const SdDrawDocument *pDoc)
Definition: navigatr.cxx:156
void FirstFocus()
Definition: navigatr.cxx:104
virtual ~SdNavigatorWin() override
Definition: navigatr.cxx:128
std::unique_ptr< weld::ComboBox > mxLbDocs
Definition: navigatr.hxx:132
std::unique_ptr< SdPageObjsTLV > mxTlbObjects
Definition: navigatr.hxx:131
SdNavigatorWin(weld::Widget *pParent, SfxBindings *pBindings, SfxNavigator *pNavigatorDlg)
Create a new instance of the navigator.
Definition: navigatr.cxx:56
friend class SdNavigatorControllerItem
Definition: navigatr.hxx:127
NavigatorDragType meDragType
Definition: navigatr.hxx:140
std::unique_ptr< SdPageNameControllerItem > mpPageNameCtrlItem
Definition: navigatr.hxx:144
NavDocInfo * GetDocInfo()
Definition: navigatr.cxx:707
bool InsertFile(const OUString &rFileName)
Definition: navigatr.cxx:549
void RefreshDocumentLB(const OUString *pDocName=nullptr)
Definition: navigatr.cxx:623
bool mbDocImported
Definition: navigatr.hxx:138
VclPtr< SfxNavigator > mxNavigatorDlg
Definition: navigatr.hxx:136
OUString maDropFileName
Definition: navigatr.hxx:139
std::unique_ptr< weld::Toolbar > mxToolbox
Definition: navigatr.hxx:130
friend class SdPageNameControllerItem
Definition: navigatr.hxx:128
::std::function< void()> UpdateRequestFunctor
Definition: navigatr.hxx:103
SfxBindings * mpBindings
Definition: navigatr.hxx:142
void SetUpdateRequestFunctor(const UpdateRequestFunctor &rUpdateRequest)
Definition: navigatr.cxx:118
std::unique_ptr< SdNavigatorControllerItem > mpNavigatorCtrlItem
Definition: navigatr.hxx:143
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem *pState) override
Definition: navigatr.cxx:844
SdPageNameControllerItem(sal_uInt16, SdNavigatorWin *, SfxBindings *)
ControllerItem for Navigator to show page in TreeLB.
Definition: navigatr.cxx:835
SdNavigatorWin * pNavigatorWin
Definition: navigatr.hxx:206
void unselect_all()
Definition: sdtreelb.hxx:307
static bool IsInDrag()
Definition: sdtreelb.cxx:76
weld::TreeView & get_treeview()
Definition: sdtreelb.hxx:292
void start_editing()
Definition: sdtreelb.hxx:178
bool SelectEntry(std::u16string_view rName)
select an entry in TreeLB
Definition: sdtreelb.cxx:1324
size_t GetMarkedObjectCount() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
void EnableUndo(bool bEnable)
bool IsUndoEnabled() const
SdrModel & getSdrModelFromSdrObject() const
virtual const OUString & GetName() const
virtual void SetName(const OUString &rStr, const bool bSetChanged=true)
SdrPageView * GetSdrPageView() const
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
SfxViewFrame * GetFrame() const
ErrCode GuessFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
void UseInteractionHandler(bool)
const OUString & GetName() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxMedium * GetMedium() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
SfxObjectCreateMode GetCreateMode() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
const OUString & GetName() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
sd::ViewShell * GetViewShell()
bool IsInDestruction() const
SdDrawDocument * GetDoc()
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
View for MDIFrame.
Definition: FrameView.hxx:36
bool IsNavigatorShowingAllShapes() const
Definition: FrameView.hxx:163
void SetIsNavigatorShowingAllShapes(const bool bIsNavigatorShowingAllShapes)
Definition: frmview.cxx:912
static bool IsRunning(ViewShellBase const &rBase)
returns true if there is a running presentation for the given ViewShellBase
Definition: slideshow.cxx:208
static void Stop(ViewShellBase const &rBase)
Definition: slideshow.cxx:201
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.
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
FrameView * GetFrameView()
Definition: ViewShell.hxx:221
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
SdrView * GetDrawView() const
Definition: ViewShell.hxx:552
void GrabFocus()
virtual bool has_focus() const=0
URL aURL
float u
sal_Int32 nState
#define ERRCODE_NONE
constexpr sal_uInt16 KEY_ESCAPE
sal_uInt16 nPos
aStr
void InsertFile(SwUnoCursor *pUnoCursor, const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions)
long Long
IMPL_LINK(SdNavigatorWin, CommandHdl, const CommandEvent &, rCEvt, bool)
Definition: navigatr.cxx:250
IMPL_STATIC_LINK_NOARG(SdNavigatorWin, MouseReleaseHdl, const MouseEvent &, bool)
Definition: navigatr.cxx:245
IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, weld::TreeView &, bool)
Definition: navigatr.cxx:324
static void lcl_select_marked_object(const sd::ViewShell *pViewShell, SdPageObjsTLV *pTlbObjects)
Definition: navigatr.cxx:139
NavState
Definition: navigatr.hxx:39
@ BtnNextEnabled
@ BtnPrevEnabled
@ BtnFirstDisabled
@ BtnPrevDisabled
@ BtnFirstEnabled
@ BtnLastDisabled
@ BtnNextDisabled
@ BtnLastEnabled
PageJump
Definition: pgjump.hxx:23
@ PAGE_NEXT
Definition: pgjump.hxx:27
@ PAGE_FIRST
Definition: pgjump.hxx:25
@ PAGE_NONE
Definition: pgjump.hxx:24
@ PAGE_LAST
Definition: pgjump.hxx:28
@ PAGE_PREVIOUS
Definition: pgjump.hxx:26
SfxItemState
NavigatorDragType
Definition: pres.hxx:65
@ NAVIGATOR_DRAGTYPE_NONE
Definition: pres.hxx:66
@ NAVIGATOR_DRAGTYPE_EMBEDDED
Definition: pres.hxx:69
@ NAVIGATOR_DRAGTYPE_LINK
Definition: pres.hxx:68
@ NAVIGATOR_DRAGTYPE_URL
Definition: pres.hxx:67