summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-04 16:50:54 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-07-07 07:33:56 +0000
commit2aa92af90a50896aa4f5d2a2287eb5db12e6c621 (patch)
tree4626d839b7aaaab97622c95e5568feae01d0a9bd
parentb1d4fbb69491bcf211fb4c8cb5c2dd4d9efb4edb (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 (cherry picked from commit b1cd83c625a2afeb9da43cc9745d79c01963c797) Reviewed-on: https://gerrit.libreoffice.org/10099 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-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 27274f2ac824..c3e29c30deb0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2169,9 +2169,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();
@@ -2183,24 +2192,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();