sc/inc/docoptio.hxx | 4 - sc/inc/optuno.hxx | 9 +--- sc/inc/scmod.hxx | 4 - sc/qa/unit/tiledrendering/tiledrendering.cxx | 30 ++++++++------ sc/source/core/data/docpool.cxx | 3 - sc/source/core/tool/docoptio.cxx | 1 sc/source/ui/app/inputhdl.cxx | 2 sc/source/ui/app/scmod.cxx | 45 +++++++++++---------- sc/source/ui/docshell/docsh3.cxx | 4 - sc/source/ui/docshell/docsh4.cxx | 4 - sc/source/ui/inc/tabview.hxx | 1 sc/source/ui/unoobj/docuno.cxx | 57 ++++++++++++++++++--------- sc/source/ui/unoobj/funcuno.cxx | 39 ++++++++++++++++++ sc/source/ui/unoobj/optuno.cxx | 28 ------------- sc/source/ui/view/gridwin4.cxx | 18 +++----- sc/source/ui/view/tabview.cxx | 28 +++++++++---- sc/source/ui/view/tabvwsh4.cxx | 2 sc/source/ui/view/viewdata.cxx | 3 - sc/source/ui/view/viewfun2.cxx | 6 +- 19 files changed, 167 insertions(+), 121 deletions(-)
New commits: commit 7ecf1c5aceec1cf93e00f4caf94d06e78f678278 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri Feb 23 21:12:15 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Feb 29 09:59:26 2024 +0100 move inline spelling setting out of document and into viewshell like what writer does, so one view of a document can have spelling enabled and another disabled Change-Id: I9eae02fd1a2def56bfa9399860e416180fc178c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163874 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx index 6e4d4f124cda..80c5654efeca 100644 --- a/sc/inc/docoptio.hxx +++ b/sc/inc/docoptio.hxx @@ -39,7 +39,6 @@ class SC_DLLPUBLIC ScDocOptions bool bIsIter; ///< iterations for circular refs bool bCalcAsShown; ///< calculate as shown (wrt precision) bool bMatchWholeCell; ///< search criteria must match the whole cell - bool bDoAutoSpell; ///< auto-spelling bool bLookUpColRowNames; ///< determine column-/row titles automagically mutable bool bFormulaRegexEnabled; ///< regular expressions in formulas enabled, only when reading settings mutable bool bFormulaWildcardsEnabled;///< wildcards in formulas enabled, only when reading settings @@ -50,8 +49,6 @@ public: bool IsLookUpColRowNames() const { return bLookUpColRowNames; } void SetLookUpColRowNames( bool bVal ) { bLookUpColRowNames = bVal; } - bool IsAutoSpell() const { return bDoAutoSpell; } - void SetAutoSpell( bool bVal ) { bDoAutoSpell = bVal; } bool IsMatchWholeCell() const { return bMatchWholeCell; } void SetMatchWholeCell( bool bVal ) { bMatchWholeCell = bVal; } bool IsIgnoreCase() const { return bIsIgnoreCase; } @@ -116,7 +113,6 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const && rOpt.nTabDistance == nTabDistance && rOpt.bCalcAsShown == bCalcAsShown && rOpt.bMatchWholeCell == bMatchWholeCell - && rOpt.bDoAutoSpell == bDoAutoSpell && rOpt.bLookUpColRowNames == bLookUpColRowNames && rOpt.bFormulaRegexEnabled == bFormulaRegexEnabled && rOpt.bFormulaWildcardsEnabled == bFormulaWildcardsEnabled diff --git a/sc/inc/optuno.hxx b/sc/inc/optuno.hxx index 72050044e363..27b0c3d6dc56 100644 --- a/sc/inc/optuno.hxx +++ b/sc/inc/optuno.hxx @@ -31,16 +31,13 @@ #define PROP_UNO_LOOKUPLABELS 7 #define PROP_UNO_MATCHWHOLE 8 #define PROP_UNO_NULLDATE 9 -#define PROP_UNO_SPELLONLINE 10 -#define PROP_UNO_STANDARDDEC 11 -#define PROP_UNO_REGEXENABLED 12 -#define PROP_UNO_WILDCARDSENABLED 13 +#define PROP_UNO_STANDARDDEC 10 +#define PROP_UNO_REGEXENABLED 11 +#define PROP_UNO_WILDCARDSENABLED 12 class ScDocOptionsHelper { public: - static std::span<const SfxItemPropertyMapEntry> GetPropertyMap(); - static bool setPropertyValue( ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, std::u16string_view aPropertyName, diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index fe318c63e8b7..26b79b17b63b 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -174,9 +174,9 @@ public: void SetPrintOptions ( const ScPrintOptions& rOpt ); void InsertEntryToLRUList(sal_uInt16 nFIndex); - static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang, - bool& rAutoSpell ); + static void GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang ); static void SetAutoSpellProperty( bool bSet ); + static bool GetAutoSpellProperty(); static bool HasThesaurusLanguage( LanguageType nLang ); static LanguageType GetOptDigitLanguage(); // from CTL options diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index d6eab7cafea2..0d87dc012d1f 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -667,8 +667,11 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testViewCursors) CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSpellOnlineRenderParameter) { ScModelObj* pModelObj = createDoc("empty.ods"); - ScDocument* pDoc = pModelObj->GetDocument(); - bool bSet = pDoc->GetDocOptions().IsAutoSpell(); + + ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView); + + bool bSet = pView->IsAutoSpell(); uno::Sequence<beans::PropertyValue> aPropertyValues = { @@ -676,7 +679,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSpellOnlineRenderParameter) }; pModelObj->initializeForTiledRendering(aPropertyValues); - CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); + CPPUNIT_ASSERT_EQUAL(!bSet, pView->IsAutoSpell()); } CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testTextViewSelection) @@ -1755,16 +1758,19 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testFunctionDlg) CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSpellOnlineParameter) { - ScModelObj* pModelObj = createDoc("empty.ods"); - ScDocument* pDoc = pModelObj->GetDocument(); - bool bSet = pDoc->GetDocOptions().IsAutoSpell(); + createDoc("empty.ods"); + + ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView); + + bool bSet = pView->IsAutoSpell(); uno::Sequence<beans::PropertyValue> params = { comphelper::makePropertyValue("Enable", uno::Any(!bSet)), }; dispatchCommand(mxComponent, ".uno:SpellOnline", params); - CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); + CPPUNIT_ASSERT_EQUAL(!bSet, pView->IsAutoSpell()); // set the same state as now and we don't expect any change (no-toggle) params = @@ -1772,7 +1778,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSpellOnlineParameter) comphelper::makePropertyValue("Enable", uno::Any(!bSet)), }; dispatchCommand(mxComponent, ".uno:SpellOnline", params); - CPPUNIT_ASSERT_EQUAL(!bSet, pDoc->GetDocOptions().IsAutoSpell()); + CPPUNIT_ASSERT_EQUAL(!bSet, pView->IsAutoSpell()); } CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testVbaRangeCopyPaste) @@ -3147,11 +3153,11 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetViewRenderState) int nFirstViewId = SfxLokHelper::getView(); ViewCallback aView1; - CPPUNIT_ASSERT_EQUAL(";Default"_ostr, pModelObj->getViewRenderState()); + CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, pModelObj->getViewRenderState()); // Create a second view SfxLokHelper::createView(); ViewCallback aView2; - CPPUNIT_ASSERT_EQUAL(";Default"_ostr, pModelObj->getViewRenderState()); + CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, pModelObj->getViewRenderState()); // Set second view to dark scheme { uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( @@ -3161,11 +3167,11 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testGetViewRenderState) ); dispatchCommand(mxComponent, ".uno:ChangeTheme", aPropertyValues); } - CPPUNIT_ASSERT_EQUAL(";Dark"_ostr, pModelObj->getViewRenderState()); + CPPUNIT_ASSERT_EQUAL("S;Dark"_ostr, pModelObj->getViewRenderState()); // Switch back to first view and make sure it's the same SfxLokHelper::setView(nFirstViewId); - CPPUNIT_ASSERT_EQUAL(";Default"_ostr, pModelObj->getViewRenderState()); + CPPUNIT_ASSERT_EQUAL("S;Default"_ostr, pModelObj->getViewRenderState()); } /* diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx index f23a6087256c..88053bad6dc3 100644 --- a/sc/source/core/data/docpool.cxx +++ b/sc/source/core/data/docpool.cxx @@ -196,8 +196,7 @@ static ItemInfoPackage& getItemInfoPackageScDocument() ItemInfoPackageScDocument() { LanguageType nDefLang, nCjkLang, nCtlLang; - bool bAutoSpell; - ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell ); + ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang ); // latin font from GetDefaultFonts is not used, DEFAULTFONT_LATIN_SPREADSHEET instead SvxFontItem* pStdFont = getDefaultFontItem(nDefLang, DefaultFontType::LATIN_SPREADSHEET, ATTR_FONT); diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index 1f88b07c9bb1..b2c1a86c59b3 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -62,7 +62,6 @@ void ScDocOptions::ResetDocOptions() nTabDistance = lcl_GetDefaultTabDist(); bCalcAsShown = false; bMatchWholeCell = true; - bDoAutoSpell = false; bLookUpColRowNames = true; bFormulaRegexEnabled= false; bFormulaWildcardsEnabled= true; diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 8d5f04b99659..6658bde6af7f 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -963,7 +963,7 @@ void ScInputHandler::UpdateSpellSettings( bool bFromStartTab ) return; ScViewData& rViewData = pActiveViewSh->GetViewData(); - bool bOnlineSpell = rViewData.GetDocument().GetDocOptions().IsAutoSpell(); + bool bOnlineSpell = pActiveViewSh->IsAutoSpell(); // SetDefaultLanguage is independent of the language attributes, // ScGlobal::GetEditDefaultLanguage is always used. diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 0e44963b5b04..9a8614aef69f 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -376,11 +376,11 @@ void ScModule::Execute( SfxRequest& rReq ) bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); else { // Toggle - ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() ); - if ( pDocSh ) - bSet = !pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); + ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + if (pViewSh) + bSet = !pViewSh->IsAutoSpell(); else - bSet = !GetDocOptions().IsAutoSpell(); + bSet = !ScModule::GetAutoSpellProperty(); } SfxItemSetFixed<SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK> aSet( GetPool() ); @@ -547,12 +547,12 @@ void ScModule::Execute( SfxRequest& rReq ) void ScModule::GetState( SfxItemSet& rSet ) { ScDocShell* pDocSh = dynamic_cast<ScDocShell*>( SfxObjectShell::Current() ); - bool bTabView = pDocSh && (pDocSh->GetBestViewShell() != nullptr); + ScTabViewShell* pTabViewShell = pDocSh ? pDocSh->GetBestViewShell() : nullptr; SfxWhichIter aIter(rSet); for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) { - if (!bTabView) + if (!pTabViewShell) { // Not in the normal calc view shell (most likely in preview shell). Disable all actions. rSet.DisableItem(nWhich); @@ -574,7 +574,7 @@ void ScModule::GetState( SfxItemSet& rSet ) rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) ); break; case SID_AUTOSPELL_CHECK: - rSet.Put( SfxBoolItem( nWhich, pDocSh->GetDocument().GetDocOptions().IsAutoSpell()) ); + rSet.Put( SfxBoolItem( nWhich, pTabViewShell->IsAutoSpell()) ); break; case SID_ATTR_LANGUAGE: case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE @@ -926,9 +926,9 @@ LanguageType ScModule::GetOptDigitLanguage() */ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) { + bool bOldAutoSpell = GetAutoSpellProperty(); LanguageType nOldSpellLang, nOldCjkLang, nOldCtlLang; - bool bOldAutoSpell; - GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang, bOldAutoSpell ); + GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang ); if (!m_pAppCfg) GetAppOptions(); @@ -1161,16 +1161,11 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) { bool bDoAutoSpell = pItem->GetValue(); - if (pDoc) + if (pViewSh) { - ScDocOptions aNewOpt = pDoc->GetDocOptions(); - if ( aNewOpt.IsAutoSpell() != bDoAutoSpell ) + if (pViewSh->IsAutoSpell() != bDoAutoSpell) { - aNewOpt.SetAutoSpell( bDoAutoSpell ); - pDoc->SetDocOptions( aNewOpt ); - - if (pViewSh) - pViewSh->EnableAutoSpell(bDoAutoSpell); + pViewSh->EnableAutoSpell(bDoAutoSpell); bRepaint = true; // Because HideAutoSpell might be invalid //TODO: Paint all Views? @@ -2267,8 +2262,7 @@ using namespace com::sun::star; constexpr OUStringLiteral LINGUPROP_AUTOSPELL = u"IsSpellAuto"; -void ScModule::GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang, - bool& rAutoSpell ) +void ScModule::GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, LanguageType& rCtlLang ) { // use SvtLinguConfig instead of service LinguProperties to avoid // loading the linguistic component @@ -2280,7 +2274,6 @@ void ScModule::GetSpellSettings( LanguageType& rDefLang, LanguageType& rCjkLang, rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, css::i18n::ScriptType::LATIN); rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN); rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); - rAutoSpell = aOptions.bIsSpellAuto; } void ScModule::SetAutoSpellProperty( bool bSet ) @@ -2292,6 +2285,18 @@ void ScModule::SetAutoSpellProperty( bool bSet ) aConfig.SetProperty( LINGUPROP_AUTOSPELL, uno::Any(bSet) ); } +bool ScModule::GetAutoSpellProperty() +{ + // use SvtLinguConfig instead of service LinguProperties to avoid + // loading the linguistic component + SvtLinguConfig aConfig; + + SvtLinguOptions aOptions; + aConfig.GetOptions( aOptions ); + + return aOptions.bIsSpellAuto; +} + bool ScModule::HasThesaurusLanguage( LanguageType nLang ) { if ( nLang == LANGUAGE_NONE ) diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx index 922c2c358a26..f00f40d853a0 100644 --- a/sc/source/ui/docshell/docsh3.cxx +++ b/sc/source/ui/docshell/docsh3.cxx @@ -427,14 +427,12 @@ void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and L // Settings from the SpellCheckCfg get into Doc- and ViewOptions LanguageType nDefLang, nCjkLang, nCtlLang; - bool bAutoSpell; - ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell ); + ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang ); ScModule* pScMod = SC_MOD(); ScDocOptions aDocOpt = pScMod->GetDocOptions(); ScFormulaOptions aFormulaOpt = pScMod->GetFormulaOptions(); ScViewOptions aViewOpt = pScMod->GetViewOptions(); - aDocOpt.SetAutoSpell( bAutoSpell ); if (!comphelper::IsFuzzing()) { diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 00477ab1107d..ca2f5d2b41f9 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1144,9 +1144,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) } else if ( aLangText == "RESET_LANGUAGES" ) { - bool bAutoSpell; - - ScModule::GetSpellSettings(eLang, eCjk, eCtl, bAutoSpell); + ScModule::GetSpellSettings(eLang, eCjk, eCtl); rDoc.SetLanguage(eLang, eCjk, eCtl); } else diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index de8324898814..2bf71e00eea1 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -617,6 +617,7 @@ public: void SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock ); void ResetBrushDocument(); + SC_DLLPUBLIC bool IsAutoSpell() const; void EnableAutoSpell( bool bEnable ); void ResetAutoSpell(); void ResetAutoSpellForContentChange(); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index c46e10b23832..25a5ca8241f4 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -177,7 +177,7 @@ static std::span<const SfxItemPropertyMapEntry> lcl_GetDocOptPropertyMap() { SC_UNO_NULLDATE, PROP_UNO_NULLDATE, cppu::UnoType<util::Date>::get(), 0, 0}, { SC_UNO_ROWLABELRNG, 0, cppu::UnoType<sheet::XLabelRanges>::get(), 0, 0}, { SC_UNO_SHEETLINKS, 0, cppu::UnoType<container::XNameAccess>::get(), 0, 0}, - { SC_UNO_SPELLONLINE, PROP_UNO_SPELLONLINE, cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_SPELLONLINE, 0, cppu::UnoType<bool>::get(), 0, 0}, { SC_UNO_STANDARDDEC, PROP_UNO_STANDARDDEC, cppu::UnoType<sal_Int16>::get(), 0, 0}, { SC_UNO_REGEXENABLED, PROP_UNO_REGEXENABLED, cppu::UnoType<bool>::get(), 0, 0}, { SC_UNO_WILDCARDSENABLED, PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(), 0, 0}, @@ -500,10 +500,27 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange ) pDocShell->PostPaint(rRange, PaintPartFlags::Grid, SC_PF_TESTMERGE); } +static OString getTabViewRenderState(ScTabViewShell& rTabViewShell) +{ + OStringBuffer aState; + + if (rTabViewShell.IsAutoSpell()) + aState.append('S'); + + aState.append(';'); + + const ScViewRenderingOptions& rViewRenderingOptions = rTabViewShell.GetViewRenderingData(); + OString aThemeName = OUStringToOString(rViewRenderingOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); + aState.append(aThemeName); + + return aState.makeStringAndClear(); +} + static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX, const Fraction& rZoomY, const SCTAB nTab, - const ViewShellDocId& rDocId) + const ViewShellDocId& rDocId, + std::string_view rViewRenderState) { constexpr size_t nMaxIter = 5; size_t nIter = 0; @@ -519,8 +536,11 @@ static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX, continue; ScViewData& rData = pTabViewShell->GetViewData(); - if (rData.GetTabNo() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY) + if (rData.GetTabNo() == nTab && rData.GetZoomX() == rZoomX && rData.GetZoomY() == rZoomY && + getTabViewRenderState(*pTabViewShell) == rViewRenderState) + { return &rData; + } } return nullptr; @@ -545,7 +565,8 @@ void ScModelObj::paintTile( VirtualDevice& rDevice, // first few shells. This is to avoid switching of zooms in ScGridWindow::PaintTile // and hence avoid grid-offset recomputation on all shapes which is not cheap. ScViewData* pViewData = lcl_getViewMatchingDocZoomTab(aFracX, aFracY, - pActiveViewData->GetTabNo(), pViewShell->GetDocId()); + pActiveViewData->GetTabNo(), pViewShell->GetDocId(), + getTabViewRenderState(*pViewShell)); if (!pViewData) pViewData = pActiveViewData; @@ -1285,8 +1306,6 @@ void ScModelObj::completeFunction(const OUString& rFunctionName) OString ScModelObj::getViewRenderState(SfxViewShell* pViewShell) { - OStringBuffer aState; - ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); if (!pTabViewShell) { @@ -1295,15 +1314,9 @@ OString ScModelObj::getViewRenderState(SfxViewShell* pViewShell) } if (pTabViewShell) - { - aState.append(';'); - - const ScViewRenderingOptions& rViewRenderingOptions = pTabViewShell->GetViewRenderingData(); - OString aThemeName = OUStringToOString(rViewRenderingOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); - aState.append(aThemeName); - } + return getTabViewRenderState(*pTabViewShell); - return aState.makeStringAndClear(); + return OString(); } void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) @@ -1321,9 +1334,9 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans { if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>()) { - ScDocOptions options = GetDocument()->GetDocOptions(); - options.SetAutoSpell(rValue.Value.get<bool>()); - GetDocument()->SetDocOptions(options); + ScViewData* pViewData = ScDocShell::GetViewData(); + if (ScTabViewShell* pTabViewShell = pViewData ? pViewData->GetViewShell() : nullptr) + pTabViewShell->EnableAutoSpell(rValue.Value.get<bool>()); } else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) sThemeName = rValue.Value.get<OUString>(); @@ -2926,6 +2939,11 @@ void SAL_CALL ScModelObj::setPropertyValue( aPropertyName == SC_UNO_LOOKUPLABELS ) bHardRecalc = false; } + else if (aPropertyName == SC_UNO_SPELLONLINE) + { + if (ScTabViewShell* pViewShell = pDocShell->GetBestViewShell(false)) + pViewShell->EnableAutoSpell(ScUnoHelpFunctions::GetBoolFromAny(aValue)); + } else if ( aPropertyName == SC_UNONAME_CLOCAL ) { lang::Locale aLocale; @@ -3073,6 +3091,11 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const OUString& aPropertyName ) { // done... } + else if (aPropertyName == SC_UNO_SPELLONLINE) + { + if (ScTabViewShell* pViewShell = pDocShell->GetBestViewShell(false)) + aRet <<= pViewShell->IsAutoSpell(); + } else if ( aPropertyName == SC_UNONAME_CLOCAL ) { LanguageType eLatin, eCjk, eCtl; diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 89e616f744e2..38e849a21317 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -45,6 +45,7 @@ #include <clipparam.hxx> #include <stringutil.hxx> #include <tokenarray.hxx> +#include <unonames.hxx> #include <memory> using namespace com::sun::star; @@ -166,8 +167,33 @@ static bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange, return true; } +namespace +{ + std::span<const SfxItemPropertyMapEntry> GetPropertyMap() + { + static const SfxItemPropertyMapEntry aMap[] = + { + { SC_UNO_CALCASSHOWN, PROP_UNO_CALCASSHOWN , cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_DEFTABSTOP, PROP_UNO_DEFTABSTOP , cppu::UnoType<sal_Int16>::get(), 0, 0}, + { SC_UNO_IGNORECASE, PROP_UNO_IGNORECASE , cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_ITERENABLED, PROP_UNO_ITERENABLED , cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_ITERCOUNT, PROP_UNO_ITERCOUNT , cppu::UnoType<sal_Int32>::get(), 0, 0}, + { SC_UNO_ITEREPSILON, PROP_UNO_ITEREPSILON , cppu::UnoType<double>::get(), 0, 0}, + { SC_UNO_LOOKUPLABELS, PROP_UNO_LOOKUPLABELS, cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_MATCHWHOLE, PROP_UNO_MATCHWHOLE , cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_NULLDATE, PROP_UNO_NULLDATE , cppu::UnoType<util::Date>::get(), 0, 0}, + // SpreadsheetDocumentSettings supports "SpellOnline" so we must claim to support this here too + { SC_UNO_SPELLONLINE, 0 , cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_STANDARDDEC, PROP_UNO_STANDARDDEC , cppu::UnoType<sal_Int16>::get(), 0, 0}, + { SC_UNO_REGEXENABLED, PROP_UNO_REGEXENABLED, cppu::UnoType<bool>::get(), 0, 0}, + { SC_UNO_WILDCARDSENABLED, PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(), 0, 0}, + }; + return aMap; + } +} + ScFunctionAccess::ScFunctionAccess() : - aPropertyMap( ScDocOptionsHelper::GetPropertyMap() ), + aPropertyMap( GetPropertyMap() ), mbArray( true ), // default according to behaviour of older Office versions mbValid( true ) { @@ -238,6 +264,11 @@ void SAL_CALL ScFunctionAccess::setPropertyValue( if( !(aValue >>= mbArray) ) throw lang::IllegalArgumentException(); } + else if (aPropertyName == SC_UNO_SPELLONLINE) + { + // silently ignore this property + SAL_WARN("sc", "'SpellOnline' not implemented for ScFunctionAccess"); + } else { if ( !pOptions ) @@ -258,6 +289,12 @@ uno::Any SAL_CALL ScFunctionAccess::getPropertyValue( const OUString& aPropertyN if ( aPropertyName == "IsArrayFunction" ) return uno::Any( mbArray ); + if (aPropertyName == SC_UNO_SPELLONLINE) + { + SAL_WARN("sc", "'SpellOnline' not implemented for ScFunctionAccess"); + return uno::Any(false); + } + if ( !pOptions ) pOptions.reset( new ScDocOptions() ); diff --git a/sc/source/ui/unoobj/optuno.cxx b/sc/source/ui/unoobj/optuno.cxx index 09e17add09b8..ce885684a254 100644 --- a/sc/source/ui/unoobj/optuno.cxx +++ b/sc/source/ui/unoobj/optuno.cxx @@ -24,32 +24,10 @@ #include <optuno.hxx> #include <miscuno.hxx> -#include <unonames.hxx> #include <docoptio.hxx> using namespace com::sun::star; -std::span<const SfxItemPropertyMapEntry> ScDocOptionsHelper::GetPropertyMap() -{ - static const SfxItemPropertyMapEntry aMap[] = - { - { SC_UNO_CALCASSHOWN, PROP_UNO_CALCASSHOWN , cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_DEFTABSTOP, PROP_UNO_DEFTABSTOP , cppu::UnoType<sal_Int16>::get(), 0, 0}, - { SC_UNO_IGNORECASE, PROP_UNO_IGNORECASE , cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_ITERENABLED, PROP_UNO_ITERENABLED , cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_ITERCOUNT, PROP_UNO_ITERCOUNT , cppu::UnoType<sal_Int32>::get(), 0, 0}, - { SC_UNO_ITEREPSILON, PROP_UNO_ITEREPSILON , cppu::UnoType<double>::get(), 0, 0}, - { SC_UNO_LOOKUPLABELS, PROP_UNO_LOOKUPLABELS, cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_MATCHWHOLE, PROP_UNO_MATCHWHOLE , cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_NULLDATE, PROP_UNO_NULLDATE , cppu::UnoType<util::Date>::get(), 0, 0}, - { SC_UNO_SPELLONLINE, PROP_UNO_SPELLONLINE , cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_STANDARDDEC, PROP_UNO_STANDARDDEC , cppu::UnoType<sal_Int16>::get(), 0, 0}, - { SC_UNO_REGEXENABLED, PROP_UNO_REGEXENABLED, cppu::UnoType<bool>::get(), 0, 0}, - { SC_UNO_WILDCARDSENABLED, PROP_UNO_WILDCARDSENABLED, cppu::UnoType<bool>::get(), 0, 0}, - }; - return aMap; -} - bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, std::u16string_view aPropertyName, const uno::Any& aValue ) @@ -104,9 +82,6 @@ bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year ); } break; - case PROP_UNO_SPELLONLINE: - rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - break; case PROP_UNO_STANDARDDEC: { sal_Int16 nIntVal = 0; @@ -169,9 +144,6 @@ uno::Any ScDocOptionsHelper::getPropertyValue( aRet <<= aDate; } break; - case PROP_UNO_SPELLONLINE: - aRet <<= rOptions.IsAutoSpell(); - break; case PROP_UNO_STANDARDDEC : aRet <<= static_cast<sal_Int16>( rOptions.GetStdPrecision() ); break; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 1e776ec853aa..8ff73d07a05d 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -688,16 +688,18 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI aGridColor = rOpts.GetGridColor(); } + ScTabViewShell* pCurTabViewShell = mrViewData.GetViewShell(); + aOutputData.SetSyntaxMode ( mrViewData.IsSyntaxMode() ); aOutputData.SetGridColor ( aGridColor ); aOutputData.SetShowNullValues ( rOpts.GetOption( VOPT_NULLVALS ) ); aOutputData.SetShowFormulas ( rOpts.GetOption( VOPT_FORMULAS ) ); - aOutputData.SetShowSpellErrors ( rDoc.GetDocOptions().IsAutoSpell() ); + aOutputData.SetShowSpellErrors ( pCurTabViewShell && pCurTabViewShell->IsAutoSpell() ); aOutputData.SetMarkClipped ( SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCTEXTOVERFLOW).bIsVisible ); aOutputData.SetUseStyleColor( true ); // always set in table view - aOutputData.SetViewShell( mrViewData.GetViewShell() ); + aOutputData.SetViewShell(pCurTabViewShell); bool bGrid = rOpts.GetOption( VOPT_GRID ) && mrViewData.GetShowGrid(); bool bGridFirst = !rOpts.GetOption( VOPT_GRID_ONTOP ); @@ -796,13 +798,11 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI { // init redraw - ScTabViewShell* pTabViewShell = mrViewData.GetViewShell(); - - if(pTabViewShell) + if (pCurTabViewShell) { MapMode aCurrentMapMode(pContentDev->GetMapMode()); pContentDev->SetMapMode(aDrawMode); - SdrView* pDrawView = pTabViewShell->GetScDrawView(); + SdrView* pDrawView = pCurTabViewShell->GetScDrawView(); if(pDrawView) { @@ -1038,9 +1038,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI { // end redraw - ScTabViewShell* pTabViewShell = mrViewData.GetViewShell(); - - if(pTabViewShell) + if (pCurTabViewShell) { MapMode aCurrentMapMode(pContentDev->GetMapMode()); pContentDev->SetMapMode(aDrawMode); @@ -1066,7 +1064,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI rDevice.SetMapMode(aNew); } - SdrView* pDrawView = pTabViewShell->GetScDrawView(); + SdrView* pDrawView = pCurTabViewShell->GetScDrawView(); if(pDrawView) { diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 5d0699f26e6b..a8a3642df240 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -169,18 +169,11 @@ bool lcl_HasRowOutline( const ScViewData& rViewData ) return false; } -ScViewRenderingOptions getViewRenderingOptions(ScDocShell& rDocShell) -{ - ScTabViewShell* pViewShell = rDocShell.GetBestViewShell(); - return pViewShell ? pViewShell->GetViewRenderingData() : ScViewRenderingOptions(); -} - } // anonymous namespace ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) : pFrameWin( pParent ), aViewData( rDocSh, pViewShell ), - aViewRenderingData(getViewRenderingOptions(rDocSh)), aFunctionSet( &aViewData ), aHdrFunc( &aViewData ), aVScrollTop( VclPtr<ScrollAdaptor>::Create( pFrameWin, false ) ), @@ -225,6 +218,12 @@ ScTabView::ScTabView( vcl::Window* pParent, ScDocShell& rDocSh, ScTabViewShell* bBlockRows( false ), mbInlineWithScrollbar( false ) { + // copy settings of existing shell for this document + if (ScTabViewShell* pExistingViewShell = rDocSh.GetBestViewShell()) + { + aViewRenderingData = pExistingViewShell->GetViewRenderingData(); + EnableAutoSpell(pExistingViewShell->IsAutoSpell()); + } Init(); } @@ -2398,6 +2397,7 @@ void ScTabView::EnableRefInput(bool bFlag) void ScTabView::EnableAutoSpell( bool bEnable ) { + const bool bWasEnabled = IsAutoSpell(); if (bEnable) mpSpellCheckCxt = std::make_shared<sc::SpellCheckContext>(&aViewData.GetDocument(), @@ -2412,6 +2412,20 @@ void ScTabView::EnableAutoSpell( bool bEnable ) pWin->SetAutoSpellContext(mpSpellCheckCxt); } + + if (bWasEnabled != bEnable && comphelper::LibreOfficeKit::isActive()) + { + if (ScTabViewShell* pViewSh = aViewData.GetViewShell()) + { + ScModelObj* pModel = comphelper::getFromUnoTunnel<ScModelObj>(pViewSh->GetCurrentDocument()); + SfxLokHelper::notifyViewRenderState(pViewSh, pModel); + } + } +} + +bool ScTabView::IsAutoSpell() const +{ + return static_cast<bool>(mpSpellCheckCxt); } void ScTabView::ResetAutoSpell() diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index d8d8b08219a3..6004c31a0016 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1504,7 +1504,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode ) bReadOnly = pDocSh->IsReadOnly(); bIsActive = false; - EnableAutoSpell(rDoc.GetDocOptions().IsAutoSpell()); + EnableAutoSpell(ScModule::GetAutoSpellProperty()); SetName("View"); // for SBX Color aColBlack( COL_BLACK ); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 964ceba34688..83975c6b0ee9 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -4096,7 +4096,8 @@ bool ScViewData::UpdateFixY( SCTAB nTab ) // true = value changed void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) const { ScDocument& rLocalDoc = GetDocument(); - bool bOnlineSpell = rLocalDoc.GetDocOptions().IsAutoSpell(); + const ScTabViewShell* pTabViewShell = GetViewShell(); + const bool bOnlineSpell = pTabViewShell && pTabViewShell->IsAutoSpell(); EEControlBits nCntrl = rOutl.GetControlWord(); nCntrl |= EEControlBits::MARKNONURLFIELDS; diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 249105efd843..b47bd907d1bd 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -1425,7 +1425,8 @@ void ScViewFunc::FillSimple( FillDir eDir ) UpdateScrollBars(); auto& rDoc = pDocSh->GetDocument(); - bool bDoAutoSpell = rDoc.GetDocOptions().IsAutoSpell(); + const ScTabViewShell* pTabViewShell = GetViewData().GetViewShell(); + const bool bDoAutoSpell = pTabViewShell && pTabViewShell->IsAutoSpell(); if ( bDoAutoSpell ) { // Copy AutoSpellData from above(left/right/below) if no selection. @@ -1500,7 +1501,8 @@ void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow, pDocSh->UpdateOle(GetViewData()); UpdateScrollBars(); - bool bDoAutoSpell = pDocSh->GetDocument().GetDocOptions().IsAutoSpell(); + const ScTabViewShell* pTabViewShell = GetViewData().GetViewShell(); + const bool bDoAutoSpell = pTabViewShell && pTabViewShell->IsAutoSpell(); if ( bDoAutoSpell ) CopyAutoSpellData(eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount);