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

Jan-Marek Glogowski glogow at fbihome.de
Wed Nov 20 10:03:35 PST 2013


 sw/source/core/inc/rootfrm.hxx   |    4 ++++
 sw/source/core/layout/newfrm.cxx |    4 +++-
 sw/source/ui/dbui/dbmgr.cxx      |   21 +++++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 13a8fac05425f9d66c643f25faa49c1f17c62474
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Wed Nov 20 10:39:49 2013 +0100

    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 at canonical.com>
    Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 32bc022..a011d2e 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 20a8d24..62355e6 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 6b54023..c1ab684 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


More information about the Libreoffice-commits mailing list