summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorSkyler Grey <skyler.grey@collabora.com>2023-11-09 16:57:50 +0000
committerAndras Timar <andras.timar@collabora.com>2023-11-10 18:30:32 +0100
commit6450a0a13637dba080c98514409678d24ea2101a (patch)
tree8b4abf74c137dad09450cf5392ecd0d4c1e51ce6 /sw/source/filter
parent642ef173af38faafed6b612291b8acd08d27195d (diff)
Fix STYLEREF crashes and forwards-compatibility
This commit fixes a crash in STYLEREF caused by a dereferenced nullptr when serializing chapter fields for .doc export. Along with the STYLEREF changes, I also changed the chapter export logic to allow exporting chapter fields when they were in document text, and to use the style of the thing they pointed to. Unfortunately, in some cases that would be null. This commit makes us fall back to previous behavior in those cases. This commit also adds import logic for styleref on the TEXT namespace in addition to LO_EXT. This is important as if/when the STYLEREF field is no longer LO_EXT we want to be able to open new documents in old versions of libreoffice. This was erroneously missed when we changed TEXT references to LO_EXT in our export logic. Change-Id: I383828c9409afc8545af379307f528cee2e1a960 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159230 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 62ae243168ec..6e73e9255495 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3430,6 +3430,9 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
// Otherwise, get the style of the text and use it as the style name
const SwTextNode* pOutlineNd = pTextNd->FindOutlineNodeOfLevel(aCopy.GetLevel());
+ if (!pOutlineNd) break;
+ // Sometimes we can't find the outline node, in that case let's just fallback to exporting the text
+
sStr = FieldString(ww::eSTYLEREF)
+ GetExport().GetStyleRefName(pOutlineNd->GetFormatColl()->GetName());
}