summaryrefslogtreecommitdiff
path: root/vcl/source/outdev/text.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-04-10 12:15:55 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-04-19 05:31:51 +0200
commit2642643ec07cd7f3d28fe558769297578c36de19 (patch)
treef86a597e9d05e9d3e91f0f9bd4a905d6fbcb5a5f /vcl/source/outdev/text.cxx
parent58e79c4394783033f61e1309214d9060e2f0adf2 (diff)
tdf#160622: Let SalLayout::GetBoundRect return basegfx::B2DRectangle
This avoids premature rounding in TextLayouterDevice::getTextBoundRect. The box in D2DWriteTextOutRenderer::performRender needs to be expanded to allow room for the line width (which now will be guaranteed on all sides; previously, the rounding could happen to give no room on some side, even prior to commit 8962141a12c966b2d891829925e6203bf8d51852). Fixes some lines partially cut off in smaller text (or zoomed out). Change-Id: I07335136021f894cf045363b4d736bfab06c64d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166236 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source/outdev/text.cxx')
-rw-r--r--vcl/source/outdev/text.cxx38
1 files changed, 30 insertions, 8 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 1eb9bd82425f..961c095e01f9 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -21,6 +21,7 @@
#include <sal/log.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <tools/lineend.hxx>
#include <tools/debug.hxx>
#include <comphelper/configuration.hxx>
@@ -214,7 +215,11 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
tools::Rectangle aBoundRect;
rSalLayout.DrawBase() = basegfx::B2DPoint( 0, 0 );
rSalLayout.DrawOffset() = Point( 0, 0 );
- if (!rSalLayout.GetBoundRect(aBoundRect))
+ if (basegfx::B2DRectangle r; rSalLayout.GetBoundRect(r))
+ {
+ aBoundRect = SalLayout::BoundRect2Rectangle(r);
+ }
+ else
{
// guess vertical text extents if GetBoundRect failed
double nRight = rSalLayout.GetTextWidth();
@@ -1903,8 +1908,21 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
std::span<const sal_Bool> pKashidaAry,
const SalLayoutGlyphs* pGlyphs ) const
{
+ basegfx::B2DRectangle aRect;
+ bool bRet = GetTextBoundRect(aRect, rStr, nBase, nIndex, nLen, nLayoutWidth, pDXAry,
+ pKashidaAry, pGlyphs);
+ rRect = SalLayout::BoundRect2Rectangle(aRect);
+ return bRet;
+}
+
+bool OutputDevice::GetTextBoundRect(basegfx::B2DRectangle& rRect, const OUString& rStr,
+ sal_Int32 nBase, sal_Int32 nIndex, sal_Int32 nLen,
+ sal_uLong nLayoutWidth, KernArraySpan pDXAry,
+ std::span<const sal_Bool> pKashidaAry,
+ const SalLayoutGlyphs* pGlyphs) const
+{
bool bRet = false;
- rRect.SetEmpty();
+ rRect.reset();
std::unique_ptr<SalLayout> pSalLayout;
const Point aPoint;
@@ -1928,18 +1946,22 @@ bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
nullptr, pGlyphs);
if( pSalLayout )
{
- tools::Rectangle aPixelRect;
+ basegfx::B2DRectangle aPixelRect;
bRet = pSalLayout->GetBoundRect(aPixelRect);
if( bRet )
{
- Point aRotatedOfs( mnTextOffX, mnTextOffY );
basegfx::B2DPoint aPos = pSalLayout->GetDrawPosition(basegfx::B2DPoint(nXOffset, 0));
- aRotatedOfs -= Point(aPos.getX(), aPos.getY());
- aPixelRect += aRotatedOfs;
+ auto m = basegfx::utils::createTranslateB2DHomMatrix(mnTextOffX - aPos.getX(),
+ mnTextOffY - aPos.getY());
+ aPixelRect.transform(m);
rRect = PixelToLogic( aPixelRect );
- if( mbMap )
- rRect += Point( maMapRes.mnMapOfsX, maMapRes.mnMapOfsY );
+ if (mbMap)
+ {
+ m = basegfx::utils::createTranslateB2DHomMatrix(maMapRes.mnMapOfsX,
+ maMapRes.mnMapOfsY);
+ rRect.transform(m);
+ }
}
}