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@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
@@ -316,6 +316,15 @@ DECLARE_HTMLIMPORT_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
|
|||||||
uno::UNO_QUERY);
|
uno::UNO_QUERY);
|
||||||
// This failed, OLE object had no replacement image.
|
// This failed, OLE object had no replacement image.
|
||||||
CPPUNIT_ASSERT(xObject->getReplacementGraphic().is());
|
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();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -434,6 +434,28 @@ void SwHTMLParser::InsertEmbed()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
rObj.SetGraphic(aGraphic, OUString());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user