diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-08-13 14:50:24 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-08-14 10:48:51 +0200 |
commit | 4a0cd8990467466a04bafd7bb1a780247535ab83 (patch) | |
tree | 0ad062668269da8435c78bebc766f0e1531afe32 /include/drawinglayer/primitive2d | |
parent | cf23025faabdae03f4d4706410c80c7c46c683e9 (diff) |
CairoSDPR: Handle EmphasisMarks
Handling EmphasisMarks for direct text rendering
was a hard task - the EmphasisMark stuff is deeply
buried in vcl (would have needed to move quite some
includes from vcl to public) and thus hard to use.
It is also quite old (tools Polygon, Rectangle).
It was missing in the decomposition of the
TextDecoratedPortionPrimitive2D (for good reason),
but is needed now.
I found a way using a callback lambda function to
create the needed geometry in vcl and hand back the
needed data to the caller, in this case to the
decomposition. Adding it to the decomposition of
TextDecoratedPortionPrimitive2D also guarantees
that other renderers/usages will do the correct
thing and all will look identical.
Interestingly EmphasisMarks were never added to
Metafiles (see OutputDevice::ImplDrawEmphasisMarks)
so they were not 'missing' in Metafile-based
exports. But for SDPRs they have to work. I added
another encapsulating TextHierarchyPrimitive to
encapsulate primitives that do represent
EmphasisMarks and added to ignore these in the
VclMetafileProcessor2D (as needed).
Change-Id: I5b5c1528d86a123df2beb57d8366f05aa71e77cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171826
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include/drawinglayer/primitive2d')
4 files changed, 37 insertions, 1 deletions
diff --git a/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 015d0befe32f..8989f77c6b8b 100644 --- a/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/include/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -112,6 +112,7 @@ #define PRIMITIVE2D_ID_POLYPOLYGONRGBAPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 78) #define PRIMITIVE2D_ID_BITMAPALPHAPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 79) #define PRIMITIVE2D_ID_POLYPOLYGONALPHAGRADIENTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 80) +#define PRIMITIVE2D_ID_TEXTHIERARCHYEMPHASISMARKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 81) // When you add a new primitive, please update the drawinglayer::primitive2d::idToString() function // in drawinglayer/source/primitive2d/Tools.cxx. diff --git a/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx b/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx index 62cb9099c985..0efebc0a7f0c 100644 --- a/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx @@ -177,6 +177,16 @@ namespace drawinglayer::primitive2d /// provide unique ID virtual sal_uInt32 getPrimitive2DID() const override; }; + + class DRAWINGLAYER_DLLPUBLIC TextHierarchyEmphasisMarkPrimitive2D final : public GroupPrimitive2D + { + public: + /// constructor + explicit TextHierarchyEmphasisMarkPrimitive2D(Primitive2DContainer&& aContent); + + /// provide unique ID + virtual sal_uInt32 getPrimitive2DID() const override; + }; } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/textlayoutdevice.hxx b/include/drawinglayer/primitive2d/textlayoutdevice.hxx index de7a1e214a2a..5a0849100142 100644 --- a/include/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/include/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -22,9 +22,11 @@ #include <drawinglayer/drawinglayerdllapi.h> #include <basegfx/range/b2drange.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> #include <vector> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <vcl/svapp.hxx> +#include <tools/fontenum.hxx> #include <span> // predefines @@ -37,6 +39,10 @@ namespace vcl { class Font; } +namespace vcl::font +{ +class EmphasisMark; +} namespace tools { class Rectangle; @@ -118,7 +124,12 @@ public: sal_uInt32 nLength, const basegfx::B2DPoint& rStartPoint, const KernArray& rDXArray, - std::span<const sal_Bool> pKashidaAry); + std::span<const sal_Bool> pKashidaAry) const; + void + createEmphasisMarks(SalLayout& rSalLayout, TextEmphasisMark aTextEmphasisMark, bool bAbove, + std::function<void(const basegfx::B2DPoint&, const basegfx::B2DPolyPolygon&, + bool, const tools::Rectangle&, const tools::Rectangle&)> + aCallback) const; }; // helper methods for vcl font handling diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx b/include/drawinglayer/primitive2d/textprimitive2d.hxx index b5cff99f4047..44c59ae47828 100644 --- a/include/drawinglayer/primitive2d/textprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx @@ -30,10 +30,18 @@ #include <tools/long.hxx> #include <basegfx/color/bcolor.hxx> #include <com/sun/star/lang/Locale.hpp> +#include <memory> #include <vector> namespace drawinglayer::primitive2d { +class TextLayouterDevice; +} + +class SalLayout; + +namespace drawinglayer::primitive2d +{ /** TextSimplePortionPrimitive2D class This is the basic primitive for representing a text portion. It contains @@ -134,6 +142,12 @@ protected: create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; public: + /// helpers to create a TextLayouterDevice and SalLayout, e.g. needed for SDPRs + // and decompose. NOTE: the TextLayouterDevice is filled, but should always only + // be used temporary (do not try to buffer) + void createTextLayouter(TextLayouterDevice& rTextLayouter) const; + std::unique_ptr<SalLayout> createSalLayout(TextLayouterDevice& rTextLayouter) const; + /// constructor TextSimplePortionPrimitive2D(basegfx::B2DHomMatrix aNewTransform, OUString aText, sal_Int32 nTextPosition, sal_Int32 nTextLength, |