diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-04-09 16:40:01 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-04-12 15:37:21 +0200 |
commit | 332f5479ec30588305b9077eed81a644bbb5d4e8 (patch) | |
tree | 5175d45c528a986be87cde2e159ee79469a5b979 /sw/source | |
parent | 4b6da738fdd934bfac1bb9779682398bea771867 (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>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 9 |
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 } } |