diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-09-03 11:33:36 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-09-03 13:32:38 +0100 |
commit | b2ad33fd5a1ee0cd9a1e657725aedc90da659f24 (patch) | |
tree | 5cf1b28d3e67ec2fee33d8b46ae5243ed24f3182 | |
parent | 28650e0bcf120428d244578266acad9339a88540 (diff) |
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.
Change-Id: Ida0c15779d4583ca075428d77b8dc03c32f22edb
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf93676-1.odt | bin | 0 -> 18743 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 11 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 10 |
4 files changed, 27 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf93676-1.odt b/sw/qa/extras/ooxmlexport/data/tdf93676-1.odt Binary files differnew file mode 100644 index 000000000000..37d621b903cd --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf93676-1.odt diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index 07f461ce91bd..732d6d838cd5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -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(); diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 3d2ba4c67eb4..02b134a8247f 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1593,24 +1593,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 != SwFormatFrmSize::SYNCED) { 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 != SwFormatFrmSize::SYNCED) { pFS->startElementNS(XML_wp14, XML_sizeRelV, XML_relativeFrom, (rSize.GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME ? "page" : "margin"), FSEND); pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND); - fprintf(stderr, "height pc is %d\n", rSize.GetHeightPercent()); - 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); } diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index e8e2006afb21..c1ac77ee1f55 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1721,9 +1721,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 != SwFormatFrmSize::SYNCED) { - 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()) @@ -1737,9 +1738,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 != SwFormatFrmSize::SYNCED) { - 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()) |