[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa sw/source

Luboš Luňák l.lunak at collabora.com
Mon Aug 18 02:25:59 PDT 2014


 sw/qa/extras/ww8import/data/bnc787942.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx      |    6 ++++++
 sw/source/filter/ww8/ww8par.hxx           |    2 ++
 sw/source/filter/ww8/ww8par6.cxx          |   14 +++++++++++++-
 4 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 8d7354156aa4fe672766d5dba364037b66cb3435
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Sun Aug 17 18:12:16 2014 +0200

    fix reading a .doc that has frame anchored to the end of page (bnc#787942)
    
    MSWord, unlike Writer, can anchor even to a page break (i.e. after the last
    paragraph). When this document was read, what happended was:
    - the last paragraph was read and the current position PaM was set to point
      after it
    - frame was read and anchored to the PaM
    - page break was read, making everything following be moved to the next page;
      including whatever ended up at the PaM position
    Handle this by checking for this case and inserting an extra empty paragraph
    before the break. This shouldn't affect layout of the page itself anyway,
    since the break should leave room for it (and MSWord shows a page break
    there if control characters are enabled, so there is room).
    
    (cherry picked from commit 4a1888a97eab4ead2e0bec76cd1cba410a8e7e13)
    
    Conflicts:
    	sw/qa/extras/ww8import/ww8import.cxx
    
    Change-Id: Ia2a13bf5cf1c959b5aa228254365019a00a22679
    Reviewed-on: https://gerrit.libreoffice.org/10951
    Reviewed-by: Matúš Kukan <matus.kukan at collabora.com>
    Tested-by: Matúš Kukan <matus.kukan at collabora.com>

diff --git a/sw/qa/extras/ww8import/data/bnc787942.doc b/sw/qa/extras/ww8import/data/bnc787942.doc
new file mode 100644
index 0000000..06b2c39
Binary files /dev/null and b/sw/qa/extras/ww8import/data/bnc787942.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 33e0cfb..81b0043 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -490,6 +490,12 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-
     CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
 }
 
+DECLARE_WW8IMPORT_TEST(testBnc787942, "bnc787942.doc")
+{
+    // The frame ended up on the second page instead of first.
+    parseDump("/root/page[1]/body/txt[4]/anchored");
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 99b5de2..0acfdb8 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1345,6 +1345,8 @@ private:
     // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
     SwPaM* mpPosAfterTOC;
 
+    boost::scoped_ptr< SwPosition > lastAnchorPos;
+
     bool mbCareFirstParaEndInToc;
     bool mbCareLastParaEndInToc;
     cp_set maTOXEndCps;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 6942f88..5e7ce09 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -794,6 +794,18 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/)
     if (!pSep)
         return;
 
+    if (!maSegments.empty() && mrReader.lastAnchorPos.get() && *mrReader.lastAnchorPos == *mrReader.pPaM->GetPoint())
+    {
+        bool insert = true;
+        SwPaM pam( *mrReader.lastAnchorPos );
+        if( pam.Move(fnMoveBackward, fnGoNode))
+            if( SwTxtNode* txtNode = pam.GetPoint()->nNode.GetNode().GetTxtNode())
+                if( txtNode->Len() == 0 )
+                    insert = false;
+        if( insert )
+            mrReader.AppendTxtNode(*mrReader.pPaM->GetPoint());
+    }
+
     ww::WordVersion eVer = mrReader.GetFib().GetFIBVersion();
 
     // M.M. Create a linked section if the WkbPLCF
@@ -1735,7 +1747,6 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
                             const sal_Int32 nIniFlyDx,
                             const sal_Int32 nIniFlyDy )
 {
-    (void) rPaM;
     (void) nPgLeft;
 
     memset( this, 0, sizeof( WW8SwFlyPara ) );  // Initialisieren
@@ -1803,6 +1814,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
     //#i53725# - absolute positioned objects have to be
     // anchored at-paragraph to assure its correct anchor position.
     eAnchor = FLY_AT_PARA;
+    rIo.lastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
 
     switch (nYBind)
     {


More information about the Libreoffice-commits mailing list