summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-09 16:40:01 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-05-23 10:54:01 +0200
commit44d80c54581b818a7405e98a591ba3b0632747ee (patch)
tree7745214e642ea2a4885304065b06e51a646dd321
parent9b1d7b235753c85151cc97503764bc99a8903618 (diff)
sw style copy: fix crash when handling a conditional paragraphy style
- "Text body" is normally a conditional style for a full-blown, default SwDoc - SwTransferable::GetData() creates a temporary, stripped down SwDoc, which has a "Text body" style, but it's not conditional - SwDoc::CopyFormatArr() assumes that in case the target already has a style with a given name, then either both the source and destination styles are conditional, or neither - in practice this only causes a crash if the style is customized, as we skip default styles, probably that's why this was not noticed so far The Online case invokes this as part of lok::Document::getSelectionType(), so it was enough to set the paragraph style to Text body and then select some of that text (with a suitable document) to hit this. Based on a patch from Michael Meeks, thanks for that. (cherry picked from commit ce98bef935dccd79735615a9299b2aa7a1ab0b94) Conflicts: sw/qa/extras/tiledrendering/tiledrendering.cxx Change-Id: Ic3c27ec582ae1745469042856254313cbc996ee0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113970 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/source/core/doc/docfmt.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index f7a11676594e..e61d27c6a961 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1328,9 +1328,18 @@ void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
//FEATURE::CONDCOLL
if( RES_CONDTXTFMTCOLL == pSrc->Which() )
+ {
+ if (pDstColl->Which() != RES_CONDTXTFMTCOLL)
+ {
+ // Target already had a style with a matching name, but it's not a conditional
+ // style, then don't copy the conditions.
+ continue;
+ }
+
// Copy the conditions, but delete the old ones first!
static_cast<SwConditionTextFormatColl*>(pDstColl)->SetConditions(
static_cast<SwConditionTextFormatColl*>(pSrc)->GetCondColls() );
+ }
//FEATURE::CONDCOLL
}
}