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

Luboš Luňák l.lunak at collabora.com
Mon Jul 21 02:02:35 PDT 2014


 sw/qa/extras/ooxmlimport/data/floating-table-section-columns.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                          |    7 +++
 sw/qa/extras/ww8import/data/floating-table-section-columns.doc    |binary
 sw/qa/extras/ww8import/data/floating-table-section-margins.doc    |binary
 sw/qa/extras/ww8import/ww8import.cxx                              |   19 ++++++++++
 sw/source/filter/ww8/ww8par.cxx                                   |    4 ++
 sw/source/filter/ww8/ww8par6.cxx                                  |    4 +-
 writerfilter/source/dmapper/PropertyMap.cxx                       |    4 +-
 writerfilter/source/dmapper/PropertyMap.hxx                       |    1 
 9 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit c5ed52b1cd6f22787c94bec035ceecf9e1da3271
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Mon Jul 21 10:56:52 2014 +0200

    ww8import create a pagedesc if continuous section changes margins (bnc#875383)
    
    This is similar to what writerfilter does. MSWord can have one page with several
    different margins, which are saved using continuous sections, which causes all
    kinds of trouble, because either we treat them as Writer sections, which means
    we lose some of the data, or we treat them as Writer page styles, which causes
    spurious page breaks if in the wrong place. Either option has its problems, but
    here it seems slightly better to go for keeping the data and hoping the page
    break will be in a place where a break will be anyway.
    
    Change-Id: I8f52aa820750da6788ea04180a15ac334f6bf87b

diff --git a/sw/qa/extras/ww8import/data/floating-table-section-margins.doc b/sw/qa/extras/ww8import/data/floating-table-section-margins.doc
new file mode 100644
index 0000000..f414be7
Binary files /dev/null and b/sw/qa/extras/ww8import/data/floating-table-section-margins.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index a5f3a8c..fe4a8fc 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -34,6 +34,18 @@ public:
 
 #define DECLARE_WW8IMPORT_TEST(TestName, filename) DECLARE_SW_IMPORT_TEST(TestName, filename, Test)
 
+DECLARE_WW8IMPORT_TEST(testFloatingTableSectionMargins, "floating-table-section-margins.doc")
+{
+    sal_Int32 pageLeft = parseDump("/root/page[2]/infos/bounds", "left").toInt32();
+    sal_Int32 pageWidth = parseDump("/root/page[2]/infos/bounds", "width").toInt32();
+    sal_Int32 tableLeft = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "left").toInt32();
+    sal_Int32 tableWidth = parseDump("/root/page[2]/body/column/body/section/column/body/txt[2]/anchored/fly/tab/infos/bounds", "width").toInt32();
+    CPPUNIT_ASSERT( pageWidth > 0 );
+    CPPUNIT_ASSERT( tableWidth > 0 );
+    // The table's resulting position should be roughly centered.
+    CPPUNIT_ASSERT( abs(( pageLeft + pageWidth / 2 ) - ( tableLeft + tableWidth / 2 )) < 20 );
+}
+
 DECLARE_WW8IMPORT_TEST(testN757910, "n757910.doc")
 {
     // The internal margin was larger than 0.28cm
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 56c184d..0906232 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4440,6 +4440,10 @@ void wwSectionManager::InsertSegments()
 
         bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() &&  bThisAndPreviousAreCompatible;
         bool bInsertPageDesc = !bInsertSection;
+        // HACK Force new pagedesc if margins change, otherwise e.g. floating tables may be anchored improperly.
+        if( aIter->maSep.dyaTop != aPrev->maSep.dyaTop || aIter->maSep.dyaBottom != aPrev->maSep.dyaBottom
+            || aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
+            bInsertPageDesc = true;
         bool bProtected = SectionIsProtected(*aIter); // do we really  need this ?? I guess I have a different logic in editshell which disables this...
         if (bUseEnhFields && mrReader.pWDop->fProtEnabled && aIter->IsNotProtected())
         {
commit 2aa6589aa5bbcd7cd74b33b81e431fb6837a2458
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Mon Jul 7 13:56:02 2014 +0200

    fix floating table over section with several columns (part of bnc#875383)
    
    Change-Id: Ic6e75cc2cedb61754b45bc4678a1185f580d5ed6

diff --git a/sw/qa/extras/ooxmlimport/data/floating-table-section-columns.docx b/sw/qa/extras/ooxmlimport/data/floating-table-section-columns.docx
new file mode 100644
index 0000000..50bb7ac
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/floating-table-section-columns.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 061c393..a8c0936 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2290,6 +2290,13 @@ DECLARE_OOXMLIMPORT_TEST(testUnbalancedColumnsCompat, "unbalanced-columns-compat
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-columns.docx")
+{
+    OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width");
+    // table width was restricted by a column
+    CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ww8import/data/floating-table-section-columns.doc b/sw/qa/extras/ww8import/data/floating-table-section-columns.doc
new file mode 100644
index 0000000..6471ded
Binary files /dev/null and b/sw/qa/extras/ww8import/data/floating-table-section-columns.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 354e555..a5f3a8c 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -485,6 +485,13 @@ DECLARE_WW8IMPORT_TEST(testFdo81102, "fdo81102.doc")
     CPPUNIT_ASSERT(!headerIsShared);
 }
 
+DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-columns.doc")
+{
+    OUString tableWidth = parseDump("/root/page[1]/body/section/column[2]/body/txt/anchored/fly/tab/infos/bounds", "width");
+    // table width was restricted by a column
+    CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 08e216f..750dad7 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -4953,7 +4953,9 @@ bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap)
         // If the table is wider than the text area, then don't create a fly
         // for the table: no wrapping will be performed anyway, but multi-page
         // tables will be broken.
-        pTabPos->bNoFly = nTableWidth >= nTextAreaWidth;
+        // If there are columns, do create a fly, as the flow of the columns
+        // would otherwise restrict the table.
+        pTabPos->bNoFly = nTableWidth >= nTextAreaWidth  && maSectionManager.CurrentSectionColCount() < 2;
     }
     return bRet;
 }
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 3ec36cd..f3d93f8 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -913,8 +913,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
         // tables will be broken.
         // If the position is relative to the edge of the page, then we always
         // create the fly.
+        // If there are columns, always create the fly, otherwise the columns would
+        // restrict geometry of the table.
         if ( ( rInfo.getPropertyValue("HoriOrientRelation") == text::RelOrientation::PAGE_FRAME ) ||
-             ( rInfo.m_nTableWidth < nTextAreaWidth ) )
+             ( rInfo.m_nTableWidth < nTextAreaWidth ) || ColumnCount() + 1 >= 2 )
             xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties);
     }
     rPendingFloatingTables.clear();
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 98e4a1f..cbefc97 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -239,6 +239,7 @@ public:
     void SetBorderParams( sal_Int32 nSet ) { m_nBorderParams = nSet; }
 
     void SetColumnCount( sal_Int16 nCount ) { m_nColumnCount = nCount; }
+    sal_Int16 ColumnCount() const { return m_nColumnCount; }
     void SetColumnDistance( sal_Int32 nDist ) { m_nColumnDistance = nDist; }
     void AppendColumnWidth( sal_Int32 nWidth ) { m_aColWidth.push_back( nWidth ); }
     void AppendColumnSpacing( sal_Int32 nDist ) {m_aColDistance.push_back( nDist ); }


More information about the Libreoffice-commits mailing list