sw/qa/extras/uiwriter/uiwriter.cxx | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
New commits: commit f8db2d7533785b89a149e7879d7a3c1909d41e6b Author: Varun <varun.dh...@studentpartner.com> Date: Thu Jul 2 16:06:41 2015 +0530 Add test for tdf#90808 duplicate CrossRefBookmarks Change-Id: I4aad0cbb07c07cfcb80bccbbd55d9a26fae88f73 Reviewed-on: https://gerrit.libreoffice.org/16689 Reviewed-by: Michael Stahl <mst...@redhat.com> Tested-by: Michael Stahl <mst...@redhat.com> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 0339860..6138ed2 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -54,6 +54,7 @@ #include "com/sun/star/util/SearchAlgorithms.hpp" #include "com/sun/star/i18n/TransliterationModulesExtra.hpp" #include "com/sun/star/sdbcx/XTablesSupplier.hpp" +#include "com/sun/star/text/XParagraphCursor.hpp" #include <osl/file.hxx> static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; @@ -101,6 +102,7 @@ public: void testTdf69282(); void testTdf69282WithMirror(); void testSearchWithTransliterate(); + void testTdf90808(); void testTdf75137(); void testTdf83798(); void testTableBackgroundColor(); @@ -150,6 +152,7 @@ public: CPPUNIT_TEST(testTdf69282); CPPUNIT_TEST(testTdf69282WithMirror); CPPUNIT_TEST(testSearchWithTransliterate); + CPPUNIT_TEST(testTdf90808); CPPUNIT_TEST(testTdf75137); CPPUNIT_TEST(testTdf83798); CPPUNIT_TEST(testTableBackgroundColor); @@ -1180,6 +1183,51 @@ void SwUiWriterTest::testSearchWithTransliterate() CPPUNIT_ASSERT_EQUAL(1,(int)case2); } +void SwUiWriterTest::testTdf90808() +{ + createDoc(); + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextRange> xTextRange(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<text::XText> xText(xTextRange->getText(), uno::UNO_QUERY); + uno::Reference<text::XParagraphCursor> xCrsr(xText->createTextCursor(), uno::UNO_QUERY); + //inserting text into document so that the paragraph is not empty + xText->setString(OUString("Hello World!")); + uno::Reference<lang::XMultiServiceFactory> xFact(mxComponent, uno::UNO_QUERY); + //creating bookmark 1 + uno::Reference<text::XTextContent> type1bookmark1(xFact->createInstance("com.sun.star.text.Bookmark"), uno::UNO_QUERY); + uno::Reference<container::XNamed> xName1(type1bookmark1, uno::UNO_QUERY); + xName1->setName("__RefHeading__1"); + //moving cursor to the starting of paragraph + xCrsr->gotoStartOfParagraph(false); + //inserting the bookmark in paragraph + xText->insertTextContent(xCrsr, type1bookmark1, true); + //creating bookmark 2 + uno::Reference<text::XTextContent> type1bookmark2(xFact->createInstance("com.sun.star.text.Bookmark"), uno::UNO_QUERY); + uno::Reference<container::XNamed> xName2(type1bookmark2, uno::UNO_QUERY); + xName2->setName("__RefHeading__2"); + //inserting the bookmark in same paragraph, at the end + //only one bookmark of this type is allowed in each paragraph an exception of com.sun.star.lang.IllegalArgumentException must be thrown when inserting the other bookmark in same paragraph + xCrsr->gotoEndOfParagraph(true); + CPPUNIT_ASSERT_THROW(xText->insertTextContent(xCrsr, type1bookmark2, true), com::sun::star::lang::IllegalArgumentException); + //now testing for __RefNumPara__ + //creating bookmark 1 + uno::Reference<text::XTextContent> type2bookmark1(xFact->createInstance("com.sun.star.text.Bookmark"), uno::UNO_QUERY); + uno::Reference<container::XNamed> xName3(type2bookmark1, uno::UNO_QUERY); + xName3->setName("__RefNumPara__1"); + //moving cursor to the starting of paragraph + xCrsr->gotoStartOfParagraph(false); + //inserting the bookmark in paragraph + xText->insertTextContent(xCrsr, type2bookmark1, true); + //creating bookmark 2 + uno::Reference<text::XTextContent> type2bookmark2(xFact->createInstance("com.sun.star.text.Bookmark"), uno::UNO_QUERY); + uno::Reference<container::XNamed> xName4(type2bookmark2, uno::UNO_QUERY); + xName4->setName("__RefNumPara__2"); + //inserting the bookmark in same paragraph, at the end + //only one bookmark of this type is allowed in each paragraph an exception of com.sun.star.lang.IllegalArgumentException must be thrown when inserting the other bookmark in same paragraph + xCrsr->gotoEndOfParagraph(true); + CPPUNIT_ASSERT_THROW(xText->insertTextContent(xCrsr, type2bookmark2, true), com::sun::star::lang::IllegalArgumentException); +} + void SwUiWriterTest::testTdf75137() { SwDoc* pDoc = createDoc(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits