From 0e206454b13efa8248dd3338a6eb0b0fe70bfffb Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Tue, 6 Oct 2026 12:15:49 +0200 Subject: [PATCH] svtools: Drop now unused WB_NAMEFIELD logic from ValueSet The last case where that style flag was set was ported away from ValueSet to use weld::IconView instead in earlier commit Change-Id: I1c23a305322105608d0152bcd0b0fa195be14eff Author: Michael Weghorn Date: Tue Oct 6 11:48:21 2026 +0200 cui: Port Callout tab page from ValueSet to weld::IconView Therefore, drop the logic in ValueSet handling that flag, to simplify the code. This also means that the `pItem` param for ValueSet::ImplDrawSelect is now unused, so drop that one, too. Change-Id: I0150e699602a625874e5a09b8df38110f52c0c03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211898 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- include/svtools/valueset.hxx | 12 ++-- svtools/source/control/valueset.cxx | 83 ++---------------------- svx/source/tbxctrls/SvxColorValueSet.cxx | 2 +- 3 files changed, 11 insertions(+), 86 deletions(-) diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index c8242963a490..a4480bb99cfb 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -74,8 +74,6 @@ WB_DOUBLEBORDER Items will be bordered twice. Additionally WB_ITEMBORDER effect. It is needed if there are items with a white background, since otherwise the 3D effect wouldn't be recognizable. -WB_NAMEFIELD There is a namefield, where the name of an item will be - shown. WB_VSCROLL A scrollbar will be always shown. The visible number of lines have to be specified with SetLineCount() if this flag is set. @@ -164,7 +162,6 @@ to be set (before Show) with SetStyle(). #define WB_ITEMBORDER (WinBits(0x00010000)) #define WB_DOUBLEBORDER (WinBits(0x00020000)) -#define WB_NAMEFIELD (WinBits(0x00040000)) #define WB_FLATVALUESET (WinBits(0x02000000)) #define WB_NO_DIRECTSELECT (WinBits(0x04000000)) #define WB_MENUSTYLEVALUESET (WinBits(0x08000000)) @@ -218,14 +215,13 @@ private: SVT_DLLPRIVATE void ImplDeleteItems(); SVT_DLLPRIVATE void ImplFormatItem(vcl::RenderContext const& rRenderContext, ValueSetItem& rItem, tools::Rectangle aRect); - SVT_DLLPRIVATE void ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rStr); // nItemId is the item to draw selected, but if nothing is selected something else may be drawn as selected instead, the item to draw // selected is returned SVT_DLLPRIVATE ValueSetItem* ImplGetDrawSelectItem(sal_uInt16 nItemId, const bool bFocus, tools::Rectangle& rRect); - SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext, - const tools::Rectangle& rRect, const ValueSetItem* pItem, - const bool bFocus, const bool bDrawSel, - const bool bSelected, const bool bHover); + SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext, + const tools::Rectangle& rRect, const bool bFocus, + const bool bDrawSel, const bool bSelected, + const bool bHover); SVT_DLLPRIVATE void ImplDrawSelect(vcl::RenderContext& rRenderContext); SVT_DLLPRIVATE void ImplHighlightItem(sal_uInt16 nItemId); SVT_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index abe8375deb10..649fcb626c4f 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -635,29 +635,6 @@ void ValueSet::ImplDraw(vcl::RenderContext& rRenderContext) rRenderContext.DrawOutDev(aDefPos, aSize, aDefPos, aSize, *maVirDev); - // draw parting line to the Namefield - if (GetStyle() & WB_NAMEFIELD) - { - if (!(GetStyle() & WB_FLATVALUESET)) - { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - Size aWinSize(GetOutputSizePixel()); - Point aPos1(NAME_LINE_OFF_X, mnTextOffset + NAME_LINE_OFF_Y); - Point aPos2(aWinSize.Width() - (NAME_LINE_OFF_X * 2), mnTextOffset + NAME_LINE_OFF_Y); - if (!(rStyleSettings.GetOptions() & StyleSettingsOptions::Mono)) - { - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.DrawLine(aPos1, aPos2); - aPos1.AdjustY( 1 ); - aPos2.AdjustY( 1 ); - rRenderContext.SetLineColor(rStyleSettings.GetLightColor()); - } - else - rRenderContext.SetLineColor(rStyleSettings.GetWindowTextColor()); - rRenderContext.DrawLine(aPos1, aPos2); - } - } - ImplDrawSelect(rRenderContext); } @@ -803,7 +780,6 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) Size aWinSize(GetOutputSizePixel()); size_t nItemCount = mItemList.size(); WinBits nStyle = GetStyle(); - tools::Long nTxtHeight = rRenderContext.GetTextHeight(); if (mxScrolledWindow && !(nStyle & WB_VSCROLL) && mxScrolledWindow->get_vpolicy() != VclPolicyType::NEVER) TurnOffScrollBar(); @@ -814,20 +790,7 @@ void ValueSet::Format(vcl::RenderContext const & rRenderContext) aWinSize.AdjustHeight(-mnMargin * 2); } - // consider size, if NameField does exist - if (nStyle & WB_NAMEFIELD) - { - mnTextOffset = aWinSize.Height() - nTxtHeight - NAME_OFFSET; - aWinSize.AdjustHeight( -(nTxtHeight + NAME_OFFSET) ); - - if (!(nStyle & WB_FLATVALUESET)) - { - mnTextOffset -= NAME_LINE_HEIGHT + NAME_LINE_OFF_Y; - aWinSize.AdjustHeight( -(NAME_LINE_HEIGHT + NAME_LINE_OFF_Y) ); - } - } - else - mnTextOffset = 0; + mnTextOffset = 0; mnTextOffset += mnMargin; @@ -1079,7 +1042,7 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext) if (pSelectedItem) { const bool bHover = pSelectedItem == pHighlightItem; - ImplDrawSelect(rRenderContext, aSelectedRect, pSelectedItem, bFocus, !mbNoSelection, true, bHover); + ImplDrawSelect(rRenderContext, aSelectedRect, bFocus, !mbNoSelection, true, bHover); } if (pHighlightItem && (pSelectedItem != pHighlightItem || mbNoSelection)) { @@ -1097,7 +1060,7 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext) else bDrawFocus = pSelectedItem == pHighlightItem && mbNoSelection; - ImplDrawSelect(rRenderContext, aHoverRect, pHighlightItem, bDrawFocus, mbHighlight, false, true); + ImplDrawSelect(rRenderContext, aHoverRect, bDrawFocus, mbHighlight, false, true); } } @@ -1117,10 +1080,9 @@ ValueSetItem* ValueSet::ImplGetDrawSelectItem(sal_uInt16 nItemId, const bool bFo return pItem; } -void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, - const tools::Rectangle& rRect, const ValueSetItem* pItem, - const bool bFocus, const bool bDrawSel, - const bool bSelected, const bool bHover) +void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, + const bool bFocus, const bool bDrawSel, const bool bSelected, + const bool bHover) { tools::Rectangle aRect(rRect); @@ -1259,8 +1221,6 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, if (bFocus) InvertFocusRect(rRenderContext, aFocusRect); } - - ImplDrawItemText(rRenderContext, pItem->maText); } void ValueSet::ImplFormatItem(vcl::RenderContext const& rRenderContext, ValueSetItem& rItem, @@ -1378,29 +1338,6 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const& rRenderContext, ValueSet } } -void ValueSet::ImplDrawItemText(vcl::RenderContext& rRenderContext, const OUString& rText) -{ - if (!(GetStyle() & WB_NAMEFIELD)) - return; - - Size aWinSize(GetOutputSizePixel()); - tools::Long nTxtWidth = rRenderContext.GetTextWidth(rText); - tools::Long nTxtOffset = mnTextOffset; - - auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::TEXTCOLOR); - - // delete rectangle and show text - const bool bFlat(GetStyle() & WB_FLATVALUESET); - if (!bFlat) - nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y; - - rRenderContext.SetTextColor(Application::GetSettings().GetStyleSettings().GetButtonTextColor()); - // tdf#153787 highlighted entry text is drawn in the same Paint as the selected text, so can - // overwrite already rendered text - rRenderContext.Erase(tools::Rectangle(Point(0, nTxtOffset), Point(aWinSize.Width(), aWinSize.Height()))); - rRenderContext.DrawText(Point((aWinSize.Width() - nTxtWidth) / 2, nTxtOffset + (NAME_OFFSET / 2)), rText); -} - void ValueSet::StyleUpdated() { mbFormat = true; @@ -1505,7 +1442,6 @@ Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCol Size aSize( rItemSize.Width() * nCalcCols, rItemSize.Height() * nCalcLines ); WinBits nStyle = GetStyle(); - tools::Long nTxtHeight = GetTextHeight(); if ( nStyle & WB_ITEMBORDER ) { @@ -1525,13 +1461,6 @@ Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCol aSize.AdjustHeight(mnSpacing * (nCalcLines - 1) ); } - if ( nStyle & WB_NAMEFIELD ) - { - aSize.AdjustHeight(nTxtHeight + NAME_OFFSET ); - if ( !(nStyle & WB_FLATVALUESET) ) - aSize.AdjustHeight(NAME_LINE_HEIGHT + NAME_LINE_OFF_Y ); - } - if ( mnMargin ) { aSize.AdjustWidth(mnMargin * 2); diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx index c15d73262789..848041947877 100644 --- a/svx/source/tbxctrls/SvxColorValueSet.cxx +++ b/svx/source/tbxctrls/SvxColorValueSet.cxx @@ -62,7 +62,7 @@ void SvxColorValueSet::layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntry const WinBits aWinBits(GetStyle() & ~WB_VSCROLL); // get size with all fields disabled - const WinBits aWinBitsNoScrollNoFields(GetStyle() & ~(WB_VSCROLL | WB_NAMEFIELD)); + const WinBits aWinBitsNoScrollNoFields(GetStyle() & ~WB_VSCROLL); SetStyle(aWinBitsNoScrollNoFields); const Size aSizeNoScrollNoFields(CalcWindowSizePixel(aItemSize, SvxColorValueSet::getColumnCount()));