[Libreoffice-commits] core.git: drawinglayer/source include/drawinglayer solenv/clang-format
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 23 07:30:58 UTC 2020
drawinglayer/source/primitive2d/textlayoutdevice.cxx | 746 ++++++++----------
include/drawinglayer/primitive2d/textlayoutdevice.hxx | 166 +---
solenv/clang-format/excludelist | 2
3 files changed, 423 insertions(+), 491 deletions(-)
New commits:
commit 9f7999c6281293d01f143e899056d72496868345
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Oct 18 21:55:51 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Nov 23 08:30:16 2020 +0100
remove textlayoutdevice.{hxx,cxx} from clang-format excludelist
Change-Id: Ia80a0331246b4e25cdc3387c50bd97c6befc4ea4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106382
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index 43afce5d0f1e..c842517b3e72 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -36,473 +36,423 @@
#include <i18nlangtag/languagetag.hxx>
#include <vcl/svapp.hxx>
-
// VDev RevDevice provider
namespace
{
- class ImpTimedRefDev;
+class ImpTimedRefDev;
- //the scoped_timed_RefDev owns an ImpTimeRefDev and releases it on dtor
- //or disposing of the default XComponentContext which causes the underlying
- //OutputDevice to get released
+//the scoped_timed_RefDev owns an ImpTimeRefDev and releases it on dtor
+//or disposing of the default XComponentContext which causes the underlying
+//OutputDevice to get released
- //The ImpTimerRefDev itself, if the timeout ever gets hit, will call
- //reset on the scoped_timed_RefDev to release the ImpTimerRefDev early
- //if it's unused for a few minutes
- class scoped_timed_RefDev : public comphelper::unique_disposing_ptr<ImpTimedRefDev>
+//The ImpTimerRefDev itself, if the timeout ever gets hit, will call
+//reset on the scoped_timed_RefDev to release the ImpTimerRefDev early
+//if it's unused for a few minutes
+class scoped_timed_RefDev : public comphelper::unique_disposing_ptr<ImpTimedRefDev>
+{
+public:
+ scoped_timed_RefDev()
+ : comphelper::unique_disposing_ptr<ImpTimedRefDev>(
+ (css::uno::Reference<css::lang::XComponent>(
+ ::comphelper::getProcessComponentContext(), css::uno::UNO_QUERY_THROW)))
{
- public:
- scoped_timed_RefDev() : comphelper::unique_disposing_ptr<ImpTimedRefDev>((css::uno::Reference<css::lang::XComponent>(::comphelper::getProcessComponentContext(), css::uno::UNO_QUERY_THROW)))
- {
- }
- };
+ }
+};
- class the_scoped_timed_RefDev : public rtl::Static<scoped_timed_RefDev, the_scoped_timed_RefDev> {};
+class the_scoped_timed_RefDev : public rtl::Static<scoped_timed_RefDev, the_scoped_timed_RefDev>
+{
+};
- class ImpTimedRefDev : public Timer
- {
- scoped_timed_RefDev& mrOwnerOfMe;
- VclPtr<VirtualDevice> mpVirDev;
- sal_uInt32 mnUseCount;
-
- public:
- explicit ImpTimedRefDev(scoped_timed_RefDev& rOwnerofMe);
- virtual ~ImpTimedRefDev() override;
- virtual void Invoke() override;
-
- VirtualDevice& acquireVirtualDevice();
- void releaseVirtualDevice();
- };
-
- ImpTimedRefDev::ImpTimedRefDev(scoped_timed_RefDev& rOwnerOfMe)
- : Timer( "drawinglayer ImpTimedRefDev destroy mpVirDev" ),
- mrOwnerOfMe(rOwnerOfMe),
- mpVirDev(nullptr),
- mnUseCount(0)
- {
- SetTimeout(3L * 60L * 1000L); // three minutes
- Start();
- }
+class ImpTimedRefDev : public Timer
+{
+ scoped_timed_RefDev& mrOwnerOfMe;
+ VclPtr<VirtualDevice> mpVirDev;
+ sal_uInt32 mnUseCount;
+
+public:
+ explicit ImpTimedRefDev(scoped_timed_RefDev& rOwnerofMe);
+ virtual ~ImpTimedRefDev() override;
+ virtual void Invoke() override;
+
+ VirtualDevice& acquireVirtualDevice();
+ void releaseVirtualDevice();
+};
+
+ImpTimedRefDev::ImpTimedRefDev(scoped_timed_RefDev& rOwnerOfMe)
+ : Timer("drawinglayer ImpTimedRefDev destroy mpVirDev")
+ , mrOwnerOfMe(rOwnerOfMe)
+ , mpVirDev(nullptr)
+ , mnUseCount(0)
+{
+ SetTimeout(3L * 60L * 1000L); // three minutes
+ Start();
+}
- ImpTimedRefDev::~ImpTimedRefDev()
- {
- OSL_ENSURE(0 == mnUseCount, "destruction of a still used ImpTimedRefDev (!)");
- const SolarMutexGuard aSolarGuard;
- mpVirDev.disposeAndClear();
- }
+ImpTimedRefDev::~ImpTimedRefDev()
+{
+ OSL_ENSURE(0 == mnUseCount, "destruction of a still used ImpTimedRefDev (!)");
+ const SolarMutexGuard aSolarGuard;
+ mpVirDev.disposeAndClear();
+}
+
+void ImpTimedRefDev::Invoke()
+{
+ // for obvious reasons, do not call anything after this
+ mrOwnerOfMe.reset();
+}
- void ImpTimedRefDev::Invoke()
+VirtualDevice& ImpTimedRefDev::acquireVirtualDevice()
+{
+ if (!mpVirDev)
{
- // for obvious reasons, do not call anything after this
- mrOwnerOfMe.reset();
+ mpVirDev = VclPtr<VirtualDevice>::Create();
+ mpVirDev->SetReferenceDevice(VirtualDevice::RefDevMode::MSO1);
}
- VirtualDevice& ImpTimedRefDev::acquireVirtualDevice()
+ if (!mnUseCount)
{
- if(!mpVirDev)
- {
- mpVirDev = VclPtr<VirtualDevice>::Create();
- mpVirDev->SetReferenceDevice( VirtualDevice::RefDevMode::MSO1 );
- }
+ Stop();
+ }
- if(!mnUseCount)
- {
- Stop();
- }
+ mnUseCount++;
- mnUseCount++;
+ return *mpVirDev;
+}
- return *mpVirDev;
- }
+void ImpTimedRefDev::releaseVirtualDevice()
+{
+ OSL_ENSURE(mnUseCount, "mismatch call number to releaseVirtualDevice() (!)");
+ mnUseCount--;
- void ImpTimedRefDev::releaseVirtualDevice()
+ if (!mnUseCount)
{
- OSL_ENSURE(mnUseCount, "mismatch call number to releaseVirtualDevice() (!)");
- mnUseCount--;
-
- if(!mnUseCount)
- {
- Start();
- }
+ Start();
}
+}
} // end of anonymous namespace
-
// access to one global ImpTimedRefDev incarnation in namespace drawinglayer::primitive
namespace drawinglayer::primitive2d
{
- // static methods here
- static VirtualDevice& acquireGlobalVirtualDevice()
- {
- scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
+// static methods here
+static VirtualDevice& acquireGlobalVirtualDevice()
+{
+ scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
- if(!rStdRefDevice)
- rStdRefDevice.reset(new ImpTimedRefDev(rStdRefDevice));
+ if (!rStdRefDevice)
+ rStdRefDevice.reset(new ImpTimedRefDev(rStdRefDevice));
- return rStdRefDevice->acquireVirtualDevice();
- }
+ return rStdRefDevice->acquireVirtualDevice();
+}
- static void releaseGlobalVirtualDevice()
- {
- scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
+static void releaseGlobalVirtualDevice()
+{
+ scoped_timed_RefDev& rStdRefDevice = the_scoped_timed_RefDev::get();
- OSL_ENSURE(rStdRefDevice, "releaseGlobalVirtualDevice() without prior acquireGlobalVirtualDevice() call(!)");
- rStdRefDevice->releaseVirtualDevice();
- }
+ OSL_ENSURE(rStdRefDevice,
+ "releaseGlobalVirtualDevice() without prior acquireGlobalVirtualDevice() call(!)");
+ rStdRefDevice->releaseVirtualDevice();
+}
- TextLayouterDevice::TextLayouterDevice()
- : maSolarGuard(),
- mrDevice(acquireGlobalVirtualDevice())
- {
- }
+TextLayouterDevice::TextLayouterDevice()
+ : maSolarGuard()
+ , mrDevice(acquireGlobalVirtualDevice())
+{
+}
- TextLayouterDevice::~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE
- {
- releaseGlobalVirtualDevice();
- }
+TextLayouterDevice::~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE { releaseGlobalVirtualDevice(); }
- void TextLayouterDevice::setFont(const vcl::Font& rFont)
- {
- mrDevice.SetFont( rFont );
- }
+void TextLayouterDevice::setFont(const vcl::Font& rFont) { mrDevice.SetFont(rFont); }
- void TextLayouterDevice::setFontAttribute(
- const attribute::FontAttribute& rFontAttribute,
- double fFontScaleX,
- double fFontScaleY,
- const css::lang::Locale& rLocale)
- {
- setFont(getVclFontFromFontAttribute(
- rFontAttribute,
- fFontScaleX,
- fFontScaleY,
- 0.0,
- rLocale));
- }
+void TextLayouterDevice::setFontAttribute(const attribute::FontAttribute& rFontAttribute,
+ double fFontScaleX, double fFontScaleY,
+ const css::lang::Locale& rLocale)
+{
+ setFont(getVclFontFromFontAttribute(rFontAttribute, fFontScaleX, fFontScaleY, 0.0, rLocale));
+}
- double TextLayouterDevice::getOverlineOffset() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- double fRet = (rMetric.GetInternalLeading() / 2.0) - rMetric.GetAscent();
- return fRet;
- }
+double TextLayouterDevice::getOverlineOffset() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ double fRet = (rMetric.GetInternalLeading() / 2.0) - rMetric.GetAscent();
+ return fRet;
+}
- double TextLayouterDevice::getUnderlineOffset() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- double fRet = rMetric.GetDescent() / 2.0;
- return fRet;
- }
+double TextLayouterDevice::getUnderlineOffset() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ double fRet = rMetric.GetDescent() / 2.0;
+ return fRet;
+}
- double TextLayouterDevice::getStrikeoutOffset() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- double fRet = (rMetric.GetAscent() - rMetric.GetInternalLeading()) / 3.0;
- return fRet;
- }
+double TextLayouterDevice::getStrikeoutOffset() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ double fRet = (rMetric.GetAscent() - rMetric.GetInternalLeading()) / 3.0;
+ return fRet;
+}
- double TextLayouterDevice::getOverlineHeight() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- double fRet = rMetric.GetInternalLeading() / 2.5;
- return fRet;
- }
+double TextLayouterDevice::getOverlineHeight() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ double fRet = rMetric.GetInternalLeading() / 2.5;
+ return fRet;
+}
- double TextLayouterDevice::getUnderlineHeight() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- double fRet = rMetric.GetDescent() / 4.0;
- return fRet;
- }
+double TextLayouterDevice::getUnderlineHeight() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ double fRet = rMetric.GetDescent() / 4.0;
+ return fRet;
+}
- double TextLayouterDevice::getTextHeight() const
- {
- return mrDevice.GetTextHeight();
- }
+double TextLayouterDevice::getTextHeight() const { return mrDevice.GetTextHeight(); }
- double TextLayouterDevice::getTextWidth(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const
- {
- return mrDevice.GetTextWidth(rText, nIndex, nLength);
- }
+double TextLayouterDevice::getTextWidth(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const
+{
+ return mrDevice.GetTextWidth(rText, nIndex, nLength);
+}
- void TextLayouterDevice::getTextOutlines(
- basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength,
- const std::vector< double >& rDXArray) const
- {
- const sal_uInt32 nDXArrayCount(rDXArray.size());
- sal_uInt32 nTextLength(nLength);
- const sal_uInt32 nStringLength(rText.getLength());
-
- if(nTextLength + nIndex > nStringLength)
- {
- nTextLength = nStringLength - nIndex;
- }
-
- if(nDXArrayCount)
- {
- OSL_ENSURE(nDXArrayCount == nTextLength, "DXArray size does not correspond to text portion size (!)");
- std::vector< tools::Long > aIntegerDXArray(nDXArrayCount);
-
- for(sal_uInt32 a(0); a < nDXArrayCount; a++)
- {
- aIntegerDXArray[a] = basegfx::fround(rDXArray[a]);
- }
-
- mrDevice.GetTextOutlines(
- rB2DPolyPolyVector,
- rText,
- nIndex,
- nIndex,
- nLength,
- 0,
- aIntegerDXArray.data());
- }
- else
- {
- mrDevice.GetTextOutlines(
- rB2DPolyPolyVector,
- rText,
- nIndex,
- nIndex,
- nLength);
- }
- }
+void TextLayouterDevice::getTextOutlines(basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
+ const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength,
+ const std::vector<double>& rDXArray) const
+{
+ const sal_uInt32 nDXArrayCount(rDXArray.size());
+ sal_uInt32 nTextLength(nLength);
+ const sal_uInt32 nStringLength(rText.getLength());
- basegfx::B2DRange TextLayouterDevice::getTextBoundRect(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const
- {
- sal_uInt32 nTextLength(nLength);
- const sal_uInt32 nStringLength(rText.getLength());
-
- if(nTextLength + nIndex > nStringLength)
- {
- nTextLength = nStringLength - nIndex;
- }
-
- if(nTextLength)
- {
- ::tools::Rectangle aRect;
-
- mrDevice.GetTextBoundRect(
- aRect,
- rText,
- nIndex,
- nIndex,
- nLength);
-
- // #i104432#, #i102556# take empty results into account
- if(!aRect.IsEmpty())
- {
- return vcl::unotools::b2DRectangleFromRectangle(aRect);
- }
- }
-
- return basegfx::B2DRange();
- }
+ if (nTextLength + nIndex > nStringLength)
+ {
+ nTextLength = nStringLength - nIndex;
+ }
- double TextLayouterDevice::getFontAscent() const
- {
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- return rMetric.GetAscent();
- }
+ if (nDXArrayCount)
+ {
+ OSL_ENSURE(nDXArrayCount == nTextLength,
+ "DXArray size does not correspond to text portion size (!)");
+ std::vector<tools::Long> aIntegerDXArray(nDXArrayCount);
- double TextLayouterDevice::getFontDescent() const
+ for (sal_uInt32 a(0); a < nDXArrayCount; a++)
{
- const ::FontMetric& rMetric = mrDevice.GetFontMetric();
- return rMetric.GetDescent();
+ aIntegerDXArray[a] = basegfx::fround(rDXArray[a]);
}
- void TextLayouterDevice::addTextRectActions(
- const ::tools::Rectangle& rRectangle,
- const OUString& rText,
- DrawTextFlags nStyle,
- GDIMetaFile& rGDIMetaFile) const
- {
- mrDevice.AddTextRectActions(
- rRectangle, rText, nStyle, rGDIMetaFile);
- }
+ mrDevice.GetTextOutlines(rB2DPolyPolyVector, rText, nIndex, nIndex, nLength, 0,
+ aIntegerDXArray.data());
+ }
+ else
+ {
+ mrDevice.GetTextOutlines(rB2DPolyPolyVector, rText, nIndex, nIndex, nLength);
+ }
+}
- std::vector< double > TextLayouterDevice::getTextArray(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const
- {
- std::vector< double > aRetval;
- sal_uInt32 nTextLength(nLength);
- const sal_uInt32 nStringLength(rText.getLength());
-
- if(nTextLength + nIndex > nStringLength)
- {
- nTextLength = nStringLength - nIndex;
- }
-
- if(nTextLength)
- {
- aRetval.reserve(nTextLength);
- std::vector<tools::Long> aArray(nTextLength);
- mrDevice.GetTextArray(rText, aArray.data(), nIndex, nLength);
- aRetval.assign(aArray.begin(), aArray.end());
- }
-
- return aRetval;
- }
+basegfx::B2DRange TextLayouterDevice::getTextBoundRect(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const
+{
+ sal_uInt32 nTextLength(nLength);
+ const sal_uInt32 nStringLength(rText.getLength());
+
+ if (nTextLength + nIndex > nStringLength)
+ {
+ nTextLength = nStringLength - nIndex;
+ }
+
+ if (nTextLength)
+ {
+ ::tools::Rectangle aRect;
- std::vector< double > TextLayouterDevice::getCaretPositions(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const
+ mrDevice.GetTextBoundRect(aRect, rText, nIndex, nIndex, nLength);
+
+ // #i104432#, #i102556# take empty results into account
+ if (!aRect.IsEmpty())
{
- std::vector< double > aRetval;
- sal_uInt32 nTextLength(nLength);
- const sal_uInt32 nStringLength(rText.getLength());
-
- if(nTextLength + nIndex > nStringLength)
- {
- nTextLength = nStringLength - nIndex;
- }
-
- if(nTextLength)
- {
- aRetval.reserve(2 * nTextLength);
- std::vector<tools::Long> aArray(2 * nTextLength);
- mrDevice.GetCaretPositions(rText, aArray.data(), nIndex, nLength);
- aRetval.assign(aArray.begin(), aArray.end());
- }
-
- return aRetval;
+ return vcl::unotools::b2DRectangleFromRectangle(aRect);
}
+ }
+
+ return basegfx::B2DRange();
+}
+
+double TextLayouterDevice::getFontAscent() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ return rMetric.GetAscent();
+}
+
+double TextLayouterDevice::getFontDescent() const
+{
+ const ::FontMetric& rMetric = mrDevice.GetFontMetric();
+ return rMetric.GetDescent();
+}
+
+void TextLayouterDevice::addTextRectActions(const ::tools::Rectangle& rRectangle,
+ const OUString& rText, DrawTextFlags nStyle,
+ GDIMetaFile& rGDIMetaFile) const
+{
+ mrDevice.AddTextRectActions(rRectangle, rText, nStyle, rGDIMetaFile);
+}
+
+std::vector<double> TextLayouterDevice::getTextArray(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const
+{
+ std::vector<double> aRetval;
+ sal_uInt32 nTextLength(nLength);
+ const sal_uInt32 nStringLength(rText.getLength());
+
+ if (nTextLength + nIndex > nStringLength)
+ {
+ nTextLength = nStringLength - nIndex;
+ }
+ if (nTextLength)
+ {
+ aRetval.reserve(nTextLength);
+ std::vector<tools::Long> aArray(nTextLength);
+ mrDevice.GetTextArray(rText, aArray.data(), nIndex, nLength);
+ aRetval.assign(aArray.begin(), aArray.end());
+ }
+
+ return aRetval;
+}
+
+std::vector<double> TextLayouterDevice::getCaretPositions(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const
+{
+ std::vector<double> aRetval;
+ sal_uInt32 nTextLength(nLength);
+ const sal_uInt32 nStringLength(rText.getLength());
+
+ if (nTextLength + nIndex > nStringLength)
+ {
+ nTextLength = nStringLength - nIndex;
+ }
+
+ if (nTextLength)
+ {
+ aRetval.reserve(2 * nTextLength);
+ std::vector<tools::Long> aArray(2 * nTextLength);
+ mrDevice.GetCaretPositions(rText, aArray.data(), nIndex, nLength);
+ aRetval.assign(aArray.begin(), aArray.end());
+ }
+
+ return aRetval;
+}
// helper methods for vcl font handling
- vcl::Font getVclFontFromFontAttribute(
- const attribute::FontAttribute& rFontAttribute,
- double fFontScaleX,
- double fFontScaleY,
- double fFontRotation,
- const css::lang::Locale& rLocale)
- {
- // detect FontScaling
- const sal_uInt32 nHeight(basegfx::fround(fabs(fFontScaleY)));
- const sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX)));
- const bool bFontIsScaled(nHeight != nWidth);
+vcl::Font getVclFontFromFontAttribute(const attribute::FontAttribute& rFontAttribute,
+ double fFontScaleX, double fFontScaleY, double fFontRotation,
+ const css::lang::Locale& rLocale)
+{
+ // detect FontScaling
+ const sal_uInt32 nHeight(basegfx::fround(fabs(fFontScaleY)));
+ const sal_uInt32 nWidth(basegfx::fround(fabs(fFontScaleX)));
+ const bool bFontIsScaled(nHeight != nWidth);
#ifdef _WIN32
- // for WIN32 systems, start with creating an unscaled font. If FontScaling
- // is wanted, that width needs to be adapted using FontMetric again to get a
- // width of the unscaled font
- vcl::Font aRetval(
- rFontAttribute.getFamilyName(),
- rFontAttribute.getStyleName(),
- Size(0, nHeight));
+ // for WIN32 systems, start with creating an unscaled font. If FontScaling
+ // is wanted, that width needs to be adapted using FontMetric again to get a
+ // width of the unscaled font
+ vcl::Font aRetval(rFontAttribute.getFamilyName(), rFontAttribute.getStyleName(),
+ Size(0, nHeight));
#else
- // for non-WIN32 systems things are easier since these accept a Font creation
- // with initially nWidth != nHeight for FontScaling. Despite that, use zero for
- // FontWidth when no scaling is used to explicitly have that zero when e.g. the
- // Font would be recorded in a MetaFile (The MetaFile FontAction WILL record a
- // set FontWidth; import that in a WIN32 system, and trouble is there)
- vcl::Font aRetval(
- rFontAttribute.getFamilyName(),
- rFontAttribute.getStyleName(),
- Size(bFontIsScaled ? std::max<sal_uInt32>(nWidth, 1) : 0, nHeight));
+ // for non-WIN32 systems things are easier since these accept a Font creation
+ // with initially nWidth != nHeight for FontScaling. Despite that, use zero for
+ // FontWidth when no scaling is used to explicitly have that zero when e.g. the
+ // Font would be recorded in a MetaFile (The MetaFile FontAction WILL record a
+ // set FontWidth; import that in a WIN32 system, and trouble is there)
+ vcl::Font aRetval(rFontAttribute.getFamilyName(), rFontAttribute.getStyleName(),
+ Size(bFontIsScaled ? std::max<sal_uInt32>(nWidth, 1) : 0, nHeight));
#endif
- // define various other FontAttribute
- aRetval.SetAlignment(ALIGN_BASELINE);
- aRetval.SetCharSet(rFontAttribute.getSymbol() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE);
- aRetval.SetVertical(rFontAttribute.getVertical());
- aRetval.SetWeight(static_cast<FontWeight>(rFontAttribute.getWeight()));
- aRetval.SetItalic(rFontAttribute.getItalic() ? ITALIC_NORMAL : ITALIC_NONE);
- aRetval.SetOutline(rFontAttribute.getOutline());
- aRetval.SetPitch(rFontAttribute.getMonospaced() ? PITCH_FIXED : PITCH_VARIABLE);
- aRetval.SetLanguage(LanguageTag::convertToLanguageType( rLocale, false));
+ // define various other FontAttribute
+ aRetval.SetAlignment(ALIGN_BASELINE);
+ aRetval.SetCharSet(rFontAttribute.getSymbol() ? RTL_TEXTENCODING_SYMBOL
+ : RTL_TEXTENCODING_UNICODE);
+ aRetval.SetVertical(rFontAttribute.getVertical());
+ aRetval.SetWeight(static_cast<FontWeight>(rFontAttribute.getWeight()));
+ aRetval.SetItalic(rFontAttribute.getItalic() ? ITALIC_NORMAL : ITALIC_NONE);
+ aRetval.SetOutline(rFontAttribute.getOutline());
+ aRetval.SetPitch(rFontAttribute.getMonospaced() ? PITCH_FIXED : PITCH_VARIABLE);
+ aRetval.SetLanguage(LanguageTag::convertToLanguageType(rLocale, false));
#ifdef _WIN32
- // for WIN32 systems, correct the FontWidth if FontScaling is used
- if(bFontIsScaled && nHeight > 0)
- {
- const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aRetval));
-
- if(aUnscaledFontMetric.GetAverageFontWidth() > 0)
- {
- const double fScaleFactor(static_cast<double>(nWidth) / static_cast<double>(nHeight));
- const sal_uInt32 nScaledWidth(basegfx::fround(static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor));
- aRetval.SetAverageFontWidth(nScaledWidth);
- }
- }
-#endif
- // handle FontRotation (if defined)
- if(!basegfx::fTools::equalZero(fFontRotation))
- {
- sal_Int16 aRotate10th(static_cast<sal_Int16>(fFontRotation * (-1800.0/F_PI)));
- aRetval.SetOrientation(Degree10(aRotate10th % 3600));
- }
-
- return aRetval;
- }
+ // for WIN32 systems, correct the FontWidth if FontScaling is used
+ if (bFontIsScaled && nHeight > 0)
+ {
+ const FontMetric aUnscaledFontMetric(
+ Application::GetDefaultDevice()->GetFontMetric(aRetval));
- attribute::FontAttribute getFontAttributeFromVclFont(
- basegfx::B2DVector& o_rSize,
- const vcl::Font& rFont,
- bool bRTL,
- bool bBiDiStrong)
+ if (aUnscaledFontMetric.GetAverageFontWidth() > 0)
{
- const attribute::FontAttribute aRetval(
- rFont.GetFamilyName(),
- rFont.GetStyleName(),
- static_cast<sal_uInt16>(rFont.GetWeight()),
- RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet(),
- rFont.IsVertical(),
- ITALIC_NONE != rFont.GetItalic(),
- PITCH_FIXED == rFont.GetPitch(),
- rFont.IsOutline(),
- bRTL,
- bBiDiStrong);
- // TODO: eKerning
-
- // set FontHeight and init to no FontScaling
- o_rSize.setY(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
- o_rSize.setX(o_rSize.getY());
+ const double fScaleFactor(static_cast<double>(nWidth) / static_cast<double>(nHeight));
+ const sal_uInt32 nScaledWidth(basegfx::fround(
+ static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor));
+ aRetval.SetAverageFontWidth(nScaledWidth);
+ }
+ }
+#endif
+ // handle FontRotation (if defined)
+ if (!basegfx::fTools::equalZero(fFontRotation))
+ {
+ sal_Int16 aRotate10th(static_cast<sal_Int16>(fFontRotation * (-1800.0 / F_PI)));
+ aRetval.SetOrientation(Degree10(aRotate10th % 3600));
+ }
+
+ return aRetval;
+}
+
+attribute::FontAttribute getFontAttributeFromVclFont(basegfx::B2DVector& o_rSize,
+ const vcl::Font& rFont, bool bRTL,
+ bool bBiDiStrong)
+{
+ const attribute::FontAttribute aRetval(
+ rFont.GetFamilyName(), rFont.GetStyleName(), static_cast<sal_uInt16>(rFont.GetWeight()),
+ RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet(), rFont.IsVertical(),
+ ITALIC_NONE != rFont.GetItalic(), PITCH_FIXED == rFont.GetPitch(), rFont.IsOutline(), bRTL,
+ bBiDiStrong);
+ // TODO: eKerning
+
+ // set FontHeight and init to no FontScaling
+ o_rSize.setY(std::max<tools::Long>(rFont.GetFontSize().getHeight(), 0));
+ o_rSize.setX(o_rSize.getY());
#ifdef _WIN32
- // for WIN32 systems, the FontScaling at the Font is detected by
- // checking that FontWidth != 0. When FontScaling is used, WIN32
- // needs to do extra stuff to detect the correct width (since it's
- // zero and not equal the font height) and its relationship to
- // the height
- if(rFont.GetFontSize().getWidth() > 0)
- {
- vcl::Font aUnscaledFont(rFont);
- aUnscaledFont.SetAverageFontWidth(0);
- const FontMetric aUnscaledFontMetric(Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
-
- if(aUnscaledFontMetric.GetAverageFontWidth() > 0)
- {
- const double fScaleFactor(static_cast<double>(rFont.GetFontSize().getWidth()) / static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()));
- o_rSize.setX(fScaleFactor * o_rSize.getY());
- }
- }
+ // for WIN32 systems, the FontScaling at the Font is detected by
+ // checking that FontWidth != 0. When FontScaling is used, WIN32
+ // needs to do extra stuff to detect the correct width (since it's
+ // zero and not equal the font height) and its relationship to
+ // the height
+ if (rFont.GetFontSize().getWidth() > 0)
+ {
+ vcl::Font aUnscaledFont(rFont);
+ aUnscaledFont.SetAverageFontWidth(0);
+ const FontMetric aUnscaledFontMetric(
+ Application::GetDefaultDevice()->GetFontMetric(aUnscaledFont));
+
+ if (aUnscaledFontMetric.GetAverageFontWidth() > 0)
+ {
+ const double fScaleFactor(
+ static_cast<double>(rFont.GetFontSize().getWidth())
+ / static_cast<double>(aUnscaledFontMetric.GetAverageFontWidth()));
+ o_rSize.setX(fScaleFactor * o_rSize.getY());
+ }
+ }
#else
- // For non-WIN32 systems the detection is the same, but the value
- // is easier achieved since width == height is interpreted as no
- // scaling. Ergo, Width == 0 means width == height, and width != 0
- // means the scaling is in the direct relation of width to height
- if(rFont.GetFontSize().getWidth() > 0)
- {
- o_rSize.setX(static_cast<double>(rFont.GetFontSize().getWidth()));
- }
+ // For non-WIN32 systems the detection is the same, but the value
+ // is easier achieved since width == height is interpreted as no
+ // scaling. Ergo, Width == 0 means width == height, and width != 0
+ // means the scaling is in the direct relation of width to height
+ if (rFont.GetFontSize().getWidth() > 0)
+ {
+ o_rSize.setX(static_cast<double>(rFont.GetFontSize().getWidth()));
+ }
#endif
- return aRetval;
- }
+ return aRetval;
+}
} // end of namespace
diff --git a/include/drawinglayer/primitive2d/textlayoutdevice.hxx b/include/drawinglayer/primitive2d/textlayoutdevice.hxx
index 10f0fc0b23c1..93587769c449 100644
--- a/include/drawinglayer/primitive2d/textlayoutdevice.hxx
+++ b/include/drawinglayer/primitive2d/textlayoutdevice.hxx
@@ -28,115 +28,99 @@
// predefines
class VirtualDevice;
-namespace vcl { class Font; }
class GDIMetaFile;
-namespace tools { class Rectangle; }
enum class DrawTextFlags;
-namespace drawinglayer::attribute {
- class FontAttribute;
+namespace vcl
+{
+class Font;
+}
+namespace tools
+{
+class Rectangle;
+}
+namespace drawinglayer::attribute
+{
+class FontAttribute;
+}
+namespace com::sun::star::lang
+{
+struct Locale;
}
-
-namespace com::sun::star::lang { struct Locale; }
// access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive
namespace drawinglayer::primitive2d
{
- /** TextLayouterDevice class
+/** TextLayouterDevice class
- This helper class exists to isolate all accesses to VCL
- text formatting/handling functionality for primitive implementations.
- When in the future FontHandling may move to an own library independent
- from VCL, primitives will be prepared.
- */
- class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
- {
- /// internally used VirtualDevice
- SolarMutexGuard maSolarGuard;
- VirtualDevice& mrDevice;
-
- public:
- /// constructor/destructor
- TextLayouterDevice();
- ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE;
-
- /// tooling methods
- void setFont(const vcl::Font& rFont);
- void setFontAttribute(
- const attribute::FontAttribute& rFontAttribute,
- double fFontScaleX,
- double fFontScaleY,
- const css::lang::Locale & rLocale);
-
- double getTextHeight() const;
- double getOverlineHeight() const;
- double getOverlineOffset() const;
- double getUnderlineHeight() const;
- double getUnderlineOffset() const;
- double getStrikeoutOffset() const;
-
- 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;
-
- basegfx::B2DRange getTextBoundRect(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const;
-
- double getFontAscent() const;
- double getFontDescent() const;
-
- void addTextRectActions(
- const tools::Rectangle& rRectangle,
- const OUString& rText,
- DrawTextFlags nStyle,
- GDIMetaFile& rGDIMetaFile) const;
-
- ::std::vector< double > getTextArray(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const;
-
- ::std::vector< double > getCaretPositions(
- const OUString& rText,
- sal_uInt32 nIndex,
- sal_uInt32 nLength) const;
- };
-
- // helper methods for vcl font handling
-
- /** Create a VCL-Font based on the definitions in FontAttribute
+ This helper class exists to isolate all accesses to VCL
+ text formatting/handling functionality for primitive implementations.
+ When in the future FontHandling may move to an own library independent
+ from VCL, primitives will be prepared.
+ */
+class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
+{
+ /// internally used VirtualDevice
+ SolarMutexGuard maSolarGuard;
+ VirtualDevice& mrDevice;
+
+public:
+ /// constructor/destructor
+ TextLayouterDevice();
+ ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE;
+
+ /// tooling methods
+ void setFont(const vcl::Font& rFont);
+ void setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX,
+ double fFontScaleY, const css::lang::Locale& rLocale);
+
+ double getTextHeight() const;
+ double getOverlineHeight() const;
+ double getOverlineOffset() const;
+ double getUnderlineHeight() const;
+ double getUnderlineOffset() const;
+ double getStrikeoutOffset() const;
+
+ 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;
+
+ basegfx::B2DRange getTextBoundRect(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const;
+
+ double getFontAscent() const;
+ double getFontDescent() const;
+
+ void addTextRectActions(const tools::Rectangle& rRectangle, const OUString& rText,
+ DrawTextFlags nStyle, GDIMetaFile& rGDIMetaFile) const;
+
+ ::std::vector<double> getTextArray(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const;
+
+ ::std::vector<double> getCaretPositions(const OUString& rText, sal_uInt32 nIndex,
+ sal_uInt32 nLength) const;
+};
+
+// helper methods for vcl font handling
+
+/** Create a VCL-Font based on the definitions in FontAttribute
and the given FontScaling. The FontScaling defines the FontHeight
(fFontScaleY) and the FontWidth (fFontScaleX). The combination of
both defines FontStretching, where no stretching happens at
fFontScaleY == fFontScaleX
*/
- vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute(
- const attribute::FontAttribute& rFontAttribute,
- double fFontScaleX,
- double fFontScaleY,
- double fFontRotation,
- const css::lang::Locale & rLocale);
-
- /** Generate FontAttribute DataSet derived from the given VCL-Font.
+vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute(
+ const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY,
+ double fFontRotation, const css::lang::Locale& rLocale);
+
+/** Generate FontAttribute DataSet derived from the given VCL-Font.
The FontScaling with fFontScaleY, fFontScaleX relationship (see
above) will be set in return parameter o_rSize to allow further
processing
*/
- attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont(
- basegfx::B2DVector& o_rSize,
- const vcl::Font& rFont,
- bool bRTL,
- bool bBiDiStrong);
+attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont(
+ basegfx::B2DVector& o_rSize, const vcl::Font& rFont, bool bRTL, bool bBiDiStrong);
} // end of namespace drawinglayer::primitive2d
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 6a0e2f667dee..2ccf6ad44357 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -3392,7 +3392,6 @@ drawinglayer/source/primitive2d/textbreakuphelper.cxx
drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
drawinglayer/source/primitive2d/textenumsprimitive2d.cxx
drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
-drawinglayer/source/primitive2d/textlayoutdevice.cxx
drawinglayer/source/primitive2d/textlineprimitive2d.cxx
drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx
drawinglayer/source/primitive2d/transformprimitive2d.cxx
@@ -5281,7 +5280,6 @@ include/drawinglayer/primitive2d/textbreakuphelper.hxx
include/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx
include/drawinglayer/primitive2d/textenumsprimitive2d.hxx
include/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx
-include/drawinglayer/primitive2d/textlayoutdevice.hxx
include/drawinglayer/primitive2d/transformprimitive2d.hxx
include/drawinglayer/primitive2d/transparenceprimitive2d.hxx
include/drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx
More information about the Libreoffice-commits
mailing list