Kaydet (Commit) 3755c87d authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 09c0a96e
This diff was suppressed by a .gitattributes entry.
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment