summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-06-04 14:02:52 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-06-04 14:54:45 +0200
commit26d2b19d4e9388072b8dae574efdf00d7f7a0f2f (patch)
tree15f52f1275de376a98386b9ded7d787d211aba40 /sw
parent4839b7ca3b5a730edf90ebebc749db145efec098 (diff)
sw HTML export: fix pixel size of shapes
- the twips logic size was set, but it was consumed as mm100 logic size, so the pixel size was about half of the correct one - the HTML export didn't write a logic size ("CSS pixels size") for shapes Change-Id: I37f6b4acde9d1298fae81f9975e9db95485631ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116691 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/htmlexport/htmlexport.cxx9
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx22
2 files changed, 28 insertions, 3 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index b97cf7968640..1f5182ac6e4c 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1723,6 +1723,15 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNG)
// - Actual : image/x-vclgraphic
// i.e. the result was invalid ReqIF.
assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "type", "image/png");
+
+ // Then check the pixel size of the shape:
+ Size aPixelSize(Application::GetDefaultDevice()->LogicToPixel(Size(10000, 10000),
+ MapMode(MapUnit::Map100thMM)));
+ // Without the accompanying fix in place, this test would have failed with:
+ // - no attribute 'width' exist
+ // i.e. shapes had no width.
+ assertXPath(pXmlDoc, "//reqif-xhtml:p/reqif-xhtml:object", "width",
+ OUString::number(aPixelSize.getWidth()));
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index ed6d646594ee..8f6608097f07 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -933,12 +933,28 @@ void SwHTMLWriter::writeFrameFormatOptions(HtmlWriter& aHtml, const SwFrameForma
// "width" and/or "height"
// Only output SwFrameSize::Variable/SwFrameSize::Minimum if ANYSIZE is set
+ const SwFormatFrameSize* pFSItem = nullptr;
+ std::optional<SwFormatFrameSize> aFrameSize;
+ if (SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ))
+ {
+ pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
+ }
+ else if (const SdrObject* pObject = rFrameFormat.FindSdrObject())
+ {
+ // Write size for Draw shapes as well.
+ const tools::Rectangle& rSnapRect = pObject->GetSnapRect();
+ aFrameSize.emplace();
+ aFrameSize->SetWidthSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetWidth(rSnapRect.getWidth());
+ aFrameSize->SetHeightSizeType(SwFrameSize::Fixed);
+ aFrameSize->SetHeight(rSnapRect.getHeight());
+ pFSItem = &*aFrameSize;
+ }
if( (nFrameOptions & HtmlFrmOpts::Size) &&
- SfxItemState::SET == rItemSet.GetItemState( RES_FRM_SIZE, true, &pItem ) &&
+ pFSItem &&
( (nFrameOptions & HtmlFrmOpts::AnySize) ||
- SwFrameSize::Fixed == static_cast<const SwFormatFrameSize *>(pItem)->GetHeightSizeType()) )
+ SwFrameSize::Fixed == pFSItem->GetHeightSizeType()) )
{
- const SwFormatFrameSize *pFSItem = static_cast<const SwFormatFrameSize *>(pItem);
sal_uInt8 nPercentWidth = pFSItem->GetWidthPercent();
sal_uInt8 nPercentHeight = pFSItem->GetHeightPercent();