diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 12:29:05 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-02 15:59:51 +0200 |
commit | 50d9f1508709e0849e8ecabfe04ac9281160d9e0 (patch) | |
tree | 2c93fb636da0807259b4e170e6e0dc10b51a06a4 /sd/source | |
parent | fb4660e217de4658587a62fd58f038f4b984277f (diff) |
weld Break dialog
Change-Id: I1657a02c775cf08e0888ba4cc9f9ae3b06550020
Reviewed-on: https://gerrit.libreoffice.org/52256
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/brkdlg.cxx | 106 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.cxx | 14 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.hxx | 11 | ||||
-rw-r--r-- | sd/source/ui/inc/BreakDlg.hxx | 53 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 2 |
5 files changed, 82 insertions, 104 deletions
diff --git a/sd/source/ui/dlg/brkdlg.cxx b/sd/source/ui/dlg/brkdlg.cxx index 724df7d201cb..80e8fb8f6a8f 100644 --- a/sd/source/ui/dlg/brkdlg.cxx +++ b/sd/source/ui/dlg/brkdlg.cxx @@ -38,59 +38,34 @@ namespace sd { * dialog to split metafiles */ -BreakDlg::BreakDlg( - vcl::Window* pWindow, - DrawView* _pDrView, - DrawDocShell* pShell, - sal_uLong nSumActionCount, - sal_uLong nObjCount ) - : SfxModalDialog(pWindow, "BreakDialog", "modules/sdraw/ui/breakdialog.ui") - , mpProgress( nullptr ) +BreakDlg::BreakDlg(weld::Window* pWindow, DrawView* pDrView, DrawDocShell* pShell, + sal_uLong nSumActionCount, sal_uLong nObjCount) + : GenericDialogController(pWindow, "modules/sdraw/ui/breakdialog.ui", "BreakDialog") + , m_xFiObjInfo(m_xBuilder->weld_label("metafiles")) + , m_xFiActInfo(m_xBuilder->weld_label("metaobjects")) + , m_xFiInsInfo(m_xBuilder->weld_label("drawingobjects")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) + , m_pDrView(pDrView) + , m_bCancel(false) { m_aUpdateIdle.SetPriority( TaskPriority::REPAINT ); m_aUpdateIdle.SetInvokeHandler( LINK( this, BreakDlg, InitialUpdate ) ); m_aUpdateIdle.SetDebugName( "sd::BreakDlg m_aUpdateIdle" ); - get(m_pFiObjInfo, "metafiles"); - get(m_pFiActInfo, "metaobjects"); - get(m_pFiInsInfo, "drawingobjects"); - get(m_pBtnCancel, "cancel"); + m_xBtnCancel->connect_clicked(LINK(this, BreakDlg, CancelButtonHdl)); - m_pBtnCancel->SetClickHdl( LINK( this, BreakDlg, CancelButtonHdl)); + m_xProgress.reset(new SfxProgress(pShell, SdResId(STR_BREAK_METAFILE), nSumActionCount*3)); - mpProgress = new SfxProgress( pShell, SdResId(STR_BREAK_METAFILE), nSumActionCount*3 ); - - pProgrInfo = new SvdProgressInfo( LINK(this, BreakDlg, UpDate) ); + m_xProgrInfo.reset(new SvdProgressInfo(LINK(this, BreakDlg, UpDate))); // every action is edited 3 times in DoImport() - pProgrInfo->Init( nObjCount ); - - pDrView = _pDrView; - bCancel = false; -} - -BreakDlg::~BreakDlg() -{ - disposeOnce(); -} - -void BreakDlg::dispose() -{ - delete mpProgress; - mpProgress = nullptr; - delete pProgrInfo; - pProgrInfo = nullptr; - m_pFiObjInfo.clear(); - m_pFiActInfo.clear(); - m_pFiInsInfo.clear(); - m_pBtnCancel.clear(); - SfxModalDialog::dispose(); + m_xProgrInfo->Init( nObjCount ); } // Control-Handler for cancel button -IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl, Button*, void) +IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl, weld::Button&, void) { - bCancel = true; - m_pBtnCancel->Disable(); + m_bCancel = true; + m_xBtnCancel->set_sensitive(false); } /** @@ -101,73 +76,72 @@ IMPL_LINK_NOARG(BreakDlg, CancelButtonHdl, Button*, void) */ IMPL_LINK( BreakDlg, UpDate, void*, nInit, bool ) { - if(pProgrInfo == nullptr) + if (!m_xProgrInfo) return true; // update status bar or show a error message? if(nInit == reinterpret_cast<void*>(1)) { - std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xErrBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_BREAK_FAIL))); xErrBox->run(); } else { - if(mpProgress) - mpProgress->SetState( pProgrInfo->GetSumCurAction() ); + if (m_xProgress) + m_xProgress->SetState(m_xProgrInfo->GetSumCurAction()); } // which object is shown at the moment? - OUString info = OUString::number( pProgrInfo->GetCurObj() ) + OUString info = OUString::number(m_xProgrInfo->GetCurObj()) + "/" - + OUString::number( pProgrInfo->GetObjCount() ); - m_pFiObjInfo->SetText(info); + + OUString::number(m_xProgrInfo->GetObjCount()); + m_xFiObjInfo->set_label(info); // how many actions are started? - if(pProgrInfo->GetActionCount() == 0) + if (m_xProgrInfo->GetActionCount() == 0) { - m_pFiActInfo->SetText( OUString() ); + m_xFiActInfo->set_label( OUString() ); } else { - info = OUString::number( pProgrInfo->GetCurAction() ) + info = OUString::number(m_xProgrInfo->GetCurAction()) + "/" - + OUString::number( pProgrInfo->GetActionCount() ); - m_pFiActInfo->SetText(info); + + OUString::number(m_xProgrInfo->GetActionCount()); + m_xFiActInfo->set_label(info); } // and inserted???? - if(pProgrInfo->GetInsertCount() == 0) + if (m_xProgrInfo->GetInsertCount() == 0) { - m_pFiInsInfo->SetText( OUString() ); + m_xFiInsInfo->set_label( OUString() ); } else { - info = OUString::number( pProgrInfo->GetCurInsert() ) + info = OUString::number(m_xProgrInfo->GetCurInsert()) + "/" - + OUString::number( pProgrInfo->GetInsertCount() ); - m_pFiInsInfo->SetText(info); + + OUString::number(m_xProgrInfo->GetInsertCount()); + m_xFiInsInfo->set_label(info); } // make sure dialog gets painted, it is intended to // show the progress to the user. Also necessary to // provide a clickable cancel button - ensureRepaint(); + Application::Reschedule(true); // return okay-value (-> !cancel) - return !bCancel; + return !m_bCancel; } /** * open a modal dialog and start a timer which calls the working function after * the opening of the dialog */ -short BreakDlg::Execute() +short BreakDlg::execute() { - m_aUpdateIdle.Start(); - - return SfxModalDialog::Execute(); + m_aUpdateIdle.Start(); + return run(); } /** @@ -175,8 +149,8 @@ short BreakDlg::Execute() */ IMPL_LINK_NOARG(BreakDlg, InitialUpdate, Timer *, void) { - pDrView->DoImportMarkedMtf(pProgrInfo); - EndDialog(RET_OK); + m_pDrView->DoImportMarkedMtf(m_xProgrInfo.get()); + m_xDialog->response(RET_OK); } } // end of namespace sd diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx index f64679846ccf..a1872faad60e 100644 --- a/sd/source/ui/dlg/sddlgfact.cxx +++ b/sd/source/ui/dlg/sddlgfact.cxx @@ -65,6 +65,16 @@ IMPL_ABSTDLG_BASE(AbstractSdPublishingDlg_Impl); IMPL_ABSTDLG_BASE(AbstractHeaderFooterDialog_Impl); IMPL_ABSTDLG_BASE(AbstractBulletDialog_Impl); +AbstractBreakDlg_Impl::AbstractBreakDlg_Impl(::sd::BreakDlg* pDlg) + : m_xDlg(pDlg) +{ +} + +short AbstractBreakDlg_Impl::Execute() +{ + return m_xDlg->execute(); +} + void AbstractCopyDlg_Impl::GetAttr( SfxItemSet& rOutAttrs ) { pDlg->GetAttr( rOutAttrs ); @@ -284,13 +294,13 @@ void AbstractSdPublishingDlg_Impl::GetParameterSequence( css::uno::Sequence< css //-------------- SdAbstractDialogFactory implementation-------------- VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateBreakDlg( - vcl::Window* pParent, + weld::Window* pParent, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount ) { - return VclPtr<SdVclAbstractDialog_Impl>::Create( VclPtr<::sd::BreakDlg>::Create( pParent, pDrView, pShell, nSumActionCount, nObjCount ) ); + return VclPtr<AbstractBreakDlg_Impl>::Create(new ::sd::BreakDlg(pParent, pDrView, pShell, nSumActionCount, nObjCount)); } VclPtr<AbstractCopyDlg> SdAbstractDialogFactory_Impl::CreateCopyDlg(vcl::Window* pParent, diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index dc88ed893bb2..bb8586386467 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -63,6 +63,15 @@ class SdVclAbstractDialog_Impl : public VclAbstractDialog DECL_ABSTDLG_BASE(SdVclAbstractDialog_Impl,Dialog) }; +class AbstractBreakDlg_Impl : public VclAbstractDialog +{ +private: + std::unique_ptr<sd::BreakDlg> m_xDlg; +public: + AbstractBreakDlg_Impl(::sd::BreakDlg* pDlg); + virtual short Execute() override; +}; + class AbstractCopyDlg_Impl : public AbstractCopyDlg { DECL_ABSTDLG_BASE(AbstractCopyDlg_Impl,::sd::CopyDlg) @@ -209,7 +218,7 @@ class SdAbstractDialogFactory_Impl : public SdAbstractDialogFactory public: virtual ~SdAbstractDialogFactory_Impl() {} - virtual VclPtr<VclAbstractDialog> CreateBreakDlg(vcl::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override; + virtual VclPtr<VclAbstractDialog> CreateBreakDlg(weld::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override; virtual VclPtr<AbstractCopyDlg> CreateCopyDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override; virtual VclPtr<AbstractSdCustomShowDlg> CreateSdCustomShowDlg(vcl::Window* pParent, SdDrawDocument& rDrawDoc) override; virtual VclPtr<SfxAbstractTabDialog> CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override; diff --git a/sd/source/ui/inc/BreakDlg.hxx b/sd/source/ui/inc/BreakDlg.hxx index 55faf6cb2d32..02d7a3081aed 100644 --- a/sd/source/ui/inc/BreakDlg.hxx +++ b/sd/source/ui/inc/BreakDlg.hxx @@ -20,18 +20,10 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_BREAKDLG_HXX #define INCLUDED_SD_SOURCE_UI_INC_BREAKDLG_HXX -#include <vcl/group.hxx> -#include <vcl/button.hxx> -#include <svx/dlgctrl.hxx> -#include <vcl/field.hxx> -#include <vcl/fixed.hxx> -#include <vcl/prgsbar.hxx> -#include <vcl/edit.hxx> -#include <sfx2/basedlgs.hxx> +#include <sfx2/progress.hxx> +#include <svx/svdetc.hxx> #include <vcl/idle.hxx> - -class SvdProgressInfo; -class SfxProgress; +#include <vcl/weld.hxx> namespace sd { @@ -41,38 +33,31 @@ class DrawView; /** * dialog to break meta files */ -class BreakDlg - : public SfxModalDialog +class BreakDlg : public weld::GenericDialogController { public: - BreakDlg ( - vcl::Window* pWindow, - DrawView* pDrView, - DrawDocShell* pShell, - sal_uLong nSumActionCount, - sal_uLong nObjCount); - virtual ~BreakDlg() override; - virtual void dispose() override; + BreakDlg(weld::Window* pWindow, DrawView* pDrView, DrawDocShell* pShell, + sal_uLong nSumActionCount, sal_uLong nObjCount); - short Execute() override; + short execute(); private: - VclPtr<FixedText> m_pFiObjInfo; - VclPtr<FixedText> m_pFiActInfo; - VclPtr<FixedText> m_pFiInsInfo; - VclPtr<CancelButton> m_pBtnCancel; + std::unique_ptr<weld::Label> m_xFiObjInfo; + std::unique_ptr<weld::Label> m_xFiActInfo; + std::unique_ptr<weld::Label> m_xFiInsInfo; + std::unique_ptr<weld::Button> m_xBtnCancel; - DrawView* pDrView; + DrawView* m_pDrView; - bool bCancel; + bool m_bCancel; - Idle m_aUpdateIdle; - SvdProgressInfo *pProgrInfo; - SfxProgress *mpProgress; + Idle m_aUpdateIdle; + std::unique_ptr<SvdProgressInfo> m_xProgrInfo; + std::unique_ptr<SfxProgress> m_xProgress; - DECL_LINK( CancelButtonHdl, Button*, void ); - DECL_LINK( UpDate, void*, bool ); - DECL_LINK( InitialUpdate, Timer*, void ); + DECL_LINK(CancelButtonHdl, weld::Button&, void); + DECL_LINK(UpDate, void*, bool); + DECL_LINK(InitialUpdate, Timer*, void); }; } // end of namespace sd diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 35d290692da6..65ffb4268311 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2790,7 +2790,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); if( pFact ) { - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetActiveWindow(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); + ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); if( pDlg ) { pDlg->Execute(); |