summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-04-19 18:04:47 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-04-29 21:04:59 +0200
commit0c1e01cd8370b1c05e12dc965bf3e95bc2fd7378 (patch)
tree165cd8842de38132745a31ebb297a8919ec922e8
parent4d744d94cc4ee114a7e5d5373b2b599baed31ee5 (diff)
tdf#114287 tdf#159366 xmloff: ODF import: revert text:list override
This reverts commit ade0a153f453500f15343380ac937252992733e0 "tdf#114287 xmloff: ODF import: fix text:list override of list style" and subsequent commits 7cf5faec6fdbc27dd77d2d36fb2ff205322cba0d and 1b2a6b98291cf8b7022951be19b915fe2a9e18e6. It turns out that there is actually a paragraph in ODF 1.2 and later that gives paragraph's indent priority over the list style's, which i unfortunately missed when investigating the above issues: 17.20 <style:list-level-label-alignment> ... The fo:text-indent and fo:margin-left attributes are evaluated only for paragraphs inside list items whose paragraph styles do not specify them. If one of the two properties, or both, are specified by the paragraph style, the text indent and/or left margin are taken from the paragraph style. In this case the paragraph style's properties are used to determine the indent and margin for the text lines and thus also the alignment position. This is usually interpreted as "on the same level", so applying a list-style at a paragraph style overrides the indents inherited from a parent paragraph style, but if the style then specifies its own indents that overrides the list style's indents. Furthermore it turns out that Google Docs now imports this bugdoc the same way as LO 7.5 does; unclear if that changed recently (it shows it like Word does in the preview, but like LO 7.5 does after opening it). This means the way MS Word imports the bugdoc, which remains unchanged, now looks like a bug and we should not change LO to be compatible with it (when the same structure is created in Word, storing to ODF and loading again, it looks different too). Change-Id: I0c65bde38de9e6fcbccec55899c60c3245adb5ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166309 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins (cherry picked from commit 546741148863ae0b2a25cc994a7323c8113cb573) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166717 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx6
-rw-r--r--xmloff/source/text/XMLTextListBlockContext.hxx1
-rw-r--r--xmloff/source/text/txtimp.cxx72
3 files changed, 5 insertions, 74 deletions
diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx
index 103892a7723a..67080ede80a9 100644
--- a/sw/qa/extras/odfexport/odfexport2.cxx
+++ b/sw/qa/extras/odfexport/odfexport2.cxx
@@ -852,9 +852,9 @@ DECLARE_ODFEXPORT_TEST(testTdf114287, "tdf114287.odt")
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/prtBounds", "left", "2268");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/infos/prtBounds", "right", "11339");
- // the problem was that the list style name of the list must override the
- // paragraph style even though it's the same list style
- assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/infos/prtBounds", "left", "357");
+ // the list style name of the list is the same as the list style name of the
+ // paragraph, but in any case the margins of the paragraph take precedence
+ assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/infos/prtBounds", "left", "2268");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[9]/infos/prtBounds", "right", "11339");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[16]/infos/prtBounds", "left", "357");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[16]/infos/prtBounds", "right", "11339");
diff --git a/xmloff/source/text/XMLTextListBlockContext.hxx b/xmloff/source/text/XMLTextListBlockContext.hxx
index 4b18d625cc36..a529afd1e476 100644
--- a/xmloff/source/text/XMLTextListBlockContext.hxx
+++ b/xmloff/source/text/XMLTextListBlockContext.hxx
@@ -66,7 +66,6 @@ public:
void ResetRestartNumbering() { mbRestartNumbering = false; }
/// does this list have (possibly inherited from parent) list-style-name?
- bool HasListStyleName() { return !msListStyleName.isEmpty(); }
const css::uno::Reference < css::container::XIndexReplace >& GetNumRules() const
{ return mxNumRules; }
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index f63b13cebe86..0a7856bca90e 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -1004,45 +1004,6 @@ static bool lcl_HasListStyle( const OUString& sStyleName,
return bRet;
}
-namespace {
-
-auto IsPropertySet(uno::Reference<container::XNameContainer> const& rxParaStyles,
- uno::Reference<beans::XPropertySet> const& rxPropSet,
- OUString const& rProperty)
-{
- uno::Reference<beans::XPropertyState> const xPropState(rxPropSet, uno::UNO_QUERY);
- // note: this is true only if it is set in automatic style
- if (xPropState->getPropertyState(rProperty) == beans::PropertyState_DIRECT_VALUE)
- {
- return true;
- }
- if (xPropState->getPropertyState("NumberingStyleName") == beans::PropertyState_DIRECT_VALUE)
- {
- return false; // tdf#159903 this overrides value in the parent style
- }
- // check if it is set by any parent common style
- OUString style;
- rxPropSet->getPropertyValue("ParaStyleName") >>= style;
- while (!style.isEmpty() && rxParaStyles.is() && rxParaStyles->hasByName(style))
- {
- uno::Reference<style::XStyle> const xStyle(rxParaStyles->getByName(style), uno::UNO_QUERY);
- assert(xStyle.is());
- uno::Reference<beans::XPropertyState> const xStyleProps(xStyle, uno::UNO_QUERY);
- if (xStyleProps->getPropertyState(rProperty) == beans::PropertyState_DIRECT_VALUE)
- {
- return true;
- }
- if (xStyleProps->getPropertyState("NumberingStyleName") == beans::PropertyState_DIRECT_VALUE)
- {
- return false; // tdf#159903 this overrides value in the parent style
- }
- style = xStyle->getParentStyle();
- }
- return false;
-};
-
-} // namespace
-
OUString XMLTextImportHelper::SetStyleAndAttrs(
SvXMLImport & rImport,
const Reference < XTextCursor >& rCursor,
@@ -1126,17 +1087,8 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
bool bNumberingIsNumber(true);
// Assure that list style of automatic paragraph style is applied at paragraph. (#i101349#)
bool bApplyNumRules(pStyle && pStyle->IsListStyleSet());
- bool bApplyNumRulesFix(false);
if (pListBlock) {
- // the xNumRules is always created, even without a list-style-name
- if (!bApplyNumRules
- && (pListBlock->HasListStyleName()
- || (pListItem != nullptr && pListItem->HasNumRulesOverride())))
- {
- bApplyNumRules = true; // tdf#114287
- bApplyNumRulesFix = rImport.isGeneratorVersionOlderThan(SvXMLImport::AOO_4x, SvXMLImport::LO_76);
- }
if (!pListItem) {
bNumberingIsNumber = false; // list-header
@@ -1168,7 +1120,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
if (pListBlock || pNumberedParagraph)
{
- if (!bApplyNumRules || bApplyNumRulesFix)
+ if (!bApplyNumRules)
{
bool bSameNumRules = xNewNumRules == xNumRules;
if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
@@ -1192,14 +1144,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
}
}
}
- if (!bApplyNumRules)
- {
- bApplyNumRules = !bSameNumRules;
- }
- if (!bSameNumRules)
- {
- bApplyNumRulesFix = false;
- }
+ bApplyNumRules = !bSameNumRules;
}
if ( bApplyNumRules )
@@ -1213,19 +1158,6 @@ OUString XMLTextImportHelper::SetStyleAndAttrs(
{
xPropSet->setPropertyValue(
s_NumberingRules, Any(xNewNumRules) );
- if (bApplyNumRulesFix)
- { // tdf#156146 override list margins for bug compatibility
- if (IsPropertySet(m_xImpl->m_xParaStyles, xPropSet, "ParaLeftMargin"))
- {
- uno::Any const left(xPropSet->getPropertyValue("ParaLeftMargin"));
- xPropSet->setPropertyValue("ParaLeftMargin", left);
- }
- if (IsPropertySet(m_xImpl->m_xParaStyles, xPropSet, "ParaFirstLineIndent"))
- {
- uno::Any const first(xPropSet->getPropertyValue("ParaFirstLineIndent"));
- xPropSet->setPropertyValue("ParaFirstLineIndent", first);
- }
- }
}
catch(const Exception&)
{