summaryrefslogtreecommitdiff
path: root/oox
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 /oox
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 'oox')
-rw-r--r--oox/source/drawingml/textbodycontext.cxx12
-rw-r--r--oox/source/drawingml/textrun.cxx8
2 files changed, 19 insertions, 1 deletions
diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx
index 49b50309f597..e2b3de1d1ab2 100644
--- a/oox/source/drawingml/textbodycontext.cxx
+++ b/oox/source/drawingml/textbodycontext.cxx
@@ -28,6 +28,8 @@
#include <oox/drawingml/shape.hxx>
#include <oox/token/namespaces.hxx>
+#include "hyperlinkcontext.hxx"
+
#include <oox/mathml/import.hxx>
#include <sal/log.hxx>
@@ -101,6 +103,16 @@ ContextHandlerRef TextParagraphContext::onCreateContext( sal_Int32 aElementToken
return this;
case OOX_TOKEN(a14, m):
return CreateLazyMathBufferingContext(*this, mrParagraph);
+ case W_TOKEN( hyperlink ):
+ {
+ TextRunPtr pRun = std::make_shared<TextRun>();
+ mrParagraph.addRun(pRun);
+ // parse hyperlink attributes: use HyperLinkContext for that
+ rtl::Reference<HyperLinkContext> pContext(new HyperLinkContext(
+ *this, rAttribs, pRun->getTextCharacterProperties().maHyperlinkPropertyMap));
+ // but create text run context because HyperLinkContext can't process internal w:r, w:t, etc
+ return new RegularTextRunContext(*this, pRun);
+ }
default:
SAL_WARN("oox", "TextParagraphContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
}
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
index ab87fb732141..e3bcecb745d5 100644
--- a/oox/source/drawingml/textrun.cxx
+++ b/oox/source/drawingml/textrun.cxx
@@ -69,7 +69,13 @@ sal_Int32 TextRun::insertAt(
Any aOldFontFamily = xState->getPropertyDefault("CharFontFamily");
TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
- aTextCharacterProps.assignUsed( maTextCharacterProperties );
+
+ // If no text color specified lets anyway initialize it as default:
+ // this will help to recover after hyperlink
+ if (!aTextCharacterProps.maFillProperties.maFillColor.isUsed())
+ aTextCharacterProps.maFillProperties.moFillType = XML_solidFill;
+
+ aTextCharacterProps.assignUsed(maTextCharacterProperties);
if ( aTextCharacterProps.moHeight.has() )
nCharHeight = aTextCharacterProps.moHeight.get();
else