summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2014-11-16 16:47:08 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-11-17 17:13:06 +0000
commitb1bd96e70230e498ea1c76388a684e5a5c3cbff4 (patch)
treefe5e23c9ce0b7878758023b272531561639912e5 /sw
parented2c3a53853fbc4df843c10aecbfa463b6a67475 (diff)
fdo#85542: fix DOCX import of overlapping bookmarks
This was broken by 345a3a394e082595924bf219796627f6c00ae2dd. Kill the static variable and instead have some more state in the implementation. Still not ideal, but at least fixes the regression. Change-Id: I562f7d88a1983bd0ec2e01d6bb1e4a53551d0953 Reviewed-on: https://gerrit.libreoffice.org/12491 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlimport/data/fdo85542.docxbin0 -> 10299 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx31
2 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/fdo85542.docx b/sw/qa/extras/ooxmlimport/data/fdo85542.docx
new file mode 100644
index 000000000000..db4940845140
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/fdo85542.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 57ae73534127..3f2dd6baad2b 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
#include <com/sun/star/text/XDependentTextField.hpp>
#include <com/sun/star/text/XFormField.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
@@ -2501,6 +2502,36 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(10), 3), "IsStart"));
}
+DECLARE_OOXMLIMPORT_TEST(testFdo85542, "fdo85542.docx")
+{
+ //CPPUNIT_ASSERT_EQUAL(false,true);
+ uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(xBookmarksByIdx->getCount(), 3);
+ uno::Reference<container::XNameAccess> xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("B1"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("B2"));
+ CPPUNIT_ASSERT(xBookmarksByName->hasByName("B3"));
+ // B1
+ uno::Reference<text::XTextContent> xContent1(xBookmarksByName->getByName("B1"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange1(xContent1->getAnchor(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(xRange1->getString(), OUString("ABB"));
+ // B2
+ uno::Reference<text::XTextContent> xContent2(xBookmarksByName->getByName("B2"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange2(xContent2->getAnchor(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(xRange2->getString(), OUString("BBC"));
+ // B3 -- testing a collapsed bookmark
+ uno::Reference<text::XTextContent> xContent3(xBookmarksByName->getByName("B3"), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xRange3(xContent3->getAnchor(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString(""));
+ uno::Reference<text::XText> xText(xRange3->getText( ), uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xNeighborhoodCursor(xText->createTextCursor( ), uno::UNO_QUERY);
+ xNeighborhoodCursor->gotoRange(xRange3, false);
+ xNeighborhoodCursor->goLeft(1, false);
+ xNeighborhoodCursor->goRight(2, true);
+ uno::Reference<text::XTextRange> xTextNeighborhood(xNeighborhoodCursor, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(xTextNeighborhood->getString(), OUString("AB"));
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();