diff options
author | Varun <varun.dhall@studentpartner.com> | 2015-03-31 18:21:25 +0530 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-04-02 14:51:50 +0200 |
commit | c35bf9ef22809b01cc8a6e765856d24a17afd8cc (patch) | |
tree | 3ce3e7cde7f489d49bce8ac5e64ca4514aa9a161 /sw | |
parent | ea441294e15b23f703f139055e9a18287745ca23 (diff) |
Added test function for Search-and-Replace with Transliteration
This test function checks the search-and-replace operation with some Transliteration Flags enabled.
Change-Id: I86e0068e9d91e4fe426f9d6c120baf66e59e2b7e
Signed-off-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 31b9bdffcdbd..88f595ac8618 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -42,6 +42,13 @@ #include "UndoManager.hxx" +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/util/SearchOptions.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include "com/sun/star/util/SearchAlgorithms.hpp" +#include "com/sun/star/i18n/TransliterationModulesExtra.hpp" + static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; class SwUiWriterTest : public SwModelTestBase @@ -80,6 +87,7 @@ public: void testTdf68183(); void testCp1000115(); void testTdf90003(); + void testSearchWithTransliterate(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -112,6 +120,7 @@ public: CPPUNIT_TEST(testTdf68183); CPPUNIT_TEST(testCp1000115); CPPUNIT_TEST(testTdf90003); + CPPUNIT_TEST(testSearchWithTransliterate); CPPUNIT_TEST_SUITE_END(); @@ -847,6 +856,40 @@ void SwUiWriterTest::testTdf90003() assertXPath(pXmlDoc, "//Special[@nType='POR_FLY']", 0); } +void SwUiWriterTest::testSearchWithTransliterate() +{ + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1); + SwPaM aPaM(aIdx); + pDoc->getIDocumentContentOperations().InsertString(aPaM,"This is paragraph one"); + pWrtShell->SplitNode(); + aIdx = SwNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1); + aPaM = SwPaM(aIdx); + pDoc->getIDocumentContentOperations().InsertString(aPaM,"This is Other PARAGRAPH"); + com::sun::star::util::SearchOptions SearchOpt; + SearchOpt.algorithmType = com::sun::star::util::SearchAlgorithms_ABSOLUTE; + SearchOpt.searchFlag = 0x00000001; + SearchOpt.searchString = "other"; + SearchOpt.replaceString = ""; + SearchOpt.changedChars = 0; + SearchOpt.deletedChars = 0; + SearchOpt.insertedChars = 0; + SearchOpt.transliterateFlags = com::sun::star::i18n::TransliterationModulesExtra::IGNORE_DIACRITICS_CTL; + //transliteration option set so that at least one of the search strings is not found + sal_uLong case1 = pWrtShell->SearchPattern(SearchOpt,true,DOCPOS_START,DOCPOS_END,FND_IN_BODY,false); + SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(true); + CPPUNIT_ASSERT_EQUAL(OUString(""),pShellCrsr->GetTxt()); + CPPUNIT_ASSERT_EQUAL(0,(int)case1); + SearchOpt.searchString = "paragraph"; + SearchOpt.transliterateFlags = com::sun::star::i18n::TransliterationModulesExtra::IGNORE_KASHIDA_CTL; + //transliteration option set so that all search strings are found + sal_uLong case2 = pWrtShell->SearchPattern(SearchOpt,true,DOCPOS_START,DOCPOS_END,FND_IN_BODY,false); + pShellCrsr = pWrtShell->getShellCrsr(true); + CPPUNIT_ASSERT_EQUAL(OUString("paragraph"),pShellCrsr->GetTxt()); + CPPUNIT_ASSERT_EQUAL(1,(int)case2); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); |