summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-09-01 20:37:51 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-09-23 23:25:49 +0200
commit260cd3aeea2d02507dd131ee2028c4f48f7562f8 (patch)
treecefc4785f11746e77ba6353e3e0bc67cde4fc56a /sw/source/uibase
parent178a23a827f16e046e5d5efb2aa2aa3fc990452a (diff)
MM account next record fields for progress dialog
When calculating the maximum document count, we were not accounting "next record" fields in the document, like in labels etc. Also any selection of records was ignored. Fixes accounting part of tdf#101841. Change-Id: I703d2186d44d2e5426c4af0d4b2d89e0fe820039
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx39
1 files changed, 30 insertions, 9 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 238f62d2e536..ff90ea629dba 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -178,10 +178,14 @@ static SfxObjectShell* lcl_CreateWorkingDocument(
SwDBManager** const pDBManager,
SwView** const pView, SwWrtShell** const pWrtShell, SwDoc** const pDoc );
-static bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<sdbc::XResultSet>& xResultSet )
+static bool lcl_getCountFromResultSet( sal_Int32& rCount, const SwDSParam* pParam )
{
- uno::Reference<beans::XPropertySet> xPrSet(xResultSet, uno::UNO_QUERY);
- if(xPrSet.is())
+ rCount = pParam->aSelection.getLength();
+ if ( rCount > 0 )
+ return true;
+
+ uno::Reference<beans::XPropertySet> xPrSet(pParam->xResultSet, uno::UNO_QUERY);
+ if ( xPrSet.is() )
{
try
{
@@ -190,8 +194,8 @@ static bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<s
aFinal >>= bFinal;
if(!bFinal)
{
- xResultSet->last();
- xResultSet->first();
+ pParam->xResultSet->last();
+ pParam->xResultSet->first();
}
uno::Any aCount = xPrSet->getPropertyValue("RowCount");
if( aCount >>= rCount )
@@ -1264,16 +1268,33 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
}
sal_Int32 nDocNo = 1;
- sal_Int32 nDocCount = 0;
+
// For single file mode, the number of pages in the target document so far, which is used
// by AppendDoc() to adjust position of page-bound objects. Getting this information directly
// from the target doc would require repeated layouts of the doc, which is expensive, but
// it can be manually computed from the source documents (for which we do layouts, so the page
// count is known, and there is a blank page between each of them in the target document).
int targetDocPageCount = 0;
- if( !bIsMergeSilent && !bMT_PRINTER &&
- lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
- static_cast<CreateMonitor*>( pProgressDlg.get() )->SetTotalCount( nDocCount );
+
+ if( !bIsMergeSilent && !bMT_PRINTER )
+ {
+ sal_Int32 nRecordCount = 1;
+ lcl_getCountFromResultSet( nRecordCount, pImpl->pMergeData );
+
+ // syncronized docs don't auto-advance the record set, but there is a
+ // "security" check, which will always advance the record set, if there
+ // is no "next record" field in a synchronized doc => nRecordPerDoc > 0
+ sal_Int32 nRecordPerDoc = pSourceShell->GetDoc()
+ ->getIDocumentFieldsAccess().GetRecordsPerDocument();
+ if ( bSynchronizedDoc && (nRecordPerDoc > 1) )
+ --nRecordPerDoc;
+ assert( nRecordPerDoc > 0 );
+
+ sal_Int32 nMaxDocs = nRecordCount / nRecordPerDoc;
+ if ( 0 != nRecordCount % nRecordPerDoc )
+ nMaxDocs += 1;
+ static_cast<CreateMonitor*>( pProgressDlg.get() )->SetTotalCount( nMaxDocs );
+ }
long nStartRow, nEndRow;
bool bFreezedLayouts = false;