Related: tdf#122791 take *final* dialog preferred size
as the size to consider when trying to fit as many column widgets into
it. Not the size it is when the column page is inserted, which
is just that of the column page and preceeding pages
Change-Id: Id78085c92e9b5718e7282bf8ebd2bde1cdc50689
Reviewed-on: https://gerrit.libreoffice.org/78855
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index adcd25a..f56e3c2 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -702,6 +702,7 @@ DeactivateRC SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet )
SwTableColumnPage::SwTableColumnPage(TabPageParent pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "modules/swriter/ui/tablecolumnpage.ui", "TableColumnPage", &rSet)
, pTableData(nullptr)
, m_pSizeHdlEvent(nullptr)
, nTableWidth(0)
, nMinWidth(MINLAY)
, nMetFields(MET_FIELDS)
@@ -731,9 +732,19 @@ SwTableColumnPage::SwTableColumnPage(TabPageParent pParent, const SfxItemSet& rS
{
SetExchangeSupport();
// fire off this handler to happen on next event loop when all the rest of
// the pages are instantiated and the dialog preferred size is that of the
// all the pages that currently exist and the rest to come after this one
m_pSizeHdlEvent = Application::PostUserEvent(LINK(this, SwTableColumnPage, SizeHdl));
}
IMPL_LINK_NOARG(SwTableColumnPage, SizeHdl, void*, void)
{
m_pSizeHdlEvent = nullptr;
//tdf#120420 keeping showing column width fields unless
//the dialog begins to grow, then stop adding them
weld::Window* pTopLevel = pParent.GetFrameWeld();
weld::Window* pTopLevel = GetDialogFrameWeld();
Size aOrigSize = pTopLevel->get_preferred_size();
for (sal_uInt16 i = 0; i < MET_FIELDS; ++i)
{
@@ -750,12 +761,23 @@ SwTableColumnPage::SwTableColumnPage(TabPageParent pParent, const SfxItemSet& rS
}
const SfxPoolItem* pItem;
Init(SfxItemState::SET == rSet.GetItemState( SID_HTML_MODE, false,&pItem )
Init(SfxItemState::SET == GetItemSet().GetItemState(SID_HTML_MODE, false, &pItem)
&& static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON);
}
SwTableColumnPage::~SwTableColumnPage()
{
disposeOnce();
}
void SwTableColumnPage::dispose()
{
if (m_pSizeHdlEvent)
{
Application::RemoveUserEvent(m_pSizeHdlEvent);
m_pSizeHdlEvent = nullptr;
}
SfxTabPage::dispose();
}
VclPtr<SfxTabPage> SwTableColumnPage::Create(TabPageParent pParent, const SfxItemSet* rAttrSet)
diff --git a/sw/source/uibase/table/tablepg.hxx b/sw/source/uibase/table/tablepg.hxx
index e5b47fb..f9d7c8d 100644
--- a/sw/source/uibase/table/tablepg.hxx
+++ b/sw/source/uibase/table/tablepg.hxx
@@ -93,6 +93,7 @@ public:
class SwTableColumnPage : public SfxTabPage
{
SwTableRep* pTableData;
ImplSVEvent* m_pSizeHdlEvent;
SwTwips nTableWidth;
SwTwips nMinWidth;
sal_uInt16 nMetFields;
@@ -121,12 +122,14 @@ class SwTableColumnPage : public SfxTabPage
void UpdateCols( sal_uInt16 nCurrentPos );
SwTwips GetVisibleWidth(sal_uInt16 nPos);
void SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth);
DECL_LINK(SizeHdl, void*, void);
using TabPage::ActivatePage;
using TabPage::DeactivatePage;
public:
SwTableColumnPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual void dispose() override;
virtual ~SwTableColumnPage() override;
static VclPtr<SfxTabPage> Create( TabPageParent pParent, const SfxItemSet* rAttrSet);