diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-03-20 11:56:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-03-22 14:21:02 +0100 |
commit | fbd79c6125fd302dde9af2d76171dd5ca794af4d (patch) | |
tree | dc5b94523c89d892c07544368643bad2eea4c3af /sw/source/ui | |
parent | 7d0bd54bad1782f74c156aa667e875c33efee0c1 (diff) |
weld SwFieldDlg
Change-Id: I324a581721e01c907113bb3ab1cc91a290bd71a7
Reviewed-on: https://gerrit.libreoffice.org/69475
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 49 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 20 | ||||
-rw-r--r-- | sw/source/ui/fldui/DropDownFieldDialog.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/DropDownFormFieldDialog.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldpage.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldtdlg.cxx | 149 | ||||
-rw-r--r-- | sw/source/ui/fldui/inpdlg.cxx | 2 |
8 files changed, 106 insertions, 130 deletions
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index fb764f190916..7d36a5e527e1 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -196,7 +196,10 @@ short AbstractSwAutoFormatDlg_Impl::Execute() return m_xDlg->run(); } -IMPL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl); +short AbstractSwFieldDlg_Impl::Execute() +{ + return m_xDlg->run(); +} short AbstractSwRenameXNamedDlg_Impl::Execute() { @@ -441,57 +444,62 @@ SwTableAutoFormat* AbstractSwAutoFormatDlg_Impl::FillAutoFormatOfIndex() const void AbstractSwFieldDlg_Impl::SetCurPageId( const OString &rName ) { - pDlg->SetCurPageId( rName ); + m_xDlg->SetCurPageId( rName ); } const SfxItemSet* AbstractSwFieldDlg_Impl::GetOutputItemSet() const { - return pDlg->GetOutputItemSet(); + return m_xDlg->GetOutputItemSet(); } const sal_uInt16* AbstractSwFieldDlg_Impl::GetInputRanges(const SfxItemPool& pItem ) { - return pDlg->GetInputRanges( pItem ); + return m_xDlg->GetInputRanges( pItem ); } void AbstractSwFieldDlg_Impl::SetInputSet( const SfxItemSet* pInSet ) { - pDlg->SetInputSet( pInSet ); + m_xDlg->SetInputSet( pInSet ); } void AbstractSwFieldDlg_Impl::SetText( const OUString& rStr ) { - pDlg->SetText( rStr ); + m_xDlg->set_title(rStr); } -void AbstractSwFieldDlg_Impl::Start() +bool AbstractSwFieldDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) { - pDlg->Start(); + auto xDlg = m_xDlg; + return SfxTabDialogController::runAsync(m_xDlg, [=](sal_Int32 nResult){ + xDlg->Close(); + if (rCtx.isSet()) + rCtx.maEndDialogFn(nResult); + }); } void AbstractSwFieldDlg_Impl::Initialize(SfxChildWinInfo *pInfo) { - pDlg->Initialize( pInfo ); + m_xDlg->Initialize( pInfo ); } void AbstractSwFieldDlg_Impl::ReInitDlg() { - pDlg->ReInitDlg(); + m_xDlg->ReInitDlg(); } void AbstractSwFieldDlg_Impl::ActivateDatabasePage() { - pDlg->ActivateDatabasePage(); + m_xDlg->ActivateDatabasePage(); } -vcl::Window* AbstractSwFieldDlg_Impl::GetWindow() +void AbstractSwFieldDlg_Impl::ShowReferencePage() { - return static_cast<vcl::Window*>(pDlg); + m_xDlg->ShowReferencePage(); } -void AbstractSwFieldDlg_Impl::ShowReferencePage() +std::shared_ptr<SfxDialogController> AbstractSwFieldDlg_Impl::GetController() { - pDlg->ShowReferencePage(); + return m_xDlg; } void AbstractSwRenameXNamedDlg_Impl::SetForbiddenChars( const OUString& rSet ) @@ -835,13 +843,13 @@ VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwFootNoteOptio return VclPtr<AbstractTabController_Impl>::Create(std::make_unique<SwFootNoteOptionDlg>(pParent, rSh)); } -VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDownFieldDialog(weld::Window *pParent, +VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDownFieldDialog(weld::Widget *pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) { return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFieldDialog>(pParent, rSh, pField, bPrevButton, bNextButton)); } -VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Window *pParent, sw::mark::IFieldmark* pDropDownField) +VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Widget *pParent, sw::mark::IFieldmark* pDropDownField) { return VclPtr<AbstractDropDownFormFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFormFieldDialog>(pParent, pDropDownField)); } @@ -931,10 +939,9 @@ VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwTableTabDlg(w return VclPtr<AbstractTabController_Impl>::Create(std::make_unique<SwTableTabDlg>(pParent, pItemSet, pSh)); } -VclPtr<AbstractSwFieldDlg> SwAbstractDialogFactory_Impl::CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) +VclPtr<AbstractSwFieldDlg> SwAbstractDialogFactory_Impl::CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) { - VclPtr<SwFieldDlg> pDlg = VclPtr<SwFieldDlg>::Create(pB, pCW, pParent); - return VclPtr<AbstractSwFieldDlg_Impl>::Create(pDlg); + return VclPtr<AbstractSwFieldDlg_Impl>::Create(std::make_unique<SwFieldDlg>(pB, pCW, pParent)); } VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwFieldEditDlg(SwView& rVw) @@ -988,7 +995,7 @@ VclPtr<AbstractGlossaryDlg> SwAbstractDialogFactory_Impl::CreateGlossaryDlg(SfxV return VclPtr<AbstractGlossaryDlg_Impl>::Create( pDlg ); } -VclPtr<AbstractFieldInputDlg> SwAbstractDialogFactory_Impl::CreateFieldInputDlg(weld::Window *pParent, +VclPtr<AbstractFieldInputDlg> SwAbstractDialogFactory_Impl::CreateFieldInputDlg(weld::Widget *pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) { return VclPtr<AbstractFieldInputDlg_Impl>::Create(std::make_unique<SwFieldInputDlg>(pParent, rSh, pField, bPrevButton, bNextButton)); diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index d17ccab6a473..dfb5925b7a5e 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -349,19 +349,25 @@ public: class AbstractSwFieldDlg_Impl : public AbstractSwFieldDlg { - DECL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl,SwFieldDlg ) + std::shared_ptr<SwFieldDlg> m_xDlg; +public: + explicit AbstractSwFieldDlg_Impl(std::unique_ptr<SwFieldDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; virtual void SetCurPageId( const OString &rName ) override; virtual const SfxItemSet* GetOutputItemSet() const override; virtual const sal_uInt16* GetInputRanges( const SfxItemPool& pItem ) override; virtual void SetInputSet( const SfxItemSet* pInSet ) override; //From class Window. virtual void SetText( const OUString& rStr ) override; - virtual void Start() override; //this method from SfxTabDialog virtual void ShowReferencePage() override; virtual void Initialize(SfxChildWinInfo *pInfo) override; virtual void ReInitDlg() override; virtual void ActivateDatabasePage() override; - virtual vcl::Window * GetWindow() override; //this method is added for return a Window type pointer + virtual std::shared_ptr<SfxDialogController> GetController() override; }; class AbstractSwRenameXNamedDlg_Impl : public AbstractSwRenameXNamedDlg @@ -611,9 +617,9 @@ public: const SwDBData& rData) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwFootNoteOptionDlg(weld::Window *pParent, SwWrtShell &rSh) override; - virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh, + virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; - virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Window* pParent, sw::mark::IFieldmark* pDropDownField) override; + virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* pDropDownField) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override; virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager, bool bLabel) override; @@ -641,7 +647,7 @@ public: virtual VclPtr<VclAbstractDialog> CreateSwTableWidthDlg(weld::Window *pParent, SwTableFUNC &rFnc) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwTableTabDlg(weld::Window* pParent, const SfxItemSet* pItemSet, SwWrtShell* pSh) override; - virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) override; + virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) override; virtual VclPtr<SfxAbstractDialog> CreateSwFieldEditDlg ( SwView& rVw ) override; virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(weld::Window* pParent, css::uno::Reference< css::container::XNamed > & xNamed, @@ -664,7 +670,7 @@ public: virtual VclPtr<AbstractGlossaryDlg> CreateGlossaryDlg(SfxViewFrame* pViewFrame, SwGlossaryHdl* pGlosHdl, SwWrtShell *pWrtShell) override; - virtual VclPtr<AbstractFieldInputDlg> CreateFieldInputDlg(weld::Window *pParent, + virtual VclPtr<AbstractFieldInputDlg> CreateFieldInputDlg(weld::Widget *pParent, SwWrtShell &rSh, SwField* pField, bool bPrevButton, bool bNextButton) override; virtual VclPtr<AbstractInsFootNoteDlg> CreateInsFootNoteDlg( weld::Window * pParent, SwWrtShell &rSh, bool bEd = false) override; diff --git a/sw/source/ui/fldui/DropDownFieldDialog.cxx b/sw/source/ui/fldui/DropDownFieldDialog.cxx index 387bccc39490..46d6f9d9b041 100644 --- a/sw/source/ui/fldui/DropDownFieldDialog.cxx +++ b/sw/source/ui/fldui/DropDownFieldDialog.cxx @@ -28,7 +28,7 @@ using namespace ::com::sun::star; // edit insert-field -sw::DropDownFieldDialog::DropDownFieldDialog(weld::Window *pParent, SwWrtShell &rS, +sw::DropDownFieldDialog::DropDownFieldDialog(weld::Widget *pParent, SwWrtShell &rS, SwField* pField, bool bPrevButton, bool bNextButton) : GenericDialogController(pParent, "modules/swriter/ui/dropdownfielddialog.ui", "DropdownFieldDialog") , m_rSh( rS ) diff --git a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx index 42312bca3693..66dd8302543e 100644 --- a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx +++ b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx @@ -14,7 +14,7 @@ namespace sw { -DropDownFormFieldDialog::DropDownFormFieldDialog(weld::Window* pParent, +DropDownFormFieldDialog::DropDownFormFieldDialog(weld::Widget* pParent, mark::IFieldmark* pDropDownField) : GenericDialogController(pParent, "modules/swriter/ui/dropdownformfielddialog.ui", "DropDownFormFieldDialog") diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 365df5c361a4..3cbd9a6743a7 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -67,7 +67,7 @@ void SwFieldPage::Init() SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); bool bNewMode = 0 != (::GetHtmlMode(pDocSh) & HTMLMODE_ON); - m_bFieldEdit = nullptr == GetTabDialog(); + m_bFieldEdit = nullptr == dynamic_cast<SwFieldDlg*>(GetDialogController()); // newly initialise FieldManager. important for // Dok-Switch (fldtdlg:ReInitTabPage) @@ -127,7 +127,7 @@ void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUS { SwInsertField_Data aData(nTypeId, nSubType, rPar1, rPar2, nFormatId, nullptr, cSeparator, bIsAutomaticLanguage ); //#i26566# provide parent for SwWrtShell::StartInputFieldDlg - aData.m_pParent = &GetTabDialog()->GetOKButton(); + aData.m_pParent = &GetDialogController()->GetOKButton(); m_aMgr.InsertField( aData ); uno::Reference< frame::XDispatchRecorder > xRecorder = @@ -307,8 +307,7 @@ IMPL_LINK( SwFieldPage, TreeViewInsertHdl, weld::TreeView&, rBox, void ) void SwFieldPage::InsertHdl(weld::Widget* pBtn) { - SwFieldDlg *pDlg = static_cast<SwFieldDlg*>(GetTabDialog()); - if (pDlg) + if (SwFieldDlg *pDlg = dynamic_cast<SwFieldDlg*>(GetDialogController())) { pDlg->InsertHdl(); @@ -325,8 +324,7 @@ void SwFieldPage::InsertHdl(weld::Widget* pBtn) // enable/disable "Insert"-Button void SwFieldPage::EnableInsert(bool bEnable) { - SwFieldDlg *pDlg = static_cast<SwFieldDlg*>(GetTabDialog()); - if (pDlg) + if (SwFieldDlg *pDlg = dynamic_cast<SwFieldDlg*>(GetDialogController())) { if (pDlg->GetCurTabPage() == this) pDlg->EnableInsert(bEnable); diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index d9e084f01413..2b5d2eac20ee 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -391,7 +391,7 @@ IMPL_LINK_NOARG(SwFieldRefPage, TypeHdl, weld::TreeView&, void) default: if( REFFLDFLAG & nTypeId ) { - const sal_uInt16 nOldId = m_xTypeLB->get_id(nOld).toUInt32(); + const sal_uInt16 nOldId = nOld != -1 ? m_xTypeLB->get_id(nOld).toUInt32() : 0; if( nOldId & REFFLDFLAG || nOldId == TYP_GETREFFLD ) // then the old one stays nFieldDlgFormatSel = m_xFormatLB->get_selected_index(); diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index c031883746e3..cade4bbc0bd1 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -46,33 +46,26 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> // carrier of the dialog -SwFieldDlg::SwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) - : SfxTabDialog(pParent, "FieldDialog", "modules/swriter/ui/fielddialog.ui") +SwFieldDlg::SwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, weld::Window *pParent) + : SfxTabDialogController(pParent, "modules/swriter/ui/fielddialog.ui", "FieldDialog") , m_pChildWin(pCW) , m_pBindings(pB) , m_bDataBaseMode(false) - , m_nDokId(0) - , m_nVarId(0) - , m_nDokInf(0) - , m_nRefId(0) - , m_nFuncId(0) - , m_nDbId(0) + , m_bClosing(false) { - SetStyle(GetStyle()|WB_STDMODELESS); m_bHtmlMode = (::GetHtmlMode(static_cast<SwDocShell*>(SfxObjectShell::Current())) & HTMLMODE_ON) != 0; - GetCancelButton().SetClickHdl(LINK(this, SwFieldDlg, CancelHdl)); + GetCancelButton().connect_clicked(LINK(this, SwFieldDlg, CancelHdl)); + GetOKButton().connect_clicked(LINK(this, SwFieldDlg, OKHdl)); - GetOKButton().SetClickHdl(LINK(this, SwFieldDlg, OKHdl)); - - m_nDokId = AddTabPage("document", SwFieldDokPage::Create); - m_nVarId = AddTabPage("variables", SwFieldVarPage::Create); - m_nDokInf = AddTabPage("docinfo", SwFieldDokInfPage::Create); + AddTabPage("document", SwFieldDokPage::Create, nullptr); + AddTabPage("variables", SwFieldVarPage::Create, nullptr); + AddTabPage("docinfo", SwFieldDokInfPage::Create, nullptr); if (!m_bHtmlMode) { - m_nRefId = AddTabPage("ref", SwFieldRefPage::Create); - m_nFuncId = AddTabPage("functions", SwFieldFuncPage::Create); + AddTabPage("ref", SwFieldRefPage::Create, nullptr); + AddTabPage("functions", SwFieldFuncPage::Create, nullptr); utl::OConfigurationTreeRoot aCfgRoot = utl::OConfigurationTreeRoot::createWithComponentContext( @@ -87,7 +80,7 @@ SwFieldDlg::SwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pPa OUString("DatabaseFields")) >>= bDatabaseFields; if (bDatabaseFields) - m_nDbId = AddTabPage("database", SwFieldDBPage::Create); + AddTabPage("database", SwFieldDBPage::Create, nullptr); else #endif RemoveTabPage("database"); @@ -104,64 +97,34 @@ SwFieldDlg::~SwFieldDlg() { } -bool SwFieldDlg::Close() +void SwFieldDlg::EndDialog() +{ + m_bClosing = true; + SfxTabDialogController::EndDialog(); + m_bClosing = false; +} + +void SwFieldDlg::Close() { + if (m_bClosing) + return; m_pBindings->GetDispatcher()-> Execute(m_bDataBaseMode ? FN_INSERT_FIELD_DATA_ONLY : FN_INSERT_FIELD, - SfxCallMode::ASYNCHRON|SfxCallMode::RECORD); - return true; + SfxCallMode::SYNCHRON|SfxCallMode::RECORD); } void SwFieldDlg::Initialize(SfxChildWinInfo const *pInfo) { - Point aPos; - Size aSize; - - if ( pInfo->aSize.Width() != 0 && pInfo->aSize.Height() != 0 ) - { - aPos = pInfo->aPos; - if ( GetStyle() & WB_SIZEABLE ) - SetSizePixel( pInfo->aSize ); - - // remember initial size from pInfo - aSize = GetSizePixel(); - - // should the FloatingWindow get zoomed? - if ( pInfo->nFlags & SfxChildWindowFlags::ZOOMIN ) - RollUp(); - } - else - { - // remember initial size from resource or ctor - aSize = GetSizePixel(); - - Size aParentSize = GetParent()->GetOutputSizePixel(); - aPos.AdjustX(( aParentSize.Width() - aSize.Width() ) / 2 ); - aPos.AdjustY(( aParentSize.Height() - aSize.Height() ) / 2 ); - } - - Point aPoint; - tools::Rectangle aRect = GetDesktopRectPixel(); - aPoint.setX( aRect.Right() - aSize.Width() ); - aPoint.setY( aRect.Bottom() - aSize.Height() ); - - aPoint = OutputToScreenPixel( aPoint ); - - if ( aPos.X() > aPoint.X() ) - aPos.setX( aPoint.X() ) ; - if ( aPos.Y() > aPoint.Y() ) - aPos.setY( aPoint.Y() ); - - if ( aPos.X() < 0 ) aPos.setX( 0 ); - if ( aPos.Y() < 0 ) aPos.setY( 0 ); - - SetPosPixel( aPos ); + OString aWinState = pInfo->aWinState; + if (aWinState.isEmpty()) + return; + m_xDialog->set_window_state(aWinState); } -SfxItemSet* SwFieldDlg::CreateInputItemSet( sal_uInt16 nID ) +SfxItemSet* SwFieldDlg::CreateInputItemSet(const OString& rID) { SwDocShell *const pDocSh(static_cast<SwDocShell*>(SfxObjectShell::Current())); - if (nID == m_nDokInf && pDocSh) // might not have a shell if the dialog is restored on startup + if (rID == "docinfo" && pDocSh) // might not have a shell if the dialog is restored on startup { SfxItemSet* pISet = new SfxItemSet( pDocSh->GetPool(), svl::Items<SID_DOCINFO, SID_DOCINFO>{} ); using namespace ::com::sun::star; @@ -180,18 +143,18 @@ SfxItemSet* SwFieldDlg::CreateInputItemSet( sal_uInt16 nID ) } // kick off inserting of new fields -IMPL_LINK_NOARG(SwFieldDlg, OKHdl, Button*, void) +IMPL_LINK_NOARG(SwFieldDlg, OKHdl, weld::Button&, void) { - if (GetOKButton().IsEnabled()) + if (GetOKButton().get_sensitive()) { SfxTabPage* pPage = GetTabPage(GetCurPageId()); pPage->FillItemSet(nullptr); - GetOKButton().GrabFocus(); // because of InputField-Dlg + GetOKButton().grab_focus(); // because of InputField-Dlg } } -IMPL_LINK_NOARG(SwFieldDlg, CancelHdl, Button*, void) +IMPL_LINK_NOARG(SwFieldDlg, CancelHdl, weld::Button&, void) { Close(); } @@ -213,48 +176,50 @@ void SwFieldDlg::ReInitDlg() if(!pActiveView) return; const SwWrtShell& rSh = pActiveView->GetWrtShell(); - GetOKButton().Enable( !rSh.IsReadOnlyAvailable() || - !rSh.HasReadonlySel() ); + GetOKButton().set_sensitive(!rSh.IsReadOnlyAvailable() || + !rSh.HasReadonlySel()); - ReInitTabPage(m_nDokId); - ReInitTabPage(m_nVarId); - ReInitTabPage(m_nDokInf); + ReInitTabPage("document"); + ReInitTabPage("variables"); + ReInitTabPage("docinfo"); if (!m_bHtmlMode) { - ReInitTabPage(m_nRefId); - ReInitTabPage(m_nFuncId); - ReInitTabPage(m_nDbId); + ReInitTabPage("ref"); + ReInitTabPage("functions"); + ReInitTabPage("database"); } m_pChildWin->SetOldDocShell(pDocSh); } // newly initialise TabPage after Doc-Switch -void SwFieldDlg::ReInitTabPage( sal_uInt16 nPageId, bool bOnlyActivate ) +void SwFieldDlg::ReInitTabPage(const OString& rPageId, bool bOnlyActivate) { - SwFieldPage* pPage = static_cast<SwFieldPage* >(GetTabPage(nPageId)); - if ( pPage ) + SwFieldPage* pPage = static_cast<SwFieldPage*>(GetTabPage(rPageId)); + if (pPage) pPage->EditNewField( bOnlyActivate ); // newly initialise TabPage } // newly initialise after activation of a few TabPages void SwFieldDlg::Activate() { + fprintf(stderr, "SwFieldDlg::Activate()\n"); + SwView* pView = ::GetActiveView(); if( pView ) { bool bHtmlMode = (::GetHtmlMode(static_cast<SwDocShell*>(SfxObjectShell::Current())) & HTMLMODE_ON) != 0; const SwWrtShell& rSh = pView->GetWrtShell(); - GetOKButton().Enable( !rSh.IsReadOnlyAvailable() || - !rSh.HasReadonlySel() ); + GetOKButton().set_sensitive(!rSh.IsReadOnlyAvailable() || + !rSh.HasReadonlySel()); - ReInitTabPage(m_nVarId, true); + ReInitTabPage("variables", true); if( !bHtmlMode ) { - ReInitTabPage(m_nRefId, true); - ReInitTabPage(m_nFuncId, true); + ReInitTabPage("ref", true); + ReInitTabPage("functions", true); } } } @@ -270,20 +235,20 @@ void SwFieldDlg::EnableInsert(bool bEnable) pView->GetWrtShell().HasReadonlySel()) ) bEnable = false; } - GetOKButton().Enable(bEnable); + GetOKButton().set_sensitive(bEnable); } void SwFieldDlg::InsertHdl() { - GetOKButton().Click(); + GetOKButton().clicked(); } void SwFieldDlg::ActivateDatabasePage() { #if HAVE_FEATURE_DBCONNECTIVITY m_bDataBaseMode = true; - ShowPage(m_nDbId); - SfxTabPage* pDBPage = GetTabPage(m_nDbId); + ShowPage("database"); + SfxTabPage* pDBPage = GetTabPage("database"); if( pDBPage ) { static_cast<SwFieldDBPage*>(pDBPage)->ActivateMailMergeAddress(); @@ -299,13 +264,13 @@ void SwFieldDlg::ActivateDatabasePage() void SwFieldDlg::ShowReferencePage() { - ShowPage(m_nRefId); + ShowPage("ref"); } -void SwFieldDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) +void SwFieldDlg::PageCreated(const OString& rId, SfxTabPage& rPage) { #if HAVE_FEATURE_DBCONNECTIVITY - if (nId == m_nDbId) + if (rId == "database") { SfxDispatcher* pDispatch = m_pBindings->GetDispatcher(); SfxViewFrame* pViewFrame = pDispatch ? pDispatch->GetFrame() : nullptr; diff --git a/sw/source/ui/fldui/inpdlg.cxx b/sw/source/ui/fldui/inpdlg.cxx index f2bc3de52fe2..a614361058f9 100644 --- a/sw/source/ui/fldui/inpdlg.cxx +++ b/sw/source/ui/fldui/inpdlg.cxx @@ -27,7 +27,7 @@ #include <fldmgr.hxx> // edit field-insert -SwFieldInputDlg::SwFieldInputDlg(weld::Window *pParent, SwWrtShell &rS, +SwFieldInputDlg::SwFieldInputDlg(weld::Widget *pParent, SwWrtShell &rS, SwField* pField, bool bPrevButton, bool bNextButton) : GenericDialogController(pParent, "modules/swriter/ui/inputfielddialog.ui", "InputFieldDialog") , rSh( rS ) |