summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-04 16:50:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-06 15:15:10 +0100
commitb1cd83c625a2afeb9da43cc9745d79c01963c797 (patch)
tree6d92794e56db2606ab4875c3097630dca883475b
parent0cda0eb741501463baa8e7f325fe04f4687050e0 (diff)
fix crash loading ooo#93570-3.doc
regression from f2945255df273404ee2457dcf761cb8f334b732b cp#2013101510000026: doc import of comments affecting more text nodes use Move(fnMoveBackward, fnGoNode) to at least ensure we stop going backwards when we run out of valid places to go backwards to. This still isn't great because the distance between two msword character indexes only equates to the same distance between our characters in the very simple cases Change-Id: I248fd12c067577d2f1fd64f48583321eb6d453e4
-rw-r--r--sw/source/filter/ww8/ww8par.cxx39
1 files changed, 26 insertions, 13 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 53d7aa527caa..8289820c987f 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2170,9 +2170,18 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
{
WW8_CP nStart = GetAnnotationStart(nAtnIndex);
WW8_CP nEnd = GetAnnotationEnd(GetAnnotationEndIndex(nAtnIndex));
+ //It is unfortunately fragile and wrong to assume that two
+ //character positions in the original word document, which is
+ //what nStart and nEnd are, will equate to the same length in
+ //the destination writer document.
+ //
+ //Better would be, while writing the content into the writer
+ //document to store the equivalent writer document positions
+ //that relate to each annotation index as the parser passes
+ //those points.
sal_Int32 nLen = nEnd - nStart;
if( nLen )
- {
+ {
if (pPaM->GetPoint()->nContent.GetIndex() >= nLen)
{
pPaM->SetMark();
@@ -2184,24 +2193,28 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
nLen -= pPaM->GetPoint()->nContent.GetIndex();
SwTxtNode* pTxtNode = 0;
- // Find first text node which affected by the comment
- while( pPaM->GetPoint()->nNode >= 0 )
+
+ // Find first text node which is affected by the comment
+ while (nLen > 0)
{
- SwNode* pNode = 0;
- // Find previous text node
- do
+ // Move to previous content node
+ bool bSuccess = pPaM->Move(fnMoveBackward, fnGoNode);
+
+ if (!bSuccess)
{
- pPaM->GetPoint()->nNode--;
- nLen--; // End line character
- pNode = &pPaM->GetPoint()->nNode.GetNode();
+ nLen = 0;
+ break;
}
- while( !pNode->IsTxtNode() && pPaM->GetPoint()->nNode >= 0 );
+
+ --nLen; // End line character
+
+ SwNode& rNode = pPaM->GetPoint()->nNode.GetNode();
// Subtract previous text node's length
- if( pNode->IsTxtNode() )
+ if (rNode.IsTxtNode())
{
- pTxtNode = pNode->GetTxtNode();
- if( nLen < pTxtNode->Len() )
+ pTxtNode = rNode.GetTxtNode();
+ if (nLen < pTxtNode->Len())
break;
else
nLen -= pTxtNode->Len();