tdf#134054 toolbox: respect drop-down arrow rect

When centering the text and icon on the button, the code didn't
take the drop-down arrow rect width into account, resulting in an
overlapped arrow. This is especially visible, if the drop-down
is shown and the button is wrongly highlighted.

There is supposed to be some vertical mode, which I couldn't find
in the GUI, so this just adapts the width in horizontal mode.

Change-Id: I194780dc32db610041ad0ee45a425e1026c7c4e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97358
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 8ddb536..543e1b5 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2642,13 +2642,11 @@
    long    nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE;
    long    nBtnHeight = aBtnSize.Height()-SMALLBUTTON_VSIZE;
    Size    aImageSize;
    Size    aTxtSize;

    if ( bText )
    {
        aTxtSize.setWidth( GetCtrlTextWidth( pItem->maText ) );
        aTxtSize.setHeight( GetTextHeight() );
    }
    const bool bDropDown = (pItem->mnBits & ToolBoxItemBits::DROPDOWN) == ToolBoxItemBits::DROPDOWN;
    tools::Rectangle aDropDownRect;
    if (bDropDown)
        aDropDownRect = pItem->GetDropDownRect(mbHorz);

    if ( bImage )
    {
@@ -2678,7 +2676,7 @@
        }
        else
        {
            nImageOffX += (nBtnWidth-aImageSize.Width())/2;
            nImageOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aImageSize.Width())/2;
            if ( meTextPosition == ToolBoxTextPosition::Right )
                nImageOffY += (nBtnHeight-aImageSize.Height())/2;
        }
@@ -2703,6 +2701,7 @@
    bool bRotate = false;
    if ( bText )
    {
        const Size aTxtSize(GetCtrlTextWidth(pItem->maText), GetTextHeight());
        long nTextOffX = nOffX;
        long nTextOffY = nOffY;

@@ -2740,7 +2739,7 @@
            else
            {
                // center horizontally
                nTextOffX += (nBtnWidth-aTxtSize.Width() - TB_IMAGETEXTOFFSET)/2;
                nTextOffX += (nBtnWidth-(bDropDown ? aDropDownRect.getWidth() : 0)+SMALLBUTTON_OFF_NORMAL_X-aTxtSize.Width() - TB_IMAGETEXTOFFSET)/2;
                // set vertical position
                nTextOffY += nBtnHeight - aTxtSize.Height();
            }
@@ -2766,9 +2765,8 @@
    }

    // paint optional drop down arrow
    if ( pItem->mnBits & ToolBoxItemBits::DROPDOWN )
    if (bDropDown)
    {
        tools::Rectangle aDropDownRect( pItem->GetDropDownRect( mbHorz ) );
        bool bSetColor = true;
        if ( !pItem->mbEnabled || !IsEnabled() )
        {