diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-07-15 22:17:15 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-07-18 12:22:54 +0100 |
commit | ac85be1a5c89b2e0b8baf1325c38914386b9bb0e (patch) | |
tree | e3e013b20b151d7919f83e09653fa41e722bdcfd | |
parent | d349886cd73c76f2d01af00d00e170d9d888426e (diff) |
horrifically hard to find bug, deleted paras referenced by uncommitted props
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 21 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 36 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 7 |
3 files changed, 63 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 104cdfcf0a..750182ece0 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -3597,6 +3597,7 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SvStorage* pStorage, pDataStream(0), rDoc(rD), maSectionManager(*this), + m_aExtraneousParas(rD), maInsertedTables(rD), maSectionNameGenerator(rD,CREATE_CONST_ASC("WW")), maGrfNameGenerator(bNewDoc,String('G')), @@ -4084,6 +4085,21 @@ void wwSectionManager::InsertSegments() } } +void wwExtraneousParas::delete_all_from_doc() +{ + typedef std::vector<SwTxtNode*>::iterator myParaIter; + myParaIter aEnd = m_aTxtNodes.end(); + for (myParaIter aI = m_aTxtNodes.begin(); aI != aEnd; ++aI) + { + SwTxtNode *pTxtNode = *aI; + SwNodeIndex aIdx(*pTxtNode); + SwPosition aPos(aIdx); + SwPaM aTest(aPos); + m_rDoc.DelFullPara(aTest); + } + m_aTxtNodes.clear(); +} + void SwWW8ImplReader::StoreMacroCmds() { if (pWwFib->lcbCmds) @@ -4711,6 +4727,11 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) DeleteAnchorStk(); DeleteRefStks(); + //remove extra paragraphs after attribute ctrl + //stacks etc. are destroyed, and before fields + //are updated + m_aExtraneousParas.delete_all_from_doc(); + UpdateFields(); // delete the pam before the call for hide all redlines (Bug 73683) diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index df9736afff..5a941ba52c 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -57,6 +57,8 @@ #include <editeng/lrspitem.hxx> #include <oox/ole/olehelper.hxx> +#include <boost/noncopyable.hpp> + class SwDoc; class SwPaM; class SfxPoolItem; @@ -839,6 +841,33 @@ public: sal_uInt32 GetTextAreaWidth() const; }; +//Various writer elements like frames start off containing a blank paragraph, +//sometimes this paragraph turns out to be extraneous, e.g. the frame should +//only contain a table with no trailing paragraph. +// +//We want to remove these extra paragraphs, but removing them during the parse +//is problematic, because we don't want to remove any paragraphs that are still +//addressed by property entries in a SwFltControlStack which have not yet been +//committed to the document. +// +//Safest thing is to not delete SwTxtNodes from a document during import, and +//remove these extraneous paragraphs at the end after all SwFltControlStack are +//destroyed. +class wwExtraneousParas : private ::boost::noncopyable +{ +private: + /* + A vector of SwTxtNodes to erase from a document after import is complete + */ + std::vector<SwTxtNode*> m_aTxtNodes; + SwDoc& m_rDoc; +public: + wwExtraneousParas(SwDoc &rDoc) : m_rDoc(rDoc) {} + ~wwExtraneousParas() { delete_all_from_doc(); } + void push_back(SwTxtNode *pTxtNode) { m_aTxtNodes.push_back(pTxtNode); } + void delete_all_from_doc(); +}; + class wwFrameNamer { private: @@ -1007,6 +1036,13 @@ private: wwSectionManager maSectionManager; /* + A vector of surplus-to-requirements paragraph in the final document, + that exist because of quirks of the SwDoc document model and/or API, + which need to be removed. + */ + wwExtraneousParas m_aExtraneousParas; + + /* A map of of tables to their follow nodes for use in inserting tables into already existing document, i.e. insert file */ diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index ed433045eb..9870083489 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -2272,7 +2272,12 @@ SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrmFmt *pFlyFmt, aIdx++; if (aIdx == aEnd && pNd && !pNd->GetTxt().Len()) { - rDoc.DelFullPara( *pPaM ); + //An extra pre-created by writer unused paragraph + // + //delete after import is complete rather than now + //to avoid the complication of managing uncommitted + //ctrlstack properties that refer to it. + m_aExtraneousParas.push_back(pNd); SwTable& rTable = pTable->GetTable(); SwFrmFmt* pTblFmt = rTable.GetFrmFmt(); |