|
9 | 9 |
|
10 | 10 | #include <swmodeltestbase.hxx>
|
11 | 11 |
|
| 12 | +#include <comphelper/configuration.hxx> |
12 | 13 | #include <docsh.hxx>
|
| 14 | +#include <officecfg/Office/Common.hxx> |
13 | 15 | #include <unotxdoc.hxx>
|
14 | 16 |
|
15 | 17 | // If you want to add a test for a language that doesn't exists yet
|
@@ -38,6 +40,71 @@ CPPUNIT_TEST_FIXTURE(SwAutoCorrect, nl_BE)
|
38 | 40 | CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
|
39 | 41 | }
|
40 | 42 |
|
| 43 | +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, fr_FR) |
| 44 | +{ |
| 45 | + createSwDoc("fr-FR.fodt"); |
| 46 | + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); |
| 47 | + CPPUNIT_ASSERT(pTextDoc); |
| 48 | + |
| 49 | + dispatchCommand(mxComponent, u".uno:GoToEndOfDoc"_ustr, {}); |
| 50 | + |
| 51 | + // tdf#158703: Typing ":" after the spaces should start auto-correction, which is expected to |
| 52 | + // remove the spaces, and insert an NBSP instead. It must not crash. |
| 53 | + emulateTyping(*pTextDoc, u"Foo :"); |
| 54 | + CPPUNIT_ASSERT_EQUAL(u"Foo\u00A0:"_ustr, getParagraph(1)->getString()); |
| 55 | +} |
| 56 | + |
| 57 | +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, pt_BR) |
| 58 | +{ |
| 59 | + createSwDoc("pt-BR.fodt"); |
| 60 | + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); |
| 61 | + CPPUNIT_ASSERT(pTextDoc); |
| 62 | + |
| 63 | + // tdf#44293 |
| 64 | + emulateTyping(*pTextDoc, u"1a 1o "); |
| 65 | + CPPUNIT_ASSERT_EQUAL(u"1.a 1.o "_ustr, getParagraph(1)->getString()); |
| 66 | + emulateTyping(*pTextDoc, u"1ra 1ro "); |
| 67 | + CPPUNIT_ASSERT_EQUAL(u"1.a 1.o 1.a 1.o "_ustr, getParagraph(1)->getString()); |
| 68 | + emulateTyping(*pTextDoc, u"43as 43os 43ras 43ros "); |
| 69 | + CPPUNIT_ASSERT_EQUAL(u"1.a 1.o 1.a 1.o 43.as 43.os 43.as 43.os "_ustr, |
| 70 | + getParagraph(1)->getString()); |
| 71 | +} |
| 72 | + |
| 73 | +CPPUNIT_TEST_FIXTURE(SwAutoCorrect, de_DE) |
| 74 | +{ |
| 75 | + Resetter resetter([]() { |
| 76 | + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( |
| 77 | + comphelper::ConfigurationChanges::create()); |
| 78 | + officecfg::Office::Common::AutoCorrect::SingleQuoteAtStart::set(0, pBatch); |
| 79 | + officecfg::Office::Common::AutoCorrect::SingleQuoteAtEnd::set(0, pBatch); |
| 80 | + return pBatch->commit(); |
| 81 | + }); |
| 82 | + // Set Single Quotes › and ‹ |
| 83 | + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( |
| 84 | + comphelper::ConfigurationChanges::create()); |
| 85 | + officecfg::Office::Common::AutoCorrect::SingleQuoteAtStart::set(8250, pBatch); |
| 86 | + officecfg::Office::Common::AutoCorrect::SingleQuoteAtEnd::set(8249, pBatch); |
| 87 | + pBatch->commit(); |
| 88 | + |
| 89 | + createSwDoc("de-DE.fodt"); |
| 90 | + SwDoc* pDoc = getSwDoc(); |
| 91 | + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); |
| 92 | + CPPUNIT_ASSERT(pWrtShell); |
| 93 | + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); |
| 94 | + // tdf#151801: Single starting quote: 'word -> ›word |
| 95 | + emulateTyping(*pTextDoc, u"'word"); |
| 96 | + OUString sReplaced(u"\u203Aword"_ustr); |
| 97 | + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); |
| 98 | + // tdf#151801: Single ending quote: ›word' -> ›word‹ |
| 99 | + emulateTyping(*pTextDoc, u"'"); |
| 100 | + sReplaced += u"\u2039"; |
| 101 | + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); |
| 102 | + // tdf#151801: Use apostrophe without preceding starting quote: word' -> word’ |
| 103 | + emulateTyping(*pTextDoc, u" word'"); |
| 104 | + sReplaced += u" word\u2019"; |
| 105 | + CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString()); |
| 106 | +} |
| 107 | + |
41 | 108 | CPPUNIT_PLUGIN_IMPLEMENT();
|
42 | 109 |
|
43 | 110 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
0 commit comments