Kaydet (Commit) c761df1e authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#84678 DOCX import: fix handling of textbox margins

Regression from commit d379d186 (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/30255Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst fab262f1
......@@ -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: */
......@@ -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())
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment