[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Oct 25 09:32:22 UTC 2016


 sw/qa/extras/ooxmlexport/data/tdf84678.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx   |    7 +++++++
 sw/source/core/doc/textboxhelper.cxx        |   26 ++++++++++++++++++++++++++
 writerfilter/source/filter/WriterFilter.cxx |    1 +
 4 files changed, 34 insertions(+)

New commits:
commit c761df1e42fd11acc5fc05b0baacd803c3788ca6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Oct 25 09:05:47 2016 +0200

    tdf#84678 DOCX import: fix handling of textbox margins
    
    Regression from commit d379d18666aa42031359ca8eb34b0021960347ae (oox:
    import WPS shape with text as shape with textbox, 2014-06-18), the
    problem for a long time was that in Writer text frames without borders
    couldn't have text margins, either.
    
    Recently a compat setting was added in the WW8 filter for this
    situation, so use that in the DOCX import as well, and improve
    SwTextBoxHelper to handle the margin properties.
    
    Change-Id: I472bbc414f21f2ec7334482c460a5c3be3e95e94
    Reviewed-on: https://gerrit.libreoffice.org/30255
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf84678.docx b/sw/qa/extras/ooxmlexport/data/tdf84678.docx
new file mode 100644
index 0000000..f799228
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf84678.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 95b1c2d..7800cd3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -63,6 +63,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp/wps:spPr/a:prstGeom", "prst", "rect");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf84678, "tdf84678.docx")
+{
+    // This was 0, left margin inside a shape+text wasn't imported from DOCX.
+    // 360000 EMU, but layout uses twips.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(567), parseDump("/root/page/body/txt/anchored/fly/infos/prtBounds", "left").toInt32());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index c9959b8..bfa3d3a 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -32,6 +32,7 @@
 
 #include <editeng/unoprnms.hxx>
 #include <editeng/charrotateitem.hxx>
+#include <editeng/memberids.hrc>
 #include <svx/svdoashp.hxx>
 #include <svx/svdpage.hxx>
 #include <svl/itemiter.hxx>
@@ -354,6 +355,14 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, const OUString& rPrope
         syncProperty(pShape, RES_TEXT_VERT_ADJUST, 0, rValue);
     else if (rPropertyName == UNO_NAME_TEXT_AUTOGROWHEIGHT)
         syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_IS_AUTO_HEIGHT, rValue);
+    else if (rPropertyName == UNO_NAME_TEXT_LEFTDIST)
+        syncProperty(pShape, RES_BOX, LEFT_BORDER_DISTANCE, rValue);
+    else if (rPropertyName == UNO_NAME_TEXT_RIGHTDIST)
+        syncProperty(pShape, RES_BOX, RIGHT_BORDER_DISTANCE, rValue);
+    else if (rPropertyName == UNO_NAME_TEXT_UPPERDIST)
+        syncProperty(pShape, RES_BOX, TOP_BORDER_DISTANCE, rValue);
+    else if (rPropertyName == UNO_NAME_TEXT_LOWERDIST)
+        syncProperty(pShape, RES_BOX, BOTTOM_BORDER_DISTANCE, rValue);
 }
 
 void SwTextBoxHelper::getProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, css::uno::Any& rValue)
@@ -491,6 +500,23 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
         case RES_TEXT_VERT_ADJUST:
             aPropertyName = UNO_NAME_TEXT_VERT_ADJUST;
             break;
+        case RES_BOX:
+            switch (nMemberId)
+            {
+            case LEFT_BORDER_DISTANCE:
+                aPropertyName = UNO_NAME_LEFT_BORDER_DISTANCE;
+                break;
+            case RIGHT_BORDER_DISTANCE:
+                aPropertyName = UNO_NAME_RIGHT_BORDER_DISTANCE;
+                break;
+            case TOP_BORDER_DISTANCE:
+                aPropertyName = UNO_NAME_TOP_BORDER_DISTANCE;
+                break;
+            case BOTTOM_BORDER_DISTANCE:
+                aPropertyName = UNO_NAME_BOTTOM_BORDER_DISTANCE;
+                break;
+            }
+            break;
         }
 
         if (!aPropertyName.isEmpty())
diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx
index 9cc7bd1..8552fe1 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -299,6 +299,7 @@ void WriterFilter::setTargetDocument(const uno::Reference< lang::XComponent >& x
     xSettings->setPropertyValue("TabOverMargin", uno::makeAny(true));
     xSettings->setPropertyValue("TreatSingleColumnBreakAsPageBreak", uno::makeAny(true));
     xSettings->setPropertyValue("PropLineSpacingShrinksFirstLine", uno::makeAny(true));
+    xSettings->setPropertyValue("AllowSpacingWithoutBorders", uno::makeAny(true));
 }
 
 void WriterFilter::setSourceDocument(const uno::Reference< lang::XComponent >& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)


More information about the Libreoffice-commits mailing list