From 3bbe38a60b4a9ae50b59e41a02292e639ec28c09 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 17 Jun 2021 12:43:34 +0200 Subject: set size properly when setting embed size from fallback graphic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When loading e.g. OLE from ReqIF, the file contains object tag for the OLE and then as a fallback also an image. This loading code apparently sets the OLE geometry to the same as the image, for whatever reason, but if that's to be done, at least do it consistently, the same way it's done when reading the OLE. Otherwise e.g. relative width is ignored. Change-Id: Ifeafaefa4274db9ddffc6ff16210f7ecc2301a3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117464 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- sw/source/filter/html/htmlplug.cxx | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 2c06177f539c..9ae5abc57095 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -516,25 +516,14 @@ bool SwHTMLParser::InsertEmbed() rObj.SetGraphic(aGraphic, aType); // 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 true; - SwAttrSet aAttrSet(pFormat->GetAttrSet()); aAttrSet.ClearItem(RES_CNTNT); - Size aTwipSize(pDevice->PixelToLogic(aSize, MapMode(MapUnit::MapTwip))); - SwFormatFrameSize aFrameSize(SwFrameSize::Fixed, aTwipSize.Width(), aTwipSize.Height()); - aAttrSet.Put(aFrameSize); + OutputDevice* pDevice = Application::GetDefaultDevice(); + Size aDefaultTwipSize(pDevice->PixelToLogic(aGraphic.GetSizePixel(pDevice), MapMode(MapUnit::MapTwip))); + SetFixSize(aSize, aDefaultTwipSize, bPercentWidth, bPercentHeight, aPropInfo, aAttrSet); pOLENode->GetDoc().SetFlyFrameAttr(*pFormat, aAttrSet); return true; } -- cgit