[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 3 09:06:18 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf115719.docx  |binary
 sw/qa/extras/ooxmlimport/data/tdf115719b.docx |binary
 sw/qa/extras/ooxmlimport/data/tdf124600.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx     |   11 +++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx |   11 ++++++++++-
 5 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 6de9cff1f918b6fc3ef58d9e080388c741e84b55
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Sep 17 11:30:26 2019 +0200
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Thu Oct 3 11:05:18 2019 +0200

    Related: tdf#124600 DOCX import: ignore left wrap on left-aligned shapes
    
    The DOC import does the same in
    SwWW8ImplReader::AdjustLRWrapForWordMargins(). This fixes one
    sub-problem of the bugdoc, so now the shape anchored in the header has a
    correct position.
    
    This made it necessary to re-visit the tdf#115719 testcases, which are
    minimal reproducers. The original document had from-left alignment
    (instead of align-to-left), but this did not matter before. Bring the
    test documents closer to the original large document, so the tests still
    pass and don't depend on LO mis-handling the above mentioned
    left-aligned situation. (The interesting property of tdf115719.docx,
    where Word 2010 and Word 2013 handles the document differently is
    preserved after this change.)
    
    (cherry picked from commit 4883da6fd25e4645a3b30cb58212a2f666dae75a)
    
    Change-Id: I973c13df47b0867e2c4756f0c448495257b7c9d5
    Reviewed-on: https://gerrit.libreoffice.org/80041
    Tested-by: Jenkins
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf115719.docx b/sw/qa/extras/ooxmlexport/data/tdf115719.docx
index f98f8b4a05dc..4eda09a98fa2 100644
Binary files a/sw/qa/extras/ooxmlexport/data/tdf115719.docx and b/sw/qa/extras/ooxmlexport/data/tdf115719.docx differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf115719b.docx b/sw/qa/extras/ooxmlimport/data/tdf115719b.docx
index 8c552baf76c1..4cb13228443a 100644
Binary files a/sw/qa/extras/ooxmlimport/data/tdf115719b.docx and b/sw/qa/extras/ooxmlimport/data/tdf115719b.docx differ
diff --git a/sw/qa/extras/ooxmlimport/data/tdf124600.docx b/sw/qa/extras/ooxmlimport/data/tdf124600.docx
new file mode 100644
index 000000000000..d5dfa313665e
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf124600.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index e5c6e182a02e..a186e34db0f1 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -103,6 +103,17 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
         getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf124600, "tdf124600.docx")
+{
+    uno::Reference<drawing::XShape> xShape = getShape(1);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 0
+    // - Actual  : 318
+    // i.e. the shape had an unexpected left margin, but not in Word.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
+                         getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
+}
+
 DECLARE_OOXMLIMPORT_TEST(testTdf120548, "tdf120548.docx")
 {
     // Without the accompanying fix in place, this test would have failed with 'Expected: 00ff0000;
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 1d5bcbf97e74..97cc3c78fe92 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -970,7 +970,6 @@ void GraphicImport::ProcessShapeOptions(Value const & rValue)
     switch( m_pImpl->nShapeOptionType )
     {
         case NS_ooxml::LN_CT_Anchor_distL:
-            //todo: changes have to be applied depending on the orientation, see SwWW8ImplReader::AdjustLRWrapForWordMargins()
             m_pImpl->nLeftMargin = nIntValue / 360;
         break;
         case NS_ooxml::LN_CT_Anchor_distT:
@@ -1065,6 +1064,16 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
                     m_pImpl->nHoriRelation = pHandler->relation();
                     m_pImpl->nHoriOrient = pHandler->orientation();
                     m_pImpl->nLeftPosition = pHandler->position();
+
+                    // Left adjustments: if horizontally aligned to left of margin, then remove the
+                    // left wrapping.
+                    if (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT)
+                    {
+                        if (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA)
+                        {
+                            m_pImpl->nLeftMargin = 0;
+                        }
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list