diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-21 17:27:53 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-22 09:05:07 +0100 |
commit | f3c68cdf8f6a0273c62b493552f78af0138a44e8 (patch) | |
tree | 1a1742b280ff5d04794bf0726f2d79c097315f0f /sd/source | |
parent | 6e0f60fa4ad985b3939ce3ac26bc8cb68fb41470 (diff) |
tdf#115873 sd navigator: allow selecting but not focusing on objects
There were also two cases here:
- changing the selection with the keyboard or single-click only updated
the selection in the navigator
- pressing enter or double-click also selected the shape in the main
window and gave the focus away
Introduce a 3rd case for single-click: update the shape selection but
doesn't give the focus away. This way double-click is not needed to sync
navigator -> main doc selection but keyboard navigation should still
work.
An additional trick is to make sure that the current shell is the draw
shell (and not the slide sorter) after navigation, so follow-up
operations work with the selected object and not with the whole slide.
Finally, a third related problem was that the selection jumped back to
the item of the slide after clicking on a shape in the navigator. The
reason for this was the navigator list was constantly cleared and
re-filled in SdNavigatorWin::InitTreeLB(), as
SdPageObjsTLB::IsEqualToDoc() returned false (even if the list was up to
date) in case of shapes which had children but no name. Fix this by
using the same SdrIterMode::Flat iteration mode that
SdPageObjsTLB::AddShapeList() does, so the fill and the equality check
of the navigator iterates the same way.
Change-Id: I0bfc3e8b49f7ef01d5797a68284616dcd2a81c5d
Reviewed-on: https://gerrit.libreoffice.org/50118
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/navigatr.cxx | 27 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/inc/navigatr.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/inc/sdtreelb.hxx | 12 |
4 files changed, 58 insertions, 2 deletions
diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index 0fe0f97481c8..2761c6eed628 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -54,6 +54,7 @@ #include <slideshow.hxx> #include <FrameView.hxx> #include <helpids.h> +#include <Window.hxx> namespace { static const sal_uInt16 nShowNamedShapesFilter=1; @@ -215,6 +216,11 @@ NavigatorDragType SdNavigatorWin::GetNavigatorDragType() return eDT; } +VclPtr<SdPageObjsTLB> SdNavigatorWin::GetObjects() +{ + return maTlbObjects; +} + IMPL_LINK_NOARG(SdNavigatorWin, SelectToolboxHdl, ToolBox *, void) { sal_uInt16 nId = maToolbox->GetCurItemId(); @@ -351,6 +357,27 @@ IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, SvTreeListBox*, bool) if ( pShellWnd ) pShellWnd->GrabFocus(); } + + // We navigated to an object, but the current shell may be + // still the slide sorter. Explicitly try to grab the draw + // shell focus, so follow-up operations work with the object + // and not with the whole slide. + sd::DrawDocShell* pDocShell = pInfo->mpDocShell; + if (pDocShell) + { + sd::ViewShell* pViewShell = pDocShell->GetViewShell(); + if (pViewShell) + { + vcl::Window* pWindow = pViewShell->GetActiveWindow(); + if (pWindow) + pWindow->GrabFocus(); + } + } + + if (!maTlbObjects->IsNavigationGrabsFocus()) + // This is the case when keyboard navigation inside the + // navigator should continue to work. + maTlbObjects->GrabFocus(); } } } diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index b31ede51e6f8..57f1619f2613 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -58,6 +58,7 @@ #include <comphelper/processfactory.hxx> #include <tools/diagnose_ex.h> #include <o3tl/make_unique.hxx> +#include <comphelper/scopeguard.hxx> using namespace com::sun::star; @@ -205,6 +206,8 @@ SdPageObjsTLB::SdPageObjsTLB( vcl::Window* pParentWin, WinBits nStyle ) , mbSaveTreeItemState ( false ) , mbShowAllShapes ( false ) , mbShowAllPages ( false ) +, mbSelectionHandlerNavigates(false) +, mbNavigationGrabsFocus(true) { // add lines to Tree-ListBox SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES | @@ -665,7 +668,7 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc ) SdrObjListIter aIter( *pPage, !pPage->HasObjectNavigationOrder() /* use navigation order, if available */, - SdrIterMode::DeepWithGroups ); + SdrIterMode::Flat ); while( aIter.IsMore() ) { @@ -895,6 +898,9 @@ void SdPageObjsTLB::SelectHdl() } SvTreeListBox::SelectHdl(); + + if (mbSelectionHandlerNavigates) + DoubleClickHdl(); } /** @@ -939,6 +945,16 @@ void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt ) SvTreeListBox::KeyInput( rKEvt ); } +void SdPageObjsTLB::MouseButtonDown(const MouseEvent& rMEvt) +{ + mbSelectionHandlerNavigates = rMEvt.GetClicks() == 1; + comphelper::ScopeGuard aNavigationGuard([this]() { this->mbSelectionHandlerNavigates = false; }); + mbNavigationGrabsFocus = rMEvt.GetClicks() != 1; + comphelper::ScopeGuard aGrabGuard([this]() { this->mbNavigationGrabsFocus = true; }); + + SvTreeListBox::MouseButtonDown(rMEvt); +} + /** * StartDrag-Request */ diff --git a/sd/source/ui/inc/navigatr.hxx b/sd/source/ui/inc/navigatr.hxx index cd487a249058..a9501c5236a4 100644 --- a/sd/source/ui/inc/navigatr.hxx +++ b/sd/source/ui/inc/navigatr.hxx @@ -76,7 +76,7 @@ private: ::sd::DrawDocShell* mpDocShell; }; -class SdNavigatorWin : public PanelLayout +class SD_DLLPUBLIC SdNavigatorWin : public PanelLayout { public: typedef ::std::function<void ()> UpdateRequestFunctor; @@ -101,6 +101,7 @@ public: bool InsertFile(const OUString& rFileName); NavigatorDragType GetNavigatorDragType(); + VclPtr<SdPageObjsTLB> GetObjects(); protected: virtual bool EventNotify(NotifyEvent& rNEvt) override; diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx index 6f9887ecd40e..7f51a9aeb261 100644 --- a/sd/source/ui/inc/sdtreelb.hxx +++ b/sd/source/ui/inc/sdtreelb.hxx @@ -195,6 +195,7 @@ public: OUString GetEntryLongDescription( SvTreeListEntry* pEntry ) const override; virtual void SelectHdl() override; virtual void KeyInput( const KeyEvent& rKEvt ) override; + void MouseButtonDown(const MouseEvent& rMEvt) override; void SetViewFrame( SfxViewFrame* pViewFrame ); @@ -202,6 +203,7 @@ public: void Fill( const SdDrawDocument*, SfxMedium* pSfxMedium, const OUString& rDocName ); void SetShowAllShapes (const bool bShowAllShapes, const bool bFill); bool GetShowAllShapes() const { return mbShowAllShapes;} + bool IsNavigationGrabsFocus() const { return mbNavigationGrabsFocus; } bool IsEqualToDoc( const SdDrawDocument* pInDoc ); bool HasSelectedChildren( const OUString& rName ); bool SelectEntry( const OUString& rName ); @@ -247,6 +249,16 @@ private: /** This flag controls whether to show all pages. */ bool mbShowAllPages; + /** + * If changing the selection should also result in navigating to the + * relevant shape. + */ + bool mbSelectionHandlerNavigates; + /** + * If navigation should not only select the relevant shape but also change + * focus to it. + */ + bool mbNavigationGrabsFocus; /** Return <TRUE/> when the current transferable may be dropped at the given list box entry. |