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 dd4a280f52c5..097622b3c4eb 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -173,6 +173,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 a8a9a9d8b7ea..a3f3ddac0cc4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -48,6 +48,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>
@@ -63,6 +64,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),
@@ -149,6 +174,7 @@ public:
void testSignDocument_PEM_PDF();
void testTextSelectionHandles();
void testComplexSelection();
+ void testSpellcheckerMultiView();
void testDialogPaste();
void testShowHideDialog();
void testDialogInput();
@@ -209,6 +235,7 @@ public:
#endif
CPPUNIT_TEST(testTextSelectionHandles);
CPPUNIT_TEST(testComplexSelection);
+ CPPUNIT_TEST(testSpellcheckerMultiView);
CPPUNIT_TEST(testDialogPaste);
CPPUNIT_TEST(testShowHideDialog);
CPPUNIT_TEST(testDialogInput);
@@ -2783,6 +2810,55 @@ void DesktopLOKTest::testMetricField()
CPPUNIT_ASSERT_EQUAL(aMap["VALUE"], aRet["Value"]);
}
+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 53b923f45fe2..9a01ea2888ad 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -105,6 +105,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 99fb9352ac21..77bfdf2a348e 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -675,6 +675,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 93a209b95b32..39b9dbf5a417 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2706,6 +2706,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)