tdf#99631 DOCX export: keep zoom of embedded XLSX

OLE objects by exporting their VisibleArea settings

Change-Id: Iaedc1901999dd203fc9961a4775f8d2452f3ccda
Reviewed-on: https://gerrit.libreoffice.org/65435
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99631.docx b/sw/qa/extras/ooxmlexport/data/tdf99631.docx
new file mode 100644
index 0000000..c72950b
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf99631.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 547afcd..3e90ed1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -921,6 +921,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf117137, "tdf117137.docx")
    CPPUNIT_ASSERT(xPara3->getPropertyValue("NumberingRules").hasValue());
}

DECLARE_OOXMLEXPORT_TEST(testTdf99631, "tdf99631.docx")
{
    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    if (!pXmlDoc)
        return;
    assertXPath(pXmlDoc, "//w:object", 2);
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object", 2);
    // first XSLX OLE object (1:1 scale)
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dxaOrig", "2560");
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[1]/w:object[1]", "dyaOrig", "513");
    // second XLSX OLE object (same content + 1 row, but zoomed)
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dxaOrig", "2560");
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:object[1]", "dyaOrig", "768");
}

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 3791a6a..1328a07 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -148,6 +148,8 @@
#include <algorithm>
#include <stdarg.h>

#include <toolkit/helper/vclunohelper.hxx>

using ::editeng::SvxBorderLine;

using namespace oox;
@@ -5312,7 +5314,31 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
    m_rDrawingML.SetFS(m_pSerializer);
    OUString sImageId = m_rDrawingML.WriteImage( *pGraphic );

    m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
    if ( sDrawAspect == "Content" )
    {
        awt::Size aSize;
        try
        {
            aSize = xObj->getVisualAreaSize( rNode.GetAspect() );

            MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( rNode.GetAspect() ) );
            Size aOriginalSize( OutputDevice::LogicToLogic(Size( aSize.Width, aSize.Height),
                                                MapMode(aUnit), MapMode(MapUnit::MapTwip)));

            m_pSerializer->startElementNS( XML_w, XML_object,
                                   FSNS(XML_w, XML_dxaOrig), OString::number(aOriginalSize.Width()),
                                   FSNS(XML_w, XML_dyaOrig), OString::number(aOriginalSize.Height()),
                                   FSEND );
        }
        catch ( uno::Exception& )
        {
            m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
        }
    }
    else
    {
        m_pSerializer->startElementNS( XML_w, XML_object, FSEND );
    }

    OStringBuffer sShapeStyle, sShapeId;
    sShapeStyle.append( "width:" ).append( double( rSize.Width() ) / 20 )