diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-04-02 16:11:50 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-07-30 23:27:41 +0900 |
commit | e854636eb8cefc2b9954b81311935541eee85dc0 (patch) | |
tree | 6e5cf5845c874444a4c70be817cd6868850917c7 | |
parent | f181630edc27abf90e837d2143a1453e67c8f00a (diff) |
drawinglayer: ITextLayouter and use it as a VisitingParameter
feature/drawinglayercore
Change-Id: I04aa42716c2bde4a2652d10892b6b2392a20fb3b
22 files changed, 298 insertions, 48 deletions
diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk index 8359969ae80c..957f1b45ac08 100644 --- a/basegfx/Library_basegfx.mk +++ b/basegfx/Library_basegfx.mk @@ -80,6 +80,7 @@ $(eval $(call gb_Library_add_exception_objects,basegfx,\ basegfx/source/vector/b2dvector \ basegfx/source/vector/b2ivector \ basegfx/source/vector/b3dvector \ + basegfx/source/text/UnoTextLayouter \ )) diff --git a/basegfx/source/text/UnoTextLayouter.cxx b/basegfx/source/text/UnoTextLayouter.cxx new file mode 100644 index 000000000000..e3f48264c624 --- /dev/null +++ b/basegfx/source/text/UnoTextLayouter.cxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <basegfx/text/UnoTextLayouter.hxx> +#include <cppuhelper/queryinterface.hxx> + +using namespace css; + +namespace gfx +{ +// css::lang::XUnoTunnel +UNO3_GETIMPLEMENTATION_IMPL(UnoTextLayouter); + +std::shared_ptr<gfx::ITextLayouter> +getTextLayouterFromUno(uno::Reference<graphic::XTextLayouter> const& xTextLayouter) +{ + gfx::UnoTextLayouter* pUnoTextLayouter + = comphelper::getUnoTunnelImplementation<gfx::UnoTextLayouter>(xTextLayouter); + if (pUnoTextLayouter) + return pUnoTextLayouter->getTextLayouter(); + + return std::shared_ptr<gfx::ITextLayouter>(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/attribute/fontattribute.cxx b/drawinglayer/source/attribute/fontattribute.cxx index e423b8367f1c..b14397fe9d87 100644 --- a/drawinglayer/source/attribute/fontattribute.cxx +++ b/drawinglayer/source/attribute/fontattribute.cxx @@ -112,15 +112,31 @@ FontAttribute::FontAttribute() { } -FontAttribute::FontAttribute(const FontAttribute&) = default; +FontAttribute::FontAttribute(const FontAttribute& rOther) + : mpFontAttribute(rOther.mpFontAttribute) +{ +} + +FontAttribute::FontAttribute(FontAttribute&& rOther) noexcept + : mpFontAttribute(std::move(rOther.mpFontAttribute)) +{ +} -FontAttribute::FontAttribute(FontAttribute&&) = default; +FontAttribute::~FontAttribute() {} -FontAttribute::~FontAttribute() = default; +FontAttribute& FontAttribute::operator=(const FontAttribute& rOther) +{ + mpFontAttribute = rOther.mpFontAttribute; -FontAttribute& FontAttribute::operator=(const FontAttribute&) = default; + return *this; +} -FontAttribute& FontAttribute::operator=(FontAttribute&&) = default; +FontAttribute& FontAttribute::operator=(FontAttribute&& rOther) noexcept +{ + mpFontAttribute = std::move(rOther.mpFontAttribute); + + return *this; +} bool FontAttribute::operator==(const FontAttribute& rCandidate) const { diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index f0e677c0cedb..78e2ea02a0eb 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/geometry/RealRectangle2D.hpp> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <drawinglayer/processor2d/textlayoutdevice.hxx> #include <drawinglayer/converters.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -118,7 +119,8 @@ namespace drawinglayer::unorenderer } const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + auto pTextLayouter = std::make_shared<drawinglayer::processor2d::TextLayouterDevice>(); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, pTextLayouter); const sal_uInt32 nDiscreteWidth(basegfx::fround(o3tl::convert(fWidth, eRangeUnit, o3tl::Length::in) * DPI_X)); const sal_uInt32 nDiscreteHeight(basegfx::fround(o3tl::convert(fHeight, eRangeUnit, o3tl::Length::in) * DPI_Y)); diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx index 085ccc1b8c58..7ec09582886f 100644 --- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx @@ -23,7 +23,10 @@ #include <drawinglayer/primitive2d/Tools.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/utils/canvastools.hxx> +#include <basegfx/text/UnoTextLayouter.hxx> #include <comphelper/sequence.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> +#include <com/sun/star/graphic/XTextLayouter.hpp> using namespace css; @@ -85,12 +88,39 @@ void BasePrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& /*rVis { } +namespace +{ +std::shared_ptr<gfx::ITextLayouter> +getTextLayouter(const uno::Sequence<beans::PropertyValue>& rProperties) +{ + std::shared_ptr<gfx::ITextLayouter> pTextLayouter; + + if (!rProperties.hasElements()) + return pTextLayouter; + + for (const beans::PropertyValue& rProperty : rProperties) + { + if (rProperty.Name == "TextLayouter") + { + uno::Reference<graphic::XTextLayouter> xTextLayouter; + rProperty.Value >>= xTextLayouter; + if (xTextLayouter.is()) + pTextLayouter = gfx::getTextLayouterFromUno(xTextLayouter); + return pTextLayouter; + } + } + return pTextLayouter; +} + +} // end anonymous namespace + css::uno::Sequence<::css::uno::Reference<::css::graphic::XPrimitive2D>> SAL_CALL BasePrimitive2D::getDecomposition(const uno::Sequence<beans::PropertyValue>& rViewParameters) { Primitive2DContainer aContainer; geometry::ViewInformation2D aViewInformation2D(rViewParameters); - VisitingParameters aParameters(aViewInformation2D); + std::shared_ptr<gfx::ITextLayouter> pTextLayouter = getTextLayouter(rViewParameters); + VisitingParameters aParameters(aViewInformation2D, pTextLayouter); get2DDecomposition(aContainer, aParameters); return comphelper::containerToSequence(aContainer); } @@ -99,7 +129,8 @@ css::geometry::RealRectangle2D SAL_CALL BasePrimitive2D::getRange(const uno::Sequence<beans::PropertyValue>& rViewParameters) { geometry::ViewInformation2D aViewInformation2D(rViewParameters); - VisitingParameters aParameters(aViewInformation2D); + std::shared_ptr<gfx::ITextLayouter> pTextLayouter = getTextLayouter(rViewParameters); + VisitingParameters aParameters(aViewInformation2D, pTextLayouter); return basegfx::unotools::rectangle2DFromB2DRectangle(getB2DRange(aParameters)); } diff --git a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx index 0cfa014bb13e..09ae46a2230f 100644 --- a/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/patternfillprimitive2d.cxx @@ -107,7 +107,7 @@ namespace drawinglayer::primitive2d const primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; const geometry::ViewInformation2D aViewInformation2D; - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, rParameters.getTextLayouter()); const BitmapEx aBitmapEx( convertToBitmapEx( diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index fdf81482aa32..e3b25a1f1beb 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -111,9 +111,10 @@ void TextSimplePortionPrimitive2D::getTextOutlinesAndTransformation( const basegfx::B2DVector aFontScale(getCorrectedScaleAndFontScale(aScale)); // prepare textlayoutdevice - drawinglayer::processor2d::TextLayouterDevice aTextLayouter; - aTextLayouter.setFontAttribute(getFontAttribute(), aFontScale.getX(), aFontScale.getY(), - getLocale()); + std::unique_ptr<gfx::ITextLayouter> pTextLayouter + = std::make_unique<drawinglayer::processor2d::TextLayouterDevice>(); + pTextLayouter->setFontAttribute(getFontAttribute(), aFontScale.getX(), aFontScale.getY(), + getLocale()); // When getting outlines from stretched text (aScale.getX() != 1.0) it // is necessary to inverse-scale the DXArray (if used) to not get the @@ -129,14 +130,14 @@ void TextSimplePortionPrimitive2D::getTextOutlinesAndTransformation( } // get the text outlines - aTextLayouter.getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(), - aScaledDXArray); + pTextLayouter->getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(), + aScaledDXArray); } else { // get the text outlines - aTextLayouter.getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(), - getDXArray()); + pTextLayouter->getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength(), + getDXArray()); } // create primitives for the outlines diff --git a/drawinglayer/source/processor2d/contourextractor2d.cxx b/drawinglayer/source/processor2d/contourextractor2d.cxx index 5b9adf4c0ab1..919c09cfe430 100644 --- a/drawinglayer/source/processor2d/contourextractor2d.cxx +++ b/drawinglayer/source/processor2d/contourextractor2d.cxx @@ -131,7 +131,7 @@ namespace drawinglayer::processor2d getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter()); updateVisitingParameters(aVisitingParameters); // process content diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index a41037426b09..ffc6c466064f 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -240,7 +240,7 @@ namespace drawinglayer::processor2d getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter()); updateVisitingParameters(aVisitingParameters); // process child content recursively diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index cd4593b2a3a9..8a173b21fd01 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -94,7 +94,7 @@ namespace drawinglayer::processor2d getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, maVisitingParameters.getTextLayouter()); updateVisitingParameters(aVisitingParameters); // process content diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index 5eb6c9f9c8ff..bc60998f2d03 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -185,7 +185,7 @@ namespace drawinglayer::processor2d getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aParameters(aViewInformation2D); + primitive2d::VisitingParameters aParameters(aViewInformation2D, maVisitingParameters.getTextLayouter()); updateVisitingParameters(aParameters); // process content diff --git a/drawinglayer/source/processor2d/textlayoutdevice.cxx b/drawinglayer/source/processor2d/textlayoutdevice.cxx index 759a5757c8a2..1af699d766ee 100644 --- a/drawinglayer/source/processor2d/textlayoutdevice.cxx +++ b/drawinglayer/source/processor2d/textlayoutdevice.cxx @@ -164,6 +164,14 @@ TextLayouterDevice::~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE { releaseGloba void TextLayouterDevice::setFont(const vcl::Font& rFont) { mrDevice.SetFont(rFont); } +void TextLayouterDevice::setFontAttribute(const gfx::IFontAttribute& rFontAttribute, + double fFontScaleX, double fFontScaleY, + const css::lang::Locale& rLocale) +{ + auto rFontA = dynamic_cast<attribute::FontAttribute const&>(rFontAttribute); + setFontAttribute(rFontA, fFontScaleX, fFontScaleY, rLocale); +} + void TextLayouterDevice::setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, const css::lang::Locale& rLocale) @@ -342,8 +350,8 @@ std::vector<double> TextLayouterDevice::getCaretPositions(const OUString& rText, // helper methods for vcl font handling -vcl::Font getVclFontFromFontAttribute(const attribute::FontAttribute& rFontAttribute, - double fFontScaleX, double fFontScaleY, double fFontRotation, +vcl::Font getVclFontFromFontAttribute(const gfx::IFontAttribute& rFontAttribute, double fFontScaleX, + double fFontScaleY, double fFontRotation, const css::lang::Locale& rLocale) { // detect FontScaling diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 042bb4e5f54c..25a72a44fbba 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -2311,7 +2311,8 @@ void VclMetafileProcessor2D::processTransparencePrimitive2D( getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInfo); + primitive2d::VisitingParameters aVisitingParameters( + aViewInfo, maVisitingParameters.getTextLayouter()); VclPixelProcessor2D aBufferProcessor(aVisitingParameters, *aBufferDevice); @@ -2451,7 +2452,8 @@ void VclMetafileProcessor2D::processPrimitive2DOnPixelProcessor( auto pBufferDevice(CreateBufferDevice(aViewRange, aViewInfo, aRectLogic, aSizePixel)); if (pBufferDevice) { - primitive2d::VisitingParameters aVisitingParameters(aViewInfo); + primitive2d::VisitingParameters aVisitingParameters(aViewInfo, + maVisitingParameters.getTextLayouter()); VclPixelProcessor2D aBufferProcessor(aVisitingParameters, *pBufferDevice, maBColorModifierStack); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 5489e56d0c19..a2a33986a3c9 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -907,7 +907,8 @@ void VclProcessor2D::RenderTransformPrimitive2D( getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(), getViewInformation2D().getVisualizedPage(), getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, + maVisitingParameters.getTextLayouter()); updateVisitingParameters(aVisitingParameters); // process content @@ -931,7 +932,8 @@ void VclProcessor2D::RenderPagePreviewPrimitive2D( getViewInformation2D().getViewTransformation(), getViewInformation2D().getViewport(), rPagePreviewCandidate.getXDrawPage(), getViewInformation2D().getViewTime(), getViewInformation2D().getExtendedInformationSequence()); - primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D); + primitive2d::VisitingParameters aVisitingParameters(aViewInformation2D, + maVisitingParameters.getTextLayouter()); updateVisitingParameters(aVisitingParameters); // process decomposed content diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index e347e102c616..8c18973e1b8a 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -36,6 +36,7 @@ #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/attribute/lineattribute.hxx> #include <drawinglayer/attribute/fontattribute.hxx> +#include <drawinglayer/processor2d/textlayoutdevice.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> @@ -209,7 +210,8 @@ void Primitive2dXmlDump::decomposeAndWrite( ::tools::XmlWriter& rWriter) { drawinglayer::geometry::ViewInformation2D aInfo; - drawinglayer::primitive2d::VisitingParameters aVisitingParameters(aInfo); + auto pTextLayouter = std::make_shared<drawinglayer::processor2d::TextLayouterDevice>(); + drawinglayer::primitive2d::VisitingParameters aVisitingParameters(aInfo, pTextLayouter); for (size_t i = 0; i < rPrimitive2DSequence.size(); i++) { diff --git a/include/basegfx/text/ITextLayouter.hxx b/include/basegfx/text/ITextLayouter.hxx new file mode 100644 index 000000000000..26ce4697e275 --- /dev/null +++ b/include/basegfx/text/ITextLayouter.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <sal/config.h> +#include <basegfx/basegfxdllapi.h> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +namespace com::sun::star::lang +{ +struct Locale; +} + +namespace gfx +{ +class BASEGFX_DLLPUBLIC IFontAttribute +{ +public: + virtual ~IFontAttribute() {} + + virtual const OUString& getFamilyName() const = 0; + virtual const OUString& getStyleName() const = 0; + virtual sal_uInt16 getWeight() const = 0; + virtual bool getSymbol() const = 0; + virtual bool getVertical() const = 0; + virtual bool getItalic() const = 0; + virtual bool getOutline() const = 0; + virtual bool getRTL() const = 0; + virtual bool getBiDiStrong() const = 0; + virtual bool getMonospaced() const = 0; +}; + +class BASEGFX_DLLPUBLIC ITextLayouter +{ +public: + virtual ~ITextLayouter() {} + + virtual void setFontAttribute(IFontAttribute const& rFontAttribute, double fFontScaleX, + double fFontScaleY, const css::lang::Locale& rLocale) + = 0; + + virtual void getTextOutlines(basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector, + const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength, + const std::vector<double>& rDXArray) const = 0; +}; + +} // end namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basegfx/text/UnoTextLayouter.hxx b/include/basegfx/text/UnoTextLayouter.hxx new file mode 100644 index 000000000000..f8b0f250edee --- /dev/null +++ b/include/basegfx/text/UnoTextLayouter.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <comphelper/servicehelper.hxx> + +#include <com/sun/star/graphic/XTextLayouter.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <basegfx/text/ITextLayouter.hxx> +#include <basegfx/basegfxdllapi.h> + +namespace gfx +{ +BASEGFX_DLLPUBLIC std::shared_ptr<gfx::ITextLayouter> +getTextLayouterFromUno(css::uno::Reference<css::graphic::XTextLayouter> const& xTextLayouter); + +class UnoTextLayouter final + : public cppu::WeakImplHelper<css::graphic::XTextLayouter, css::lang::XUnoTunnel> +{ +private: + std::shared_ptr<gfx::ITextLayouter> mpTextLayouter; + +public: + UnoTextLayouter() {} + + UnoTextLayouter(std::shared_ptr<gfx::ITextLayouter> const& rTextLayouter) + : mpTextLayouter(rTextLayouter) + { + } + + std::shared_ptr<gfx::ITextLayouter> const& getTextLayouter() const { return mpTextLayouter; } + + void setTextLayouter(std::shared_ptr<gfx::ITextLayouter> const& rTextLayouter) + { + mpTextLayouter = rTextLayouter; + } + + UNO3_GETIMPLEMENTATION_DECL(UnoTextLayouter) +}; +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/attribute/fontattribute.hxx b/include/drawinglayer/attribute/fontattribute.hxx index 1a7250170b6e..ed0be642f615 100644 --- a/include/drawinglayer/attribute/fontattribute.hxx +++ b/include/drawinglayer/attribute/fontattribute.hxx @@ -23,6 +23,8 @@ #include <o3tl/cow_wrapper.hxx> #include <rtl/ustring.hxx> +#include <basegfx/text/ITextLayouter.hxx> + namespace drawinglayer::attribute { class ImpFontAttribute; @@ -35,7 +37,7 @@ namespace drawinglayer::attribute This attribute class is able to hold all parameters needed/used to completely define the parametrisation of a text portion. */ -class DRAWINGLAYER_DLLPUBLIC FontAttribute +class DRAWINGLAYER_DLLPUBLIC FontAttribute : public gfx::IFontAttribute { public: typedef o3tl::cow_wrapper<ImpFontAttribute> ImplType; @@ -50,26 +52,26 @@ public: bool bMonospaced = false, bool bOutline = false, bool bRTL = false, bool bBiDiStrong = false); FontAttribute(); - FontAttribute(const FontAttribute&); - FontAttribute(FontAttribute&&); - FontAttribute& operator=(const FontAttribute&); - FontAttribute& operator=(FontAttribute&&); - ~FontAttribute(); + FontAttribute(const FontAttribute& rOther); + FontAttribute(FontAttribute&& rOther) noexcept; + FontAttribute& operator=(const FontAttribute& rOther); + FontAttribute& operator=(FontAttribute&& rOther) noexcept; + virtual ~FontAttribute(); // compare operator bool operator==(const FontAttribute& rCandidate) const; /// data read access - const OUString& getFamilyName() const; - const OUString& getStyleName() const; - sal_uInt16 getWeight() const; - bool getSymbol() const; - bool getVertical() const; - bool getItalic() const; - bool getOutline() const; - bool getRTL() const; - bool getBiDiStrong() const; - bool getMonospaced() const; + const OUString& getFamilyName() const override; + const OUString& getStyleName() const override; + sal_uInt16 getWeight() const override; + bool getSymbol() const override; + bool getVertical() const override; + bool getItalic() const override; + bool getOutline() const override; + bool getRTL() const override; + bool getBiDiStrong() const override; + bool getMonospaced() const override; }; } // end of namespace drawinglayer::attribute diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx index 486bf031daf7..69ff76ae0c4c 100644 --- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -30,6 +30,7 @@ #include <cppuhelper/basemutex.hxx> #include <basegfx/range/b2drange.hxx> #include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <basegfx/text/ITextLayouter.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> @@ -39,10 +40,13 @@ class DRAWINGLAYERCORE_DLLPUBLIC VisitingParameters { private: geometry::ViewInformation2D maViewInformation; + std::shared_ptr<gfx::ITextLayouter> mpTextLayouter; public: - explicit VisitingParameters(const geometry::ViewInformation2D& rViewInformation) + explicit VisitingParameters(geometry::ViewInformation2D const& rViewInformation, + std::shared_ptr<gfx::ITextLayouter> const& pTextLayouter) : maViewInformation(rViewInformation) + , mpTextLayouter(pTextLayouter) { } @@ -54,6 +58,8 @@ public: } const geometry::ViewInformation2D& getViewInformation() const { return maViewInformation; } + + const std::shared_ptr<gfx::ITextLayouter>& getTextLayouter() const { return mpTextLayouter; } }; typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting> diff --git a/include/drawinglayer/processor2d/baseprocessor2d.hxx b/include/drawinglayer/processor2d/baseprocessor2d.hxx index 802434fd9009..c723c5c0c619 100644 --- a/include/drawinglayer/processor2d/baseprocessor2d.hxx +++ b/include/drawinglayer/processor2d/baseprocessor2d.hxx @@ -24,7 +24,7 @@ #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> - +#include <basegfx/text/ITextLayouter.hxx> namespace drawinglayer::processor2d { diff --git a/include/drawinglayer/processor2d/textlayoutdevice.hxx b/include/drawinglayer/processor2d/textlayoutdevice.hxx index ddcdf06bc0dd..edcefec190e1 100644 --- a/include/drawinglayer/processor2d/textlayoutdevice.hxx +++ b/include/drawinglayer/processor2d/textlayoutdevice.hxx @@ -25,6 +25,7 @@ #include <vector> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <vcl/svapp.hxx> +#include <basegfx/text/ITextLayouter.hxx> // predefines class VirtualDevice; @@ -58,7 +59,7 @@ namespace drawinglayer::processor2d When in the future FontHandling may move to an own library independent from VCL, primitives will be prepared. */ -class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice +class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice : public gfx::ITextLayouter { /// internally used VirtualDevice SolarMutexGuard maSolarGuard; @@ -71,6 +72,10 @@ public: /// tooling methods void setFont(const vcl::Font& rFont); + + void setFontAttribute(const gfx::IFontAttribute& rFontAttribute, double fFontScaleX, + double fFontScaleY, const css::lang::Locale& rLocale) override; + void setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, const css::lang::Locale& rLocale); @@ -84,7 +89,7 @@ public: double getTextWidth(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const; void getTextOutlines(basegfx::B2DPolyPolygonVector&, const OUString& rText, sal_uInt32 nIndex, - sal_uInt32 nLength, const ::std::vector<double>& rDXArray) const; + sal_uInt32 nLength, const ::std::vector<double>& rDXArray) const override; basegfx::B2DRange getTextBoundRect(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const; @@ -111,7 +116,7 @@ public: fFontScaleY == fFontScaleX */ vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute( - const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, + const gfx::IFontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, double fFontRotation, const css::lang::Locale& rLocale); /** Generate FontAttribute DataSet derived from the given VCL-Font. diff --git a/offapi/com/sun/star/graphic/XTextLayouter.idl b/offapi/com/sun/star/graphic/XTextLayouter.idl new file mode 100644 index 000000000000..c518558d49cf --- /dev/null +++ b/offapi/com/sun/star/graphic/XTextLayouter.idl @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef com_sun_star_graphic_XTextLayouter_idl +#define com_sun_star_graphic_XTextLayouter_idl + +#include <com/sun/star/uno/XInterface.idl> + +module com { module sun { module star { module graphic +{ + +/** Text layouter interface +*/ + +interface XTextLayouter : ::com::sun::star::uno::XInterface +{ +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |