sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 13 ++++++++ sw/source/core/unocore/unoobj2.cxx | 16 ++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-)
New commits: commit 92b10e5c0825a2fe176738a1b86e2b4db0a263cb Author: Bjoern Kirchhoff <bjoern.kirchh...@escriba.de> AuthorDate: Wed Jan 15 17:20:54 2020 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Thu Jan 16 20:42:21 2020 +0100 FirstLeft and FirstMaster not handled in CreateParentXText FirstLeft and FirstMaster were not taken into account in CreateParentXText. Code calling getAnchor().getText().toString() on text fields failed, when they where contained in footers/headers of first left or first right pages. These cases are now implemented. Change-Id: I7fbe9eb95a3fa0d90ebd8432b8a315d186da6f64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86869 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odt b/sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odt new file mode 100644 index 000000000000..5089ae8afb5e Binary files /dev/null and b/sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index a0d5f66549a0..8cbfc338e013 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -194,6 +194,7 @@ public: void testShapeTextboxAutosize(); void testFdo82191(); void testCommentedWord(); + void testTextFieldGetAnchorGetTextInFooter(); void testChineseConversionBlank(); void testChineseConversionNonChineseText(); void testChineseConversionTraditionalToSimplified(); @@ -400,6 +401,7 @@ public: CPPUNIT_TEST(testShapeTextboxAutosize); CPPUNIT_TEST(testFdo82191); CPPUNIT_TEST(testCommentedWord); + CPPUNIT_TEST(testTextFieldGetAnchorGetTextInFooter); CPPUNIT_TEST(testChineseConversionBlank); CPPUNIT_TEST(testChineseConversionNonChineseText); CPPUNIT_TEST(testChineseConversionTraditionalToSimplified); @@ -1428,6 +1430,17 @@ void SwUiWriterTest::testCommentedWord() CPPUNIT_ASSERT_EQUAL(OUString("word"), xField->getAnchor()->getString()); } +void SwUiWriterTest::testTextFieldGetAnchorGetTextInFooter() { + createDoc("textfield-getanchor-gettext-in-footer.odt"); + + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + uno::Reference<text::XTextContent> xField(xFields->nextElement(), uno::UNO_QUERY); + + OUString value = xField->getAnchor()->getText()->getString(); + CPPUNIT_ASSERT_EQUAL(OUString("userfield_in_footer"), value ); +} // Chinese conversion tests diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 66588a58919d..a4708d249970 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1111,15 +1111,25 @@ CreateParentXText(SwDoc & rDoc, const SwPosition& rPos) for(size_t i = 0; i < nPDescCount; i++) { const SwPageDesc& rDesc = rDoc.GetPageDesc( i ); + const SwFrameFormat* pFrameFormatMaster = &rDesc.GetMaster(); const SwFrameFormat* pFrameFormatLeft = &rDesc.GetLeft(); + const SwFrameFormat* pFrameFormatFirstMaster = &rDesc.GetFirstMaster(); + const SwFrameFormat* pFrameFormatFirstLeft = &rDesc.GetFirstLeft(); SwFrameFormat* pHeadFootFormat = nullptr; if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatMaster, - pHeadFootFormat)) + pHeadFootFormat)) { - lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft, - pHeadFootFormat); + if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft, + pHeadFootFormat)) + { + if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstMaster, + pHeadFootFormat)) + { + lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstLeft, pHeadFootFormat); + } + } } if (pHeadFootFormat) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits