summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-02-21 17:27:53 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-28 09:11:10 +0100
commita055e423512d2b19afb57ea5c3518b920d7dd131 (patch)
treeedecac517f17761e4a431973b0453bca3eb8b9a7
parenta7699baf74cbc97e4ee609fd1862e4e8fff2ed5d (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. Conflicts: sd/qa/unit/tiledrendering/tiledrendering.cxx sd/source/ui/dlg/navigatr.cxx (cherry picked from commit f3c68cdf8f6a0273c62b493552f78af0138a44e8) Change-Id: I0bfc3e8b49f7ef01d5797a68284616dcd2a81c5d Reviewed-on: https://gerrit.libreoffice.org/50159 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sd/qa/unit/tiledrendering/data/tdf115873.fodp29
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx38
-rw-r--r--sd/source/ui/dlg/navigatr.cxx27
-rw-r--r--sd/source/ui/dlg/sdtreelb.cxx18
-rw-r--r--sd/source/ui/inc/navigatr.hxx3
-rw-r--r--sd/source/ui/inc/sdtreelb.hxx12
6 files changed, 125 insertions, 2 deletions
diff --git a/sd/qa/unit/tiledrendering/data/tdf115873.fodp b/sd/qa/unit/tiledrendering/data/tdf115873.fodp
new file mode 100644
index 000000000000..1633a0471440
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/tdf115873.fodp
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.presentation">
+ <office:font-face-decls>
+ <style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="roman" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+ <style:default-style style:family="graphic">
+ <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap"/>
+ <style:paragraph-properties style:text-autospace="ideograph-alpha" style:punctuation-wrap="simple" style:line-break="strict" style:font-independent-line-spacing="false">
+ <style:tab-stops/>
+ </style:paragraph-properties>
+ <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Sans" fo:font-size="24pt" fo:language="en" fo:country="US" style:font-size-asian="24pt" style:language-asian="zh" style:country-asian="CN" style:font-size-complex="24pt" style:language-complex="hi" style:country-complex="IN"/>
+ </style:default-style>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="2.544cm" fo:min-width="4.58cm"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:body>
+ <office:presentation>
+ <draw:page draw:name="page1">
+ <draw:custom-shape draw:name="Rectangle" draw:style-name="gr1" draw:layer="layout" svg:width="5.08cm" svg:height="2.794cm" svg:x="12.954cm" svg:y="7.62cm">
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0 0 Z N"/>
+ </draw:custom-shape>
+ </draw:page>
+ </office:presentation>
+ </office:body>
+</office:document>
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 34ff527549df..91cc1b672c4c 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -46,6 +46,7 @@
#include <svx/svxids.hrc>
#include <DrawViewShell.hxx>
#include <pres.hxx>
+#include <navigatr.hxx>
#include <chrono>
@@ -101,6 +102,7 @@ public:
void testCommentCallbacks();
void testMultiViewInsertDeletePage();
void testTdf115783();
+ void testTdf115873();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -138,6 +140,7 @@ public:
CPPUNIT_TEST(testCommentCallbacks);
CPPUNIT_TEST(testMultiViewInsertDeletePage);
CPPUNIT_TEST(testTdf115783);
+ CPPUNIT_TEST(testTdf115873);
CPPUNIT_TEST_SUITE_END();
@@ -1847,6 +1850,41 @@ void SdTiledRenderingTest::testTdf115783()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testTdf115873()
+{
+ // Initialize the navigator.
+ SdXImpressDocument* pXImpressDocument = createDoc("tdf115873.fodp");
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ CPPUNIT_ASSERT(pViewShell);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ ScopedVclPtrInstance<SdNavigatorWin> pNavigator(nullptr, &rBindings);
+ pNavigator->InitTreeLB(pXImpressDocument->GetDoc());
+ pNavigator->Show();
+ VclPtr<SdPageObjsTLB> pObjects = pNavigator->GetObjects();
+ pObjects->Select(pObjects->GetEntry(0));
+ sd::ViewShell* pSdViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdrView* pSdrView = pSdViewShell->GetView();
+ pSdrView->UnmarkAllObj(pSdrView->GetSdrPageView());
+
+ // Make sure that no shapes are selected.
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rMarkList.GetMarkCount());
+
+ // Single-click with the mouse.
+ short nHeight = pObjects->GetEntryHeight();
+ // Position of the center of the 2nd entry (first is the slide, second is
+ // the shape).
+ Point aPoint(pObjects->GetOutputWidthPixel() / 2, nHeight * 1.5);
+ MouseEvent aMouseEvent(aPoint, /*nClicks=*/1, MouseEventModifiers::NONE, MOUSE_LEFT);
+ pObjects->MouseButtonDown(aMouseEvent);
+ pObjects->MouseButtonUp(aMouseEvent);
+ Scheduler::ProcessEventsToIdle();
+ // This failed, single-click did not result in a shape selection (only
+ // double-click did).
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rMarkList.GetMarkCount());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index 22157511eb53..3803793df122 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;
@@ -224,6 +225,11 @@ sd::DrawDocShell* SdNavigatorWin::GetDrawDocShell( const SdDrawDocument* pDoc )
return pDocShell;
}
+VclPtr<SdPageObjsTLB> SdNavigatorWin::GetObjects()
+{
+ return maTlbObjects;
+}
+
IMPL_LINK_NOARG(SdNavigatorWin, SelectToolboxHdl, ToolBox *, void)
{
sal_uInt16 nId = maToolbox->GetCurItemId();
@@ -346,6 +352,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 3bb125de459e..763c074213db 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 |
@@ -815,7 +818,7 @@ bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
SdrObjListIter aIter(
*pPage,
!pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
- SdrIterMode::DeepWithGroups );
+ SdrIterMode::Flat );
while( aIter.IsMore() )
{
@@ -1045,6 +1048,9 @@ void SdPageObjsTLB::SelectHdl()
}
SvTreeListBox::SelectHdl();
+
+ if (mbSelectionHandlerNavigates)
+ DoubleClickHdl();
}
/**
@@ -1098,6 +1104,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 f8e2590a06db..b8cf73aa660e 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 8541ace2557b..0f51776a1e6b 100644
--- a/sd/source/ui/inc/sdtreelb.hxx
+++ b/sd/source/ui/inc/sdtreelb.hxx
@@ -196,6 +196,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 );
@@ -203,6 +204,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 );
@@ -250,6 +252,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.