[Libreoffice-commits] core.git: Branch 'libreoffice-4-3-0' - sw/source

Caolán McNamara caolanm at redhat.com
Tue Jul 8 04:32:30 PDT 2014


 sw/source/filter/ww8/ww8par.cxx |   39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

New commits:
commit 6f063c3b0d58f27187948e013fbd759767324f5c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jul 4 16:50:54 2014 +0100

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 2aa92af90a50896aa4f5d2a2287eb5db12e6c621)
    Reviewed-on: https://gerrit.libreoffice.org/10110
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 27274f2..c3e29c3 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();


More information about the Libreoffice-commits mailing list