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

fix crash loading ooo#93570-3.doc

regression from f2945255
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
üst 0cda0eb7
...@@ -2170,9 +2170,18 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) ...@@ -2170,9 +2170,18 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
{ {
WW8_CP nStart = GetAnnotationStart(nAtnIndex); WW8_CP nStart = GetAnnotationStart(nAtnIndex);
WW8_CP nEnd = GetAnnotationEnd(GetAnnotationEndIndex(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; sal_Int32 nLen = nEnd - nStart;
if( nLen ) if( nLen )
{ {
if (pPaM->GetPoint()->nContent.GetIndex() >= nLen) if (pPaM->GetPoint()->nContent.GetIndex() >= nLen)
{ {
pPaM->SetMark(); pPaM->SetMark();
...@@ -2184,24 +2193,28 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) ...@@ -2184,24 +2193,28 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
nLen -= pPaM->GetPoint()->nContent.GetIndex(); nLen -= pPaM->GetPoint()->nContent.GetIndex();
SwTxtNode* pTxtNode = 0; 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; // Move to previous content node
// Find previous text node bool bSuccess = pPaM->Move(fnMoveBackward, fnGoNode);
do
if (!bSuccess)
{ {
pPaM->GetPoint()->nNode--; nLen = 0;
nLen--; // End line character break;
pNode = &pPaM->GetPoint()->nNode.GetNode();
} }
while( !pNode->IsTxtNode() && pPaM->GetPoint()->nNode >= 0 );
--nLen; // End line character
SwNode& rNode = pPaM->GetPoint()->nNode.GetNode();
// Subtract previous text node's length // Subtract previous text node's length
if( pNode->IsTxtNode() ) if (rNode.IsTxtNode())
{ {
pTxtNode = pNode->GetTxtNode(); pTxtNode = rNode.GetTxtNode();
if( nLen < pTxtNode->Len() ) if (nLen < pTxtNode->Len())
break; break;
else else
nLen -= pTxtNode->Len(); nLen -= pTxtNode->Len();
......
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