summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-01-20 12:08:13 +0100
committerEike Rathke <erack@redhat.com>2023-02-18 20:05:49 +0000
commit509ab788baf54285b4e38f2560326657d97510fd (patch)
tree52b5691914cba7eb0629d5539bef2c1d2b791748 /sc/qa
parent0a27403bbc36c89efa321fb3c5061fe4ee7095fb (diff)
tdf#82254 - Don't remove UTF-8 BOM from CSV when saving file
Don't remove the byte-order-mark in the resulting CSV file when it was present in the CSV source file. Change-Id: Id26abad2686917f320f2ace85441621bcf57ea9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145879 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/qa')
-rwxr-xr-xsc/qa/unit/data/csv/testTdf82254-csv-bom.csv3
-rw-r--r--sc/qa/unit/subsequent_filters_test.cxx21
2 files changed, 24 insertions, 0 deletions
diff --git a/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv b/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv
new file mode 100755
index 000000000000..eabb18da0bf0
--- /dev/null
+++ b/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv
@@ -0,0 +1,3 @@
+col1 col2 col3
+row1-1 row1-2 row1-3
+row2-1 row2-2 row2-3
diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx
index 10cf129c0412..6af0460170be 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -54,6 +54,8 @@
#include <undomanager.hxx>
#include <tabprotection.hxx>
+#include <sfx2/docfile.hxx>
+
#include <orcusfilters.hxx>
#include <filter.hxx>
@@ -196,6 +198,7 @@ public:
void testImportCrashes();
void testTdf129681();
void testTdf149484();
+ void testTdf82254_csv_bom();
void testEscapedUnicodeXLSX();
void testTdf144758_DBDataDefaultOrientation();
void testSharedFormulaXLS();
@@ -321,6 +324,7 @@ public:
CPPUNIT_TEST(testImportCrashes);
CPPUNIT_TEST(testTdf129681);
CPPUNIT_TEST(testTdf149484);
+ CPPUNIT_TEST(testTdf82254_csv_bom);
CPPUNIT_TEST(testEscapedUnicodeXLSX);
CPPUNIT_TEST(testTdf144758_DBDataDefaultOrientation);
CPPUNIT_TEST(testSharedFormulaXLS);
@@ -3203,6 +3207,23 @@ void ScFiltersTest::testTdf149484()
CPPUNIT_ASSERT_EQUAL(OUString("-TRUE-"), pDoc->GetString(0, 2, 0));
}
+void ScFiltersTest::testTdf82254_csv_bom()
+{
+ setImportFilterName(SC_TEXT_CSV_FILTER_NAME);
+ createScDoc("csv/testTdf82254-csv-bom.csv");
+ saveAndReload(SC_TEXT_CSV_FILTER_NAME);
+ ScDocShell* pDocSh = getScDocShell();
+ SvStream* pStream = pDocSh->GetMedium()->GetInStream();
+
+ pStream->Seek(0);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt64(0), pStream->Tell());
+ pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8);
+ // Without the fix in place, this test would have failed with
+ // - Expected: 3
+ // - Actual : 0 (no byte order mark was read)
+ CPPUNIT_ASSERT_EQUAL(sal_uInt64(3), pStream->Tell());
+}
+
void ScFiltersTest::testEscapedUnicodeXLSX()
{
createScDoc("xlsx/escape-unicode.xlsx");