sw/qa/extras/uiwriter/uiwriter.cxx | 24 ++++++++++++++++++++++++ sw/source/uibase/docvw/edtwin.cxx | 15 ++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-)
New commits: commit 138b2890927c5c856419ac1592f168ca6a072893 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 5 08:47:18 2016 +0200 Related: tdf#84695 sw: fix TextBox begin text edit by pressing normal char When a draw shape is selected, but its text is provided by a TextBox, then F2 and Enter could start editing already, but pressing a normal character didn't work (unlike for TextFrames or regular draw shapes). Fix this by calling into lcl_goIntoTextBox() at one more place. Change-Id: Ia594279918a6c3087cac8b0c859ce7432e4a685d Reviewed-on: https://gerrit.libreoffice.org/24671 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index beed66e..57d53fc 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -198,6 +198,7 @@ public: void testTdf98987(); void testTdf99004(); void testTdf84695(); + void testTdf84695NormalChar(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -298,6 +299,7 @@ public: CPPUNIT_TEST(testTdf98987); CPPUNIT_TEST(testTdf99004); CPPUNIT_TEST(testTdf84695); + CPPUNIT_TEST(testTdf84695NormalChar); CPPUNIT_TEST_SUITE_END(); private: @@ -3680,6 +3682,28 @@ void SwUiWriterTest::testTdf84695() CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString()); } +void SwUiWriterTest::testTdf84695NormalChar() +{ + SwDoc* pDoc = createDoc("tdf84695.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(1); + SwContact* pTextBox = static_cast<SwContact*>(pObject->GetUserCall()); + // First, make sure that pTextBox is a fly frame (textbox of a shape). + CPPUNIT_ASSERT_EQUAL(RES_FLYFRMFMT, static_cast<RES_FMT>(pTextBox->GetFormat()->Which())); + + // Then select it. + pWrtShell->SelectObj(Point(), 0, pObject); + + // Now pressing 'a' should add a character. + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0); + + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + // This was empty, pressing a normal character did not start the fly frame edit mode. + CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index eaa30c6..5420d3a 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2328,9 +2328,18 @@ KEYINPUT_CHECKTABLE_INSDEL: if( !bIsDocReadOnly && bNormalChar ) { const int nSelectionType = rSh.GetSelectionType(); - if((nSelectionType & nsSelectionType::SEL_DRW) && + const bool bDrawObject = (nSelectionType & nsSelectionType::SEL_DRW) && 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) && - rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1) + rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1; + + bool bTextBox = false; + if (bDrawObject && lcl_goIntoTextBox(*this, rSh)) + // A draw shape was selected, but it has a TextBox, + // start editing that instead when the normal + // character is pressed. + bTextBox = true; + + if (bDrawObject && !bTextBox) { SdrObject* pObj = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); if(pObj) @@ -2341,7 +2350,7 @@ KEYINPUT_CHECKTABLE_INSDEL: rSh.GetDrawView()->KeyInput( rKEvt, this ); } } - else if(nSelectionType & nsSelectionType::SEL_FRM) + else if (nSelectionType & nsSelectionType::SEL_FRM || bTextBox) { rSh.UnSelectFrame(); rSh.LeaveSelFrameMode(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits