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

Miklos Vajna vmiklos at collabora.co.uk
Mon May 26 08:31:31 PDT 2014


 sw/qa/extras/ww8import/data/bnc863018.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx      |   11 +++++++++++
 sw/source/filter/ww8/ww8par.cxx           |    8 ++++++--
 sw/source/filter/ww8/ww8par.hxx           |    4 ++--
 sw/source/filter/ww8/ww8par2.cxx          |   12 ++++++++----
 sw/source/filter/ww8/ww8par6.cxx          |   20 +++++++++++++++++++-
 6 files changed, 46 insertions(+), 9 deletions(-)

New commits:
commit 9d981abc3f310adf9af3454dd515ea356b31d3c1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 26 12:04:39 2014 +0200

    bnc#863018 WW8 import: fix upper margin of multi-page floating table
    
    A vert orient position was already handled in case a floating table was
    imported as a TextFrame, but in case we didn't do that, the vert orient
    position was simply lost.
    
    Fix this by importing it as the upper margin of the table (assuming that
    the position is relative from the anchor position).
    
    (cherry picked from commit 3755c87d0426a499d4755e82d8fbc77caa240764)
    
    Conflicts:
    	sw/qa/extras/ww8import/ww8import.cxx
    
    Change-Id: I3e96f3068605fd6313dfb3e55483e1bce6c063a5
    Reviewed-on: https://gerrit.libreoffice.org/9487
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/ww8import/data/bnc863018.doc b/sw/qa/extras/ww8import/data/bnc863018.doc
new file mode 100755
index 0000000..ab7511b
Binary files /dev/null and b/sw/qa/extras/ww8import/data/bnc863018.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 410b02b..dea54e5 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -259,6 +259,17 @@ DECLARE_WW8IMPORT_TEST(testCp1000039, "cp1000039.doc")
     CPPUNIT_ASSERT_EQUAL(sal_Int16(RTL_TEXTENCODING_DONTKNOW), getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharFontCharSet"));
 }
 
+DECLARE_WW8IMPORT_TEST(testBnc863018, "bnc863018.doc")
+{
+    // The problem was that there should be some whitespace above the table,
+    // but there wasn't.
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    // This was 0.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(5002), getProperty<sal_Int32>(xTable, "TopMargin"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 213e996..0725a9a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2726,9 +2726,13 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
             maApos[nInTable] = false;
         }
 
+        // So that SwWW8ImplReader::StartApo() can write into this, and
+        // WW8TabDesc::CreateSwTable() can read it, if necessary.
+        SvxULSpaceItem aULSpaceItem(RES_UL_SPACE);
+
         if (aApo.mbStartApo)
         {
-            maApos[nInTable] = StartApo(aApo, pTabPos);
+            maApos[nInTable] = StartApo(aApo, pTabPos, &aULSpaceItem);
             // We need an ReSync after StartApo
             // (actually only if the Apo extends past a FKP border)
             rbReSync = true;
@@ -2744,7 +2748,7 @@ bool SwWW8ImplReader::ProcessSpecial(bool &rbReSync, WW8_CP nStartCp)
 
             if(nInTable < nCellLevel)
             {
-                if (StartTable(nStartCp))
+                if (StartTable(nStartCp, &aULSpaceItem))
                     ++nInTable;
                 else
                     break;
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 28dca2e..772da4c 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1473,7 +1473,7 @@ private:
 
     WW8FlyPara *ConstructApo(const ApoTestResults &rApo,
         const WW8_TablePos *pTabPos);
-    bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
+    bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos, SvxULSpaceItem* pULSpaceItem = 0);
     void StopApo();
     bool TestSameApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
     ApoTestResults TestApo(int nCellLevel, bool bTableRowEnd,
@@ -1523,7 +1523,7 @@ private:
 
     void ReadDocVars();
 
-    bool StartTable(WW8_CP nStartCp);
+    bool StartTable(WW8_CP nStartCp, SvxULSpaceItem* pULSpaceItem = 0);
     bool InEqualApo(int nLvl) const;
     bool InLocalApo() const { return InEqualApo(nInTable); }
     bool InEqualOrHigherApo(int nLvl) const;
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index f94e055..fcb5b50 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -29,6 +29,7 @@
 #include <editeng/brushitem.hxx>
 #include <editeng/boxitem.hxx>
 #include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/hyphenzoneitem.hxx>
 #include <editeng/frmdiritem.hxx>
@@ -178,7 +179,7 @@ public:
 
     WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
     bool Ok() const { return bOk; }
-    void CreateSwTable();
+    void CreateSwTable(SvxULSpaceItem* pULSpaceItem = 0);
     void UseSwTable();
     void SetSizePosition(SwFrmFmt* pFrmFmt);
     void TableCellEnd();
@@ -2324,7 +2325,7 @@ void wwSectionManager::PrependedInlineNode(const SwPosition &rPos,
         maSegments.back().maStart = SwNodeIndex(rNode);
 }
 
-void WW8TabDesc::CreateSwTable()
+void WW8TabDesc::CreateSwTable(SvxULSpaceItem* pULSpaceItem)
 {
     ::SetProgressState(pIo->nProgress, pIo->mpDocShell);   // Update
 
@@ -2380,6 +2381,9 @@ void WW8TabDesc::CreateSwTable()
     if (!pTable || !pTable->GetFrmFmt())
         return;
 
+    if (pULSpaceItem && pULSpaceItem->GetUpper() != 0)
+        aItemSet.Put(*pULSpaceItem);
+
     SwTableNode* pTableNode = pTable->GetTableNode();
     OSL_ENSURE(pTableNode, "no table node!");
     if (pTableNode)
@@ -3319,7 +3323,7 @@ void WW8TabDesc::SetNumRuleName( const OUString& rName )
     aNumRuleNames[nCol] = rName;
 }
 
-bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
+bool SwWW8ImplReader::StartTable(WW8_CP nStartCp, SvxULSpaceItem* pULSpaceItem)
 {
     // Entering a table so make sure the FirstPara flag gets set
     bFirstPara = true;
@@ -3395,7 +3399,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
                    "Not the anchor type requested!" );
             MoveInsideFly(pTableDesc->pFlyFmt);
         }
-        pTableDesc->CreateSwTable();
+        pTableDesc->CreateSwTable(pULSpaceItem);
         if (pTableDesc->pFlyFmt)
         {
             pTableDesc->SetSizePosition(pTableDesc->pFlyFmt);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 43c93cd..066b8db 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2286,7 +2286,8 @@ bool SwWW8ImplReader::IsDropCap()
 }
 
 bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
-    const WW8_TablePos *pTabPos)
+    const WW8_TablePos *pTabPos,
+    SvxULSpaceItem* pULSpaceItem)
 {
     if (0 == (pWFlyPara = ConstructApo(rApo, pTabPos)))
         return false;
@@ -2321,7 +2322,24 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
         WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, false);
 
         if (pTabPos && pTabPos->bNoFly)
+        {
             pSFlyPara->pFlyFmt = 0;
+            if (pULSpaceItem)
+            {
+                // Word positioned tables can have a position (like a
+                // fly-frame), but they also support flowing accross multiple
+                // pages. If we decide to import this as a normal table (so it
+                // can flow accross multiple pages), then turn the vertical
+                // orientation position of the fly into a table upper margin.
+                const SfxPoolItem* pItem = 0;
+                if (aFlySet.HasItem(RES_VERT_ORIENT, &pItem))
+                {
+                    const SwFmtVertOrient* pOrient = static_cast<const SwFmtVertOrient*>(pItem);
+                    if (pOrient->GetPos() != 0)
+                        pULSpaceItem->SetUpper(pOrient->GetPos());
+                }
+            }
+        }
         else
         {
             pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,


More information about the Libreoffice-commits mailing list