summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-10-02 15:13:18 +0200
committerMichael Stahl <mstahl@redhat.com>2015-10-02 15:26:45 +0200
commitc95ba3ef2613e9d5abd2f19ab2432c7bc1a40fe7 (patch)
treeccdf7efa38ab1a347e77bcc8bdb5ec97d901f26c /sw/qa
parentb80be50268f534e215d36d69b93d3f51d9410ace (diff)
sw: fix copying of bookmarks in CopyRange
If the copied range starts with a not fully selected paragraph, the bookmarks that are copied will be created on the wrong paragraphs, on the node after the correct one. This also happens when hinding the redlines, and causes asserts from attempting to create CrossRefBookmarks on table nodes on WW8 export of fdo66302-1.odt and fdo66312-1.odt. Change-Id: Id576be3e38a89527d967f02b39d9aabbf6368354
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0240015b5de5..f77cb9bce6dc 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -96,6 +96,7 @@ public:
//EDITING: undo search&replace corrupt text when searching backward
void testReplaceBackward();
void testRedlineFrame();
+ void testBookmarkCopy();
void testFdo69893();
void testFdo70807();
void testImportRTF();
@@ -170,6 +171,7 @@ public:
CPPUNIT_TEST(testReplaceForward);
CPPUNIT_TEST(testReplaceBackward);
CPPUNIT_TEST(testRedlineFrame);
+ CPPUNIT_TEST(testBookmarkCopy);
CPPUNIT_TEST(testFdo69893);
CPPUNIT_TEST(testFdo70807);
CPPUNIT_TEST(testImportRTF);
@@ -316,6 +318,61 @@ void SwUiWriterTest::testRedlineFrame()
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount());
}
+void SwUiWriterTest::testBookmarkCopy()
+{
+ SwDoc * pDoc(createDoc());
+
+ // add text and bookmark
+ IDocumentMarkAccess & rIDMA(*pDoc->getIDocumentMarkAccess());
+ IDocumentContentOperations & rIDCO(pDoc->getIDocumentContentOperations());
+ SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1);
+ SwCursor aPaM(SwPosition(aIdx), nullptr, false);
+ rIDCO.InsertString(aPaM, OUString("foo"));
+ rIDCO.SplitNode(*aPaM.GetPoint(), false);
+ rIDCO.InsertString(aPaM, OUString("bar"));
+ aPaM.SetMark();
+ aPaM.MovePara(GetfnParaCurr(), GetfnParaStart());
+ rIDMA.makeMark(aPaM, OUString("Mark"), IDocumentMarkAccess::MarkType::BOOKMARK);
+ aPaM.Exchange();
+ aPaM.DeleteMark();
+ rIDCO.SplitNode(*aPaM.GetPoint(), false);
+ rIDCO.InsertString(aPaM, OUString("baz"));
+
+ // copy range
+ rIDCO.SplitNode(*aPaM.GetPoint(), false);
+ SwPosition target(*aPaM.GetPoint());
+ aPaM.Move(fnMoveBackward, fnGoContent);
+ aPaM.SetMark();
+ aPaM.SttEndDoc(true/*start*/);
+ aPaM.Move(fnMoveForward, fnGoContent); // partially select 1st para
+
+ rIDCO.CopyRange(aPaM, target, /*bCopyAll=*/false, /*bCheckPos=*/true);
+
+ // check bookmark was copied to correct position
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), rIDMA.getBookmarksCount());
+ for (auto it(rIDMA.getBookmarksBegin()); it != rIDMA.getBookmarksEnd(); ++it)
+ {
+ OUString markText(SwPaM((*it)->GetMarkPos(), (*it)->GetOtherMarkPos()).GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar"), markText);
+ }
+
+ // copy 2nd time, such that bCanMoveBack is false in CopyImpl
+ SwPaM aCopyPaM(*aPaM.GetMark(), *aPaM.GetPoint());
+ aPaM.SttEndDoc(true/*start*/);
+ rIDCO.SplitNode(*aPaM.GetPoint(), false);
+ aPaM.SttEndDoc(true/*start*/);
+
+ rIDCO.CopyRange(aCopyPaM, *aPaM.GetPoint(), /*bCopyAll=*/false, /*bCheckPos=*/true);
+
+ // check bookmark was copied to correct position
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), rIDMA.getBookmarksCount());
+ for (auto it(rIDMA.getBookmarksBegin()); it != rIDMA.getBookmarksEnd(); ++it)
+ {
+ OUString markText(SwPaM((*it)->GetMarkPos(), (*it)->GetOtherMarkPos()).GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar"), markText);
+ }
+}
+
void SwUiWriterTest::testFdo75110()
{
SwDoc* pDoc = createDoc("fdo75110.odt");