summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-01-03 00:41:56 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-01-03 19:59:43 +0100
commitb799d4a73a6cd8c1840c77404ef6594f9599fc36 (patch)
tree5df3a474f1fcf072c018994c6898e3f2e1942e9a /sw
parentecb0776708183e8a6dd3872b7217f74bc34ad8f0 (diff)
cp#2013101510000026: doc import of comments affecting more text nodes
Change-Id: I3932d82cb4cd640b19957b93cc7e59711af1b564 (cherry picked from commit f2945255df273404ee2457dcf761cb8f334b732b)
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ww8export/data/fdo59530.docbin9728 -> 10240 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx15
-rw-r--r--sw/source/filter/ww8/ww8par.cxx49
3 files changed, 58 insertions, 6 deletions
diff --git a/sw/qa/extras/ww8export/data/fdo59530.doc b/sw/qa/extras/ww8export/data/fdo59530.doc
index 60cfe840a787..921fbca7973d 100644
--- a/sw/qa/extras/ww8export/data/fdo59530.doc
+++ b/sw/qa/extras/ww8export/data/fdo59530.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index c835c59ef221..111af7982208 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -163,7 +163,6 @@ DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
xRunEnum->nextElement();
- xRunEnum->nextElement();
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
@@ -173,6 +172,20 @@ DECLARE_WW8EXPORT_TEST(testFdo59530, "fdo59530.doc")
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
+
+ // Test commented text range which spans over more text nodes
+ // Comment starts in the second paragraph
+ xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ xRunEnum = xRunEnumAccess->createEnumeration();
+ xRunEnum->nextElement();
+ xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType"));
+ // Comment ends in the third paragraph
+ xRunEnumAccess.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ xRunEnum = xRunEnumAccess->createEnumeration();
+ xRunEnum->nextElement();
+ xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
}
#endif
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 96c3b5a68cfa..c8e89caac434 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2162,11 +2162,50 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
WW8_CP nStart = GetAnnotationStart(nAtnIndex);
WW8_CP nEnd = GetAnnotationEnd(nAtnIndex);
sal_Int32 nLen = nEnd - nStart;
- // Don't support ranges affecting multiple SwTxtNode for now.
- if (nLen && pPaM->GetPoint()->nContent.GetIndex() >= nLen)
- {
- pPaM->SetMark();
- pPaM->GetPoint()->nContent -= nLen;
+ if( nLen )
+ {
+ if (pPaM->GetPoint()->nContent.GetIndex() >= nLen)
+ {
+ pPaM->SetMark();
+ pPaM->GetPoint()->nContent -= nLen;
+ }
+ else if (pPaM->GetPoint()->nNode.GetNode().IsTxtNode() )
+ {
+ pPaM->SetMark();
+ nLen -= pPaM->GetPoint()->nContent.GetIndex();
+
+ SwTxtNode* pTxtNode = 0;
+ // Find first text node which affected by the comment
+ while( pPaM->GetPoint()->nNode >= 0 )
+ {
+ SwNode* pNode = 0;
+ // Find previous text node
+ do
+ {
+ pPaM->GetPoint()->nNode--;
+ nLen--; // End line character
+ pNode = &pPaM->GetPoint()->nNode.GetNode();
+ }
+ while( !pNode->IsTxtNode() && pPaM->GetPoint()->nNode >= 0 );
+
+ // Subtrackt previous text node's length
+ if( pNode && pNode->IsTxtNode() )
+ {
+ pTxtNode = pNode->GetTxtNode();
+ if( nLen < pTxtNode->Len() )
+ break;
+ else
+ nLen -= pTxtNode->Len();
+ }
+ }
+
+ // Set postion of the text range's first character
+ if( pTxtNode )
+ {
+ pTxtNode->MakeStartIndex(&pPaM->GetPoint()->nContent);
+ pPaM->GetPoint()->nContent += pTxtNode->Len() - nLen;
+ }
+ }
}
}
}