diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-01 21:03:39 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-02-03 11:14:02 +0100 |
commit | f3244248e151c345fdbb07185e041142a044a017 (patch) | |
tree | 92931d5361f29c3032fda1d59414221c4926e964 /include | |
parent | 01f2379603de09ba1b5e979166e4b5d60a90c1d5 (diff) |
tdf#139869 vcl: fix lazy-loading of BMP images with logic size
Regression from commit 7b355669c6ddeab2e6cec692d6afdff41c61d0fb
(Function to load graphic swapped out (loaded on demand), 2018-04-14),
the code assumes that the map mode and size of a graphic is the same
when the image is not yet loaded and when it's loaded already.
This was not the case for the BMP import, where ImplReadDIBBody()
produced a map mode with scaling and MapUnit::MapMM as the map unit,
while GraphicDescriptor assumed that the logic size is always MapUnit::Map100thMM.
This resulted in SwNoTextNode::HasContour() using one map mode when the
contour polygon is imported and an other one was used while renderin,
effectively hiding the image.
Fix the problem by extending GraphicDescriptor, so a format detector can
opt in to provide its own map mode and size according to that map mode,
this way the detector and the BMP import will create matching map modes
and sizes, resulting in a visible image in the bugdoc.
(cherry picked from commit ddc0714c40c6ea85336431a88b523f3e5c63a3f8)
Change-Id: I71e786a4601c63f58da2e6ab9d7681ec6dd7b806
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110320
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/graphicfilter.hxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index 35728237dc7a..bd108a4f49b9 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -27,6 +27,7 @@ #include <o3tl/typed_flags_set.hxx> #include <memory> +#include <optional> namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::uno { template <class E> class Sequence; } @@ -139,6 +140,8 @@ class VCL_DLLPUBLIC GraphicDescriptor final OUString aPathExt; Size aPixSize; Size aLogSize; + std::optional<Size> maPreferredLogSize; + std::optional<MapMode> maPreferredMapMode; sal_uInt16 nBitsPerPixel; sal_uInt16 nPlanes; GraphicFileFormat nFormat; @@ -209,6 +212,18 @@ public: /** @return the logical graphic size in 1/100mm or 0 size */ const Size& GetSize_100TH_MM() const { return aLogSize; } + /** + * Returns the logic size, according to the map mode available via GetPreferredMapMode(). Prefer + * this size over GetSize_100TH_MM(). + */ + std::optional<Size> GetPreferredLogSize() const { return maPreferredLogSize; } + + /** + * If available, this returns the map mode the graphic prefers, which may be other than pixel or + * 100th mm. Prefer this map mode over just assuming MapUnit::Map100thMM. + */ + std::optional<MapMode> GetPreferredMapMode() const { return maPreferredMapMode; } + /** @return bits/pixel or 0 **/ sal_uInt16 GetBitsPerPixel() const { return nBitsPerPixel; } |