summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2014-07-29 15:36:51 +0200
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2014-09-24 16:05:06 +0000
commitbc998e5e2cf43678462c8d7da8a9d6b1425ec492 (patch)
tree5b28d6b64a84626f7b590cfdd8dd672284b2eba9 /sw
parent36ac7749523e0c6f40a77beac278bd9e7a667a9b (diff)
MM: readd CreateMonitor handling
The mail merge wizard uses a different progress dialog (CreateDialog) then the UNO functions (PrintDialog). This restores the previously unused code and unifies some of the dialog handling. This reverts the dbmgr / mail merge unused code parts of commit d49d0139a7f4b9835a2179b6dcc6741a41b0197c and commit c16f45db0ea20db6ca3906551c01fb18f9258c84 Change-Id: I06088140f604893a33f3ee37507e551b043a193d Reviewed-on: https://gerrit.libreoffice.org/10985 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx93
-rw-r--r--sw/source/uibase/dbui/dbui.cxx35
-rw-r--r--sw/source/uibase/inc/dbui.hxx21
-rw-r--r--sw/uiconfig/swriter/ui/mmcreatingdialog.ui116
4 files changed, 247 insertions, 18 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index d89ffaf1bc71..91875ddbdb0b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -168,6 +168,31 @@ const sal_Char cActiveConnection[] = "ActiveConnection";
namespace
{
+bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultSet>& xResultSet )
+{
+ uno::Reference<XPropertySet> xPrSet(xResultSet, UNO_QUERY);
+ if(xPrSet.is())
+ {
+ try
+ {
+ bool bFinal = false;
+ Any aFinal = xPrSet->getPropertyValue("IsRowCountFinal");
+ aFinal >>= bFinal;
+ if(!bFinal)
+ {
+ xResultSet->last();
+ xResultSet->first();
+ }
+ Any aCount = xPrSet->getPropertyValue("RowCount");
+ if( aCount >>= rCount )
+ return true;
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return false;
+}
// copy compatibility options
void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
{
@@ -829,9 +854,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
//check if the doc is synchronized and contains at least one linked section
bool bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
bool bNoError = true;
- bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
+ const bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
- bool bMergeOnly = rMergeDescriptor.nMergeType == DBMGR_MERGE_ONLY;
+ const bool bMergeOnly = rMergeDescriptor.nMergeType == DBMGR_MERGE_ONLY;
::rtl::Reference< MailDispatcher > xMailDispatcher;
OUString sBodyMimeType;
@@ -910,6 +935,24 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
sal_uInt16 nStartingPageNo = 0;
bool bPageStylesWithHeaderFooter = false;
+ vcl::Window *pSourceWindow = 0;
+ CancelableModelessDialog *pProgressDlg = 0;
+
+ if (!IsMergeSilent()) {
+ pSourceWindow = &pSourceShell->GetView().GetEditWin();
+ if( bMergeOnly )
+ pProgressDlg = new CreateMonitor( pSourceWindow );
+ else {
+ pProgressDlg = new PrintMonitor( pSourceWindow, PrintMonitor::MONITOR_TYPE_PRINT );
+ static_cast<PrintMonitor*>( pProgressDlg )->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
+ }
+ pProgressDlg->SetCancelHdl( LINK(this, SwDBManager, PrtCancelHdl) );
+ pProgressDlg->Show();
+
+ for( sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+ }
+
if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
{
// create a target docshell to put the merged document into
@@ -919,6 +962,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
#endif
SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
+ if (bMergeOnly) {
+ //the created window has to be located at the same position as the source window
+ vcl::Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow();
+ rTargetWindow.SetPosPixel(pSourceWindow->GetPosPixel());
+ }
pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
@@ -948,13 +996,6 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
}
- PrintMonitor aPrtMonDlg(&pSourceShell->GetView().GetEditWin(), PrintMonitor::MONITOR_TYPE_PRINT);
- aPrtMonDlg.m_pDocName->SetText(pSourceShell->GetView().GetDocShell()->GetTitle(22));
-
- aPrtMonDlg.SetCancelHdl(LINK(this, SwDBManager, PrtCancelHdl));
- if (!IsMergeSilent())
- aPrtMonDlg.Show();
-
// Progress, to prohibit KeyInputs
SfxProgress aProgress(pSourceDocSh, ::aEmptyOUStr, 1);
@@ -965,7 +1006,12 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
pViewFrm->GetDispatcher()->Lock(true);
pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourceDocSh);
}
+
sal_uLong nDocNo = 1;
+ sal_Int32 nDocCount = 0;
+ if( !IsMergeSilent() && bMergeOnly &&
+ lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
+ static_cast<CreateMonitor*>( pProgressDlg )->SetTotalCount( nDocCount );
long nStartRow, nEndRow;
bool bFreezedLayouts = false;
@@ -1017,14 +1063,22 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
else
{
INetURLObject aTempFileURL(aTempFile->GetURL());
- aPrtMonDlg.m_pPrinter->SetText( aTempFileURL.GetBase() );
- OUString sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
- sStat += " ";
- sStat += OUString::number( nDocNo );
- aPrtMonDlg.m_pPrintInfo->SetText(sStat);
-
- // computation time for Save-Monitor:
- for (sal_uInt16 i = 0; i < 25; i++)
+ if (!IsMergeSilent()) {
+ if( bMergeOnly )
+ static_cast<CreateMonitor*>( pProgressDlg )->SetCurrentPosition( nDocNo );
+ else {
+ PrintMonitor *pPrintMonDlg = static_cast<PrintMonitor*>( pProgressDlg );
+ pPrintMonDlg->m_pPrinter->SetText( aTempFileURL.GetBase() );
+ OUString sStat(SW_RES(STR_STATSTR_LETTER)); // Brief
+ sStat += " ";
+ sStat += OUString::number( nDocNo );
+ pPrintMonDlg->m_pPrintInfo->SetText( sStat );
+ }
+ pProgressDlg->Update();
+ }
+
+ // Computation time for the GUI
+ for( sal_uInt16 i = 0; i < 25; i++ )
Application::Reschedule();
// The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here
@@ -1250,6 +1304,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+ for( sal_uInt16 i = 0; i < 25; i++)
+ Application::Reschedule();
+
// Unfreeze target document layouts and correct all PageDescs.
if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
{
@@ -1259,7 +1316,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));
}
- aPrtMonDlg.Show( false );
+ DELETEZ( pProgressDlg );
// save the single output document
if (bMergeOnly)
diff --git a/sw/source/uibase/dbui/dbui.cxx b/sw/source/uibase/dbui/dbui.cxx
index 677bf8836e6f..80728ef2c595 100644
--- a/sw/source/uibase/dbui/dbui.cxx
+++ b/sw/source/uibase/dbui/dbui.cxx
@@ -42,6 +42,41 @@ PrintMonitor::PrintMonitor(vcl::Window *pParent, PrintMonitorType eType )
m_pPrinting->Show();
}
+// Progress Indicator for Creation of personalized Mail Merge documents:
+CreateMonitor::CreateMonitor( vcl::Window *pParent )
+ : CancelableModelessDialog(pParent, "MMCreatingDialog",
+ "modules/swriter/ui/mmcreatingdialog.ui")
+ , m_sCountingPattern()
+ , m_sVariable_Total("%Y")
+ , m_sVariable_Position("%X")
+ , m_nTotalCount(0)
+ , m_nCurrentPosition(0)
+{
+ get(m_pCounting, "progress");
+ m_sCountingPattern = m_pCounting->GetText();
+ m_pCounting->SetText("...");
+}
+
+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);
+}
+
+void CreateMonitor::SetTotalCount( sal_Int32 nTotal )
+{
+ m_nTotalCount = nTotal;
+ UpdateCountingText();
+}
+
+void CreateMonitor::SetCurrentPosition( sal_Int32 nCurrent )
+{
+ m_nCurrentPosition = nCurrent;
+ UpdateCountingText();
+}
+
CancelableModelessDialog::CancelableModelessDialog( vcl::Window *pParent,
const OString& rID, const OUString& rUIXMLDescription )
: ModelessDialog( pParent , rID, rUIXMLDescription )
diff --git a/sw/source/uibase/inc/dbui.hxx b/sw/source/uibase/inc/dbui.hxx
index ed1e65b3bc47..fdf50d0a9ad4 100644
--- a/sw/source/uibase/inc/dbui.hxx
+++ b/sw/source/uibase/inc/dbui.hxx
@@ -53,6 +53,27 @@ public:
PrintMonitor( vcl::Window *pParent, PrintMonitorType eType );
};
+class CreateMonitor : public CancelableModelessDialog
+{
+public:
+ CreateMonitor( vcl::Window *pParent );
+
+ void SetTotalCount( sal_Int32 nTotal );
+ void SetCurrentPosition( sal_Int32 nCurrent );
+
+private:
+ void UpdateCountingText();
+
+private:
+ FixedText* m_pCounting;
+
+ OUString m_sCountingPattern;
+ OUString m_sVariable_Total;
+ OUString m_sVariable_Position;
+ sal_Int32 m_nTotalCount;
+ sal_Int32 m_nCurrentPosition;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/uiconfig/swriter/ui/mmcreatingdialog.ui b/sw/uiconfig/swriter/ui/mmcreatingdialog.ui
new file mode 100644
index 000000000000..6572c8ce965c
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/mmcreatingdialog.ui
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkDialog" id="MMCreatingDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Mail Merge</property>
+ <property name="type_hint">dialog</property>
+ <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="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Status:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Progress:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Creating documents...</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="progress">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">%X of %Y</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>