summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-08-27 18:10:15 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-09-10 21:20:31 +0200
commitd51609fbe49042867fa734ef4f6c1755df8514a2 (patch)
tree2cc0f5f776f7b69ff7c987d4b7026f344dc096b8 /sw
parent392c4f184817fda684812906a01e2b204395b6a8 (diff)
tdf#126426: support for hyperlinks in TextParagraphContext
Usually hyperlinks are processed by TextBodyContext, but for grouped shape we accidentaly gone into TextParagraphContext It has almost all possibilities to process txbxContent, but not hyperlinks. Additionally some hyperlink char attributes (color and underline) can expand to follow up ordinal text. Additional small hack applied to avoid this. Unfortunately this is not a final solution: such document fails roundtrip and hyperlinks are lost after saving to DOCX. Conflicts: oox/source/drawingml/textbodycontext.cxx Change-Id: Ie954f53696bd872cb1f59cb586fb55f6cd7c73bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121172 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121904
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf126426.docxbin0 -> 15785 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf126426.docx b/sw/qa/extras/ooxmlimport/data/tdf126426.docx
new file mode 100644
index 000000000000..d77051365ca2
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf126426.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index e01957f553ab..d0f3833aea7e 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/XTextField.hpp>
#include <xmloff/odffields.hxx>
@@ -785,6 +786,43 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf129912)
}
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf126426)
+{
+ load(mpTestDocumentPath, "tdf126426.docx");
+
+ uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroup->getCount());
+
+ // get second shape in group
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xGroup->getByIndex(1),
+ uno::UNO_QUERY_THROW);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+
+ uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY_THROW);
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xPara, uno::UNO_QUERY_THROW);
+
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ {
+ // Text before: was before this bugfix
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("Some text "), xRun->getString());
+ }
+ {
+ // Link and this content was completely missong before
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString("Link"), xRun->getString());
+ auto xURLField = getProperty<uno::Reference<text::XTextField>>(xRun, "TextField");
+ auto aURL = getProperty<OUString>(xURLField, "URL");
+ CPPUNIT_ASSERT_EQUAL(OUString("http://libreoffice.org/"), aURL);
+ }
+ {
+ // Need to ensure that text following hyperlink is still default color (-1)
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(OUString(" and something more."), xRun->getString());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xRun, "CharColor"));
+ }
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();