5 files changed, 69 insertions, 11 deletions
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 9b6cf4f612ca..8e73562cebd7 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -171,6 +171,8 @@ enum class SwPasteSdr #define SW_ADD_SELECT 1 #define SW_ENTER_GROUP 2 #define SW_LEAVE_FRAME 4 +/// Allow SwFEShell::SelectObj() to select the TextBox of a shape. +#define SW_ALLOW_TEXTBOX 8 enum class SwMove { diff --git a/sw/qa/extras/uiwriter/data/tdf84695.odt b/sw/qa/extras/uiwriter/data/tdf84695.odt Binary files differnew file mode 100644 index 000000000000..f8c3b0183bf8 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf84695.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 56db245f7045..58c78416aa4e 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -196,6 +196,7 @@ public: void testClassificationPaste(); void testTdf98987(); void testTdf99004(); + void testTdf84695(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -294,6 +295,7 @@ public: CPPUNIT_TEST(testClassificationPaste); CPPUNIT_TEST(testTdf98987); CPPUNIT_TEST(testTdf99004); + CPPUNIT_TEST(testTdf84695); CPPUNIT_TEST_SUITE_END(); private: @@ -3609,6 +3611,29 @@ void SwUiWriterTest::testTdf99004() CPPUNIT_ASSERT(nTextBox1Bottom < nRectangle2Top); } +void SwUiWriterTest::testTdf84695() +{ + 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 Enter + a key should add some text. + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RETURN); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0); + + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + // This was empty, Enter 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/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index a4215e05b5db..4583b3d8f011 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -229,19 +229,22 @@ bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj ) } } - // If the fly frame is a textbox of a shape, then select the shape instead. - std::map<SwFrameFormat*, SwFrameFormat*> aTextBoxShapes = SwTextBoxHelper::findShapes(mpDoc); - for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i) + if (!(nFlag & SW_ALLOW_TEXTBOX)) { - SdrObject* pObject = rMrkList.GetMark(i)->GetMarkedSdrObj(); - SwContact* pDrawContact = static_cast<SwContact*>(GetUserCall(pObject)); - SwFrameFormat* pFormat = pDrawContact->GetFormat(); - if (aTextBoxShapes.find(pFormat) != aTextBoxShapes.end()) + // If the fly frame is a textbox of a shape, then select the shape instead. + std::map<SwFrameFormat*, SwFrameFormat*> aTextBoxShapes = SwTextBoxHelper::findShapes(mpDoc); + for (size_t i = 0; i < rMrkList.GetMarkCount(); ++i) { - SdrObject* pShape = aTextBoxShapes[pFormat]->FindSdrObject(); - pDView->UnmarkAll(); - pDView->MarkObj(pShape, Imp()->GetPageView(), bAddSelect, bEnterGroup); - break; + SdrObject* pObject = rMrkList.GetMark(i)->GetMarkedSdrObj(); + SwContact* pDrawContact = static_cast<SwContact*>(GetUserCall(pObject)); + SwFrameFormat* pFormat = pDrawContact->GetFormat(); + if (aTextBoxShapes.find(pFormat) != aTextBoxShapes.end()) + { + SdrObject* pShape = aTextBoxShapes[pFormat]->FindSdrObject(); + pDView->UnmarkAll(); + pDView->MarkObj(pShape, Imp()->GetPageView(), bAddSelect, bEnterGroup); + break; + } } } diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 5ee9dd2a605f..204725545c95 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -199,6 +199,26 @@ extern bool g_bExecuteDrag; static SfxShell* lcl_GetTextShellFromDispatcher( SwView& rView ); +/// Check if the selected shape has a TextBox: if so, go into that instead. +static bool lcl_goIntoTextBox(SwEditWin& rEditWin, SwWrtShell& rSh) +{ + SdrObject* pSdrObject = rSh.GetDrawView()->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); + SwFrameFormat* pObjectFormat = ::FindFrameFormat(pSdrObject); + if (SwFrameFormat* pTextBoxFormat = SwTextBoxHelper::findTextBox(pObjectFormat)) + { + SdrObject* pTextBox = pTextBoxFormat->FindRealSdrObject(); + SdrView* pSdrView = rSh.GetDrawView(); + // Unmark the shape. + pSdrView->UnmarkAllObj(); + // Mark the textbox. + rSh.SelectObj(Point(), SW_ALLOW_TEXTBOX, pTextBox); + // Clear the DrawFuncPtr. + rEditWin.StopInsFrame(); + return true; + } + return false; +} + class SwAnchorMarker { SdrHdl* pHdl; @@ -1890,7 +1910,11 @@ KEYINPUT_CHECKTABLE_INSDEL: else if((nSelectionType & nsSelectionType::SEL_DRW) && 0 == (nSelectionType & nsSelectionType::SEL_DRW_TXT) && rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1) + { eKeyState = KS_GoIntoDrawing; + if (lcl_goIntoTextBox(*this, rSh)) + eKeyState = KS_GoIntoFly; + } else if( aTmpQHD.HasContent() && !rSh.HasSelection() && aTmpQHD.m_bIsAutoText ) eKeyState = KS_GlossaryExpand; @@ -2196,7 +2220,11 @@ KEYINPUT_CHECKTABLE_INSDEL: if(nSelectionType & nsSelectionType::SEL_FRM) eKeyState = KS_GoIntoFly; else if((nSelectionType & nsSelectionType::SEL_DRW)) + { eKeyState = KS_GoIntoDrawing; + if (lcl_goIntoTextBox(*this, rSh)) + eKeyState = KS_GoIntoFly; + } } break; } |