[Libreoffice-commits] core.git: sw/inc sw/source

Jan-Marek Glogowski glogow at fbihome.de
Wed Mar 25 11:21:47 PDT 2015


 sw/inc/dbmgr.hxx                      |    8 ++++++--
 sw/source/ui/dbui/mailmergewizard.cxx |    2 +-
 sw/source/ui/dbui/mmoutputpage.cxx    |    2 +-
 sw/source/uibase/dbui/dbmgr.cxx       |   15 +++++++++------
 sw/source/uibase/dbui/dbui.cxx        |   34 +++++++++++++++++++++++++++-------
 sw/source/uibase/inc/dbui.hxx         |   24 ++++++++++++++++--------
 6 files changed, 60 insertions(+), 25 deletions(-)

New commits:
commit 0ff90591d27330581da48badb2c5f1471d3aea27
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Mar 25 09:48:57 2015 +0100

    tdf#80822 Convert MM progress dialogs to modal
    
    The mail merge wizard is already modal to the source window. As
    long as the mail merge isn't finished, there is is no useable way
    to interact with the wizard. So make the progress window modal to
    the mail merge wizard to prevent the crashes when the user cancels
    the wizard while a mail merge is run.
    
    As the progress dialog can be triggered via UNO, the dialog has
    still has to be created as a non-modal floating window, when not
    called from the mail merge wizard.
    
    Change-Id: Ie8258323a0d396b40300d44bc0dea76385522847
    Reviewed-on: https://gerrit.libreoffice.org/14996
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index aa6117b..1ad4ad0 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -63,6 +63,10 @@ struct SwDBFormatData
     com::sun::star::lang::Locale aLocale;
 };
 
+namespace vcl {
+    class Window;
+}
+
 class SwView;
 class SwWrtShell;
 class SfxProgress;
@@ -211,7 +215,7 @@ friend class SwConnectionDisposedListener_Impl;
 
     /// merge to file _and_ merge to e-Mail
     SAL_DLLPRIVATE bool          MergeMailFiles(SwWrtShell* pSh,
-                                        const SwMergeDescriptor& rMergeDescriptor );
+                                        const SwMergeDescriptor& rMergeDescriptor, vcl::Window* pParent );
     SAL_DLLPRIVATE bool          ToNextRecord(SwDSParam* pParam);
 
 public:
@@ -236,7 +240,7 @@ public:
     inline void     SetMergeSilent( bool bVal )     { bMergeSilent = bVal; }
 
     /// Merging of data records into fields.
-    bool            MergeNew( const SwMergeDescriptor& rMergeDesc );
+    bool            MergeNew( const SwMergeDescriptor& rMergeDesc, vcl::Window* pParent = NULL );
     bool            Merge(SwWrtShell* pSh);
     void            MergeCancel();
 
diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index ced4c6e..9a577c4 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -282,7 +282,7 @@ void SwMailMergeWizard::CreateTargetDocument()
     aMergeDesc.pMailMergeConfigItem = &m_rConfigItem;
     aMergeDesc.bCreateSingleFile = true;
 
-    GetSwView()->GetWrtShell().GetDBManager()->MergeNew( aMergeDesc );
+    GetSwView()->GetWrtShell().GetDBManager()->MergeNew( aMergeDesc, this );
     m_rConfigItem.SetMergeDone();
     if( m_rConfigItem.GetTargetView() )
         m_rConfigItem.GetTargetView()->GetViewFrame()->GetFrame().Appear();
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx
index b31e6f1..dfcdbba 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -689,7 +689,7 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton)
         }
 
         SwView* pSourceView = rConfigItem.GetSourceView();
-        PrintMonitor aSaveMonitor(this, PrintMonitor::MONITOR_TYPE_SAVE);
+        PrintMonitor aSaveMonitor(this, false, PrintMonitor::MONITOR_TYPE_SAVE);
         aSaveMonitor.m_pDocName->SetText(pSourceView->GetDocShell()->GetTitle(22));
         aSaveMonitor.SetCancelHdl(LINK(this, SwMailMergeOutputPage, SaveCancelHdl_Impl));
         aSaveMonitor.m_pPrinter->SetText( INetURLObject( sPath ).getFSysPath( INetURLObject::FSYS_DETECT ) );
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index fa635d7..f246575 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -323,7 +323,7 @@ static bool lcl_GetColumnCnt(SwDSParam* pParam, const OUString& rColumnName,
 };
 
 // import data
-bool SwDBManager::MergeNew( const SwMergeDescriptor& rMergeDesc )
+bool SwDBManager::MergeNew( const SwMergeDescriptor& rMergeDesc, vcl::Window* pParent )
 {
     OSL_ENSURE(!bInMerge && !pImpl->pMergeData, "merge already activated!");
 
@@ -441,7 +441,7 @@ bool SwDBManager::MergeNew( const SwMergeDescriptor& rMergeDesc )
         case DBMGR_MERGE_SHELL:
             // save files and send them as e-Mail if required
             bRet = MergeMailFiles(&rMergeDesc.rSh,
-                    rMergeDesc);
+                    rMergeDesc, pParent);
             break;
 
         default:
@@ -813,7 +813,8 @@ static void lcl_SaveDoc( SfxObjectShell *xTargetDocShell,
 }
 
 bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
-                                 const SwMergeDescriptor& rMergeDescriptor)
+                                 const SwMergeDescriptor& rMergeDescriptor,
+                                 vcl::Window* pParent)
 {
     //check if the doc is synchronized and contains at least one linked section
     bool bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
@@ -941,14 +942,16 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
             bool bPageStylesWithHeaderFooter = false;
 
             vcl::Window *pSourceWindow = 0;
-            CancelableModelessDialog *pProgressDlg = 0;
+            CancelableDialog *pProgressDlg = 0;
 
             if (!IsMergeSilent()) {
                 pSourceWindow = &pSourceShell->GetView().GetEditWin();
+                if( ! pParent )
+                    pParent = pSourceWindow;
                 if( bMergeShell )
-                    pProgressDlg = new CreateMonitor( pSourceWindow );
+                    pProgressDlg = new CreateMonitor( pParent, pParent != pSourceWindow );
                 else {
-                    pProgressDlg = new PrintMonitor( pSourceWindow, PrintMonitor::MONITOR_TYPE_PRINT );
+                    pProgressDlg = new PrintMonitor( pParent, pParent != pSourceWindow, PrintMonitor::MONITOR_TYPE_PRINT );
                     static_cast<PrintMonitor*>( pProgressDlg )->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
                 }
                 pProgressDlg->SetCancelHdl( LINK(this, SwDBManager, PrtCancelHdl) );
diff --git a/sw/source/uibase/dbui/dbui.cxx b/sw/source/uibase/dbui/dbui.cxx
index 22e5070..fd94b28 100644
--- a/sw/source/uibase/dbui/dbui.cxx
+++ b/sw/source/uibase/dbui/dbui.cxx
@@ -22,8 +22,8 @@
 #include "dbui.hrc"
 #include "dbui.hxx"
 
-PrintMonitor::PrintMonitor(vcl::Window *pParent, PrintMonitorType eType )
-    : CancelableModelessDialog(pParent, "PrintMonitorDialog",
+PrintMonitor::PrintMonitor(vcl::Window *pParent, bool modal, PrintMonitorType eType )
+    : CancelableDialog(pParent, modal, "PrintMonitorDialog",
         "modules/swriter/ui/printmonitordialog.ui")
 {
     get(m_pDocName, "docname");
@@ -43,8 +43,8 @@ PrintMonitor::PrintMonitor(vcl::Window *pParent, PrintMonitorType eType )
 }
 
 // Progress Indicator for Creation of personalized Mail Merge documents:
-CreateMonitor::CreateMonitor( vcl::Window *pParent )
-    : CancelableModelessDialog(pParent, "MMCreatingDialog",
+CreateMonitor::CreateMonitor( vcl::Window *pParent, bool modal )
+    : CancelableDialog(pParent, modal, "MMCreatingDialog",
         "modules/swriter/ui/mmcreatingdialog.ui")
     , m_sCountingPattern()
     , m_sVariable_Total("%Y")
@@ -77,16 +77,36 @@ void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
     UpdateCountingText();
 }
 
-CancelableModelessDialog::CancelableModelessDialog( vcl::Window *pParent,
+CancelableDialog::CancelableDialog( vcl::Window *pParent, bool modal,
         const OUString& rID, const OUString& rUIXMLDescription )
-    : ModelessDialog( pParent , rID, rUIXMLDescription )
+    : Dialog( pParent , rID, rUIXMLDescription,
+              modal ? WINDOW_MODALDIALOG : WINDOW_MODELESSDIALOG )
+    , mbModal( modal )
 {
     get(m_pCancelButton, "cancel");
 }
 
-void CancelableModelessDialog::SetCancelHdl( const Link& rLink )
+CancelableDialog::~CancelableDialog()
+{
+    EndDialog( 0 );
+}
+
+void CancelableDialog::SetCancelHdl( const Link& rLink )
 {
     m_pCancelButton->SetClickHdl( rLink );
 }
 
+void CancelableDialog::Show()
+{
+   if (mbModal)
+       StartExecuteModal( LINK(this, CancelableDialog, DlgClosedHdl) );
+   else
+       Dialog::Show();
+}
+
+IMPL_LINK_NOARG(CancelableDialog, DlgClosedHdl)
+{
+    return 0;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/dbui.hxx b/sw/source/uibase/inc/dbui.hxx
index 265d03b..0649bcb9 100644
--- a/sw/source/uibase/inc/dbui.hxx
+++ b/sw/source/uibase/inc/dbui.hxx
@@ -24,19 +24,27 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 
-class SW_DLLPUBLIC CancelableModelessDialog : public ModelessDialog
+class SW_DLLPUBLIC CancelableDialog : public Dialog
 {
+    bool mbModal;
+
 protected:
     CancelButton* m_pCancelButton;
-    CancelableModelessDialog( vcl::Window *pParent, const OUString& rID,
-                              const OUString& rUIXMLDescription );
+    CancelableDialog( vcl::Window *pParent, bool modal, const OUString& rID,
+                      const OUString& rUIXMLDescription );
+
+    DECL_LINK(DlgClosedHdl, void *);
+
+    using Dialog::Execute;
+    using Dialog::StartExecuteModal;
 
 public:
-    virtual ~CancelableModelessDialog() {};
+    virtual ~CancelableDialog();
     void SetCancelHdl( const Link& rLink );
+    void Show();
 };
 
-class SW_DLLPUBLIC PrintMonitor: public CancelableModelessDialog
+class SW_DLLPUBLIC PrintMonitor: public CancelableDialog
 {
 public:
     enum PrintMonitorType
@@ -50,13 +58,13 @@ public:
     FixedText* m_pPrinter;
     FixedText* m_pPrintInfo;
 
-    PrintMonitor( vcl::Window *pParent, PrintMonitorType eType );
+    PrintMonitor( vcl::Window *pParent, bool modal, PrintMonitorType eType );
 };
 
-class CreateMonitor : public CancelableModelessDialog
+class CreateMonitor : public CancelableDialog
 {
 public:
-    CreateMonitor( vcl::Window *pParent );
+    CreateMonitor( vcl::Window *pParent, bool modal );
 
     void SetTotalCount( sal_Int32 nTotal );
     void SetCurrentPosition( sal_Int32 nCurrent );


More information about the Libreoffice-commits mailing list