diff options
-rw-r--r-- | include/svtools/valueset.hxx | 2 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx index a80c16751cfa..7753546e1255 100644 --- a/include/svtools/valueset.hxx +++ b/include/svtools/valueset.hxx @@ -254,7 +254,7 @@ private: SVT_DLLPRIVATE void QueueReformat(); SVT_DLLPRIVATE void SetFirstLine(sal_uInt16 nNewFirstLine); // set mnFirstLine and update scrollbar to match SVT_DLLPRIVATE void RecalcScrollBar(); - SVT_DLLPRIVATE void TurnOffScrollBar(); + SVT_DLLPRIVATE bool TurnOffScrollBar(); SVT_DLLPRIVATE void TurnOnScrollBar(); DECL_DLLPRIVATE_LINK(ImplScrollHdl, weld::ScrolledWindow&, void); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index e81aeb2745bd..c9a94de237a1 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -549,14 +549,15 @@ void ValueSet::RemoveItem( sal_uInt16 nItemId ) QueueReformat(); } -void ValueSet::TurnOffScrollBar() +bool ValueSet::TurnOffScrollBar() { if (mxScrolledWindow->get_vpolicy() == VclPolicyType::NEVER) - return; + return false; mxScrolledWindow->set_vpolicy(VclPolicyType::NEVER); weld::DrawingArea* pDrawingArea = GetDrawingArea(); Size aPrefSize(pDrawingArea->get_preferred_size()); pDrawingArea->set_size_request(aPrefSize.Width() + GetScrollWidth(), aPrefSize.Height()); + return true; } void ValueSet::TurnOnScrollBar() @@ -571,11 +572,16 @@ void ValueSet::TurnOnScrollBar() void ValueSet::RecalcScrollBar() { - // reset scrolled window state to initial value - // so it will get configured to the right adjustment - WinBits nStyle = GetStyle(); - if (mxScrolledWindow && (nStyle & WB_VSCROLL)) - TurnOffScrollBar(); + if (!mxScrolledWindow) + return; + const bool bScrollAllowed = GetStyle() & WB_VSCROLL; + if (!bScrollAllowed) + return; + // reset scrolled window state to initial value so it will get configured + // to the right adjustment on the next format which we toggle on to happen + // if the scrolledwindow wasn't in its initial state already + if (TurnOffScrollBar()) + mbFormat = true; } void ValueSet::Clear() |