summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-03-14 16:49:04 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-03-15 09:59:33 +0100
commitaeec817fe1205eba88089569ef26bff819d1fdac (patch)
treec5685075bd803e1b2ee7fb2ea2be4567d0618262 /sw/source
parenta98bb35d4e11471cee6b3dbf66b2c3d25df39bfa (diff)
weld SwInsertSectionTabDialog
Change-Id: Ic2782ed51cfb7dea25a455843eb749abd70e53a4 Reviewed-on: https://gerrit.libreoffice.org/69283 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx20
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx13
-rw-r--r--sw/source/ui/dialog/uiregionsw.cxx48
-rw-r--r--sw/source/uibase/dialog/regionsw.cxx8
-rw-r--r--sw/source/uibase/inc/regionsw.hxx12
5 files changed, 56 insertions, 45 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 3292b44eb7ec..070eea579f8b 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -244,7 +244,16 @@ short AbstractMailMergeFieldConnectionsDlg_Impl::Execute()
IMPL_ABSTDLG_BASE(AbstractMultiTOXTabDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractEditRegionDlg_Impl);
-IMPL_ABSTDLG_BASE(AbstractInsertSectionTabDialog_Impl);
+
+short AbstractInsertSectionTabDialog_Impl::Execute()
+{
+ return m_xDlg->run();
+}
+
+bool AbstractInsertSectionTabDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+ return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
short AbstractIndexMarkFloatDlg_Impl::Execute()
{
@@ -667,7 +676,7 @@ void AbstractEditRegionDlg_Impl::SelectSection(const OUString& rSectionName)
void
AbstractInsertSectionTabDialog_Impl::SetSectionData(SwSectionData const& rSect)
{
- pDlg->SetSectionData(rSect);
+ m_xDlg->SetSectionData(rSect);
}
void AbstractIndexMarkFloatDlg_Impl::ReInitDlg(SwWrtShell& rWrtShell)
@@ -1079,11 +1088,10 @@ VclPtr<AbstractEditRegionDlg> SwAbstractDialogFactory_Impl::CreateEditRegionDlg(
return VclPtr<AbstractEditRegionDlg_Impl>::Create( pDlg );
}
-VclPtr<AbstractInsertSectionTabDialog> SwAbstractDialogFactory_Impl::CreateInsertSectionTabDialog(
- vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
+VclPtr<AbstractInsertSectionTabDialog> SwAbstractDialogFactory_Impl::CreateInsertSectionTabDialog(weld::Window* pParent,
+ const SfxItemSet& rSet, SwWrtShell& rSh)
{
- VclPtr<SwInsertSectionTabDialog> pDlg = VclPtr<SwInsertSectionTabDialog>::Create(pParent, rSet, rSh);
- return VclPtr<AbstractInsertSectionTabDialog_Impl>::Create(pDlg);
+ return VclPtr<AbstractInsertSectionTabDialog_Impl>::Create(std::make_unique<SwInsertSectionTabDialog>(pParent, rSet, rSh));
}
VclPtr<AbstractMarkFloatDlg> SwAbstractDialogFactory_Impl::CreateIndexMarkFloatDlg(
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 8fb02a4c4ac6..f1ce1c6ce940 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -530,8 +530,15 @@ class AbstractEditRegionDlg_Impl : public AbstractEditRegionDlg
class SwInsertSectionTabDialog;
class AbstractInsertSectionTabDialog_Impl : public AbstractInsertSectionTabDialog
{
- DECL_ABSTDLG_BASE(AbstractInsertSectionTabDialog_Impl,SwInsertSectionTabDialog)
- virtual void SetSectionData(SwSectionData const& rSect) override;
+ std::shared_ptr<SwInsertSectionTabDialog> m_xDlg;
+public:
+ explicit AbstractInsertSectionTabDialog_Impl(std::unique_ptr<SwInsertSectionTabDialog> p)
+ : m_xDlg(std::move(p))
+ {
+ }
+ virtual short Execute() override;
+ virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
+ virtual void SetSectionData(SwSectionData const& rSect) override;
};
class SwIndexMarkFloatDlg;
@@ -693,7 +700,7 @@ public:
bool bGlobal) override;
virtual VclPtr<AbstractEditRegionDlg> CreateEditRegionDlg(vcl::Window* pParent, SwWrtShell& rWrtSh) override;
virtual VclPtr<AbstractInsertSectionTabDialog> CreateInsertSectionTabDialog(
- vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) override;
+ weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh) override;
virtual VclPtr<AbstractMarkFloatDlg> CreateIndexMarkFloatDlg(
SfxBindings* pBindings,
SfxChildWindow* pChild,
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index bbe3d39617d1..1d3eca06ec2d 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -1487,17 +1487,17 @@ static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
}
SwInsertSectionTabDialog::SwInsertSectionTabDialog(
- vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
- : SfxTabDialog(pParent, "InsertSectionDialog",
- "modules/swriter/ui/insertsectiondialog.ui", &rSet)
+ weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
+ : SfxTabDialogController(pParent, "modules/swriter/ui/insertsectiondialog.ui",
+ "InsertSectionDialog",&rSet)
, rWrtSh(rSh)
{
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
- m_nSectionPageId = AddTabPage("section", SwInsertSectionTabPage::Create);
- m_nColumnPageId = AddTabPage("columns", SwColumnPage::Create);
- m_nBackPageId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BKG ));
- m_nNotePageId = AddTabPage("notes", SwSectionFootnoteEndTabPage::Create);
- m_nIndentPage = AddTabPage("indents", SwSectionIndentTabPage::Create);
+ AddTabPage("section", SwInsertSectionTabPage::Create, nullptr);
+ AddTabPage("columns", SwColumnPage::Create, nullptr);
+ AddTabPage("background", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_BKG), nullptr);
+ AddTabPage("notes", SwSectionFootnoteEndTabPage::Create, nullptr);
+ AddTabPage("indents", SwSectionIndentTabPage::Create, nullptr);
SvxHtmlOptions& rHtmlOpt = SvxHtmlOptions::Get();
long nHtmlMode = rHtmlOpt.GetExportMode();
@@ -1505,36 +1505,36 @@ SwInsertSectionTabDialog::SwInsertSectionTabDialog(
bool bWeb = dynamic_cast<SwWebDocShell*>( rSh.GetView().GetDocShell() ) != nullptr ;
if(bWeb)
{
- RemoveTabPage(m_nNotePageId);
- RemoveTabPage(m_nIndentPage);
+ RemoveTabPage("notes");
+ RemoveTabPage("indents");
if( HTML_CFG_NS40 != nHtmlMode && HTML_CFG_WRITER != nHtmlMode)
- RemoveTabPage(m_nColumnPageId);
+ RemoveTabPage("columns");
}
- SetCurPageId(m_nSectionPageId);
+ SetCurPageId("section");
}
SwInsertSectionTabDialog::~SwInsertSectionTabDialog()
{
}
-void SwInsertSectionTabDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
+void SwInsertSectionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage)
{
- if (nId == m_nSectionPageId)
+ if (rId == "section")
static_cast<SwInsertSectionTabPage&>(rPage).SetWrtShell(rWrtSh);
- else if (nId == m_nBackPageId)
+ else if (rId == "background")
{
- SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
- aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
- rPage.PageCreated(aSet);
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_SELECTOR)));
+ rPage.PageCreated(aSet);
}
- else if (nId == m_nColumnPageId)
+ else if (rId == "columns")
{
const SwFormatFrameSize& rSize = GetInputSetImpl()->Get(RES_FRM_SIZE);
static_cast<SwColumnPage&>(rPage).SetPageWidth(rSize.GetWidth());
static_cast<SwColumnPage&>(rPage).ShowBalance(true);
static_cast<SwColumnPage&>(rPage).SetInSection(true);
}
- else if (nId == m_nIndentPage)
+ else if (rId == "indents")
static_cast<SwSectionIndentTabPage&>(rPage).SetWrtShell(rWrtSh);
}
@@ -1543,9 +1543,9 @@ void SwInsertSectionTabDialog::SetSectionData(SwSectionData const& rSect)
m_pSectionData.reset( new SwSectionData(rSect) );
}
-short SwInsertSectionTabDialog::Ok()
+short SwInsertSectionTabDialog::Ok()
{
- short nRet = SfxTabDialog::Ok();
+ short nRet = SfxTabDialogController::Ok();
OSL_ENSURE(m_pSectionData, "SwInsertSectionTabDialog: no SectionData?");
const SfxItemSet* pOutputItemSet = GetOutputItemSet();
rWrtSh.InsertSection(*m_pSectionData, pOutputItemSet);
@@ -1643,7 +1643,7 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
lcl_FillSubRegionList(*m_pWrtSh, *m_xSubRegionED, m_xCurName.get());
SwSectionData *const pSectionData =
- static_cast<SwInsertSectionTabDialog*>(GetTabDialog())
+ static_cast<SwInsertSectionTabDialog*>(GetDialogController())
->GetSectionData();
if (pSectionData) // something set?
{
@@ -1717,7 +1717,7 @@ bool SwInsertSectionTabPage::FillItemSet( SfxItemSet* )
FILE_LINK_SECTION);
}
}
- static_cast<SwInsertSectionTabDialog*>(GetTabDialog())->SetSectionData(aSection);
+ static_cast<SwInsertSectionTabDialog*>(GetDialogController())->SetSectionData(aSection);
return true;
}
diff --git a/sw/source/uibase/dialog/regionsw.cxx b/sw/source/uibase/dialog/regionsw.cxx
index 28f0ede5b7f5..30b97749e641 100644
--- a/sw/source/uibase/dialog/regionsw.cxx
+++ b/sw/source/uibase/dialog/regionsw.cxx
@@ -80,8 +80,10 @@ void SwBaseShell::InsertRegionDialog(SfxRequest& rReq)
aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
VclPtr<AbstractInsertSectionTabDialog> aTabDlg(pFact->CreateInsertSectionTabDialog(
- &GetView().GetViewFrame()->GetWindow(), aSet , rSh));
- aTabDlg->StartExecuteAsync(nullptr);
+ GetView().GetViewFrame()->GetWindow().GetFrameWeld(), aSet , rSh));
+ aTabDlg->StartExecuteAsync([aTabDlg](sal_Int32 /*nResult*/){
+ aTabDlg->disposeOnce();
+ });
rReq.Ignore();
}
else
@@ -187,7 +189,7 @@ void SwWrtShell::StartInsertRegionDialog(const SwSectionData& rSectionData)
aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
VclPtr<AbstractInsertSectionTabDialog> aTabDlg(pFact->CreateInsertSectionTabDialog(
- &GetView().GetViewFrame()->GetWindow(),aSet , *this));
+ GetView().GetViewFrame()->GetWindow().GetFrameWeld(), aSet, *this));
aTabDlg->SetSectionData(rSectionData);
aTabDlg->StartExecuteAsync(nullptr);
}
diff --git a/sw/source/uibase/inc/regionsw.hxx b/sw/source/uibase/inc/regionsw.hxx
index 822f46e8b820..fe44a70da0ca 100644
--- a/sw/source/uibase/inc/regionsw.hxx
+++ b/sw/source/uibase/inc/regionsw.hxx
@@ -241,22 +241,16 @@ public:
void SetWrtShell(SwWrtShell const & rSh);
};
-class SwInsertSectionTabDialog : public SfxTabDialog
+class SwInsertSectionTabDialog : public SfxTabDialogController
{
SwWrtShell& rWrtSh;
std::unique_ptr<SwSectionData> m_pSectionData;
- sal_uInt16 m_nSectionPageId;
- sal_uInt16 m_nColumnPageId;
- sal_uInt16 m_nBackPageId;
- sal_uInt16 m_nNotePageId;
- sal_uInt16 m_nIndentPage;
-
protected:
- virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override;
+ virtual void PageCreated(const OString& rId, SfxTabPage &rPage) override;
virtual short Ok() override;
public:
- SwInsertSectionTabDialog(vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh);
+ SwInsertSectionTabDialog(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh);
virtual ~SwInsertSectionTabDialog() override;
void SetSectionData(SwSectionData const& rSect);