diff options
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 15 |
2 files changed, 36 insertions, 3 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index beed66ebbf86..57d53fc8f4d0 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 eaa30c6554c3..5420d3a9ef7f 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(); |