solenv/clang-format/excludelist            |    1 
 sw/CppunitTest_sw_txtencexport.mk          |   63 ++++++++++++++++++
 sw/Module_sw.mk                            |    1 
 sw/qa/extras/txtencexport/data/bullets.odt |binary
 sw/qa/extras/txtencexport/txtencexport.cxx |  101 +++++++++++++++++++++++++++++
 5 files changed, 166 insertions(+)

New commits:
commit c96b61f86ef3f4cdc34f84043fed2724b6d9732b
Author:     Oleg Shchelykalnov <olegsh...@yandex.ru>
AuthorDate: Wed May 26 18:20:06 2021 +0300
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Jun 9 11:09:15 2021 +0200

    tdf#137469 Prepare tests for encoded text filter
    
    Change-Id: Ifba71748cc389544bfb64e225a7020de8261967b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105621
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index ec136c66d917..13a5f25ac5ff 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -12332,6 +12332,7 @@ sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
 sw/qa/extras/ooxmlexport/ooxmlw14export.cxx
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx
 sw/qa/extras/tiledrendering/tiledrendering.cxx
+sw/qa/extras/txtencexport/txtencexport.cxx
 sw/qa/extras/uiwriter/uiwriter.cxx
 sw/qa/extras/ww8export/ww8export.cxx
 sw/qa/extras/ww8export/ww8export2.cxx
diff --git a/sw/CppunitTest_sw_txtencexport.mk 
b/sw/CppunitTest_sw_txtencexport.mk
new file mode 100644
index 000000000000..1f37a8eba4c8
--- /dev/null
+++ b/sw/CppunitTest_sw_txtencexport.mk
@@ -0,0 +1,63 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_txtencexport))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_txtencexport))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_txtencexport, \
+    sw/qa/extras/txtencexport/txtencexport \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_txtencexport, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    i18nlangtag \
+    sal \
+    sfx \
+    sw \
+    swqahelper \
+    test \
+    tl \
+    unotest \
+    utl \
+    vcl \
+    $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_txtencexport,\
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_txtencexport,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/source/uibase/inc \
+    -I$(SRCDIR)/sw/qa/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_txtencexport,\
+    udkapi \
+    offapi \
+    oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_txtencexport))
+$(eval $(call gb_CppunitTest_use_vcl,sw_txtencexport))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_txtencexport,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_txtencexport))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 80cad58b1bdc..28782147fb9e 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -104,6 +104,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_odfexport2 \
     CppunitTest_sw_odfimport \
     CppunitTest_sw_txtexport \
+    CppunitTest_sw_txtencexport \
     CppunitTest_sw_txtimport \
     $(if $(filter-out MACOSX,$(OS)), \
         CppunitTest_sw_uiwriter \
diff --git a/sw/qa/extras/txtencexport/data/bullets.odt 
b/sw/qa/extras/txtencexport/data/bullets.odt
new file mode 100644
index 000000000000..aec2b52cbd27
Binary files /dev/null and b/sw/qa/extras/txtencexport/data/bullets.odt differ
diff --git a/sw/qa/extras/txtencexport/txtencexport.cxx 
b/sw/qa/extras/txtencexport/txtencexport.cxx
new file mode 100644
index 000000000000..ec9fa697e9d1
--- /dev/null
+++ b/sw/qa/extras/txtencexport/txtencexport.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <osl/thread.hxx>
+
+class TxtEncExportTest : public SwModelTestBase
+{
+public:
+    TxtEncExportTest(const OUString & rFilterOptions)
+        : SwModelTestBase("/sw/qa/extras/txtencexport/data/", "Text (encoded)")
+    {
+        setFilterOptions(rFilterOptions);
+    }
+
+protected:
+    OString readExportedFile()
+    {
+        SvMemoryStream aMemoryStream;
+        SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+        aStream.ReadStream(aMemoryStream);
+        const char* pData = static_cast<const char*>(aMemoryStream.GetData());
+
+        int offset = 0;
+        if (aMemoryStream.GetSize() > 2 && pData[0] == '\xEF' && pData[1] == 
'\xBB'
+            && pData[2] == '\xBF')
+            offset = 3;
+
+        return OString(pData + offset, aMemoryStream.GetSize() - offset);
+    }
+};
+
+#define DECLARE_TXTENCEXPORT_TEST(TestName, filename, filterOptions, 
ClassName) \
+    class ClassName : public TxtEncExportTest {                                
 \
+    public:                                                                    
 \
+        ClassName() : TxtEncExportTest(filterOptions) {}                       
 \
+    };                                                                         
 \
+    DECLARE_SW_EXPORT_TEST(TestName, filename, nullptr, ClassName)
+
+DECLARE_TXTENCEXPORT_TEST(testBulletsNotHidden, "bullets.odt", "UTF8,,,,", 
TxtEncExportNotHiddenTest)
+{
+    OString aData = readExportedFile();
+
+    OUString aString = OStringToOUString(
+        "1 Heading 1" SAL_NEWLINE_STRING "1.A Heading 2" SAL_NEWLINE_STRING
+        "Paragraph" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 First bullet" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 Second bullet" SAL_NEWLINE_STRING
+        "        \xe2\x97\xa6 Sub-second bullet" SAL_NEWLINE_STRING
+        "      Third bullet, but deleted" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 Fourth bullet" SAL_NEWLINE_STRING "" 
SAL_NEWLINE_STRING
+        "Numbering" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING "    1. First" 
SAL_NEWLINE_STRING
+        "    2. Second" SAL_NEWLINE_STRING "        1. Second-first" 
SAL_NEWLINE_STRING
+        "       Third, but deleted" SAL_NEWLINE_STRING "    3. Actual third" 
SAL_NEWLINE_STRING
+        "" SAL_NEWLINE_STRING "Paragraph after numbering" SAL_NEWLINE_STRING
+        "Next paragraph" SAL_NEWLINE_STRING "Hidden paragraph" 
SAL_NEWLINE_STRING
+        "Final paragraph" SAL_NEWLINE_STRING,
+        RTL_TEXTENCODING_UTF8);
+
+    // To get the stuff back in the system's encoding
+    OString aExpected(OUStringToOString(aString, RTL_TEXTENCODING_UTF8));
+
+    CPPUNIT_ASSERT_EQUAL(aExpected, aData);
+}
+
+DECLARE_TXTENCEXPORT_TEST(testBulletsHidden, "bullets.odt", "UTF8,,,,,false", 
TxtEncExportHiddenTest)
+{
+    OString aData = readExportedFile();
+
+    OUString aString = OStringToOUString(
+        "1 Heading 1" SAL_NEWLINE_STRING "1.A Heading 2" SAL_NEWLINE_STRING
+        "Paragraph" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 First bullet" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 Second bullet" SAL_NEWLINE_STRING
+        "        \xe2\x97\xa6 Sub-second bullet" SAL_NEWLINE_STRING
+        "      Third bullet, but deleted" SAL_NEWLINE_STRING
+        "    \xe2\x80\xa2 Fourth bullet" SAL_NEWLINE_STRING "" 
SAL_NEWLINE_STRING
+        "Numbering" SAL_NEWLINE_STRING "" SAL_NEWLINE_STRING "    1. First" 
SAL_NEWLINE_STRING
+        "    2. Second" SAL_NEWLINE_STRING "        1. Second-first" 
SAL_NEWLINE_STRING
+        "       Third, but deleted" SAL_NEWLINE_STRING "    3. Actual third" 
SAL_NEWLINE_STRING
+        "" SAL_NEWLINE_STRING "Paragraph after numbering" SAL_NEWLINE_STRING
+        "Next paragraph" SAL_NEWLINE_STRING "Hidden paragraph" 
SAL_NEWLINE_STRING
+        "Final paragraph" SAL_NEWLINE_STRING,
+        RTL_TEXTENCODING_UTF8);
+
+    // To get the stuff back in the system's encoding
+    OString aExpected(OUStringToOString(aString, RTL_TEXTENCODING_UTF8));
+
+    CPPUNIT_ASSERT_EQUAL(aExpected, aData);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to