summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-05-30 16:10:03 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-05-30 18:05:08 +0200
commit05bc773b0e88b408a997ffa5851cc9207d3303e5 (patch)
treebb883552a1d25ecc57d148e8a068c394059d0b4e /sw/source
parent4c29c7107ed45b777a63c4060340e03f54375391 (diff)
tdf#73483: make sure to not reset style names
The problem was, that resetting direct formatting also used to reset RES_FRMATR_STYLE_NAME and RES_FRMATR_CONDITIONAL_STYLE_NAME. These are important at autostyles export: in XMLTextParagraphExport::Add, SwXAutoStyle is queried for ParaStyleName/ParaConditionalStyleName properties, and empty values of these were used to add the autostyle to pool. Looking for the autostyle while exporting the paragraph, SwXParagraph reports the correct "Standard" as the style name, but no matching children were found for the "Standard" parent style, and so the paragraph got "Standard" style name, instead of the autostyle. Change-Id: Iadf24ebd2b85e494267b73336a54b24f85ea0a0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152393 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/docfmt.cxx60
1 files changed, 33 insertions, 27 deletions
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index bc5994a58d37..8ed9c4c9d249 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -116,7 +116,8 @@ static bool lcl_RstAttr( SwNode* pNd, void* pArgs )
SfxItemSetFixed<
RES_PARATR_NUMRULE, RES_PARATR_NUMRULE,
RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1,
- RES_PAGEDESC, RES_BREAK> aSavedAttrsSet(rDoc.GetAttrPool());
+ RES_PAGEDESC, RES_BREAK,
+ RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME> aSavedAttrsSet(rDoc.GetAttrPool());
const SfxItemSet* pAttrSetOfNode = pNode->GetpSwAttrSet();
std::vector<sal_uInt16> aClearWhichIds;
@@ -137,32 +138,35 @@ static bool lcl_RstAttr( SwNode* pNd, void* pArgs )
}
}
- const SfxPoolItem* pItem;
-
- sal_uInt16 const aSavIds[3] = { RES_PAGEDESC, RES_BREAK, RES_PARATR_NUMRULE };
- for (sal_uInt16 aSavId : aSavIds)
+ if (auto pItem = pAttrSetOfNode->GetItemIfSet(RES_PARATR_NUMRULE, false);
+ pItem && !pItem->GetValue().isEmpty())
{
- if (SfxItemState::SET == pAttrSetOfNode->GetItemState(aSavId, false, &pItem))
- {
- bool bSave = false;
- switch( aSavId )
- {
- case RES_PAGEDESC:
- bSave = nullptr != pItem->StaticWhichCast(RES_PAGEDESC).GetPageDesc();
- break;
- case RES_BREAK:
- bSave = SvxBreak::NONE != pItem->StaticWhichCast(RES_BREAK).GetBreak();
- break;
- case RES_PARATR_NUMRULE:
- bSave = !pItem->StaticWhichCast(RES_PARATR_NUMRULE).GetValue().isEmpty();
- break;
- }
- if( bSave )
- {
- aSavedAttrsSet.Put(*pItem);
- aClearWhichIds.push_back(aSavId);
- }
- }
+ aSavedAttrsSet.Put(*pItem);
+ aClearWhichIds.push_back(RES_PARATR_NUMRULE);
+ }
+ if (auto pItem = pAttrSetOfNode->GetItemIfSet(RES_PAGEDESC, false);
+ pItem && pItem->GetPageDesc())
+ {
+ aSavedAttrsSet.Put(*pItem);
+ aClearWhichIds.push_back(RES_PAGEDESC);
+ }
+ if (auto pItem = pAttrSetOfNode->GetItemIfSet(RES_BREAK, false);
+ pItem && pItem->GetBreak() != SvxBreak::NONE)
+ {
+ aSavedAttrsSet.Put(*pItem);
+ aClearWhichIds.push_back(RES_BREAK);
+ }
+ if (auto pItem = pAttrSetOfNode->GetItemIfSet(RES_FRMATR_STYLE_NAME, false);
+ pItem && !pItem->GetValue().isEmpty())
+ {
+ aSavedAttrsSet.Put(*pItem);
+ aClearWhichIds.push_back(RES_FRMATR_STYLE_NAME);
+ }
+ if (auto pItem = pAttrSetOfNode->GetItemIfSet(RES_FRMATR_CONDITIONAL_STYLE_NAME, false);
+ pItem && !pItem->GetValue().isEmpty())
+ {
+ aSavedAttrsSet.Put(*pItem);
+ aClearWhichIds.push_back(RES_FRMATR_CONDITIONAL_STYLE_NAME);
}
// do not clear items directly from item set and only clear to be kept
@@ -186,10 +190,12 @@ static bool lcl_RstAttr( SwNode* pNd, void* pArgs )
OSL_ENSURE( !bKeepAttributes,
"<lcl_RstAttr(..)> - certain attributes are kept, but not needed." );
SfxItemIter aIter( *pPara->pDelSet );
- for (pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
+ for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
{
if ( ( pItem->Which() != RES_PAGEDESC &&
pItem->Which() != RES_BREAK &&
+ pItem->Which() != RES_FRMATR_STYLE_NAME &&
+ pItem->Which() != RES_FRMATR_CONDITIONAL_STYLE_NAME &&
pItem->Which() != RES_PARATR_NUMRULE ) ||
( aSavedAttrsSet.GetItemState( pItem->Which(), false ) != SfxItemState::SET ) )
{