summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-10-25 09:05:47 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-10-25 09:32:01 +0000
commitc761df1e42fd11acc5fc05b0baacd803c3788ca6 (patch)
tree6ed550b92aefe19191fa14b462894714907baa3c
parentfab262f115e5c0e6d43b65e376241152ddff82b3 (diff)
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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf84678.docxbin0 -> 17834 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport9.cxx7
-rw-r--r--sw/source/core/doc/textboxhelper.cxx26
-rw-r--r--writerfilter/source/filter/WriterFilter.cxx1
4 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf84678.docx b/sw/qa/extras/ooxmlexport/data/tdf84678.docx
new file mode 100644
index 000000000000..f79922861ce1
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf84678.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 95b1c2dbf44f..7800cd37fab4 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 c9959b8200c2..bfa3d3a1836d 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 9cc7bd1ba202..8552fe1de860 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)