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 3755c87d0426a499d4755e82d8fbc77caa240764 Author: Miklos Vajna <vmik...@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). Change-Id: I3e96f3068605fd6313dfb3e55483e1bce6c063a5 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 5ec8f9f..8ef83c1 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -396,6 +396,17 @@ DECLARE_WW8IMPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.doc") CPPUNIT_ASSERT_EQUAL( -50, int(data[0x6b4])); } +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 41bfc4f..4712493 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2720,9 +2720,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; @@ -2738,7 +2742,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 eb7e578..8754970 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1463,7 +1463,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, @@ -1513,7 +1513,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 c4ba4a9..324b85c 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -33,6 +33,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(); @@ -2276,7 +2277,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 @@ -2332,6 +2333,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) @@ -3264,7 +3268,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; @@ -3340,7 +3344,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 f41eafd..1ab57d5 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2291,7 +2291,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; @@ -2326,7 +2327,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, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits