summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-05-15 12:51:29 +0300
committerJustin Luth <justin_luth@sil.org>2020-05-25 06:43:33 +0200
commit50b76d9bf3747e1b5bcb6ce189337872db379e45 (patch)
treeb9894ff99955a22db9ed5e6f16e7f3d59dfa1c94 /writerfilter
parent21875558f6c478f07d68ff39e025d7ffd451674f (diff)
tdf#133000 writerfilter: apply non-contradictory num-style
This fixes 7.0 regression exposed by tdf#131321's commit 35fc5ef0a759884b24ed8b83cd05702a0fab64cc This patch version heavily depends on recent changes, but could easily be adapted to older ways. (See previous versions in gerrit.) Because LO can now find the numbering rule through the para-style definition, it doesn't bother creating it as a direct paragraph property anymore. So that "directness" has to be specified during the import. This problem manifested itself in two ways. 1.) In SW, the direct numbering was lost and it simply inherits from the para-style. If numbering is now turned off in the para-style, then the paragraph loses it too. 2.) Because the numbering was considered to be defined by the paragraph style, the para-style-indents had higher priority than the numbering-indents. When numbering is defined directly on the paragraph, it has higher priority than the para-style-indents. Change-Id: I04c3944de8a91d9f253791fbd05d6324a8b7a9da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94365 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx1
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx33
-rw-r--r--writerfilter/source/dmapper/NumberingManager.hxx1
3 files changed, 29 insertions, 6 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index a09271548e97..539114928bd3 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3506,6 +3506,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
// to the next paragraph in sw SplitNode and then be applied to
// every following paragraph
xContext->Erase(PROP_NUMBERING_RULES);
+ static_cast<ParagraphPropertyMap*>(xContext.get())->SetListId(-1);;
xContext->Erase(PROP_NUMBERING_LEVEL);
}
m_pImpl->SetParaSectpr(false);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4b7b3ccd45ef..3021aec15c6c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1372,19 +1372,40 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
OSL_ENSURE( pEntry.get(), "no style sheet found" );
const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
bool isNumberingViaStyle(false);
+ bool isNumberingViaRule = pParaContext && pParaContext->GetListId() > -1;
//apply numbering to paragraph if it was set at the style, but only if the paragraph itself
//does not specify the numbering
sal_Int32 nListId = -1;
- if ( !bRemove && pStyleSheetProperties && pParaContext && !pParaContext->isSet(PROP_NUMBERING_RULES) )
+ if ( !bRemove && pStyleSheetProperties && pParaContext )
{
+ const sal_Int16 nListLevel = pStyleSheetProperties->GetListLevel();
+
bool bNumberingFromBaseStyle = false;
nListId = pEntry ? lcl_getListId(pEntry, GetStyleSheetTable(), bNumberingFromBaseStyle) : -1;
auto const pList(GetListTable()->GetList(nListId));
if (pList && nListId >= 0 && !pParaContext->isSet(PROP_NUMBERING_STYLE_NAME))
{
- pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny( pList->GetStyleName() ), false);
- isNumberingViaStyle = true;
+ if ( !isNumberingViaRule )
+ {
+ isNumberingViaStyle = true;
+ // Since LO7.0/tdf#131321 fixed the loss of numbering in styles, this OUGHT to be obsolete,
+ // but now other new/critical LO7.0 code expects it, and perhaps some corner cases still need it as well.
+ pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny(pList->GetStyleName()), true );
+ }
+ else if ( !pList->isOutlineNumbering(nListLevel) )
+ {
+ // After ignoring anything related to the special Outline levels,
+ // we have direct numbering, as well as paragraph-style numbering.
+ // Apply the style if it uses the same list as the direct numbering,
+ // otherwise the directly-applied-to-paragraph status will be lost,
+ // and the priority of the numbering-style-indents will be lowered. tdf#133000
+ if ( nListId == pParaContext->GetListId() )
+ pParaContext->Insert( PROP_NUMBERING_STYLE_NAME, uno::makeAny(pList->GetStyleName()), true );
+ }
+ }
+ if ( isNumberingViaStyle )
+ {
// Indent properties from the paragraph style have priority
// over the ones from the numbering styles in Word
// but in Writer numbering styles have priority,
@@ -1420,8 +1441,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
pParaContext->Insert(PROP_PARA_RIGHT_MARGIN, uno::makeAny(nParaRightMargin), /*bOverwrite=*/false);
}
}
-
- if ( pStyleSheetProperties->GetListLevel() >= 0 )
+ if ( !isNumberingViaRule && pStyleSheetProperties->GetListLevel() >= 0 )
pParaContext->Insert( PROP_NUMBERING_LEVEL, uno::makeAny(pStyleSheetProperties->GetListLevel()), false);
}
@@ -1625,7 +1645,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
return rValue.Name == "NumberingRules";
});
- bool isNumberingViaRule = (itNumberingRules != aProperties.end());
+ assert( isNumberingViaRule == (itNumberingRules != aProperties.end()) );
+ isNumberingViaRule = (itNumberingRules != aProperties.end());
if (m_xPreviousParagraph.is() && (isNumberingViaRule || isNumberingViaStyle))
{
// This textnode has numbering. Look up the numbering style name of the current and previous paragraph.
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index f5c2d01e6e64..f2f89eca9f40 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -166,6 +166,7 @@ public:
const OUString& GetStyleLink() const { return m_sStyleLink; };
const OUString& MapListId(OUString const& rId);
+ bool isOutlineNumbering( sal_uInt16 nLvl ) { return GetLevel(nLvl) && GetLevel(nLvl)->isOutlineNumbering(); }
};
class ListDef : public AbstractListDef