[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 7 19:21:12 UTC 2016


 sw/qa/extras/uiwriter/data/tdf84695-tab.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx          |   27 +++++++++++++++++++++++++++
 sw/source/core/frmedt/feshview.cxx          |    4 ++++
 3 files changed, 31 insertions(+)

New commits:
commit 5d2c189aee5057d1533165c368227c9c4c49d330
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 7 18:02:07 2016 +0100

    sw: fix keyboard-based iteration on draw shapes wrt. textboxes
    
    Pressing <tab> resulted in no action, as we jumped to the textbox of the
    shape, which was correct to jump to the shape, so we never arrived to
    the next draw shape.
    
    Change-Id: I8c6458994ce985fc420999042a1d8e69b6e6712b
    Reviewed-on: https://gerrit.libreoffice.org/31733
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/data/tdf84695-tab.odt b/sw/qa/extras/uiwriter/data/tdf84695-tab.odt
new file mode 100644
index 0000000..aa438bd
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf84695-tab.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 44dd39e..13e2fa4 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -207,6 +207,7 @@ public:
     void testTdf99004();
     void testTdf84695();
     void testTdf84695NormalChar();
+    void testTdf84695Tab();
     void testTableStyleUndo();
     void testRedlineParam();
     void testRedlineViewAuthor();
@@ -320,6 +321,7 @@ public:
     CPPUNIT_TEST(testTdf99004);
     CPPUNIT_TEST(testTdf84695);
     CPPUNIT_TEST(testTdf84695NormalChar);
+    CPPUNIT_TEST(testTdf84695Tab);
     CPPUNIT_TEST(testTableStyleUndo);
     CPPUNIT_TEST(testRedlineParam);
     CPPUNIT_TEST(testRedlineViewAuthor);
@@ -3818,6 +3820,31 @@ void SwUiWriterTest::testTdf84695NormalChar()
     CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString());
 }
 
+void SwUiWriterTest::testTdf84695Tab()
+{
+    SwDoc* pDoc = createDoc("tdf84695-tab.odt");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    SdrObject* pObject = pPage->GetObj(0);
+    SwContact* pShape = static_cast<SwContact*>(pObject->GetUserCall());
+    // First, make sure that pShape is a draw shape.
+    CPPUNIT_ASSERT_EQUAL(RES_DRAWFRMFMT, static_cast<RES_FMT>(pShape->GetFormat()->Which()));
+
+    // Then select it.
+    pWrtShell->SelectObj(Point(), 0, pObject);
+
+    // Now pressing 'tab' should jump to the other shape.
+    SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB);
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_TAB);
+
+    // And finally make sure the selection has changed.
+    const SdrMarkList& rMarkList = pWrtShell->GetDrawView()->GetMarkedObjectList();
+    SwContact* pOtherShape = static_cast<SwContact*>(rMarkList.GetMark(0)->GetMarkedSdrObj()->GetUserCall());
+    // This failed, 'tab' didn't do anything -> the selected shape was the same.
+    CPPUNIT_ASSERT(pOtherShape != pShape);
+}
+
 void SwUiWriterTest::testTableStyleUndo()
 {
     SwDoc* pDoc = createDoc();
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index de6fcc5..06f1a4b 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -1509,6 +1509,10 @@ const SdrObject* SwFEShell::GetBestObject( bool bNext, GotoObjFlags eType, bool
             bool bFlyFrame = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) !=  nullptr;
             if( ( bNoFly && bFlyFrame ) ||
                 ( bNoDraw && !bFlyFrame ) ||
+                // Ignore TextBoxes of draw shapes here, so that
+                // SwFEShell::SelectObj() won't jump back on this list, meaning
+                // we never jump to the next draw shape.
+                SwTextBoxHelper::isTextBox(pObj) ||
                 ( eType == GotoObjFlags::DrawSimple && lcl_IsControlGroup( pObj ) ) ||
                 ( eType == GotoObjFlags::DrawControl && !lcl_IsControlGroup( pObj ) ) ||
                 ( pFilter && !pFilter->includeObject( *pObj ) ) )


More information about the Libreoffice-commits mailing list