Kaydet (Commit) 7d60c076 authored tarafından Caolán McNamara's avatar Caolán McNamara

fix crash on export of ooo67471-2.sxw to docx

This old-school table has three rows in it, but the second row is of 0 height
so is indistinguisable from the third row by layout positioning, so the
WW8TableNodeInfo view of the table is that it has two rows, and the comparison
of being on the last row is done with the m_xTableWrt->GetRows view which
considers it to have 3, so the table end marks are never output.

add a new finalEndOfLine property that the WW8TableNodeInfo sets on the last
end of row of the table as it sees it, which should resolve this.

old style tables are a cess pit, which is why they were replaced

Change-Id: I996aa59a338a594487f49ec0f228af3fb3032d15
(cherry picked from commit 6f9b3532)
üst c34014b9
...@@ -825,6 +825,12 @@ DECLARE_OOXMLEXPORT_TEST(testOO47778_2, "ooo47778-4.odt") ...@@ -825,6 +825,12 @@ DECLARE_OOXMLEXPORT_TEST(testOO47778_2, "ooo47778-4.odt")
assertXPathContent(pXmlDoc, "(//w:t)[4]", "c"); assertXPathContent(pXmlDoc, "(//w:t)[4]", "c");
} }
DECLARE_OOXMLEXPORT_TEST(testOO67471, "ooo67471-2.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
assertXPathContent(pXmlDoc, "(//w:t)[2]", "B");
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -58,6 +58,7 @@ class WW8TableNodeInfoInner ...@@ -58,6 +58,7 @@ class WW8TableNodeInfoInner
sal_uInt32 mnShadowsBefore; sal_uInt32 mnShadowsBefore;
sal_uInt32 mnShadowsAfter; sal_uInt32 mnShadowsAfter;
bool mbEndOfLine; bool mbEndOfLine;
bool mbFinalEndOfLine;
bool mbEndOfCell; bool mbEndOfCell;
bool mbFirstInTable; bool mbFirstInTable;
bool mbVertMerge; bool mbVertMerge;
...@@ -77,10 +78,11 @@ public: ...@@ -77,10 +78,11 @@ public:
void setShadowsBefore(sal_uInt32 nShadowsBefore); void setShadowsBefore(sal_uInt32 nShadowsBefore);
void setShadowsAfter(sal_uInt32 nShadowsAfter); void setShadowsAfter(sal_uInt32 nShadowsAfter);
void setEndOfLine(bool bEndOfLine); void setEndOfLine(bool bEndOfLine);
void setFinalEndOfLine(bool bEndOfLine);
void setEndOfCell(bool bEndOfCell); void setEndOfCell(bool bEndOfCell);
void setFirstInTable(bool bFirstInTable); void setFirstInTable(bool bFirstInTable);
void setVertMerge(bool bVertMErge); void setVertMerge(bool bVertMerge);
void setTableBox(const SwTableBox * pTableBox); void setTableBox(const SwTableBox *pTableBox);
void setTable(const SwTable * pTable); void setTable(const SwTable * pTable);
void setRect(const SwRect & rRect); void setRect(const SwRect & rRect);
...@@ -91,6 +93,7 @@ public: ...@@ -91,6 +93,7 @@ public:
sal_uInt32 getShadowsAfter() const { return mnShadowsAfter;} sal_uInt32 getShadowsAfter() const { return mnShadowsAfter;}
bool isEndOfCell() const { return mbEndOfCell;} bool isEndOfCell() const { return mbEndOfCell;}
bool isEndOfLine() const { return mbEndOfLine;} bool isEndOfLine() const { return mbEndOfLine;}
bool isFinalEndOfLine() const { return mbFinalEndOfLine;}
bool isFirstInTable() const { return mbFirstInTable;} bool isFirstInTable() const { return mbFirstInTable;}
bool isVertMerge() const; bool isVertMerge() const;
const SwTableBox * getTableBox() const { return mpTableBox;} const SwTableBox * getTableBox() const { return mpTableBox;}
...@@ -156,6 +159,9 @@ public: ...@@ -156,6 +159,9 @@ public:
typedef ::std::multiset<CellInfo, ::std::less<CellInfo> > CellInfoMultiSet; typedef ::std::multiset<CellInfo, ::std::less<CellInfo> > CellInfoMultiSet;
typedef boost::shared_ptr<CellInfoMultiSet> CellInfoMultiSetPtr; typedef boost::shared_ptr<CellInfoMultiSet> CellInfoMultiSetPtr;
typedef ::std::map<sal_uInt32, WW8TableNodeInfoInner*,
::std::greater<sal_uInt32> > RowEndInners_t;
class WW8TableInfo; class WW8TableInfo;
class WW8TableNodeInfo class WW8TableNodeInfo
...@@ -278,7 +284,7 @@ public: ...@@ -278,7 +284,7 @@ public:
void insert(const SwRect & rRect, WW8TableNodeInfo * pNodeInfo, void insert(const SwRect & rRect, WW8TableNodeInfo * pNodeInfo,
unsigned long * pFormatFrmWidth = NULL); unsigned long * pFormatFrmWidth = NULL);
void addShadowCells(); void addShadowCells();
WW8TableNodeInfo * connectCells(); WW8TableNodeInfo *connectCells(RowEndInners_t &rLastRowEnds);
#ifdef DBG_UTIL #ifdef DBG_UTIL
::std::string toString(); ::std::string toString();
...@@ -305,14 +311,15 @@ class WW8TableInfo ...@@ -305,14 +311,15 @@ class WW8TableInfo
processTableLine(const SwTable * pTable, processTableLine(const SwTable * pTable,
const SwTableLine * pTableLine, const SwTableLine * pTableLine,
sal_uInt32 nRow, sal_uInt32 nRow,
sal_uInt32 nDepth, WW8TableNodeInfo * pPrev); sal_uInt32 nDepth, WW8TableNodeInfo * pPrev, RowEndInners_t &rLastRowEnds);
WW8TableNodeInfo * WW8TableNodeInfo *
processTableBox(const SwTable * pTable, processTableBox(const SwTable * pTable,
const SwTableBox * pTableBox, const SwTableBox * pTableBox,
sal_uInt32 nRow, sal_uInt32 nRow,
sal_uInt32 nCell, sal_uInt32 nCell,
sal_uInt32 nDepth, bool bEndOfLine, WW8TableNodeInfo * pPrev); sal_uInt32 nDepth, bool bEndOfLine,
WW8TableNodeInfo * pPrev, RowEndInners_t &rLastRowEnds);
WW8TableNodeInfo::Pointer_t WW8TableNodeInfo::Pointer_t
processTableBoxLines(const SwTableBox * pBox, processTableBoxLines(const SwTableBox * pBox,
...@@ -341,12 +348,12 @@ public: ...@@ -341,12 +348,12 @@ public:
virtual ~WW8TableInfo(); virtual ~WW8TableInfo();
void processSwTable(const SwTable * pTable); void processSwTable(const SwTable * pTable);
WW8TableNodeInfo * processSwTableByLayout(const SwTable * pTable); WW8TableNodeInfo * processSwTableByLayout(const SwTable * pTable, RowEndInners_t &rLastRowEnds);
WW8TableNodeInfo::Pointer_t getTableNodeInfo(const SwNode * pNode); WW8TableNodeInfo::Pointer_t getTableNodeInfo(const SwNode * pNode);
const SwNode * getNextNode(const SwNode * pNode); const SwNode * getNextNode(const SwNode * pNode);
const WW8TableNodeInfo * getFirstTableNodeInfo() const; const WW8TableNodeInfo * getFirstTableNodeInfo() const;
WW8TableNodeInfo * reorderByLayout(const SwTable * pTable); WW8TableNodeInfo * reorderByLayout(const SwTable * pTable, RowEndInners_t &rLastRowEnds);
}; };
} }
......
...@@ -719,8 +719,6 @@ void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointe ...@@ -719,8 +719,6 @@ void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointe
InitTableHelper( pInner ); InitTableHelper( pInner );
const size_t nLinesCount = m_xTableWrt->GetRows().size();
// HACK // HACK
// msoffice seems to have an internal limitation of 63 columns for tables // msoffice seems to have an internal limitation of 63 columns for tables
// and refuses to load .docx with more, even though the spec seems to allow that; // and refuses to load .docx with more, even though the spec seems to allow that;
...@@ -764,7 +762,7 @@ void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointe ...@@ -764,7 +762,7 @@ void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointe
EndTableRow(); EndTableRow();
// This is the end of the table // This is the end of the table
if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount ) if (pInner->isFinalEndOfLine())
EndTable(); EndTable();
} }
} }
......
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