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 b0c925d6657dcb3af35e9c09fd479a354fbcc73c Author: Miklos Vajna <[email protected]> AuthorDate: Thu Aug 26 11:40:49 2021 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Aug 31 21:22:04 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 <[email protected]> Tested-by: Jenkins Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121094 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 911c17189f8c..ff2b0a192c62 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 5fa8a22864d4..d7ea6592d1c9 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -115,6 +115,7 @@ #include <vcl/BitmapTools.hxx> #include <comphelper/lok.hxx> +#include <vcl/GraphicLoader.hxx> #define COL_NOTES_SIDEPANE Color(230,230,230) #define COL_NOTES_SIDEPANE_BORDER Color(200,200,200) @@ -1690,6 +1691,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 );
