Kaydet (Commit) f8db2d75 authored tarafından Varun's avatar Varun Kaydeden (comit) Michael Stahl

Add test for tdf#90808 duplicate CrossRefBookmarks

Change-Id: I4aad0cbb07c07cfcb80bccbbd55d9a26fae88f73
Reviewed-on: https://gerrit.libreoffice.org/16689Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 897694d2
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment