summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--comphelper/source/misc/lok.cxx5
-rw-r--r--desktop/qa/data/sheet_with_image.odsbin9980 -> 10491 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx76
-rw-r--r--include/comphelper/lok.hxx2
-rw-r--r--include/vcl/settings.hxx1
-rw-r--r--vcl/source/app/settings.cxx5
6 files changed, 89 insertions, 0 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 4c1337dd927e..2cab40dfa8f9 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -156,6 +156,11 @@ void setCompatFlag(Compat flag) { g_eCompatFlags = static_cast<Compat>(g_eCompat
bool isCompatFlagSet(Compat flag) { return (g_eCompatFlags & flag) == flag; }
+void setLanguageTag(const OUString& lang, bool bCanonicalize)
+{
+ g_aLanguageTag = LanguageTag(lang, bCanonicalize);
+}
+
void setLanguageTag(const LanguageTag& languageTag)
{
if (g_aLanguageTag != languageTag)
diff --git a/desktop/qa/data/sheet_with_image.ods b/desktop/qa/data/sheet_with_image.ods
index 94dbb37858da..00c0019cb80c 100644
--- a/desktop/qa/data/sheet_with_image.ods
+++ b/desktop/qa/data/sheet_with_image.ods
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2649c0cb0d40..e04ad53559aa 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -45,6 +45,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <unotools/datetime.hxx>
+#include <unotools/syslocaleoptions.hxx>
#include <comphelper/string.hxx>
#include <comphelper/scopeguard.hxx>
#include <cairo.h>
@@ -59,6 +60,30 @@ using namespace desktop;
class DesktopLOKTest : public UnoApiTest
{
+ class Resetter
+ {
+ private:
+ std::function<void ()> m_Func;
+
+ public:
+ Resetter(std::function<void ()> const& rFunc)
+ : m_Func(rFunc)
+ {
+ }
+ ~Resetter()
+ {
+ try
+ {
+ m_Func();
+ }
+ catch (...) // has to be reliable
+ {
+ fprintf(stderr, "resetter failed with exception\n");
+ abort();
+ }
+ }
+ };
+
public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
m_nSelectionBeforeSearchResult(0),
@@ -145,6 +170,7 @@ public:
void testSignDocument_PEM_PDF();
void testTextSelectionHandles();
void testComplexSelection();
+ void testSpellcheckerMultiView();
void testDialogPaste();
void testShowHideDialog();
void testDialogInput();
@@ -203,6 +229,7 @@ public:
#endif
CPPUNIT_TEST(testTextSelectionHandles);
CPPUNIT_TEST(testComplexSelection);
+ CPPUNIT_TEST(testSpellcheckerMultiView);
CPPUNIT_TEST(testDialogPaste);
CPPUNIT_TEST(testShowHideDialog);
CPPUNIT_TEST(testDialogInput);
@@ -2736,6 +2763,55 @@ void DesktopLOKTest::testCalcSaveAs()
CPPUNIT_ASSERT_EQUAL(OString("X"), aView.m_aCellFormula);
}
+void DesktopLOKTest::testSpellcheckerMultiView()
+{
+ static const OUString aLangISO("en-US");
+ SvtSysLocaleOptions aSysLocaleOptions;
+ aSysLocaleOptions.SetLocaleConfigString(aLangISO);
+ aSysLocaleOptions.SetUILocaleConfigString(aLangISO);
+ comphelper::LibreOfficeKit::setLanguageTag(aLangISO, true);
+
+ auto aSavedSettings = Application::GetSettings();
+ std::unique_ptr<Resetter> pResetter(
+ new Resetter([&]() { Application::SetSettings(aSavedSettings); }));
+ AllSettings aSettings(aSavedSettings);
+ aSettings.SetLanguageTag(aLangISO, true);
+ Application::SetSettings(aSettings);
+
+ LibLODocument_Impl* pDocument = loadDoc("sheet_with_image.ods", LOK_DOCTYPE_SPREADSHEET);
+ pDocument->pClass->setViewLanguage(pDocument, 0, "en-US"); // For spellchecking.
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'a', 0);
+ pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 0, com::sun::star::awt::Key::ESCAPE);
+
+ // Start spellchecking.
+ pDocument->pClass->postUnoCommand(pDocument, ".uno:SpellDialog", nullptr, false);
+
+ // Uncommenting this will result in a deadlock.
+ // Because the language configuration above is not effective, and no
+ // language is actually set, the spell-dialog finds no misspelled
+ // words, and displays a message box, which must be dismissed to
+ // continue.
+ // Need to fix the language configuration issue to enable this.
+ // Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+
+ // Now create another view.
+ const int nViewId = pDocument->m_pDocumentClass->createView(pDocument);
+ CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+
+ // And destroy it.
+ pDocument->m_pDocumentClass->destroyView(pDocument, nViewId);
+
+ // We should survive the destroyed view.
+ CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
+}
+
namespace {
constexpr size_t classOffset(int i)
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index b4658913f0d1..53ee43f498db 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -95,6 +95,8 @@ COMPHELPER_DLLPUBLIC bool isViewIdForVisCursorInvalidation();
COMPHELPER_DLLPUBLIC void setViewIdForVisCursorInvalidation(bool bViewIdForVisCursorInvalidation);
/// Update the current LOK's language.
+COMPHELPER_DLLPUBLIC void setLanguageTag(const OUString& lang, bool bCanonicalize = false);
+/// Update the current LOK's language.
COMPHELPER_DLLPUBLIC void setLanguageTag(const LanguageTag& languageTag);
/// Get the current LOK's language.
COMPHELPER_DLLPUBLIC const LanguageTag& getLanguageTag();
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index a45e0e685633..dafae8735682 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -672,6 +672,7 @@ public:
void SetHelpSettings( const HelpSettings& rSet );
const HelpSettings& GetHelpSettings() const;
+ void SetLanguageTag(const OUString& rLanguage, bool bCanonicalize);
void SetLanguageTag( const LanguageTag& rLanguageTag );
const LanguageTag& GetLanguageTag() const;
const LanguageTag& GetUILanguageTag() const;
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 900dd98d34ff..30e9616740a3 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2708,6 +2708,11 @@ bool AllSettings::operator ==( const AllSettings& rSet ) const
return false;
}
+void AllSettings::SetLanguageTag(const OUString& rLanguage, bool bCanonicalize)
+{
+ SetLanguageTag(LanguageTag(rLanguage, bCanonicalize));
+}
+
void AllSettings::SetLanguageTag( const LanguageTag& rLanguageTag )
{
if (mxData->maLocale != rLanguageTag)