Blame SOURCES/0103-cp-2013101510000026-doc-import-of-comments-affecting.patch

f0633d
From 17f7655b6dedb7349c3ecd8445f119c4d14641b0 Mon Sep 17 00:00:00 2001
f0633d
From: =?UTF-8?q?Zolnai=20Tam=C3=A1s?= <tamas.zolnai@collabora.com>
f0633d
Date: Fri, 3 Jan 2014 00:41:56 +0100
f0633d
Subject: [PATCH 103/109] cp#2013101510000026: doc import of comments affecting
f0633d
 more text nodes
f0633d
f0633d
Change-Id: I3932d82cb4cd640b19957b93cc7e59711af1b564
f0633d
(cherry picked from commit f2945255df273404ee2457dcf761cb8f334b732b)
f0633d
(cherry picked from commit e0bd7b01f31bfbaeac3bce86403bf25929c61c84)
f0633d
---
f0633d
 sw/qa/extras/ww8export/data/fdo59530.doc | Bin 9728 -> 10240 bytes
f0633d
 sw/qa/extras/ww8export/ww8export.cxx     |  15 +++++++++-
f0633d
 sw/source/filter/ww8/ww8par.cxx          |  49 +++++++++++++++++++++++++++----
f0633d
 3 files changed, 58 insertions(+), 6 deletions(-)
f0633d
f0633d
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
f0633d
index 56040b7..645d246 100644
f0633d
--- a/sw/source/filter/ww8/ww8par.cxx
f0633d
+++ b/sw/source/filter/ww8/ww8par.cxx
f0633d
@@ -1825,11 +1825,50 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
f0633d
                 WW8_CP nStart = GetAnnotationStart(nAtnIndex);
f0633d
                 WW8_CP nEnd = GetAnnotationEnd(nAtnIndex);
f0633d
                 sal_Int32 nLen = nEnd - nStart;
f0633d
-                // Don't support ranges affecting multiple SwTxtNode for now.
f0633d
-                if (nLen && pPaM->GetPoint()->nContent.GetIndex() >= nLen)
f0633d
-                {
f0633d
-                    pPaM->SetMark();
f0633d
-                    pPaM->GetPoint()->nContent -= nLen;
f0633d
+                if( nLen )
f0633d
+                 {
f0633d
+                    if (pPaM->GetPoint()->nContent.GetIndex() >= nLen)
f0633d
+                    {
f0633d
+                        pPaM->SetMark();
f0633d
+                        pPaM->GetPoint()->nContent -= nLen;
f0633d
+                    }
f0633d
+                    else if (pPaM->GetPoint()->nNode.GetNode().IsTxtNode() )
f0633d
+                    {
f0633d
+                        pPaM->SetMark();
f0633d
+                        nLen -= pPaM->GetPoint()->nContent.GetIndex();
f0633d
+
f0633d
+                        SwTxtNode* pTxtNode = 0;
f0633d
+                        // Find first text node which affected by the comment
f0633d
+                        while( pPaM->GetPoint()->nNode >= 0 )
f0633d
+                        {
f0633d
+                            SwNode* pNode = 0;
f0633d
+                            // Find previous text node
f0633d
+                            do
f0633d
+                            {
f0633d
+                                pPaM->GetPoint()->nNode--;
f0633d
+                                nLen--; // End line character
f0633d
+                                pNode = &pPaM->GetPoint()->nNode.GetNode();
f0633d
+                            }
f0633d
+                            while( !pNode->IsTxtNode() && pPaM->GetPoint()->nNode >= 0 );
f0633d
+
f0633d
+                            // Subtrackt previous text node's length
f0633d
+                            if( pNode && pNode->IsTxtNode() )
f0633d
+                            {
f0633d
+                                pTxtNode = pNode->GetTxtNode();
f0633d
+                                if( nLen < pTxtNode->Len() )
f0633d
+                                    break;
f0633d
+                                else
f0633d
+                                    nLen -= pTxtNode->Len();
f0633d
+                            }
f0633d
+                        }
f0633d
+
f0633d
+                        // Set postion of the text range's first character
f0633d
+                        if( pTxtNode )
f0633d
+                        {
f0633d
+                            pTxtNode->MakeStartIndex(&pPaM->GetPoint()->nContent);
f0633d
+                            pPaM->GetPoint()->nContent += pTxtNode->Len() - nLen;
f0633d
+                        }
f0633d
+                    }
f0633d
                 }
f0633d
             }
f0633d
         }
f0633d
-- 
f0633d
1.8.4.2
f0633d