sw/qa/core/layout/data/bullet.png |binary sw/qa/core/layout/data/linked-bullet.odt |binary sw/qa/core/layout/layout.cxx | 21 +++++++++++++++++++++ sw/source/core/layout/paintfrm.cxx | 8 ++++++++ 4 files changed, 29 insertions(+)
New commits: commit 5e9692564c6145a6662d49ad1735996d17bf1cd7 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Aug 26 11:40:49 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Aug 26 13:26:25 2021 +0200 tdf#125743 sw: fix rendering of graphics bullet with linked images Regression from commit d72145f9307c732ced4a546ac1e5093ec7c1a982 (Move BackGraphicURL property & friends to BackGraphic + fixes, 2018-03-01), the problem was that now SvXMLImport::loadGraphicByURL() produces a Graphic that has its type set to GraphicType::Default, but when paintGraphicUsingPrimitivesHelper() consumes this graphic, it expects that the type is either a bitmap or a metafile. Fix the problem by explicitly loading the image when the default-type, origin-url-set case happens: this is rendering, so no problem to load the URL and that will give us the expected graphic type. This is also meant to keep the original problem fixed, since we only load images when painting, not during import. Change-Id: I951bc92d05bb8ec57d2ba6958c47947f8f9b5c78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121082 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/layout/data/bullet.png b/sw/qa/core/layout/data/bullet.png new file mode 100644 index 000000000000..4e2dcf414919 Binary files /dev/null and b/sw/qa/core/layout/data/bullet.png differ diff --git a/sw/qa/core/layout/data/linked-bullet.odt b/sw/qa/core/layout/data/linked-bullet.odt new file mode 100644 index 000000000000..ae165531abba Binary files /dev/null and b/sw/qa/core/layout/data/linked-bullet.odt differ diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 77d8f66e1109..1f24962e4545 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -13,6 +13,7 @@ #include <vcl/gdimtf.hxx> #include <svx/svdpage.hxx> +#include <svx/unopage.hxx> #include <wrtsh.hxx> #include <docsh.hxx> @@ -505,6 +506,26 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testCrashRemoveFromLayout) load(DATA_DIRECTORY, "tdf122894-4.doc"); } +CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testLinkedBullet) +{ + // Given a document with a graphic bullet, where the image is a linked one: + load(DATA_DIRECTORY, "linked-bullet.odt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDocShell* pShell = pTextDoc->GetDocShell(); + + // When rendering that document: + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + + // Then make sure the render result contains exactly one bitmap: + MetafileXmlDump aDumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(aDumper, *xMetaFile); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // i.e. the bullet's bitmap was lost. + assertXPath(pXmlDoc, "//bmpexscale", 1); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index ceba5eb0fe59..de9a006d743d 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -116,6 +116,7 @@ #include <vcl/BitmapTools.hxx> #include <comphelper/lok.hxx> #include <svtools/optionsdrawinglayer.hxx> +#include <vcl/GraphicLoader.hxx> #define COL_NOTES_SIDEPANE Color(230,230,230) #define COL_NOTES_SIDEPANE_BORDER Color(200,200,200) @@ -1691,6 +1692,13 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, vcl::RenderContext &rOu GraphicObject *pGrf = const_cast<GraphicObject*>(rBrush.GetGraphicObject()); + OUString aOriginURL = pGrf->GetGraphic().getOriginURL(); + if (pGrf->GetGraphic().GetType() == GraphicType::Default && !aOriginURL.isEmpty()) + { + Graphic aGraphic = vcl::graphic::loadFromURL(aOriginURL); + pGrf->SetGraphic(aGraphic); + } + // Outsource drawing of background with a background color ::lcl_DrawGraphicBackground( rBrush, rOutDev, aAlignedGrfRect, *pGrf, bGrfNum, properties, bBackgrdAlreadyDrawn );