summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-12-20 12:14:16 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-12-20 15:47:00 +0000
commit209dce614c43f63f63f5b42a746665c0ec1cbfe3 (patch)
tree981eedd498637f642ae15df774da2a0427ae8196 /xmloff
parent3e9e457f931502b9a64fd8b58b37ad1fe4c9ebbe (diff)
sw: fix ODT import of paragraph marker formatting
The DOCX bugdoc had a numbering portion which was not bold, even if all characters in the paragrpah was bold. This was rendered fine, but once it was saved to ODT + reloaded, the numbering portion became bold as well, which is buggy. What happens here is that there is one span that covers the entire paragraph (and is bold) and there is an empty span at paragraph end (which is not bold), so the ODT export is fine. But once we import it back, the first span gets "upgraded" to paragraph-level formatting (because SetAttrMode::NOFORMATATTR is not used when inserting the hints) and the second span is not mapped back to the original RES_PARATR_LIST_AUTOFMT in the text node. Fix the problem by 1) improving SwXTextCursor::setPropertyValue() to work with SetAttrMode::NOFORMATATTR when multiple spans are inserted and by 2) extending SwUnoCursorHelper::SetCursorPropertyValue() to create RES_PARATR_LIST_AUTOFMT for empty spans at paragraph end. This way the original doc model and the one created after ODT export + import is much closer to each other. This builds on top of 6249858a8972aef077e0249bd93cfe8f01bce4d6 (sw: ODT import/export of DOCX's paragraph marker formatting, 2022-12-19), previously the ODT export and import of paragraph marker formatting was completely missing. (cherry picked from commit 1feb1aa08421f9d0934ab65ce94cf6054818c0f3) Also includes commit de235fe13a2e5a4db043f44e6d5636e308f2b979 (sw layout xml dump: show numbering portion weight, 2022-12-19). Change-Id: I139e11217dcbc18744aeeb80638090781aa74933 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144602 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/txtparai.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 49d4f5abd3c4..9844e2628c89 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -1821,6 +1821,19 @@ void XMLParaContext::endFastElement(sal_Int32 )
if (m_xHints)
{
+ bool bSetNoFormatAttr = false;
+ uno::Reference<beans::XPropertySet> xCursorProps(xAttrCursor, uno::UNO_QUERY);
+ if (m_xHints->GetHints().size() > 1)
+ {
+ // We have multiple hints, then make try to ask the cursor to not upgrade our character
+ // attributes to paragraph-level formatting, which would lead to incorrect rendering.
+ uno::Reference<beans::XPropertySetInfo> xCursorPropsInfo = xCursorProps->getPropertySetInfo();
+ bSetNoFormatAttr = xCursorPropsInfo->hasPropertyByName("NoFormatAttr");
+ }
+ if (bSetNoFormatAttr)
+ {
+ xCursorProps->setPropertyValue("NoFormatAttr", uno::Any(true));
+ }
for (const auto & i : m_xHints->GetHints())
{
XMLHint_Impl *const pHint = i.get();
@@ -1960,6 +1973,10 @@ void XMLParaContext::endFastElement(sal_Int32 )
break;
}
}
+ if (bSetNoFormatAttr)
+ {
+ xCursorProps->setPropertyValue("NoFormatAttr", uno::Any(false));
+ }
}
m_xHints.reset();
}