comphelper/source/misc/lok.cxx | 5 + desktop/qa/data/sheet_with_image.ods |binary desktop/qa/desktop_lib/test_desktop_lib.cxx | 76 ++++++++++++++++++++++++++++ include/comphelper/lok.hxx | 2 include/vcl/settings.hxx | 1 sc/source/ui/view/spelldialog.cxx | 5 + vcl/source/app/settings.cxx | 5 + 7 files changed, 94 insertions(+)
New commits: commit 66c1f6bee6f463786540b2e73d52f35461063589 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Tue Jul 23 19:11:36 2019 -0400 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Dec 16 13:51:23 2019 +0100 desktop: unit-test to check SpellDialog works in multiple views Unfortunately, this isn't fully functional, but didn't want to lose the effort. The problem is that there is no proper config for languages in the unit-tests. So even when we set the language explicitly, it still doesn't apply to the SpellCheckerDispatcher, which is where it matters. This seems to be because the config is not properly propagated and broadcast. Below is the stacktrace as works on desktop. During the unittest the Broadcaster has no change listener for LngSvcMgr, so SpellCheckerDispatcher::SetServiceList doesn't get called. #0 0x00007f47f3fed7e6 in SpellCheckerDispatcher::SetServiceList(com::sun::star::lang::Locale const&, com::sun::star::uno::Sequence<rtl::OUString> const&) (this=0x5589de40e7a0, rLocale=..., rSvcImplNames=uno::Sequence of length 1 = {...}) at /home/ash/prj/master/linguistic/source/spelldsp.cxx:795 #1 0x00007f47f3fcc0ad in LngSvcMgr::Notify(com::sun::star::uno::Sequence<rtl::OUString> const&) (this=0x5589de43b4e0, rPropertyNames=uno::Sequence of length 4 = {...}) at /home/ash/prj/master/linguistic/source/lngsvcmgr.cxx:826 #2 0x00007f47fa2d3c8d in utl::ConfigItem::CallNotify(com::sun::star::uno::Sequence<rtl::OUString> const&) (this=0x5589de43b530, rPropertyNames=uno::Sequence of length 4 = {...}) at /home/ash/prj/master/unotools/source/config/configitem.cxx:181 #3 0x00007f47fa2d3946 in utl::ConfigChangeListener_Impl::changesOccurred(com::sun::star::util::ChangesEvent const&) (this=0x5589de464b90, rEvent=...) at /home/ash/prj/master/unotools/source/config/configitem.cxx:143 #4 0x00007f47e273bb61 in configmgr::Broadcaster::send() (this=0x7ffcc604c5b0) at /home/ash/prj/master/configmgr/source/broadcaster.cxx:182 #5 0x00007f47e277f002 in configmgr::RootAccess::commitChanges() (this=0x5589dd557400) at /home/ash/prj/master/configmgr/source/rootaccess.cxx:171 #6 0x00007f47fa2d80e3 in utl::ConfigItem::ReplaceSetProperties(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (this=0x5589dd5571b0, rNode="ServiceManager/SpellCheckerList", rValues=uno::Sequence of length 4 = {...}) at /home/ash/prj/master/unotools/source/config/configitem.cxx:1025 #7 0x00007f47fa339983 in SvtLinguConfig::ReplaceSetProperties(rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (this=0x7ffcc604cb40, rNode="ServiceManager/SpellCheckerList", rValues=uno::Sequence of length 4 = {...}) at /home/ash/prj/master/unotools/source/config/lingucfg.cxx:847 #8 0x00007f47f3fcb88f in LngSvcMgr::UpdateAll() (this=0x5589de43b4e0) at /home/ash/prj/master/linguistic/source/lngsvcmgr.cxx:765 #9 0x00007f47f3fc9caa in LngSvcMgr::LngSvcMgr() (this=0x5589de43b4e0) at /home/ash/prj/master/linguistic/source/lngsvcmgr.cxx:438 #10 0x00007f47f3fd3baf in LngSvcMgr_CreateInstance(com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> const&) () at /home/ash/prj/master/linguistic/source/lngsvcmgr.cxx:1967 #11 0x00007f4800e9656b in cppu::OSingleFactoryHelper::createInstanceEveryTime(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x5589de3ccfc8, xContext= uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630) at /home/ash/prj/master/cppuhelper/source/factory.cxx:149 #12 0x00007f4800e96790 in cppu::OSingleFactoryHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x5589de3ccfc8, xContext=uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630) at /home/ash/prj/master/cppuhelper/source/factory.cxx:175 #13 0x00007f4800e97107 in cppu::OFactoryComponentHelper::createInstanceWithContext(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x5589de3ccf60, xContext=uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630) at /home/ash/prj/master/cppuhelper/source/factory.cxx:374 #14 0x00007f4800eebc8f in cppuhelper::ServiceManager::Data::Implementation::createInstance(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, bool) (this=0x5589dbd2f030, context=uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630, singletonRequest=false) at /home/ash/prj/master/cppuhelper/source/servicemanager.cxx:667 #15 0x00007f4800eee587 in cppuhelper::ServiceManager::createInstanceWithContext(rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (this=0x5589dbcbaaf0, aServiceSpecifier="com.sun.star.linguistic2.LinguServiceManager", Context=uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630) at /home/ash/prj/master/cppuhelper/source/servicemanager.cxx:991 #16 0x00007f4800776778 in com::sun::star::linguistic2::LinguServiceManager::create(com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&) (the_context=uno::Reference to (cppu::ComponentContext *) 0x5589dbcca630) at /home/ash/prj/master/workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/linguistic2/LinguServiceManager.hpp:38 #17 0x00007f4800772d51 in GetLngSvcMgr_Impl() () at /home/ash/prj/master/editeng/source/misc/unolingu.cxx:66 #18 0x00007f4800773449 in SpellDummy_Impl::GetSpell_Impl() (this=0x5589dd82f420) at /home/ash/prj/master/editeng/source/misc/unolingu.cxx:217 #19 0x00007f4800773614 in SpellDummy_Impl::isValid(rtl::OUString const&, short, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (this=0x5589dd82f420, rWord="a", nLanguage=1033, rProperties=empty uno::Sequence) at /home/ash/prj/master/editeng/source/misc/unolingu.cxx:249 #20 0x00007f48006ae4c2 in ImpEditEngine::DoOnlineSpelling(ContentNode*, bool, bool) (this=0x5589de195060, pThisNodeOnly=0x0, bSpellAtCursorPos=false, bInterruptible=true) at /home/ash/prj/master/editeng/source/editeng/impedit4.cxx:2306 #21 0x00007f480067d0d2 in ImpEditEngine::OnlineSpellHdl(Timer*) (this=0x5589de195060) at /home/ash/prj/master/editeng/source/editeng/impedit3.cxx:322 Change-Id: Iffef03502c78311427aa8883739678120cc84931 (cherry picked from commit 4f77bd94028a140133814d735c0425bbd0de4839) Reviewed-on: https://gerrit.libreoffice.org/85007 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index 4fa7a6f8bddc..fa1344330e77 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -157,6 +157,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 Binary files a/desktop/qa/data/sheet_with_image.ods and b/desktop/qa/data/sheet_with_image.ods differ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 2d2278d6701f..f819443473d7 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -42,6 +42,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> @@ -55,6 +56,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), @@ -142,6 +167,7 @@ public: void testSignDocument_PEM_PDF(); void testTextSelectionHandles(); void testComplexSelection(); + void testSpellcheckerMultiView(); void testDialogPaste(); void testCalcSaveAs(); void testDialogInput(); @@ -197,6 +223,7 @@ public: CPPUNIT_TEST(testSignDocument_PEM_PDF); CPPUNIT_TEST(testTextSelectionHandles); CPPUNIT_TEST(testComplexSelection); + CPPUNIT_TEST(testSpellcheckerMultiView); CPPUNIT_TEST(testDialogPaste); CPPUNIT_TEST(testCalcSaveAs); CPPUNIT_TEST(testDialogInput); @@ -2696,6 +2723,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 @@ -94,6 +94,8 @@ COMPHELPER_DLLPUBLIC bool isViewIdForVisCursorInvalidation(); /// Set whether clients want viewId in visible cursor invalidation payload. 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. diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index 4cdef3a00b1e..bd020ec0ee9a 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -699,6 +699,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 a742aea809f7..31efba0d1eac 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2732,6 +2732,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) commit e1ca2b989bf4d124588c35f7f4a0bc3da3c1f58e Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Sat Aug 10 12:26:40 2019 -0400 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Dec 16 13:51:13 2019 +0100 sc: clear the spell checking markers after applying corrections Change-Id: Ia3fc3b5a21d21b9b945ce72f397350a57859f107 (cherry picked from commit afa5f2b0edb43b36b1b4f0ab8f70ecbe638435e5) Reviewed-on: https://gerrit.libreoffice.org/85006 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx index 76865b3924c0..7c60e755787c 100644 --- a/sc/source/ui/view/spelldialog.cxx +++ b/sc/source/ui/view/spelldialog.cxx @@ -93,7 +93,12 @@ void ScSpellDialogChildWindow::ApplyChangedSentence( const svx::SpellPortions& r { if( mxEngine.get() && mpViewData ) if( EditView* pEditView = mpViewData->GetSpellingView() ) + { mxEngine->ApplyChangedSentence( *pEditView, rChanged, bRecheck ); + + // Reset the spell checking results to clear the markers. + mpViewData->GetActiveWin()->ResetAutoSpell(); + } } void ScSpellDialogChildWindow::GetFocus() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits