[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/qa sc/source
sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv |8 sc/source/ui/docshell/impex.cxx| 98 -- 2 files changed, 83 insertions(+), 23 deletions(-) New commits: commit 4f75dd78d68dbbe6bab957595a2cfdaed077a709 Author: Eike Rathke AuthorDate: Sun Oct 2 01:16:00 2022 +0200 Commit: Balazs Varga CommitDate: Thu Apr 20 13:08:13 2023 +0200 Resolves: tdf#125110 tdf#151211 Disentangle the convoluted CSV/TSV-clip import The chain of fixes for #i119960# tdf#48621 tdf#125440 produced code that is suboptimal and not robust enough against some further corner cases, taking quoted field content where there shouldn't be. First, in ReadCsvLine() assume that if a generator is broken enough to start a field quoted followed by containing an unescaped embedded quote and there is no closing quote (i.e. immediately before a field delimiter) until the line end then the generator will not be clever enough to write embedded linefeeds either and the field starting quote wasn't one but to be taken literally as all other quotes until the now unquoted field end. In this case do not read a subsequent source line for the current row. Then, for individual fields of a row make a similar assumption, a quote-started field has to end with a quote before a field separator (or line end) or otherwise all quotes of that field are literal data up to the next field separator. This made it necessary to adapt two test cases of the garbage CSV import test to produce different garbage than before. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140850 Reviewed-by: Eike Rathke Tested-by: Jenkins (cherry picked from commit d8152efac5a9226f2b56020965a5f5f4f3ef9aa2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140874 Reviewed-by: Caolán McNamara Change-Id: I4424b65c87c7f9dcbe717a7e6cf207352cb613f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150682 Tested-by: Gabor Kelemen Reviewed-by: Balazs Varga diff --git a/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv b/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv index dfc83c5f3ced..8e10063eefe5 100644 --- a/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv +++ b/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv @@ -53,8 +53,8 @@ No it doesn't,,, ",<- needed to end test file here,, ,,, i80385_test2.csv,,, -test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","de""b,a -""abcdef"" test ""abc","def""g""h","def""gh""",,, +test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","""de""b",a +"abcdef"" test ""abc","def""g""h","def""gh""", "this is a test","yes it @@ -78,8 +78,8 @@ No it doesn't,,, ""a""b""",,, ,,, i80385_test4.csv,,, -test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","de""b,a -""abcdef"" test ""abc","def""g""h","def""gh""",,, +test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","""de""b",a +"abcdef"" test ""abc","def""g""h","def""gh""", "this is a test","yes it diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 5adc2093c185..14ada5cbffb1 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -544,6 +544,11 @@ void ScImportExport::SetNoEndianSwap( SvStream& rStrm ) #endif } +static inline bool lcl_isFieldEnd( sal_Unicode c, const sal_Unicode* pSeps ) +{ +return !c || ScGlobal::UnicodeStrChr( pSeps, c); +} + enum QuoteType { FIELDSTART_QUOTE, @@ -574,7 +579,7 @@ static QuoteType lcl_isFieldEndQuote( const sal_Unicode* p, const sal_Unicode* p const bool bBlankSep = (p[1] == cBlank && !rcDetectSep && p[2] && p[2] != cBlank); while (p[1] == cBlank) ++p; -if (!p[1] || ScGlobal::UnicodeStrChr( pSeps, p[1])) +if (lcl_isFieldEnd( p[1], pSeps)) return FIELDEND_QUOTE; // Extended separator detection after a closing quote (with or without // blanks). Note that nQuotes is incremented *after* the call so is not yet @@ -667,9 +672,26 @@ enum class DoubledQuoteMode ESCAPE, // escaped quote, one is taken, one ignored }; -static const sal_Unicode* lcl_ScanString( const sal_Unicode* p, OUString& rString, +/** Scan for a quoted string. +Precondition: initial current position *p is a cStr quote. +For DoubledQuoteMode::ESCAPE, if after the closing quote there is a field +end (with or without trailing blanks and
[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/qa sc/source
dev/null |binary sc/qa/unit/scshapetest.cxx| 112 -- sc/source/filter/xml/xmlexprt.cxx | 47 +++ 3 files changed, 9 insertions(+), 150 deletions(-) New commits: commit cc45b8fd92b4d82cda77987d2e3cf8dd6ef69a86 Author: Balazs Varga AuthorDate: Tue Apr 11 20:23:08 2023 +0200 Commit: Balazs Varga CommitDate: Wed Apr 12 12:36:12 2023 +0200 Revert "tdf#117948 Do not treat hidden rows as zero in ODF export" This reverts commit 393d061a0e34917b1029f399b86058bd94a16d51. Change-Id: I7e7a1cf089bd0d0889a0596ee10c8a24a1950ae2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150265 Tested-by: Balazs Varga Reviewed-by: Balazs Varga diff --git a/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods b/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods deleted file mode 100644 index bbc1af87cf07.. Binary files a/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods and /dev/null differ diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index f348854bb9e3..55a2b0a8537c 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -30,18 +29,14 @@ class ScShapeTest : public CalcUnoApiTest { public: ScShapeTest(); -void saveAndReload(css::uno::Reference& xComponent, - const OUString& rFilter); virtual void tearDown() override; -void testTdf117948_CollapseBeforeShape(); void testFitToCellSize(); void testCustomShapeCellAnchoredRotatedShape(); void testFormSizeWithHiddenCol(); CPPUNIT_TEST_SUITE(ScShapeTest); -CPPUNIT_TEST(testTdf117948_CollapseBeforeShape); CPPUNIT_TEST(testFitToCellSize); CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape); CPPUNIT_TEST(testFormSizeWithHiddenCol); @@ -56,21 +51,6 @@ ScShapeTest::ScShapeTest() { } -void ScShapeTest::saveAndReload(css::uno::Reference& xComponent, -const OUString& rFilter) -{ -utl::TempFile aTempFile; -aTempFile.EnableKillingFile(); -css::uno::Sequence aArgs(1); -aArgs[0].Name = "FilterName"; -aArgs[0].Value <<= rFilter; // e.g. "calc8" -css::uno::Reference xStorable(xComponent, css::uno::UNO_QUERY_THROW); -xStorable->storeAsURL(aTempFile.GetURL(), aArgs); -css::uno::Reference xCloseable(xComponent, css::uno::UNO_QUERY_THROW); -xCloseable->close(true); -xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument"); -} - static OUString lcl_compareRectWithTolerance(const tools::Rectangle& rExpected, const tools::Rectangle& rActual, const sal_Int32 nTolerance) @@ -94,98 +74,6 @@ static OUString lcl_compareRectWithTolerance(const tools::Rectangle& rExpected, return sErrors; } -static void lcl_AssertRectEqualWithTolerance(const OString& sInfo, - const tools::Rectangle& rExpected, - const tools::Rectangle& rActual, - const sal_Int32 nTolerance) -{ -// Left -OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual " - + OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance); -CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance); -// Top -sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual " - + OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance); -CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance); -// Width -sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual " - + OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance); -CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance); -// Height -sMsg = sInfo + " Height expected " + OString::number(rExpected.GetHeight()) + " actual " - + OString::number(rActual.GetHeight()) + " Tolerance " + OString::number(nTolerance); -CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), - labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); -} - -void ScShapeTest::testTdf117948_CollapseBeforeShape() -{ -// The document contains a column group left from the image. The group is exanded. Collapse the -// group, save and reload. The original error was, that the line was on wrong position after reload. -// After the fix for 'resive with cell', the custom shape had wrong position and size too. -OUString
[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/qa sc/source
sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods |binary sc/qa/unit/scshapetest.cxx| 112 ++ sc/source/filter/xml/xmlexprt.cxx | 47 ++- 3 files changed, 150 insertions(+), 9 deletions(-) New commits: commit 393d061a0e34917b1029f399b86058bd94a16d51 Author: Regina Henschel AuthorDate: Sat Nov 7 01:08:53 2020 +0100 Commit: Thorsten Behrens CommitDate: Tue Mar 21 09:25:26 2023 + tdf#117948 Do not treat hidden rows as zero in ODF export The object geometry in ODF file format has values so as if no hidden columns or rows exists. But for rendering the object geometry has to treat hidden rows and columns as zero. This patch changes the object geometry temporarily to the 'no hidden columns and rows' mode for export and restores the original geometry afterwards. The patch considers hidden columns left from the shape and hidden rows above the shape. So the object is shifted. Considering hidden columns or rows in the area, which is covered by the shape, is still missing. That would possibly require scaling. cherry-pick from commit: 1cb6bb9576871ff5d56c9810ff1791abc3dd64fd (tdf#117948 Do not treat hidden rows as zero in ODF export) Change-Id: Icdb3f08404ca4d212d25a1967bfdc0bfc7186007 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105427 Tested-by: Jenkins Reviewed-by: Regina Henschel Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149163 Tested-by: Gabor Kelemen Reviewed-by: Thorsten Behrens diff --git a/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods b/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods new file mode 100644 index ..bbc1af87cf07 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf117948_CollapseBeforeShape.ods differ diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index 55a2b0a8537c..f348854bb9e3 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -29,14 +30,18 @@ class ScShapeTest : public CalcUnoApiTest { public: ScShapeTest(); +void saveAndReload(css::uno::Reference& xComponent, + const OUString& rFilter); virtual void tearDown() override; +void testTdf117948_CollapseBeforeShape(); void testFitToCellSize(); void testCustomShapeCellAnchoredRotatedShape(); void testFormSizeWithHiddenCol(); CPPUNIT_TEST_SUITE(ScShapeTest); +CPPUNIT_TEST(testTdf117948_CollapseBeforeShape); CPPUNIT_TEST(testFitToCellSize); CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape); CPPUNIT_TEST(testFormSizeWithHiddenCol); @@ -51,6 +56,21 @@ ScShapeTest::ScShapeTest() { } +void ScShapeTest::saveAndReload(css::uno::Reference& xComponent, +const OUString& rFilter) +{ +utl::TempFile aTempFile; +aTempFile.EnableKillingFile(); +css::uno::Sequence aArgs(1); +aArgs[0].Name = "FilterName"; +aArgs[0].Value <<= rFilter; // e.g. "calc8" +css::uno::Reference xStorable(xComponent, css::uno::UNO_QUERY_THROW); +xStorable->storeAsURL(aTempFile.GetURL(), aArgs); +css::uno::Reference xCloseable(xComponent, css::uno::UNO_QUERY_THROW); +xCloseable->close(true); +xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument"); +} + static OUString lcl_compareRectWithTolerance(const tools::Rectangle& rExpected, const tools::Rectangle& rActual, const sal_Int32 nTolerance) @@ -74,6 +94,98 @@ static OUString lcl_compareRectWithTolerance(const tools::Rectangle& rExpected, return sErrors; } +static void lcl_AssertRectEqualWithTolerance(const OString& sInfo, + const tools::Rectangle& rExpected, + const tools::Rectangle& rActual, + const sal_Int32 nTolerance) +{ +// Left +OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual " + + OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance); +CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance); +// Top +sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual " + + OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance); +CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance); +// Width +sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual " + + OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance); +