summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Kirchhoff <bjoern.kirchhoff@escriba.de>2020-01-15 17:20:54 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-01-16 20:42:21 +0100
commit92b10e5c0825a2fe176738a1b86e2b4db0a263cb (patch)
treed9b15eb41c7debacfe0dd4d283e31c26d71f82f7 /sw
parented4a1a71f0bcbcaceba8929456ea4e7dd1d43a8f (diff)
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.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odtbin0 -> 8966 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx13
-rw-r--r--sw/source/core/unocore/unoobj2.cxx16
3 files changed, 26 insertions, 3 deletions
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
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/textfield-getanchor-gettext-in-footer.odt
Binary files 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)