[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Mar 7 08:06:50 UTC 2018
sw/qa/extras/htmlimport/htmlimport.cxx | 9 +++++++++
sw/source/filter/html/htmlplug.cxx | 22 ++++++++++++++++++++++
2 files changed, 31 insertions(+)
New commits:
commit 970d20a3abd187d5a14f0af3639f116e47d15179
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Mar 6 13:45:19 2018 +0100
sw XHTML import: handle size of replacement graphic of <object>
Similar to how <img src="..."> defaults to the pixel size.
Change-Id: I2c55522366e8635c491b322ca70fc3e2d79617fc
Reviewed-on: https://gerrit.libreoffice.org/50836
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 6a1a2f9b046b..7cdf5f45dc1e 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -316,6 +316,15 @@ DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
uno::UNO_QUERY);
// This failed, OLE object had no replacement image.
CPPUNIT_ASSERT(xObject->getReplacementGraphic().is());
+
+ uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY);
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ Size aPixel(64, 64);
+ // Expected to be 1693.
+ Size aLogic(pDevice->PixelToLogic(aPixel, MapMode(MapUnit::Map100thMM)));
+ awt::Size aSize = xShape->getSize();
+ // This was only 1247, size was not set explicitly.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aLogic.getWidth()), aSize.Width);
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 638835931b4e..ca7219baa8d8 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -434,6 +434,28 @@ void SwHTMLParser::InsertEmbed()
return;
rObj.SetGraphic(aGraphic, OUString());
+
+ // Set the size of the OLE frame to the size of the graphic.
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ if (aSize.getHeight() == USHRT_MAX || aSize.getWidth() == USHRT_MAX)
+ {
+ Size aPixelSize = aGraphic.GetSizePixel(pDevice);
+ if (aSize.getWidth() == USHRT_MAX)
+ aSize.setWidth(aPixelSize.getWidth());
+ if (aSize.getHeight() == USHRT_MAX)
+ aSize.setHeight(aPixelSize.getHeight());
+ }
+
+ SwFrameFormat* pFormat = pOLENode->GetFlyFormat();
+ if (!pFormat)
+ return;
+
+ SwAttrSet aAttrSet(pFormat->GetAttrSet());
+ aAttrSet.ClearItem(RES_CNTNT);
+ Size aTwipSize(pDevice->PixelToLogic(aSize, MapMode(MapUnit::MapTwip)));
+ SwFormatFrameSize aFrameSize(ATT_FIX_SIZE, aTwipSize.Width(), aTwipSize.Height());
+ aAttrSet.Put(aFrameSize);
+ pOLENode->GetDoc()->SetFlyFrameAttr(*pFormat, aAttrSet);
return;
}
More information about the Libreoffice-commits
mailing list