Kaydet (Commit) a74f3bf8 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

Related: tdf#93676 special 255 Percent Flag should not be exported to docx

as a true percentage value. 255 is a special flag that the value is synced to
the other dimension. Without this word gives the frame in the attached example
a huge height.

(cherry picked from commit b2ad33fd)

Change-Id: Ida0c15779d4583ca075428d77b8dc03c32f22edb
Reviewed-on: https://gerrit.libreoffice.org/18332Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst c44b8a3f
......@@ -912,6 +912,21 @@ DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:extent","cx","0");
}
// part of tdf#93676, word gives the frame in the exported .docx a huge height,
// because its exported with 255% height percentage from a 255 HeightPercent
// settings, but 255 is a special flag that the value is synced to the
// other dimension.
DECLARE_OOXMLEXPORT_TEST(testSyncedRelativePercent, "tdf93676-1.odt")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
// check no explicit pctHeight has been exported, all we care
// about at this point is that its not 255000
assertXPath(pXmlDoc, "//wp14:pctHeight", 0);
}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1594,23 +1594,25 @@ void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId, bo
pFS->endElementNS(XML_a, XML_graphic);
// Relative size of the Text Frame.
if (rSize.GetWidthPercent())
const sal_uInt8 nWidthPercent = rSize.GetWidthPercent();
if (nWidthPercent && nWidthPercent != 0xff)
{
pFS->startElementNS(XML_wp14, XML_sizeRelH,
XML_relativeFrom, (rSize.GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
FSEND);
pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
pFS->writeEscaped(OUString::number(rSize.GetWidthPercent() * oox::drawingml::PER_PERCENT));
pFS->writeEscaped(OUString::number(nWidthPercent * oox::drawingml::PER_PERCENT));
pFS->endElementNS(XML_wp14, XML_pctWidth);
pFS->endElementNS(XML_wp14, XML_sizeRelH);
}
if (rSize.GetHeightPercent())
const sal_uInt8 nHeightPercent = rSize.GetHeightPercent();
if (nHeightPercent && nHeightPercent != 0xff)
{
pFS->startElementNS(XML_wp14, XML_sizeRelV,
XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"),
FSEND);
pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
pFS->writeEscaped(OUString::number(rSize.GetHeightPercent() * oox::drawingml::PER_PERCENT));
pFS->writeEscaped(OUString::number(nHeightPercent * oox::drawingml::PER_PERCENT));
pFS->endElementNS(XML_wp14, XML_pctHeight);
pFS->endElementNS(XML_wp14, XML_sizeRelV);
}
......
......@@ -1600,9 +1600,10 @@ void lcl_TextFrameRelativeSize(std::vector< std::pair<OString, OString> >& rFlyP
const SwFormatFrmSize& rSize = rFrameFormat.GetFrmSize();
// Relative size of the Text Frame.
if (rSize.GetWidthPercent())
const sal_uInt8 nWidthPercent = rSize.GetWidthPercent();
if (nWidthPercent && nWidthPercent != 0xff)
{
rFlyProperties.push_back(std::make_pair<OString, OString>("pctHoriz", OString::number(rSize.GetWidthPercent() * 10)));
rFlyProperties.push_back(std::make_pair<OString, OString>("pctHoriz", OString::number(nWidthPercent * 10)));
OString aRelation;
switch (rSize.GetWidthPercentRelation())
......@@ -1616,9 +1617,10 @@ void lcl_TextFrameRelativeSize(std::vector< std::pair<OString, OString> >& rFlyP
}
rFlyProperties.push_back(std::make_pair("sizerelh", aRelation));
}
if (rSize.GetHeightPercent())
const sal_uInt8 nHeightPercent = rSize.GetHeightPercent();
if (nHeightPercent && nHeightPercent != 0xff)
{
rFlyProperties.push_back(std::make_pair<OString, OString>("pctVert", OString::number(rSize.GetHeightPercent() * 10)));
rFlyProperties.push_back(std::make_pair<OString, OString>("pctVert", OString::number(nHeightPercent * 10)));
OString aRelation;
switch (rSize.GetHeightPercentRelation())
......
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