sw/qa/extras/layout/data/tdf120287.fodt |   40 ++++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout.cxx          |   12 +++++++++
 sw/source/filter/xml/xmlimp.cxx         |   12 +++++++++
 3 files changed, 64 insertions(+)

New commits:
commit 54204d53eb4854715500edc064123e8d687381b2
Author:     Miklos Vajna <vmik...@collabora.co.uk>
AuthorDate: Thu Oct 4 09:57:57 2018 +0200
Commit:     Miklos Vajna <vmik...@collabora.co.uk>
CommitDate: Thu Oct 4 13:29:36 2018 +0200

    tdf#120287 sw layout, TabOverMargin: imply PrinterIndependentLayout=high-res
    
    In case an ODT document has the usual layout compat flags enabled (by
    the DOC/DOCX/RTF imports) to emulate Word behavior, then it's expected
    that Word will lay out the resulting ODT document similar to Writer.
    
    This works most of the time, but in case exact spacing matters, it's
    important that PrinterIndependentLayout is not disabled, as that doesn't
    match the Word default and will result in mismatching Writer vs Word
    layout.
    
    Change-Id: I0fbe110a6417ffa5d919fb81236a60bfa1fc30f5
    Reviewed-on: https://gerrit.libreoffice.org/61352
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/data/tdf120287.fodt 
b/sw/qa/extras/layout/data/tdf120287.fodt
new file mode 100644
index 000000000000..55527c1e2797
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf120287.fodt
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:settings>
+    <config:config-item-set config:name="ooo:configuration-settings">
+      <config:config-item config:name="TabOverMargin" 
config:type="boolean">true</config:config-item>
+      <config:config-item config:name="TabsRelativeToIndent" 
config:type="boolean">true</config:config-item>
+      <config:config-item config:name="PrinterIndependentLayout" 
config:type="string">disabled</config:config-item>
+    </config:config-item-set>
+  </office:settings>
+  <office:font-face-decls>
+    <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+  </office:font-face-decls>
+  <office:styles>
+    <style:default-style style:family="paragraph"/>
+    <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+      <style:text-properties style:use-window-font-color="true" 
style:font-name="Liberation Serif" fo:font-family="&apos;Liberation 
Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable" 
fo:font-size="10pt" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" 
fo:hyphenation-push-char-count="2"/>
+    </style:style>
+  </office:styles>
+  <office:automatic-styles>
+    <style:style style:name="P1" style:family="paragraph" 
style:parent-style-name="Standard" style:master-page-name="page style">
+      <style:paragraph-properties fo:margin-left="1.251cm" 
fo:margin-right="2.499cm" fo:text-align="start" 
style:justify-single-word="false" fo:text-indent="-1.251cm" 
style:auto-text-indent="false">
+        <style:tab-stops>
+          <style:tab-stop style:position="9.751cm" style:type="right"/>
+        </style:tab-stops>
+      </style:paragraph-properties>
+      <style:text-properties officeooo:rsid="0022ea4f" 
officeooo:paragraph-rsid="0022ea4f"/>
+    </style:style>
+    <style:page-layout style:name="pm1" style:page-usage="mirrored">
+      <style:page-layout-properties fo:page-width="14.801cm" 
fo:page-height="21.001cm" fo:margin-top="1.101cm" fo:margin-bottom="1cm" 
fo:margin-left="1.9cm" fo:margin-right="1.9cm"/>
+    </style:page-layout>
+  </office:automatic-styles>
+  <office:master-styles>
+    <style:master-page style:name="page style" 
style:page-layout-name="pm1"></style:master-page>
+  </office:master-styles>
+  <office:body>
+    <office:text>
+      <text:p text:style-name="P1">b)<text:tab/>Lorem ipsum dolor sit amet, 
consetetur sadips<text:tab/>1 2 3 4 5 6 78sed diam</text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index fc17a36500f9..79211e1c4007 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -49,6 +49,7 @@ public:
     void testTdf117188();
     void testTdf117187();
     void testTdf119875();
+    void testTdf120287();
 
     CPPUNIT_TEST_SUITE(SwLayoutWriter);
     CPPUNIT_TEST(testRedlineFootnotes);
@@ -73,6 +74,7 @@ public:
     CPPUNIT_TEST(testTdf117188);
     CPPUNIT_TEST(testTdf117187);
     CPPUNIT_TEST(testTdf119875);
+    CPPUNIT_TEST(testTdf120287);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1445,6 +1447,16 @@ void SwLayoutWriter::testTdf119875()
     CPPUNIT_ASSERT_LESS(nSecondTop, nFirstTop);
 }
 
+void SwLayoutWriter::testTdf120287()
+{
+    createDoc("tdf120287.fodt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    // This was 2, TabOverMargin Word-specific compat flag did not imply
+    // default-in-Word printer-independent layout, resulting in an additional
+    // line break.
+    assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index dd419b586119..e76ae1a787fe 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1388,6 +1388,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence 
< PropertyValue > & aC
     bool bClippedPictures = false;
     bool bBackgroundParaOverDrawings = false;
     bool bTabOverMargin = false;
+    bool bTabOverMarginValue = false;
     bool bPropLineSpacingShrinksFirstLine = false;
     bool bSubtractFlysAnchoredAtFlys = false;
     bool bDisableOffPagePositioning = false;
@@ -1478,7 +1479,10 @@ void SwXMLImport::SetConfigurationSettings(const 
Sequence < PropertyValue > & aC
                 else if ( pValues->Name == "BackgroundParaOverDrawings" )
                     bBackgroundParaOverDrawings = true;
                 else if ( pValues->Name == "TabOverMargin" )
+                {
                     bTabOverMargin = true;
+                    pValues->Value >>= bTabOverMarginValue;
+                }
                 else if ( pValues->Name == "PropLineSpacingShrinksFirstLine" )
                     bPropLineSpacingShrinksFirstLine = true;
                 else if (pValues->Name == "SubtractFlysAnchoredAtFlys")
@@ -1639,6 +1643,14 @@ void SwXMLImport::SetConfigurationSettings(const 
Sequence < PropertyValue > & aC
     if ( !bTabOverMargin )
         xProps->setPropertyValue("TabOverMargin", makeAny( false ) );
 
+    if (bTabOverMarginValue)
+        // Let TabOverMargin imply the new default for
+        // PrinterIndependentLayout, knowing the first is set by Word import
+        // filters and Word defaults to our new default as well.
+        xProps->setPropertyValue(
+            "PrinterIndependentLayout",
+            
uno::Any(static_cast<sal_Int16>(document::PrinterIndependentLayout::HIGH_RESOLUTION)));
+
     if (!bPropLineSpacingShrinksFirstLine)
         xProps->setPropertyValue("PropLineSpacingShrinksFirstLine", 
makeAny(false));
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to