sc/source/ui/view/hdrcont.cxx |   33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

New commits:
commit c65eadf2caca9bd7bf92af7448794077d2098f97
Author:     Heiko Tietze <tietze.he...@gmail.com>
AuthorDate: Wed Aug 27 10:15:41 2025 +0200
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Fri Aug 29 17:10:58 2025 +0200

    Resolves tdf#168092 - Column titles must not overlap
    
    Clipping enabled, and text right-aligned in case of unsufficient space
    
    Change-Id: Ieeff301addba7a828eecea1a0e3a37abd375bcea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190270
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index ee8a90f92d70..8413d94bd452 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -249,12 +249,10 @@ void ScHeaderControl::Paint( vcl::RenderContext& 
/*rRenderContext*/, const tools
 
     bool bLayoutRTL = IsLayoutRTL();
     tools::Long nLayoutSign = bLayoutRTL ? -1 : 1;
-    bool bMirrored = IsMirrored();
 
     OUString            aString;
     sal_uInt16          nBarSize;
     Point               aScrPos;
-    Size                aTextSize;
 
     if (bVertical)
         nBarSize = static_cast<sal_uInt16>(GetSizePixel().Width());
@@ -586,25 +584,20 @@ void ScHeaderControl::Paint( vcl::RenderContext& 
/*rRenderContext*/, const tools
                                         bBoldSet = bMark;
                                     }
                                 }
-
-                                aString = GetEntryText( nEntryNo );
-                                aTextSize.setWidth( GetTextWidth( aString ) );
-                                aTextSize.setHeight( GetTextHeight() );
-
-                                Point aTxtPos(aScrPos);
-                                if (bVertical)
-                                {
-                                    
aTxtPos.AdjustX((nBarSize-aTextSize.Width())/2 );
-                                    
aTxtPos.AdjustY((nSizePix*nLayoutSign-aTextSize.Height())/2 );
-                                    if ( bMirrored )
-                                        aTxtPos.AdjustX(1 );   // dark border 
is left instead of right
-                                }
+                                aString = GetEntryText(nEntryNo);
+                                const bool bRight
+                                    = GetTextWidth(aString) > fabs(aScrPos.X() 
- aEndPos.X());
+                                DrawTextFlags nDrawTextStyle(
+                                    (bRight ? DrawTextFlags::Right : 
DrawTextFlags::Center)
+                                    | DrawTextFlags::VCenter | 
DrawTextFlags::Clip);
+                                tools::Rectangle aRect;
+                                if (!bVertical && bLayoutRTL)
+                                    aRect = tools::Rectangle(aEndPos.X(), 
aScrPos.Y(), aScrPos.X(),
+                                                             aEndPos.Y());
                                 else
-                                {
-                                    
aTxtPos.AdjustX((nSizePix*nLayoutSign-aTextSize.Width()+1)/2 );
-                                    
aTxtPos.AdjustY((nBarSize-aTextSize.Height())/2 );
-                                }
-                                GetOutDev()->DrawText( aTxtPos, aString );
+                                    aRect = tools::Rectangle(aScrPos.X(), 
aScrPos.Y(), aEndPos.X(),
+                                                             aEndPos.Y());
+                                GetOutDev()->DrawText(aRect, aString, 
nDrawTextStyle);
                             }
                             break;
                     }

Reply via email to