[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/inc sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Apr 21 16:03:17 UTC 2016
sw/inc/fesh.hxx | 2 ++
sw/qa/extras/uiwriter/data/tdf84695.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 25 +++++++++++++++++++++++++
sw/source/core/frmedt/feshview.cxx | 25 ++++++++++++++-----------
sw/source/uibase/docvw/edtwin.cxx | 28 ++++++++++++++++++++++++++++
5 files changed, 69 insertions(+), 11 deletions(-)
New commits:
commit 79509573b8666c18027f1e642d9bdadd88c3fcc6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Apr 5 09:45:21 2016 +0200
tdf#84695 sw: make TextBox in shape accessible without mouse
F2 or Enter can now switch to text edit mode.
Change-Id: I1aea09bd2fc4fa64db49b2037894082fe33af934
Reviewed-on: https://gerrit.libreoffice.org/23836
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit ab450ee1ca2bee69cba752045781a3298311b181)
Reviewed-on: https://gerrit.libreoffice.org/24080
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index f036728..5821cb1 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
new file mode 100644
index 0000000..f8c3b01
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf84695.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 246201e..c4adc56 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -184,6 +184,7 @@ public:
void testTdf88453Table();
void testTdf98987();
void testTdf99004();
+ void testTdf84695();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -274,6 +275,7 @@ public:
CPPUNIT_TEST(testTdf88453Table);
CPPUNIT_TEST(testTdf98987);
CPPUNIT_TEST(testTdf99004);
+ CPPUNIT_TEST(testTdf84695);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3159,6 +3161,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 4526f4e..6e2917e 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -228,19 +228,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 f83359d..48ccdf2 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;
@@ -1888,7 +1908,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;
@@ -2180,7 +2204,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;
}
More information about the Libreoffice-commits
mailing list