diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-09-20 10:48:14 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-20 13:58:04 +0200 |
commit | 6b5b2bbdf88aec54fc648a019e544addabdece6b (patch) | |
tree | e68b5cde19f16d3b022428c532d50e7c9bdd9e1f /sfx2 | |
parent | b613eeeb566adc8955248c31b94a7ed32ebba4d1 (diff) |
weld SwDropCapsDlg
Change-Id: Ibd01c0fb54f0e3b361d5e1f196bfeb44a1fcb99c
Reviewed-on: https://gerrit.libreoffice.org/60805
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 108 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/singletabdialog.ui | 11 |
2 files changed, 116 insertions, 3 deletions
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 0868350ec74e..bb944a05e89b 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -733,4 +733,112 @@ void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage) } } +SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rSet, + const OUString& rUIXMLDescription, const OString& rID) + : GenericDialogController(pParent, rUIXMLDescription, rID) + , m_pInputSet(&rSet) + , m_xContainer(m_xDialog->weld_content_area()) + , m_xOKBtn(m_xBuilder->weld_button("ok")) + , m_xHelpBtn(m_xBuilder->weld_button("help")) +{ + m_xOKBtn->connect_clicked(LINK(this, SfxSingleTabDialogController, OKHdl_Impl)); +} + +SfxSingleTabDialogController::~SfxSingleTabDialogController() +{ + m_xSfxPage.disposeAndClear(); +} + +/* [Description] + + Insert a (new) TabPage; an existing page is deleted. + The passed on page is initialized with the initially given Itemset + through calling Reset(). +*/ +void SfxSingleTabDialogController::SetTabPage(SfxTabPage* pTabPage) +{ + m_xSfxPage.disposeAndClear(); + m_xSfxPage = pTabPage; + + if (m_xSfxPage) + { + // First obtain the user data, only then Reset() + OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME ); + OUString sUserData; + aUserItem >>= sUserData; + m_xSfxPage->SetUserData(sUserData); + m_xSfxPage->Reset(GetInputItemSet()); +//TODO m_xSfxPage->Show(); + + m_xHelpBtn->show(Help::IsContextHelpEnabled()); + + // Set TabPage text in the Dialog if there is any + OUString sTitle(m_xSfxPage->GetText()); + if (!sTitle.isEmpty()) + m_xDialog->set_title(sTitle); + + // Dialog receives the HelpId of TabPage if there is any + OString sHelpId(m_xSfxPage->GetHelpId()); + if (!sHelpId.isEmpty()) + m_xDialog->set_help_id(sHelpId); + } +} + +/* [Description] + + Ok_Handler; FillItemSet() is called for setting of Page. +*/ +IMPL_LINK_NOARG(SfxSingleTabDialogController, OKHdl_Impl, weld::Button&, void) +{ + const SfxItemSet* pInputSet = GetInputItemSet(); + if (!pInputSet) + { + // TabPage without ItemSet + m_xDialog->response(RET_OK); + return; + } + + if (!GetOutputItemSet()) + { + CreateOutputItemSet(*pInputSet); + } + + bool bModified = false; + + if (m_xSfxPage->HasExchangeSupport()) + { + DeactivateRC nRet = m_xSfxPage->DeactivatePage(m_xOutputSet.get()); + if (nRet != DeactivateRC::LeavePage) + return; + else + bModified = m_xOutputSet->Count() > 0; + } + else + bModified = m_xSfxPage->FillItemSet(m_xOutputSet.get()); + + if (bModified) + { + // Save user data in IniManager. + m_xSfxPage->FillUserData(); + OUString sData(m_xSfxPage->GetUserData()); + + OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(), + RTL_TEXTENCODING_UTF8); + SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId); + aPageOpt.SetUserItem( USERITEM_NAME, makeAny( sData ) ); + m_xDialog->response(RET_OK); + } + else + m_xDialog->response(RET_CANCEL); +} + +void SfxSingleTabDialogController::CreateOutputItemSet(const SfxItemSet& rSet) +{ + assert(!m_xOutputSet && "Double creation of OutputSet!"); + m_xOutputSet.reset(new SfxItemSet(rSet)); + m_xOutputSet->ClearItem(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/uiconfig/ui/singletabdialog.ui b/sfx2/uiconfig/ui/singletabdialog.ui index f4adba48d7d9..254638b10b91 100644 --- a/sfx2/uiconfig/ui/singletabdialog.ui +++ b/sfx2/uiconfig/ui/singletabdialog.ui @@ -1,21 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sfx"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="SingleTabDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="resizable">False</property> + <property name="modal">True</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> + <property name="orientation">vertical</property> <property name="spacing">12</property> <child internal-child="action_area"> <object class="GtkButtonBox" id="dialog-action_area1"> <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="layout_style">start</property> + <property name="layout_style">end</property> <child> <object class="GtkButton" id="ok"> <property name="label">gtk-ok</property> @@ -58,6 +62,7 @@ <property name="expand">False</property> <property name="fill">True</property> <property name="position">2</property> + <property name="secondary">True</property> </packing> </child> </object> |