summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2013-11-20 10:39:49 +0100
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2013-11-20 12:03:16 -0600
commit13a8fac05425f9d66c643f25faa49c1f17c62474 (patch)
tree9991e3914b9d306eb285cfc48c15865abca196e7
parent73c5e9824690b2fc38976d5e53e1fd10a16dc47b (diff)
Freeze layout / page format normalization.
For single-file mail merge this skips the page format normalization, which would be run during each document / page append. Instead the normalization / checks are run for the whole document at the end of the generation, changing this code from O(n2) to O(n). This way each mail merge generated document uses the same time, because the target document isn't completely traversed for each page change. With my test document this produces the same output, save some changed internal document IDs. This fixes fdo#56355. Change-Id: Ia779705cfb107383341f946542d28434c986591a Reviewed-on: https://gerrit.libreoffice.org/6733 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r--sw/source/core/inc/rootfrm.hxx4
-rw-r--r--sw/source/core/layout/newfrm.cxx4
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx21
3 files changed, 28 insertions, 1 deletions
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 32bc02285729..a011d2ea57e7 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -86,6 +86,7 @@ class SwRootFrm: public SwLayoutFrm
sal_Bool bIsNewLayout :1; //Layout geladen oder neu erzeugt.
sal_Bool bCallbackActionEnabled:1; //Keine Action in Benachrichtung erwuenscht
//siehe dcontact.cxx, ::Changed()
+ bool bLayoutFreezed;
//Fuer den BrowseMode. nBrowseWidth ist die Aeussere Kante des am weitesten
//rechts stehenden Objectes. Die rechte Kante der Seiten soll im BrowseMode
@@ -351,6 +352,9 @@ public:
bool IsLeftToRightViewLayout() const;
const SwRect& GetPagesArea() const { return maPagesArea; }
void SetSidebarChanged() { mbSidebarChanged = true; }
+
+ bool IsLayoutFreezed() const { return bLayoutFreezed; }
+ void FreezeLayout( bool freeze ) { bLayoutFreezed = freeze; }
};
inline long SwRootFrm::GetBrowseWidth() const
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 20a8d246f6ae..62355e6d27e9 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -480,6 +480,7 @@ SwRootFrm::SwRootFrm( SwFrmFmt *pFmt, SwViewShell * pSh ) :
bIsVirtPageNum( false ),
bIsNewLayout( true ),
bCallbackActionEnabled ( false ),
+ bLayoutFreezed ( false ),
nBrowseWidth( MM50*4 ), //2cm minimum
pTurbo( 0 ),
pLastPage( 0 ),
@@ -659,7 +660,8 @@ void SwRootFrm::RemoveMasterObjs( SdrPage *pPg )
void SwRootFrm::AllCheckPageDescs() const
{
- CheckPageDescs( (SwPageFrm*)this->Lower() );
+ if ( !IsLayoutFreezed() )
+ CheckPageDescs( (SwPageFrm*)this->Lower() );
}
void SwRootFrm::AllInvalidateAutoCompleteWords() const
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 6b54023923b4..c1ab684951e6 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -124,6 +124,7 @@
#include <vector>
#include <unomid.h>
#include <section.hxx>
+#include <rootfrm.hxx>
using namespace ::osl;
using namespace ::svx;
@@ -968,6 +969,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
sal_uLong nDocNo = 1;
long nStartRow, nEndRow;
+ bool bFreezedLayouts = false;
// collect temporary files
::std::vector< OUString> aFilesToRemove;
do
@@ -1235,9 +1237,28 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
}
nDocNo++;
nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0;
+
+ // Freeze the layouts of the target document after the first inserted
+ // sub-document, to get the correct PageDesc.
+ if(!bFreezedLayouts && (rMergeDescriptor.bCreateSingleFile || bAsSingleFile))
+ {
+ std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
+ ::std::bind2nd(::std::mem_fun(&SwRootFrm::FreezeLayout), true));
+ bFreezedLayouts = true;
+ }
} while( !bCancel &&
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
+ // Unfreeze target document layouts and correct all PageDescs.
+ if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+ {
+ std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
+ ::std::bind2nd(::std::mem_fun(&SwRootFrm::FreezeLayout), false));
+ std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));
+ }
+
aPrtMonDlg.Show( sal_False );
// save the single output document