Resolves: more crash on export of ooo47778-3.sxw to docx

This is more of the horror where the table in the frame has its cells out of
visual sequence, extend the previous fix of this kind to accept cells within
the original unmodified selected range

Change-Id: I6e8220f712fe9de5d4b98fb3cb5ed67e3762e929
This commit is contained in:
Caolán McNamara
2015-06-09 10:11:28 +01:00
parent fce7587b4d
commit 60f8dd78fa
4 changed files with 26 additions and 7 deletions

Binary file not shown.

View File

@@ -813,12 +813,18 @@ DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt")
}
}
DECLARE_OOXMLEXPORT_TEST(testOO47778, "ooo47778-3.odt")
DECLARE_OOXMLEXPORT_TEST(testOO47778_1, "ooo47778-3.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
assertXPathContent(pXmlDoc, "(//w:t)[3]", "c");
}
DECLARE_OOXMLEXPORT_TEST(testOO47778_2, "ooo47778-4.odt")
{
if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
assertXPathContent(pXmlDoc, "(//w:t)[4]", "c");
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1720,6 +1720,8 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u
sal_uInt8 nOldTyp = m_nTextTyp;
m_nTextTyp = nTTyp;
SwPaM* pOldPam = m_pCurPam; //!! Simply shifting the PaM without restoring should do the job too
sal_uLong nOldStart = m_nCurStart;
sal_uLong nOldEnd = m_nCurEnd;
SwPaM* pOldEnd = m_pOrigPam;
bool bOldPageDescs = m_bOutPageDescs;
m_bOutPageDescs = false;
@@ -1731,6 +1733,8 @@ void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_u
m_bOutPageDescs = bOldPageDescs;
delete m_pCurPam; // delete Pam
m_pCurPam = pOldPam;
m_nCurStart = nOldStart;
m_nCurEnd = nOldEnd;
m_pOrigPam = pOldEnd;
m_nTextTyp = nOldTyp;
}
@@ -1791,6 +1795,8 @@ void WW8Export::WriteChar( sal_Unicode c )
void MSWordExportBase::SetCurPam(sal_uLong nStt, sal_uLong nEnd)
{
m_nCurStart = nStt;
m_nCurEnd = nEnd;
m_pCurPam = Writer::NewSwPaM( *m_pDoc, nStt, nEnd );
// Recognize tables in special cases
@@ -1842,6 +1848,8 @@ void MSWordExportBase::RestoreData()
delete m_pCurPam;
m_pCurPam = rData.pOldPam;
m_nCurStart = rData.nOldStart;
m_nCurEnd = rData.nOldEnd;
m_pOrigPam = rData.pOldEnd;
m_bOutTable = rData.bOldOutTable;
@@ -2530,11 +2538,12 @@ class TrackContentToExport
{
private:
SwPaM *m_pCurPam;
SwPaM m_aOrigPam;
sal_uLong m_nStart, m_nEnd;
public:
TrackContentToExport(SwPaM *pCurPam)
TrackContentToExport(SwPaM *pCurPam, sal_uLong nCurStart, sal_uLong nCurEnd)
: m_pCurPam(pCurPam)
, m_aOrigPam(*pCurPam, NULL)
, m_nStart(nCurStart)
, m_nEnd(nCurEnd)
{
}
@@ -2559,8 +2568,8 @@ public:
if (pNextNode && pCurrentNode != pNextNode)
{
return pNextNode->GetIndex() >= m_aOrigPam.GetPoint()->nNode.GetIndex() &&
pNextNode->GetIndex() < m_aOrigPam.GetMark()->nNode.GetIndex();
return pNextNode->GetIndex() >= m_nStart &&
pNextNode->GetIndex() < m_nEnd;
}
return false;
@@ -2569,7 +2578,7 @@ public:
void MSWordExportBase::WriteText()
{
TrackContentToExport aContentTracking(m_pCurPam);
TrackContentToExport aContentTracking(m_pCurPam, m_nCurStart, m_nCurEnd);
while (aContentTracking.contentRemainsToExport(m_pTableInfo.get()))
{
SwNode& rNd = m_pCurPam->GetNode();
@@ -3561,6 +3570,8 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM
, m_bOutOutlineOnly(false)
, m_bFontSizeWritten(false)
, m_pDoc(pDocument)
, m_nCurStart(pCurrentPam->GetPoint()->nNode.GetIndex())
, m_nCurEnd(pCurrentPam->GetMark()->nNode.GetIndex())
, m_pCurPam(pCurrentPam)
, m_pOrigPam(pOriginalPam)
{

View File

@@ -437,6 +437,7 @@ struct MSWordSaveData
RndStdIds eOldAnchorType;
ww::bytes* pOOld; ///< WW8Export only
SwPaM* pOldPam, *pOldEnd;
sal_uLong nOldStart, nOldEnd;
const sw::Frame* pOldFlyFormat;
const SwPageDesc* pOldPageDesc;
@@ -554,6 +555,7 @@ public:
bool m_bFontSizeWritten;
SwDoc *m_pDoc;
sal_uLong m_nCurStart, m_nCurEnd;
SwPaM *m_pCurPam, *m_pOrigPam;
/// Stack to remember the nesting (see MSWordSaveData for more)