include/svx/sidebar/ValueSetWithTextControl.hxx      |    1 +
 svx/source/sidebar/tools/ValueSetWithTextControl.cxx |    9 +++++++++
 sw/source/uibase/sidebar/PageSizeControl.cxx         |    1 +
 3 files changed, 11 insertions(+)

New commits:
commit 1876feb8a8805b2f80537e2828c152ccbdf67fe2
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Mon Jul 10 15:27:29 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Tue Jul 18 01:22:41 2023 +0200

    tdf#136905 NBB: let ValueSetWithTextControl set optimal height
    
    There was no way to specify a "good font size" to use
    for .uno:AttributePageSize in the notebookbar.
    The font "resized to match to size of the box"
    which is hard-coded to aSize(250, 300).
    
    (Even if ValueSet::SetOptimalSize worked, it would set an
    inadequate height.)
    
    So it seems like the best thing to do is simply add a function
    that allows the box height to be modified.
    
    Using the fontsize from GetDefaultFont is not correct.
    Use the OS-defined label font size instead, which seems to be
    the most common choice - GetPushButtonFont would has also worked.
    
    I verified that the label font size is controled by
    the OS' font preference.
    
    The ability to define the box's optimal height
    is still (somewhat) necessary. It isn't good enough
    to just "use the system font size".
    I tested with an OS font size of 48 (instead of 11),
    and in that case the box height was too small
    (but with the font only using 4/9's of a 12pt space,
    even a 24pt font looked OK without adjusting optimal height).
    
    Change-Id: I0a0774dea9c2a6c21a8e84439318a94f39783413
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154286
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/include/svx/sidebar/ValueSetWithTextControl.hxx 
b/include/svx/sidebar/ValueSetWithTextControl.hxx
index ac397f9fdab6..407e9606757f 100644
--- a/include/svx/sidebar/ValueSetWithTextControl.hxx
+++ b/include/svx/sidebar/ValueSetWithTextControl.hxx
@@ -40,6 +40,7 @@ public:
 
     SVX_DLLPRIVATE virtual void SetDrawingArea(weld::DrawingArea* 
pDrawingArea) override;
 
+    void SetOptimalDrawingAreaHeight();
     void AddItem(const OUString& rItemText, const OUString& rItemText2);
 
     SVX_DLLPRIVATE virtual void UserDraw(const UserDrawEvent& rUDEvt) override;
diff --git a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx 
b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
index 1b6ca2d42979..77b260272264 100644
--- a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
+++ b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
@@ -43,6 +43,15 @@ void 
ValueSetWithTextControl::SetDrawingArea(weld::DrawingArea* pDrawingArea)
     SetColCount();
 }
 
+void ValueSetWithTextControl::SetOptimalDrawingAreaHeight()
+{
+    const vcl::Font 
aFont(Application::GetSettings().GetStyleSettings().GetLabelFont());
+    const sal_Int32 nRowHeight = aFont.GetFontSize().Height() * 9 / 4; // see 
UserDraw()
+    const Size aSize(GetOutputSizePixel().Width(), nRowHeight * 
maItems.size());
+    GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
+    SetOutputSizePixel(aSize);
+}
+
 void ValueSetWithTextControl::AddItem(
     const OUString& rItemText,
     const OUString& rItemText2 )
diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx 
b/sw/source/uibase/sidebar/PageSizeControl.cxx
index 211ebece9e5e..a85848ad753d 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.cxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.cxx
@@ -165,6 +165,7 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, 
weld::Widget* pParent)
     }
     mxSizeValueSet->SetNoSelection();
     mxSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl, ImplSizeHdl ) );
+    mxSizeValueSet->SetOptimalDrawingAreaHeight();
     mxSizeValueSet->Show();
     mxSizeValueSet->Resize();
 

Reply via email to