[Libreoffice-commits] core.git: 2 commits - sw/qa

Michael Stahl mstahl at redhat.com
Thu Apr 2 05:57:54 PDT 2015


 sw/qa/extras/uiwriter/uiwriter.cxx |   43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

New commits:
commit ba431cd20a8a4a97720884487b3f943c55685ac1
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 2 14:51:27 2015 +0200

    sw: [loplugin:stringconstant]
    
    Change-Id: Idb8a113254574ca5f998980ede91e42f9bd09277

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 88f595a..e792e5c 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -871,7 +871,7 @@ void SwUiWriterTest::testSearchWithTransliterate()
     SearchOpt.algorithmType = com::sun::star::util::SearchAlgorithms_ABSOLUTE;
     SearchOpt.searchFlag = 0x00000001;
     SearchOpt.searchString = "other";
-    SearchOpt.replaceString = "";
+    SearchOpt.replaceString.clear();
     SearchOpt.changedChars = 0;
     SearchOpt.deletedChars = 0;
     SearchOpt.insertedChars = 0;
commit c35bf9ef22809b01cc8a6e765856d24a17afd8cc
Author: Varun <varun.dhall at studentpartner.com>
Date:   Tue Mar 31 18:21:25 2015 +0530

    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 at redhat.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 31b9bdf..88f595a 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();
 


More information about the Libreoffice-commits mailing list