diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-14 10:28:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-14 14:05:56 +0200 |
commit | c7ac8480c9df601a58bad892c472dcf7c5e9dc01 (patch) | |
tree | a012748981761ccb647d3f5161e444bba574ad19 /sw | |
parent | 267240ecf71b71c0d4234ee32b745e8789f39089 (diff) |
weld CreateMonitor and PrintMonitor
Change-Id: Icf57a0660482cf283d6f993f72f72def2ddf6181
Reviewed-on: https://gerrit.libreoffice.org/54307
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/dbmgr.hxx | 3 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmresultdialogs.cxx | 15 | ||||
-rw-r--r-- | sw/source/ui/inc/mmresultdialogs.hxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 42 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbui.cxx | 78 | ||||
-rw-r--r-- | sw/source/uibase/inc/dbui.hxx | 39 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/printmonitordialog.ui | 1 |
7 files changed, 51 insertions, 128 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 4af6308b6003..03e8c2f7ecc9 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -30,6 +30,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <vcl/weld.hxx> #include <memory> #include <vector> @@ -270,8 +271,6 @@ class SW_DLLPUBLIC SwDBManager SAL_DLLPRIVATE SwDSParam* FindDSData(const SwDBData& rData, bool bCreate); SAL_DLLPRIVATE SwDSParam* FindDSConnection(const OUString& rSource, bool bCreate); - DECL_DLLPRIVATE_LINK( PrtCancelHdl, Button *, void ); - /// Insert data record as text into document. SAL_DLLPRIVATE void ImportFromConnection( SwWrtShell* pSh); diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx index ff1487e2cd90..a558f12712ac 100644 --- a/sw/source/ui/dbui/mmresultdialogs.cxx +++ b/sw/source/ui/dbui/mmresultdialogs.cxx @@ -462,11 +462,6 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, CopyToHdl_Impl, Button*, void) } } -IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveCancelHdl_Impl, weld::Button&, void) -{ - m_bCancelSaving = true; -} - namespace { int documentStartPageNumber(SwMailMergeConfigItem* pConfigItem, int document) @@ -627,10 +622,13 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void) SwView* pSourceView = xConfigItem->GetSourceView(); std::shared_ptr<SaveMonitor> xSaveMonitor(new SaveMonitor(m_xDialog.get())); xSaveMonitor->m_xDocName->set_label(pSourceView->GetDocShell()->GetTitle(22)); - xSaveMonitor->m_xCancel->connect_clicked(LINK(this, SwMMResultSaveDialog, SaveCancelHdl_Impl)); xSaveMonitor->m_xPrinter->set_label( INetURLObject( sPath ).getFSysPath( FSysStyle::Detect ) ); m_bCancelSaving = false; - weld::DialogController::runAsync(xSaveMonitor, [](int) {}); + weld::DialogController::runAsync(xSaveMonitor, [this, &xSaveMonitor](sal_Int32 nResult){ + if (nResult == RET_CANCEL) + m_bCancelSaving = true; + xSaveMonitor.reset(); + }); for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc) { @@ -707,7 +705,8 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void) } } } - xSaveMonitor->response(RET_OK); + if (xSaveMonitor) + xSaveMonitor->response(RET_OK); ::osl::File::remove( sTargetTempURL ); } diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx index cde6faee8f9f..d391f34a50f9 100644 --- a/sw/source/ui/inc/mmresultdialogs.hxx +++ b/sw/source/ui/inc/mmresultdialogs.hxx @@ -57,7 +57,6 @@ class SwMMResultSaveDialog : public weld::GenericDialogController std::unique_ptr<weld::Button> m_xOKButton; DECL_LINK(SaveOutputHdl_Impl, weld::Button& , void); - DECL_LINK(SaveCancelHdl_Impl, weld::Button&, void); DECL_LINK(DocumentSelectionHdl_Impl, weld::ToggleButton&, void); public: diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 9430342bc158..8d6487dae6ee 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -1312,22 +1312,25 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, sal_uInt16 nStartingPageNo = 0; vcl::Window *pSourceWindow = nullptr; - VclPtr<CancelableDialog> pProgressDlg; + std::shared_ptr<weld::GenericDialogController> xProgressDlg; if( !bIsMergeSilent ) { // construct the process dialog pSourceWindow = &pSourceShell->GetView().GetEditWin(); if (!bMT_PRINTER) - pProgressDlg = VclPtr<CreateMonitor>::Create(pSourceWindow); + xProgressDlg.reset(new CreateMonitor(pSourceWindow->GetFrameWeld())); else { - pProgressDlg = VclPtr<PrintMonitor>::Create(pSourceWindow); - static_cast<PrintMonitor*>( pProgressDlg.get() )->SetText( - pSourceDocSh->GetTitle(22) ); + xProgressDlg.reset(new PrintMonitor(pSourceWindow->GetFrameWeld())); + static_cast<PrintMonitor*>(xProgressDlg.get())->set_title( + pSourceDocSh->GetTitle(22)); } - pProgressDlg->SetCancelHdl( LINK(this, SwDBManager, PrtCancelHdl) ); - pProgressDlg->Show(); + weld::DialogController::runAsync(xProgressDlg, [this, &xProgressDlg](sal_Int32 nResult){ + if (nResult == RET_CANCEL) + MergeCancel(); + xProgressDlg.reset(); + }); Application::Reschedule( true ); } @@ -1392,7 +1395,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, sal_Int32 nMaxDocs = nRecordCount / nRecordPerDoc; if ( 0 != nRecordCount % nRecordPerDoc ) nMaxDocs += 1; - static_cast<CreateMonitor*>( pProgressDlg.get() )->SetTotalCount( nMaxDocs ); + static_cast<CreateMonitor*>(xProgressDlg.get())->SetTotalCount(nMaxDocs); } long nStartRow, nEndRow; @@ -1460,16 +1463,16 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, aTempFileURL.reset( new INetURLObject(aTempFile->GetURL())); if( !bIsMergeSilent ) { if( !bMT_PRINTER ) - static_cast<CreateMonitor*>( pProgressDlg.get() )->SetCurrentPosition( nDocNo ); + static_cast<CreateMonitor*>(xProgressDlg.get())->SetCurrentPosition(nDocNo); else { - PrintMonitor *pPrintMonDlg = static_cast<PrintMonitor*>( pProgressDlg.get() ); - pPrintMonDlg->m_pPrinter->SetText( bNeedsTempFiles - ? aTempFileURL->GetBase() : pSourceDocSh->GetTitle( 22 ) ); + PrintMonitor *pPrintMonDlg = static_cast<PrintMonitor*>(xProgressDlg.get()); + pPrintMonDlg->m_xPrinter->set_label(bNeedsTempFiles + ? aTempFileURL->GetBase() : pSourceDocSh->GetTitle( 2)); OUString sStat( SwResId(STR_STATSTR_LETTER) ); sStat += " " + OUString::number( nDocNo ); - pPrintMonDlg->m_pPrintInfo->SetText( sStat ); + pPrintMonDlg->m_xPrintInfo->set_label(sStat); } - pProgressDlg->Update(); + //TODO xProgressDlg->queue_draw(); } Application::Reschedule( true ); @@ -1702,7 +1705,10 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, Application::Reschedule( true ); - pProgressDlg.disposeAndClear(); + if (xProgressDlg) + { + xProgressDlg->response(RET_OK); + } // unlock all dispatchers pViewFrame = SfxViewFrame::GetFirst(pSourceDocSh); @@ -1748,12 +1754,6 @@ void SwDBManager::MergeCancel() m_aMergeStatus = MergeStatus::Cancel; } -IMPL_LINK( SwDBManager, PrtCancelHdl, Button *, pButton, void ) -{ - pButton->GetParent()->Hide(); - MergeCancel(); -} - // determine the column's Numberformat and transfer to the forwarded Formatter, // if applicable. sal_uLong SwDBManager::GetColumnFormat( const OUString& rDBName, diff --git a/sw/source/uibase/dbui/dbui.cxx b/sw/source/uibase/dbui/dbui.cxx index a29e3c566eb6..bcc3119648f4 100644 --- a/sw/source/uibase/dbui/dbui.cxx +++ b/sw/source/uibase/dbui/dbui.cxx @@ -28,7 +28,6 @@ SaveMonitor::SaveMonitor(weld::Window *pParent) , m_xDocName(m_xBuilder->weld_label("docname")) , m_xPrinter(m_xBuilder->weld_label("printer")) , m_xPrintInfo(m_xBuilder->weld_label("printinfo")) - , m_xCancel(m_xBuilder->weld_button("cancel")) { } @@ -36,57 +35,36 @@ SaveMonitor::~SaveMonitor() { } -PrintMonitor::PrintMonitor(vcl::Window *pParent) - : CancelableDialog(pParent, "PrintMonitorDialog", - "modules/swriter/ui/printmonitordialog.ui") +PrintMonitor::PrintMonitor(weld::Window *pParent) + : GenericDialogController(pParent, "modules/swriter/ui/printmonitordialog.ui", + "PrintMonitorDialog") + , m_xDocName(m_xBuilder->weld_label("docname")) + , m_xPrinter(m_xBuilder->weld_label("printer")) + , m_xPrintInfo(m_xBuilder->weld_label("printinfo")) { - get(m_pDocName, "docname"); - get(m_pPrinter, "printer"); - get(m_pPrintInfo, "printinfo"); - get(m_pPrinting, "printing"); } PrintMonitor::~PrintMonitor() { - disposeOnce(); -} - -void PrintMonitor::dispose() -{ - m_pDocName.clear(); - m_pPrinting.clear(); - m_pPrinter.clear(); - m_pPrintInfo.clear(); - - CancelableDialog::dispose(); } // Progress Indicator for Creation of personalized Mail Merge documents: -CreateMonitor::CreateMonitor(vcl::Window *pParent) - : CancelableDialog(pParent, "MMCreatingDialog", - "modules/swriter/ui/mmcreatingdialog.ui") +CreateMonitor::CreateMonitor(weld::Window *pParent) + : GenericDialogController(pParent, "modules/swriter/ui/mmcreatingdialog.ui", + "MMCreatingDialog") , m_sCountingPattern() , m_sVariable_Total("%Y") , m_sVariable_Position("%X") , m_nTotalCount(0) , m_nCurrentPosition(0) + , m_xCounting(m_xBuilder->weld_label("progress")) { - get(m_pCounting, "progress"); - m_sCountingPattern = m_pCounting->GetText(); - m_pCounting->SetText("..."); + m_sCountingPattern = m_xCounting->get_label(); + m_xCounting->set_label("..."); } CreateMonitor::~CreateMonitor() { - disposeOnce(); -} - -void CreateMonitor::dispose() -{ - m_pCancelButton.clear(); - m_pCounting.clear(); - - CancelableDialog::dispose(); } void CreateMonitor::UpdateCountingText() @@ -94,7 +72,7 @@ void CreateMonitor::UpdateCountingText() OUString sText(m_sCountingPattern); sText = sText.replaceAll( m_sVariable_Total, OUString::number( m_nTotalCount ) ); sText = sText.replaceAll( m_sVariable_Position, OUString::number( m_nCurrentPosition ) ); - m_pCounting->SetText(sText); + m_xCounting->set_label(sText); } void CreateMonitor::SetTotalCount( sal_Int32 nTotal ) @@ -109,34 +87,4 @@ void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent ) UpdateCountingText(); } -CancelableDialog::CancelableDialog( vcl::Window *pParent, - const OUString& rID, const OUString& rUIXMLDescription ) - : Dialog(pParent, rID, rUIXMLDescription, WindowType::MODELESSDIALOG) -{ - get(m_pCancelButton, "cancel"); -} - -CancelableDialog::~CancelableDialog() -{ - disposeOnce(); -} - -void CancelableDialog::dispose() -{ - EndDialog(); - m_pCancelButton.clear(); - - Dialog::dispose(); -} - -void CancelableDialog::SetCancelHdl( const Link<Button*,void>& rLink ) -{ - m_pCancelButton->SetClickHdl( rLink ); -} - -void CancelableDialog::Show() -{ - Dialog::Show(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/dbui.hxx b/sw/source/uibase/inc/dbui.hxx index b8935890c462..225f96240fbd 100644 --- a/sw/source/uibase/inc/dbui.hxx +++ b/sw/source/uibase/inc/dbui.hxx @@ -25,34 +25,15 @@ #include <vcl/fixed.hxx> #include <vcl/weld.hxx> -class SW_DLLPUBLIC CancelableDialog : public Dialog -{ -protected: - VclPtr<CancelButton> m_pCancelButton; - CancelableDialog( vcl::Window *pParent, const OUString& rID, - const OUString& rUIXMLDescription ); - - using Dialog::Execute; - -public: - virtual ~CancelableDialog() override; - virtual void dispose() override; - - void SetCancelHdl( const Link<Button*,void>& rLink ); - void Show(); -}; - -class SW_DLLPUBLIC PrintMonitor: public CancelableDialog +class SW_DLLPUBLIC PrintMonitor: public weld::GenericDialogController { public: - VclPtr<FixedText> m_pDocName; - VclPtr<FixedText> m_pPrinting; - VclPtr<FixedText> m_pPrinter; - VclPtr<FixedText> m_pPrintInfo; + std::unique_ptr<weld::Label> m_xDocName; + std::unique_ptr<weld::Label> m_xPrinter; + std::unique_ptr<weld::Label> m_xPrintInfo; - PrintMonitor(vcl::Window *pParent); + PrintMonitor(weld::Window *pParent); virtual ~PrintMonitor() override; - virtual void dispose() override; }; class SW_DLLPUBLIC SaveMonitor : public weld::GenericDialogController @@ -61,18 +42,16 @@ public: std::unique_ptr<weld::Label> m_xDocName; std::unique_ptr<weld::Label> m_xPrinter; std::unique_ptr<weld::Label> m_xPrintInfo; - std::unique_ptr<weld::Button> m_xCancel; SaveMonitor(weld::Window *pParent); virtual ~SaveMonitor() override; }; -class CreateMonitor : public CancelableDialog +class CreateMonitor : public weld::GenericDialogController { public: - CreateMonitor(vcl::Window *pParent); + CreateMonitor(weld::Window *pParent); virtual ~CreateMonitor() override; - virtual void dispose() override; void SetTotalCount( sal_Int32 nTotal ); void SetCurrentPosition( sal_Int32 nCurrent ); @@ -81,13 +60,13 @@ private: void UpdateCountingText(); private: - VclPtr<FixedText> m_pCounting; - OUString m_sCountingPattern; OUString m_sVariable_Total; OUString m_sVariable_Position; sal_Int32 m_nTotalCount; sal_Int32 m_nCurrentPosition; + + std::unique_ptr<weld::Label> m_xCounting; }; #endif diff --git a/sw/uiconfig/swriter/ui/printmonitordialog.ui b/sw/uiconfig/swriter/ui/printmonitordialog.ui index 825490fcd657..c191486c25e5 100644 --- a/sw/uiconfig/swriter/ui/printmonitordialog.ui +++ b/sw/uiconfig/swriter/ui/printmonitordialog.ui @@ -6,7 +6,6 @@ <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="printmonitordialog|PrintMonitorDialog">Print monitor</property> - <property name="modal">True</property> <property name="default_width">0</property> <property name="default_height">0</property> <property name="type_hint">dialog</property> |