sw/qa/extras/autocorrect/autocorrect.cxx | 274 +++++++++++++++++++++++++++++- sw/qa/extras/autocorrect/data/hu-HU.fodt | 2 sw/qa/extras/uiwriter/data/tdf38394.fodt | 52 ----- sw/qa/extras/uiwriter/uiwriter6.cxx | 275 ------------------------------- 4 files changed, 266 insertions(+), 337 deletions(-)
New commits: commit ac03c0ed332ab0dcd319c72f46a32c76b88c4812 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 15 21:29:20 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 16 08:43:38 2024 +0200 tdf#42893: sw_autocorrect: Add unittest Change-Id: Ic94061b9255f058c249fd853ad4856b284f8cfa1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170532 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/autocorrect/autocorrect.cxx b/sw/qa/extras/autocorrect/autocorrect.cxx index 2bb2d1ff608d..877254f368fb 100644 --- a/sw/qa/extras/autocorrect/autocorrect.cxx +++ b/sw/qa/extras/autocorrect/autocorrect.cxx @@ -252,6 +252,19 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, en_US) // - Actual : DŽ emulateTyping(rTextDoc, u"dž "); CPPUNIT_ASSERT_EQUAL(u"Dž "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + emulateTyping(rTextDoc, u"foo. bar "); + CPPUNIT_ASSERT_EQUAL(u"Foo. Bar "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // tdf#42893: Without the fix in place, this test would have failed with + // - Expected: F.o.o. bar + // - Actual : F.o.o. Bar + emulateTyping(rTextDoc, u"F.o.o. bar "); + CPPUNIT_ASSERT_EQUAL(u"F.o.o. bar "_ustr, getParagraph(1)->getString()); } CPPUNIT_TEST_FIXTURE(SwAutoCorrect, hu_HU) commit f31d940b3777018f385541eed351f859a58c1989 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 15 21:19:44 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 16 08:43:32 2024 +0200 tdf#57640: sw_autocorrect: Add unittest Change-Id: I2b0ccbc9826c7694b81458c540d78bb480e61f39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170531 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/autocorrect/autocorrect.cxx b/sw/qa/extras/autocorrect/autocorrect.cxx index e98cecd827fe..2bb2d1ff608d 100644 --- a/sw/qa/extras/autocorrect/autocorrect.cxx +++ b/sw/qa/extras/autocorrect/autocorrect.cxx @@ -244,6 +244,14 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, en_US) emulateTyping(rTextDoc, u" i'"); OUString sText(sIApostrophe + u" " + sIApostrophe); CPPUNIT_ASSERT_EQUAL(sText, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // tdf#57640: Without the fix in place, this test would have failed with + // - Expected: Dž + // - Actual : DŽ + emulateTyping(rTextDoc, u"dž "); + CPPUNIT_ASSERT_EQUAL(u"Dž "_ustr, getParagraph(1)->getString()); } CPPUNIT_TEST_FIXTURE(SwAutoCorrect, hu_HU) commit 8ed6db07fa5bf14bdddbf181106f3985dc8a44bd Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 15 20:29:34 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jul 16 08:43:24 2024 +0200 CppunitTest_sw_autocorrect: move some more tests here Change-Id: I89c1975d83dd52181f7d6c8dc92acd798f14291c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170529 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/autocorrect/autocorrect.cxx b/sw/qa/extras/autocorrect/autocorrect.cxx index abc752dd4865..e98cecd827fe 100644 --- a/sw/qa/extras/autocorrect/autocorrect.cxx +++ b/sw/qa/extras/autocorrect/autocorrect.cxx @@ -12,7 +12,9 @@ #include <comphelper/configuration.hxx> #include <docsh.hxx> #include <officecfg/Office/Common.hxx> +#include <unotools/syslocaleoptions.hxx> #include <unotxdoc.hxx> +#include <wrtsh.hxx> // If you want to add a test for a language that doesn't exists yet // copy an existing document and adapt "fo:language" and "fo:country" @@ -46,12 +48,21 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, fr_FR) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); - dispatchCommand(mxComponent, u".uno:GoToEndOfDoc"_ustr, {}); - // tdf#158703: Typing ":" after the spaces should start auto-correction, which is expected to // remove the spaces, and insert an NBSP instead. It must not crash. emulateTyping(*pTextDoc, u"Foo :"); CPPUNIT_ASSERT_EQUAL(u"Foo\u00A0:"_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // tdf#38394: testing autocorrect of French l'" -> l'« (instead of l'») + emulateTyping(*pTextDoc, u"l'\""); + OUString sReplaced(u"l\u2019« "_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // tdf#132301 autocorrect of qu'« + emulateTyping(*pTextDoc, u" qu'\""); + sReplaced += u" qu\u2019« "; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); } CPPUNIT_TEST_FIXTURE(SwAutoCorrect, pt_BR) @@ -72,13 +83,6 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, pt_BR) CPPUNIT_TEST_FIXTURE(SwAutoCorrect, de_DE) { - Resetter resetter([]() { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::AutoCorrect::SingleQuoteAtStart::set(0, pBatch); - officecfg::Office::Common::AutoCorrect::SingleQuoteAtEnd::set(0, pBatch); - return pBatch->commit(); - }); // Set Single Quotes › and ‹ std::shared_ptr<comphelper::ConfigurationChanges> pBatch( comphelper::ConfigurationChanges::create()); @@ -103,6 +107,237 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, de_DE) emulateTyping(*pTextDoc, u" word'"); sReplaced += u" word\u2019"; CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + + // Reset + officecfg::Office::Common::AutoCorrect::SingleQuoteAtStart::set(0, pBatch); + officecfg::Office::Common::AutoCorrect::SingleQuoteAtEnd::set(0, pBatch); + pBatch->commit(); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // tdf#128860: Second level ending quote: ‚word' -> ,word‘ + emulateTyping(*pTextDoc, u",word'"); + OUString sReplaced2(u",word\u2019"_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); + // tdf#128860: Us apostrophe without preceding starting quote: word' -> word’ + emulateTyping(*pTextDoc, u" word'"); + sReplaced2 += u" word\u2019"; + CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); + // tdf#128860: But only after letters: word.' -> word.‘ + emulateTyping(*pTextDoc, u" word.'"); + sReplaced2 += u" word.‘"; + CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); +} + +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, ru_RU) +{ + createSwDoc("ru-RU.fodt"); + SwDoc* pDoc = getSwDoc(); + + // On Windows, it will detect that system input language is en-US (despite "typing" e.g. Cyrillic characters), + // and will change Russian into English (US); in the latter language, + // the replacement from single quote will not become “, but ’. + SvtSysLocaleOptions aOptions; + aOptions.SetIgnoreLanguageChange(true); + aOptions.Commit(); + + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + // tdf#123786: Second level ending quote: „word' -> „word“ + emulateTyping(*pTextDoc, u"„слово'"); + OUString sReplaced(u"„слово“"_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // Us apostrophe without preceding starting quote: word' -> word’ + emulateTyping(*pTextDoc, u" слово'"); + sReplaced += u" слово’"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // But only after letters: word.' -> word.“ + emulateTyping(*pTextDoc, u" слово.'"); + sReplaced += u" слово.“"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); +} + +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, en_US) +{ + // Default lang is en-US + createSwDoc(); + + SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent); + + // tdf#106164: testing autocorrect of we're -> We're on start of first paragraph + emulateTyping(rTextDoc, u"we're "); + CPPUNIT_ASSERT_EQUAL(u"We\u2019re "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // tdf#59666: Testing missing autocorrect of single Greek letters + emulateTyping(rTextDoc, u"π "); + CPPUNIT_ASSERT_EQUAL(u"\u03C0 "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + //tdf#74363: testing autocorrect of initial capitals on start of first paragraph + //Inserting one all-lowercase word into the first paragraph + emulateTyping(rTextDoc, u"testing "); + //The word should be capitalized due to autocorrect + CPPUNIT_ASSERT_EQUAL(u"Testing "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + emulateTyping(rTextDoc, u"Foo - 11’--’22 "); + // tdf#155407: Without the fix in place, this would fail with + // - Expected: Foo – 11’—’22 + // - Actual : Foo – 11’--’22 + CPPUNIT_ASSERT_EQUAL(u"Foo – 11’—’22 "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + emulateTyping(rTextDoc, u"Bar -- 111--222 "); + // tdf#155407: Without the fix in place, this would fail with + // - Expected: Bar – 111–222 + // - Actual : Bar – 111-–22 + CPPUNIT_ASSERT_EQUAL(u"Bar – 111–222 "_ustr, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + emulateTyping(rTextDoc, u"This - is replaced. - But this is not replaced "); + // tdf#159797: Without the fix in place, this would fail with + // - Expected: This – is replaced. – But this is not replaced. + // - Actual : This – is replaced. - But this is not replaced. + CPPUNIT_ASSERT_EQUAL(u"This – is replaced. – But this is not replaced "_ustr, + getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // Check quotation marks are added to the selection + emulateTyping(rTextDoc, u"\""); + + CPPUNIT_ASSERT_EQUAL(u"\u201CThis – is replaced. – But this is not replaced \u201D"_ustr, + getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // Use delete before typing the quotation mark + dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); + + // tdf#54409: testing autocorrect of "tset -> "test with typographical double quotation mark U+201C + emulateTyping(rTextDoc, u"\"test "); + OUString sReplaced(u"\u201Ctest "_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // testing autocorrect of test" -> test" with typographical double quotation mark U+201D + emulateTyping(rTextDoc, u"and tset\" "); + OUString sReplaced2(sReplaced + u"and test\u201D "); + CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); + // testing autocorrect of "tset" -> "test" with typographical double quotation mark U+201C and U+201D + emulateTyping(rTextDoc, u"\"tset\" "); + OUString sReplaced3(sReplaced2 + u"\u201Ctest\u201D "); + CPPUNIT_ASSERT_EQUAL(sReplaced3, getParagraph(1)->getString()); + + dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); + + // testing autocorrect of i' -> I' on start of first paragraph + emulateTyping(rTextDoc, u"i'"); + // tdf#108423: The word "i" should be capitalized due to autocorrect, followed by a typographical apostrophe + OUString sIApostrophe(u"I\u2019"_ustr); + CPPUNIT_ASSERT_EQUAL(sIApostrophe, getParagraph(1)->getString()); + emulateTyping(rTextDoc, u" i'"); + OUString sText(sIApostrophe + u" " + sIApostrophe); + CPPUNIT_ASSERT_EQUAL(sText, getParagraph(1)->getString()); +} + +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, hu_HU) +{ + createSwDoc("hu-HU.fodt"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + // tdf#133524: 1. Testing autocorrect of >> and << + // Example: »word« + emulateTyping(*pTextDoc, u">>"); + OUString sReplaced(u"»"_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // << + emulateTyping(*pTextDoc, u"word<<"); + sReplaced += u"word«"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // tdf#133524: 2. Testing autocorrect of " to >> and << inside „...” + // Example: „Sentence and »word«.” + // opening primary level quote + emulateTyping(*pTextDoc, u" \""); + sReplaced += u" „"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // opening second level quote + emulateTyping(*pTextDoc, u"Sentence and \""); + sReplaced += u"Sentence and »"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // closing second level quote + emulateTyping(*pTextDoc, u"word\""); + sReplaced += u"word«"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // closing primary level quote + emulateTyping(*pTextDoc, u".\""); + sReplaced += u".”"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // tdf#134940 avoid premature replacement of "--" in "-->" + emulateTyping(*pTextDoc, u" -->"); + OUString sReplaced2(sReplaced + u" -->"); + // This was "–>" instead of "-->" + CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); + emulateTyping(*pTextDoc, u" "); + sReplaced += u" → "; + // This was "–>" instead of "→" + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + + // tdf#83037 + emulateTyping(*pTextDoc, u"-> "); + sReplaced += u"→ "; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + emulateTyping(*pTextDoc, u"<- "); + sReplaced += u"← "; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + emulateTyping(*pTextDoc, u"<-- "); + sReplaced += u"← "; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + emulateTyping(*pTextDoc, u"<--> "); + sReplaced += u"↔ "; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); +} + +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, ro_RO) +{ + createSwDoc("ro-RO.fodt"); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + // tdf#133524: 1. Testing autocorrect of " to << and >> inside „...” + // Example: „Sentence and «word».” + // opening primary level quote + emulateTyping(*pTextDoc, u"\""); + OUString sReplaced(u"„"_ustr); + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // opening second level quote + emulateTyping(*pTextDoc, u"Sentence and \""); + sReplaced += u"Sentence and «"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // closing second level quote + emulateTyping(*pTextDoc, u"word\""); + sReplaced += u"word»"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // closing primary level quote + emulateTyping(*pTextDoc, u".\""); + sReplaced += u".”"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // 2. Testing recognition of closing double quotation mark ” + emulateTyping(*pTextDoc, u" \""); + sReplaced += u" „"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); + // 3. Testing recognition of alternative closing double quotation mark “ + emulateTyping(*pTextDoc, u"Alternative.“ \""); + sReplaced += u"Alternative.“ „"; + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/uiwriter/data/tdf128860.fodt b/sw/qa/extras/autocorrect/data/hu-HU.fodt similarity index 93% rename from sw/qa/extras/uiwriter/data/tdf128860.fodt rename to sw/qa/extras/autocorrect/data/hu-HU.fodt index 5e93b60f667b..aaa4b88d5bc0 100644 --- a/sw/qa/extras/uiwriter/data/tdf128860.fodt +++ b/sw/qa/extras/autocorrect/data/hu-HU.fodt @@ -3,7 +3,7 @@ <office:styles> <style:style style:name="Standard" style:family="paragraph" style:class="text"/> <style:default-style style:family="paragraph"> - <style:text-properties fo:language="de" fo:country="DE"/> + <style:text-properties fo:language="hu" fo:country="HU"/> </style:default-style> </office:styles> <office:body> diff --git a/sw/qa/extras/uiwriter/data/tdf133524_ro.fodt b/sw/qa/extras/autocorrect/data/ro-RO.fodt similarity index 100% rename from sw/qa/extras/uiwriter/data/tdf133524_ro.fodt rename to sw/qa/extras/autocorrect/data/ro-RO.fodt diff --git a/sw/qa/extras/uiwriter/data/tdf123786.fodt b/sw/qa/extras/autocorrect/data/ru-RU.fodt similarity index 100% rename from sw/qa/extras/uiwriter/data/tdf123786.fodt rename to sw/qa/extras/autocorrect/data/ru-RU.fodt diff --git a/sw/qa/extras/uiwriter/data/tdf38394.fodt b/sw/qa/extras/uiwriter/data/tdf38394.fodt deleted file mode 100644 index 238bab7b7931..000000000000 --- a/sw/qa/extras/uiwriter/data/tdf38394.fodt +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> - <office:meta><meta:initial-creator>ms </meta:initial-creator><meta:creation-date>2015-04-07T22:24:25.374012080</meta:creation-date><dc:date>2015-04-07T22:25:28.460806924</dc:date><dc:creator>ms </dc:creator><meta:editing-duration>PT1M3S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="1" meta:character-count="3" meta:non-whitespace-character-count="3"/><meta:generator>LibreOfficeDev/4.5.0.0.alpha0$Linux_X86_64 LibreOffice_project/52ae345470d8fa657817cf87b3e8e8c1b51bd7da</meta:generator></office:meta> - <office:font-face-decls> - <style:font-face style:name="Lohit Devanagari1" svg:font-family="'Lohit Devanagari'"/> - <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> - <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> - <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> - <style:font-face style:name="Source Han Sans CN Normal" svg:font-family="'Source Han Sans CN Normal'" style:font-family-generic="system" style:font-pitch="variable"/> - </office:font-face-decls> - <office:styles> - <style:default-style style:family="graphic"> - <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> - <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> - <style:tab-stops/> - </style:paragraph-properties> - <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="fr" fo:country="FR" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Normal" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> - </style:default-style> - <style:default-style style:family="paragraph"> - <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> - <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="fr" fo:country="FR" style:letter-kerning="true" style:font-name-asian="Source Han Sans CN Normal" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> - </style:default-style> - <style:style style:name="Standard" style:family="paragraph" style:class="text"/> - </office:styles> - <office:automatic-styles> - <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Frame_20_contents"> - <style:text-properties officeooo:rsid="0007f24f" officeooo:paragraph-rsid="0007f24f"/> - </style:style> - <style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame"> - <style:graphic-properties fo:margin-left="0.3cm" fo:margin-right="0.3cm" fo:margin-top="1.9cm" fo:margin-bottom="0.3cm" style:run-through="background" style:wrap="run-through" style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph" fo:background-color="#004586" style:background-transparency="25%" draw:fill="solid" draw:fill-gradient-name=""> - <style:background-image/> - <style:columns fo:column-count="1" fo:column-gap="0cm"/> - </style:graphic-properties> - </style:style> - <style:page-layout style:name="pm1"> - <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm"> - <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> - </style:page-layout-properties> - <style:header-style/> - <style:footer-style/> - </style:page-layout> - </office:automatic-styles> - <office:master-styles> - <style:master-page style:name="Standard" style:page-layout-name="pm1"/> - </office:master-styles> - <office:body> - <office:text> - <text:p text:style-name="P1"></text:p> - </office:text> - </office:body> -</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 6729e081ab19..82edebf87bec 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -29,7 +29,6 @@ #include <IDocumentRedlineAccess.hxx> #include <IDocumentLayoutAccess.hxx> #include <UndoManager.hxx> -#include <unotools/syslocaleoptions.hxx> #include <svl/stritem.hxx> #include <sfx2/viewfrm.hxx> @@ -2899,23 +2898,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testEmojiAutoCorrect) CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108423) -{ - createSwDoc(); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // testing autocorrect of i' -> I' on start of first paragraph - emulateTyping(*pTextDoc, u"i'"); - // The word "i" should be capitalized due to autocorrect, followed by a typographical apostrophe - OUString sIApostrophe(u"I\u2019"_ustr); - CPPUNIT_ASSERT_EQUAL(sIApostrophe, getParagraph(1)->getString()); - emulateTyping(*pTextDoc, u" i'"); - OUString sText(sIApostrophe + u" " + sIApostrophe); - CPPUNIT_ASSERT_EQUAL(sText, getParagraph(1)->getString()); -} - CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf153423) { createSwDoc(); @@ -2940,212 +2922,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf153423) getProperty<OUString>(getParagraph(1), u"ListLabelString"_ustr)); } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf106164) -{ - createSwDoc(); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // testing autocorrect of we're -> We're on start of first paragraph - emulateTyping(*pTextDoc, u"we're "); - CPPUNIT_ASSERT_EQUAL(u"We\u2019re "_ustr, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf54409) -{ - createSwDoc(); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // testing autocorrect of "tset -> "test with typographical double quotation mark U+201C - emulateTyping(*pTextDoc, u"\"test "); - OUString sReplaced(u"\u201Ctest "_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // testing autocorrect of test" -> test" with typographical double quotation mark U+201D - emulateTyping(*pTextDoc, u"and tset\" "); - OUString sReplaced2(sReplaced + u"and test\u201D "); - CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); - // testing autocorrect of "tset" -> "test" with typographical double quotation mark U+201C and U+201D - emulateTyping(*pTextDoc, u"\"tset\" "); - OUString sReplaced3(sReplaced2 + u"\u201Ctest\u201D "); - CPPUNIT_ASSERT_EQUAL(sReplaced3, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf38394) -{ - createSwDoc("tdf38394.fodt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // testing autocorrect of French l'" -> l'« (instead of l'») - emulateTyping(*pTextDoc, u"l'\""); - OUString sReplaced(u"l\u2019« "_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // tdf#132301 autocorrect of qu'« - emulateTyping(*pTextDoc, u" qu'\""); - sReplaced += u" qu\u2019« "; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf59666) -{ - createSwDoc(); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // testing missing autocorrect of single Greek letters - emulateTyping(*pTextDoc, u"π "); - CPPUNIT_ASSERT_EQUAL(u"\u03C0 "_ustr, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133524) -{ - createSwDoc("tdf133524.fodt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // 1. Testing autocorrect of >> and << - // Example: »word« - emulateTyping(*pTextDoc, u">>"); - OUString sReplaced(u"»"_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // << - emulateTyping(*pTextDoc, u"word<<"); - sReplaced += u"word«"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // 2. Testing autocorrect of " to >> and << inside „...” - // Example: „Sentence and »word«.” - // opening primary level quote - emulateTyping(*pTextDoc, u" \""); - sReplaced += u" „"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // opening second level quote - emulateTyping(*pTextDoc, u"Sentence and \""); - sReplaced += u"Sentence and »"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // closing second level quote - emulateTyping(*pTextDoc, u"word\""); - sReplaced += u"word«"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // closing primary level quote - emulateTyping(*pTextDoc, u".\""); - sReplaced += u".”"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // tdf#134940 avoid premature replacement of "--" in "-->" - emulateTyping(*pTextDoc, u" -->"); - OUString sReplaced2(sReplaced + u" -->"); - // This was "–>" instead of "-->" - CPPUNIT_ASSERT_EQUAL(sReplaced2, getParagraph(1)->getString()); - emulateTyping(*pTextDoc, u" "); - sReplaced += u" → "; - // This was "–>" instead of "→" - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - - // tdf#83037 - emulateTyping(*pTextDoc, u"-> "); - sReplaced += u"→ "; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - emulateTyping(*pTextDoc, u"<- "); - sReplaced += u"← "; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - emulateTyping(*pTextDoc, u"<-- "); - sReplaced += u"← "; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - emulateTyping(*pTextDoc, u"<--> "); - sReplaced += u"↔ "; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133524_Romanian) -{ - createSwDoc("tdf133524_ro.fodt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // 1. Testing autocorrect of " to << and >> inside „...” - // Example: „Sentence and «word».” - // opening primary level quote - emulateTyping(*pTextDoc, u"\""); - OUString sReplaced(u"„"_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // opening second level quote - emulateTyping(*pTextDoc, u"Sentence and \""); - sReplaced += u"Sentence and «"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // closing second level quote - emulateTyping(*pTextDoc, u"word\""); - sReplaced += u"word»"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // closing primary level quote - emulateTyping(*pTextDoc, u".\""); - sReplaced += u".”"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // 2. Testing recognition of closing double quotation mark ” - emulateTyping(*pTextDoc, u" \""); - sReplaced += u" „"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // 3. Testing recognition of alternative closing double quotation mark “ - emulateTyping(*pTextDoc, u"Alternative.“ \""); - sReplaced += u"Alternative.“ „"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf128860) -{ - createSwDoc("tdf128860.fodt"); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // Second level ending quote: ‚word' -> ,word‘ - emulateTyping(*pTextDoc, u",word'"); - OUString sReplaced(u",word\u2019"_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // Us apostrophe without preceding starting quote: word' -> word’ - emulateTyping(*pTextDoc, u" word'"); - sReplaced += u" word\u2019"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // But only after letters: word.' -> word.‘ - emulateTyping(*pTextDoc, u" word.'"); - sReplaced += u" word.‘"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf123786) -{ - createSwDoc("tdf123786.fodt"); - SwDoc* pDoc = getSwDoc(); - - // On Windows, it will detect that system input language is en-US (despite "typing" e.g. Cyrillic characters), - // and will change Russian into English (US); in the latter language, - // the replacement from single quote will not become “, but ’. - SvtSysLocaleOptions aOptions; - aOptions.SetIgnoreLanguageChange(true); - aOptions.Commit(); - - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - // Second level ending quote: „word' -> „word“ - emulateTyping(*pTextDoc, u"„слово'"); - OUString sReplaced(u"„слово“"_ustr); - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // Us apostrophe without preceding starting quote: word' -> word’ - emulateTyping(*pTextDoc, u" слово'"); - sReplaced += u" слово’"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); - // But only after letters: word.' -> word.“ - emulateTyping(*pTextDoc, u" слово.'"); - sReplaced += u" слово.“"; - CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); -} - CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133589) { // Hungarian test document with right-to-left paragraph setting @@ -3353,20 +3129,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf83260) } } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf74363) -{ - createSwDoc(); - SwDoc* pDoc = getSwDoc(); - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - CPPUNIT_ASSERT(pWrtShell); - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - //testing autocorrect of initial capitals on start of first paragraph - //Inserting one all-lowercase word into the first paragraph - emulateTyping(*pTextDoc, u"testing "); - //The word should be capitalized due to autocorrect - CPPUNIT_ASSERT_EQUAL(u"Testing "_ustr, getParagraph(1)->getString()); -} - CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf139922) { createSwDoc(); @@ -3721,43 +3483,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf106663HeaderTextFrameGoToNextPlacem CPPUNIT_ASSERT(pCursor->GetPoint()->GetNode().GetTextNode()->GetText().startsWith("Heading")); } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf159797) -{ - createSwDoc(); - SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent); - - emulateTyping(rTextDoc, u"This - is replaced. - But this is not replaced."); - // Without the fix in place, this would fail with - // - Expected: This – is replaced. – But this is not replaced. - // - Actual : This – is replaced. - But this is not replaced. - CPPUNIT_ASSERT_EQUAL(u"This – is replaced. – But this is not replaced."_ustr, - getParagraph(1)->getString()); -} - -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf155407) -{ - createSwDoc(); - SwXTextDocument& rTextDoc = dynamic_cast<SwXTextDocument&>(*mxComponent); - - { - emulateTyping(rTextDoc, u"Foo - 11’--’22 "); - // Without the fix in place, this would fail with - // - Expected: Foo – 11’—’22 - // - Actual : Foo – 11’--’22 - CPPUNIT_ASSERT_EQUAL(u"Foo – 11’—’22 "_ustr, getParagraph(1)->getString()); - } - - dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); // start again - - { - emulateTyping(rTextDoc, u"Bar -- 111--222 "); - // Without the fix in place, this would fail with - // - Expected: Bar – 111–222 - // - Actual : Bar – 111-–22 - CPPUNIT_ASSERT_EQUAL(u"Bar – 111–222 "_ustr, getParagraph(1)->getString()); - } -} - CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf158454) { createSwDoc("tdf158454.odt");