Resolves: tdf#127218 allow changes dialog to shrink when button text changes

original the dialog has super wide button contents when the initial size
is calculated, and then the buttons are changed afterwards, but the dialog
remains at its initial size.

Change-Id: Ib29ab9ebdec01a93561a8b304572df60b6ad5ad2
Reviewed-on: https://gerrit.libreoffice.org/79634
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx
index a9ee961..15d2772 100644
--- a/include/svx/ctredlin.hxx
+++ b/include/svx/ctredlin.hxx
@@ -246,6 +246,7 @@ private:
    bool bEnableRejectAll;
    bool bEnableUndo;

    weld::Window* m_pDialog;
    std::unique_ptr<weld::Button> m_xAccept;
    std::unique_ptr<weld::Button> m_xReject;
    std::unique_ptr<weld::Button> m_xAcceptAll;
@@ -256,7 +257,7 @@ private:
    DECL_LINK( PbClickHdl, weld::Button&, void );

public:
    SvxTPView(weld::Container* pParent, weld::Builder* pTopLevel);
    SvxTPView(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel);
    virtual ~SvxTPView() override;

    SvxRedlinTable* GetTableControl() { return m_xViewData.get(); }
@@ -265,7 +266,7 @@ public:
    void            EnableAcceptAll(bool bFlag);
    void            EnableReject(bool bFlag);
    void            EnableRejectAll(bool bFlag);
    static void     EnableClearFormatButton(weld::Button&, bool bFlag);
    void            EnableClearFormatButton(weld::Button&, bool bFlag);
    void            EnableClearFormat(bool bFlag);
    void            EnableClearFormatAll(bool bFlag);
    void            EnableUndo(bool bFlag=true);
@@ -300,7 +301,7 @@ private:
    DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);

public:
    SvxAcceptChgCtr(weld::Container* pParent, weld::Builder* pTopLevel);
    SvxAcceptChgCtr(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel);
    ~SvxAcceptChgCtr();

    void            ShowFilterPage();
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 3b381cd..82333e4a 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -101,7 +101,7 @@ ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Windo
    , m_xContentArea(m_xDialog->weld_content_area())
    , m_xPopup(m_xBuilder->weld_menu("calcmenu"))
{
    m_xAcceptChgCtr.reset(new SvxAcceptChgCtr(m_xContentArea.get(), m_xBuilder.get()));
    m_xAcceptChgCtr.reset(new SvxAcceptChgCtr(m_xContentArea.get(), m_xDialog.get(), m_xBuilder.get()));
    nAcceptCount=0;
    nRejectCount=0;
    aReOpenIdle.SetInvokeHandler(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
index 67e84c7..705eefd 100644
--- a/svx/source/dialog/ctredlin.cxx
+++ b/svx/source/dialog/ctredlin.cxx
@@ -25,8 +25,6 @@
#include <sfx2/module.hxx>
#include <svtools/ctrlbox.hxx>
#include <unotools/textsearch.hxx>
#include <vcl/svlbitm.hxx>
#include <vcl/viewdataentry.hxx>
#include <unotools/charclass.hxx>

#include <editeng/unolingu.hxx>
@@ -282,13 +280,14 @@ void SvxTPage::ActivatePage()
{
}

SvxTPView::SvxTPView(weld::Container* pParent, weld::Builder* pTopLevel)
SvxTPView::SvxTPView(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel)
    : SvxTPage(pParent, "svx/ui/redlineviewpage.ui", "RedlineViewPage")
    , bEnableAccept(true)
    , bEnableAcceptAll(true)
    , bEnableReject(true)
    , bEnableRejectAll(true)
    , bEnableUndo(true)
    , m_pDialog(pDialog)
    , m_xAccept(pTopLevel->weld_button("accept"))
    , m_xReject(pTopLevel->weld_button("reject"))
    , m_xAcceptAll(pTopLevel->weld_button("acceptall"))
@@ -414,6 +413,12 @@ void SvxTPView::EnableClearFormatButton(weld::Button& rButton, bool bFlag)
            rButton.set_label(sText.copy(0, nPos - 1));
        }
    }

    if (m_pDialog)
    {
        // tdf#127218 allow dialog to shrink
        m_pDialog->resize_to_request();
    }
}

void SvxTPView::EnableClearFormat(bool bFlag)
@@ -956,7 +961,7 @@ IMPL_LINK_NOARG(SvxTPFilter, RefHandle, weld::Button&, void)
    aRefLink.Call(this);
}

SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container* pParent, weld::Builder* pTopLevel)
SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container* pParent, weld::Window* pDialog, weld::Builder* pTopLevel)
    : m_xBuilder(Application::CreateBuilder(pParent, "svx/ui/redlinecontrol.ui"))
    , m_xTabCtrl(m_xBuilder->weld_notebook("RedlineControl"))
{
@@ -964,7 +969,7 @@ SvxAcceptChgCtr::SvxAcceptChgCtr(weld::Container* pParent, weld::Builder* pTopLe
    m_xTabCtrl->connect_leave_page(LINK(this, SvxAcceptChgCtr, DeactivatePageHdl));

    m_xTPFilter.reset(new SvxTPFilter(m_xTabCtrl->get_page("filter")));
    m_xTPView.reset(new SvxTPView(m_xTabCtrl->get_page("view"), pTopLevel));
    m_xTPView.reset(new SvxTPView(m_xTabCtrl->get_page("view"), pDialog, pTopLevel));
    m_xTPFilter->SetRedlinTable(m_xTPView->GetTableControl());
    m_xTabCtrl->set_current_page("view");
    m_xTabCtrl->show();
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index 7d203de..6e32ee9 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -151,7 +151,7 @@ SwRedlineAcceptDlg::SwRedlineAcceptDlg(const std::shared_ptr<weld::Window>& rPar
    , m_bOnlyFormatedRedlines(false)
    , m_bRedlnAutoFormat(bAutoFormat)
    , m_bInhibitActivate(false)
    , m_xTabPagesCTRL(new SvxAcceptChgCtr(pContentArea, pBuilder))
    , m_xTabPagesCTRL(new SvxAcceptChgCtr(pContentArea, m_xParentDlg.get(), pBuilder))
    , m_xPopup(pBuilder->weld_menu("writermenu"))
{
    m_xTabPagesCTRL->set_help_id(HID_REDLINE_CTRL);