[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa sw/source
Attila Bakos (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 13 20:06:57 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf131539.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 10 ++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 42 +++++++++++++++++++++++++++
3 files changed, 52 insertions(+)
New commits:
commit 1ed606718db2525cae583ef03e81af65c2551e71
Author: Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Thu Apr 9 17:10:22 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Jul 13 22:06:24 2020 +0200
tdf#131539 DOCX export: fix position of OLE objects
Keeping position of OLE objects anchored to text
as a character.
Co-developer: Tibor Nagy (NISZ)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91983
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 2150fdc7d0f63288ac56c33cb898589512057642)
Change-Id: I9699250ae5c418f9994ea2a7a3b102681b042214
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98276
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf131539.odt b/sw/qa/extras/ooxmlexport/data/tdf131539.odt
new file mode 100644
index 000000000000..d0e446522a0a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131539.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 7f1e63d39cc7..0f5b5f827743 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -408,6 +408,16 @@ DECLARE_OOXMLEXPORT_TEST(testHyphenationAuto, "hyphenation.odt")
assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/w:suppressAutoHyphens", "val", "true");
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf131539, "tdf131539.odt")
+{
+ //The positions of OLE objects were not exported, check if now it is exported correctly
+ xmlDocPtr p_XmlDoc = parseExport("word/document.xml");
+ CPPUNIT_ASSERT(p_XmlDoc);
+ OUString aXmlVal = getXPath(p_XmlDoc, "/w:document/w:body/w:p[4]/w:r[1]/w:object/v:shape", "style");
+ // This data was missing
+ CPPUNIT_ASSERT(aXmlVal.indexOf("margin-left:139.95")>-1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ec73daf45c6d..fed20324b4dd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5516,11 +5516,53 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
m_pSerializer->startElementNS(XML_w, XML_object);
}
+ //tdf#131539: Export OLE positions in docx:
+ //This string will store the position output for the xml
+ OString aPos;
+ //This string will store the relative position for aPos
+ OString aAnch;
+
+ if (!rFlyFrameFormat->GetName().isEmpty())
+ {
+ //Get the horizontal alignment of the OLE via the frame format, to aHAlign
+ OString aHAlign = convertToOOXMLHoriOrient(rFlyFrameFormat->GetHoriOrient().GetHoriOrient(),
+ rFlyFrameFormat->GetHoriOrient().IsPosToggle());
+ //Get the vertical alignment of the OLE via the frame format to aVAlign
+ OString aVAlign = convertToOOXMLVertOrient(rFlyFrameFormat->GetVertOrient().GetVertOrient());
+
+ //Get the relative horizontal positions for the anchors
+ OString aHAnch = convertToOOXMLHoriOrientRel(rFlyFrameFormat->GetHoriOrient().GetRelationOrient());
+ //Get the relative vertical positions for the anchors
+ OString aVAnch = convertToOOXMLVertOrientRel(rFlyFrameFormat->GetVertOrient().GetRelationOrient());
+
+ //Choice that the horizontal position is relative or not
+ if (!aHAlign.isEmpty())
+ aHAlign = ";mso-position-horizontal:" + aHAlign;
+ aHAlign = ";mso-position-horizontal-relative:" + aHAnch;
+
+ //Choice that the vertical position is relative or not
+ if (!aVAlign.isEmpty())
+ aVAlign = ";mso-position-vertical:" + aVAlign;
+ aVAlign = ";mso-position-vertical-relative:" + aVAnch;
+
+ //Set the anchoring information into one string for aPos
+ aAnch = aHAlign + aVAlign;
+
+ //Query the positions to aPos from frameformat
+ aPos =
+ "position:absolute;margin-left:" + OString::number(double(rFlyFrameFormat->GetHoriOrient().GetPos()) / 20) +
+ "pt;margin-top:" + OString::number(double(rFlyFrameFormat->GetVertOrient().GetPos()) / 20) + "pt;";
+ }
+
OString sShapeStyle = "width:" + OString::number( double( rSize.Width() ) / 20 ) +
"pt;height:" + OString::number( double( rSize.Height() ) / 20 ) +
"pt"; //from VMLExport::AddRectangleDimensions(), it does: value/20
OString sShapeId = "ole_" + sId;
+ //Export anchor setting, if it exists
+ if (!aPos.isEmpty() && !aAnch.isEmpty())
+ sShapeStyle = aPos + sShapeStyle + aAnch;
+
// shape definition
m_pSerializer->startElementNS( XML_v, XML_shape,
XML_id, sShapeId.getStr(),
More information about the Libreoffice-commits
mailing list