[Libreoffice-commits] core.git: sw/CppunitTest_sw_uiwriter.mk sw/inc sw/qa test/Package_unittest.mk test/user-template

Daniel Sikeler d.sikeler94 at gmail.com
Fri Nov 28 03:18:34 PST 2014


 sw/CppunitTest_sw_uiwriter.mk                |    1 
 sw/inc/swacorr.hxx                           |    3 +-
 sw/qa/extras/uiwriter/uiwriter.cxx           |   32 +++++++++++++++++++++++++++
 test/Package_unittest.mk                     |    1 
 test/user-template/user/autocorr/acor_fr.dat |binary
 5 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 94bcfb04194baa55f995de57981a293cbd1a4f5e
Author: Daniel Sikeler <d.sikeler94 at gmail.com>
Date:   Wed Nov 26 07:09:00 2014 +0000

    Unittest for autocorrect in writer
    
    At first we test normal replacement of wrong words.
    Second part of the test is about style changes during autocorrection.
    And at the end we replace a word with a table.
    
    The rules for the autocorrection are in
    test/user-template/user/autocorr/acor_fr.dat
    I needed to make SwAutoCorrect public for my test.
    
    Conflicts:
    	sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: Ie753c2187c1f4eddaefe0cc428a605107112c24f
    Reviewed-on: https://gerrit.libreoffice.org/13131
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index a5c9db0..589421d 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
     comphelper \
     cppu \
     cppuhelper \
+    editeng \
     sal \
     sfx \
     svl \
diff --git a/sw/inc/swacorr.hxx b/sw/inc/swacorr.hxx
index 33598c6..ebcb304 100644
--- a/sw/inc/swacorr.hxx
+++ b/sw/inc/swacorr.hxx
@@ -25,8 +25,9 @@
 #include <com/sun/star/embed/XStorage.hpp>
 
 #include "SwXMLTextBlocks.hxx"
+#include "swdllapi.h"
 
-class SwAutoCorrect : public SvxAutoCorrect
+class SW_DLLPUBLIC SwAutoCorrect : public SvxAutoCorrect
 {
     using  SvxAutoCorrect::PutText;
 
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2ed5298..5cb5764 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -22,6 +22,8 @@
 #include <textboxhelper.hxx>
 #include <view.hxx>
 #include <hhcwrp.hxx>
+#include <swacorr.hxx>
+#include <editeng/acorrcfg.hxx>
 
 #include <svx/svdpage.hxx>
 #include <svx/svdview.hxx>
@@ -57,6 +59,7 @@ public:
     void testChineseConversionTraditionalToSimplified();
     void testChineseConversionSimplifiedToTraditional();
     void testFdo85554();
+    void testAutoCorr();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -80,6 +83,7 @@ public:
     CPPUNIT_TEST(testChineseConversionTraditionalToSimplified);
     CPPUNIT_TEST(testChineseConversionSimplifiedToTraditional);
     CPPUNIT_TEST(testFdo85554);
+    CPPUNIT_TEST(testAutoCorr);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -586,6 +590,34 @@ void SwUiWriterTest::testFdo85554()
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
 }
 
+void SwUiWriterTest::testAutoCorr()
+{
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
+    const sal_Unicode cIns = ' ';
+
+    //Normal AutoCorrect
+    pWrtShell->Insert("tset");
+    pWrtShell->AutoCorrect(corr, cIns);
+    sal_uLong nIndex = pWrtShell->GetCrsr()->GetNode().GetIndex();
+    CPPUNIT_ASSERT_EQUAL(OUString("Test "), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
+
+    //AutoCorrect with change style to bolt
+    pWrtShell->Insert("Bolt");
+    pWrtShell->AutoCorrect(corr, cIns);
+    nIndex = pWrtShell->GetCrsr()->GetNode().GetIndex();
+    const uno::Reference< text::XTextRange > xRun = getRun(getParagraph(1), 2);
+    CPPUNIT_ASSERT_EQUAL(OUString("Bolt"), xRun->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
+
+    //AutoCorrect inserts Table with 2 rows and 3 columns
+    pWrtShell->Insert("4xx");
+    pWrtShell->AutoCorrect(corr, cIns);
+    const uno::Reference< text::XTextTable > xTable(getParagraphOrTable(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getColumns()->getCount());
+}
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/test/Package_unittest.mk b/test/Package_unittest.mk
index 3c0aad7..77c4593 100644
--- a/test/Package_unittest.mk
+++ b/test/Package_unittest.mk
@@ -20,5 +20,6 @@ $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/tem
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/standard.bau,user/autotext/en-US/standard.bau))
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/crdbus50.bau,user/autotext/en-US/crdbus50.bau))
 $(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/.dummy,empty-directory-dummy))
+$(eval $(call gb_Package_add_file,test_unittest,unittest/user/autocorr/acor_en-US.dat,user/autocorr/acor_fr.dat))
 
 # vim: set noet sw=4 ts=4:
diff --git a/test/user-template/user/autocorr/acor_fr.dat b/test/user-template/user/autocorr/acor_fr.dat
new file mode 100644
index 0000000..d4ef556
Binary files /dev/null and b/test/user-template/user/autocorr/acor_fr.dat differ


More information about the Libreoffice-commits mailing list