diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-08-26 11:40:49 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-08-31 21:22:04 +0200 |
commit | b0c925d6657dcb3af35e9c09fd479a354fbcc73c (patch) | |
tree | 19caf924fc2bb73e55038d90b566740029cab056 /sw | |
parent | 132e05b43998ecaaf249b851d690fe7239d79c50 (diff) |
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 <vmiklos@collabora.com>
Tested-by: Jenkins
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121094
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/layout/data/bullet.png | bin | 0 -> 351 bytes | |||
-rw-r--r-- | sw/qa/core/layout/data/linked-bullet.odt | bin | 0 -> 8779 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layout.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 8 |
4 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/bullet.png b/sw/qa/core/layout/data/bullet.png Binary files differnew file mode 100644 index 000000000000..4e2dcf414919 --- /dev/null +++ b/sw/qa/core/layout/data/bullet.png diff --git a/sw/qa/core/layout/data/linked-bullet.odt b/sw/qa/core/layout/data/linked-bullet.odt Binary files differnew file mode 100644 index 000000000000..ae165531abba --- /dev/null +++ b/sw/qa/core/layout/data/linked-bullet.odt 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 ); |