core.git: Branch 'libreoffice-24-2' - sc/inc sc/source
sc/inc/column.hxx |2 - sc/inc/interpretercontext.hxx | 47 --- sc/inc/patattr.hxx |2 + sc/source/core/data/patattr.cxx| 11 + sc/source/core/tool/interpretercontext.cxx | 57 - 5 files changed, 94 insertions(+), 25 deletions(-) New commits: commit e310c8714cba16f592d59596caadf39bd01b61d0 Author: Caolán McNamara AuthorDate: Thu Feb 29 20:09:09 2024 + Commit: Adolfo Jayme Barrientos CommitDate: Mon Apr 15 05:55:54 2024 +0200 avoid SvNumberFormatter lock in formula-group-threading keep a per-interpret-thread cache of the SvNumberFormatter mapping while formula-group-threading, this is similar to: commit c2d8341ee392949274b901abfd44d9645d2e4e36 Date: Tue Oct 15 08:32:22 2019 +0530 Cache last used number-format-type in interpreter-context Change-Id: Ie99807eaf2f3260cec357f9d66307df0a69826e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164227 Tested-by: Jenkins Reviewed-by: Caolán McNamara (cherry picked from commit 2c3605405225de4b850064cf25b15cd64be1409b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165748 Reviewed-by: Adolfo Jayme Barrientos diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 733923b0f58c..69850197bdaa 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -984,7 +984,7 @@ inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich, inline sal_uInt32 ScColumnData::GetNumberFormat( const ScInterpreterContext& rContext, SCROW nRow ) const { -return pAttrArray->GetPattern( nRow )->GetNumberFormat( rContext.GetFormatTable() ); +return pAttrArray->GetPattern( nRow )->GetNumberFormat( rContext ); } inline void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ) diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx index 39d528cb6ca9..11e2c6990c8e 100644 --- a/sc/inc/interpretercontext.hxx +++ b/sc/inc/interpretercontext.hxx @@ -9,8 +9,11 @@ #pragma once +#include #include #include +#include +#include #include "types.hxx" namespace formula @@ -34,20 +37,6 @@ struct DelayedSetNumberFormat sal_uInt32 mnNumberFormat; }; -struct NFIndexAndFmtType -{ -sal_uInt32 nIndex; -SvNumFormatType eType : 16; -bool bIsValid : 1; - -NFIndexAndFmtType() -: nIndex(0) -, eType(static_cast(0)) -, bIsValid(false) -{ -} -}; - class ScInterpreterContextPool; struct ScInterpreterContext @@ -77,6 +66,8 @@ struct ScInterpreterContext SvNumFormatType GetNumberFormatType(sal_uInt32 nFIndex) const; +sal_uInt32 GetFormatForLanguageIfBuiltIn(sal_uInt32 nFormat, LanguageType eLnge) const; + private: friend class ScInterpreterContextPool; void ResetTokens(); @@ -85,7 +76,33 @@ private: void ClearLookupCache(const ScDocument* pDoc); void initFormatTable(); SvNumberFormatter* mpFormatter; -mutable NFIndexAndFmtType maNFTypeCache; + +// Some temp caches of the 4 most recent results from NumberFormatting +// lookups. +struct NFBuiltIn +{ +sal_uInt64 nKey; +sal_uInt32 nFormat; +NFBuiltIn() +: nKey(SAL_MAX_UINT64) +, nFormat(SAL_MAX_UINT32) +{ +} +}; +// from format+lang to builtin format +mutable std::array maNFBuiltInCache; +struct NFType +{ +sal_uInt32 nKey; +SvNumFormatType eType; +NFType() +: nKey(SAL_MAX_UINT32) +, eType(SvNumFormatType::ALL) +{ +} +}; +// from format index to type +mutable std::array maNFTypeCache; }; class ScThreadedInterpreterContextGetterGuard; diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx index d6536551f965..e4b149516c0f 100644 --- a/sc/inc/patattr.hxx +++ b/sc/inc/patattr.hxx @@ -31,6 +31,7 @@ namespace vcl { class Font; } namespace model { class ComplexColor; } +struct ScInterpreterContext; class OutputDevice; class Fraction; class ScStyleSheet; @@ -171,6 +172,7 @@ public: boolIsSymbolFont() const; sal_uInt32 GetNumberFormat( SvNumberFormatter* ) const; +sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext ) const; sal_uInt32 GetNumberFormat( SvNumberFormatter* pFormatter, const SfxItemSet* pCondSet ) const; diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 4bb79828da13..f5db8533cfe0 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1412,6 +1412,17 @@ sal_uInt32 ScPatternAttr::GetNumberFormat( SvNumberFormatter* pFormatter ) const return nFormat; } +sal_uInt32 ScPatternAttr::GetNumberFormat( const ScInterpreterContext& rContext ) const +{
core.git: Branch 'libreoffice-24-2' - sc/inc sc/source
sc/inc/refupdatecontext.hxx |2 +- sc/source/core/data/conditio.cxx | 10 +- sc/source/core/data/refupdatecontext.cxx |3 ++- sc/source/core/tool/token.cxx|2 +- 4 files changed, 9 insertions(+), 8 deletions(-) New commits: commit b30b90d7b6cc534cb96d0f97f29013e8d6cc2dd6 Author: Caolán McNamara AuthorDate: Sun Jan 7 15:52:16 2024 + Commit: Xisco Fauli CommitDate: Tue Jan 9 13:30:46 2024 +0100 cid#1583700 Uninitialized scalar variable and cid#1583699 Uninitialized scalar variable cid#1583695 Uninitialized scalar variable cid#1583694 Uninitialized scalar variable cid#1583693 Uninitialized scalar field cid#1583692 Uninitialized scalar variable cid#1583691 Uninitialized scalar variable Change-Id: I0d525d6231fe81e1cea63601bc42c3ad72808082 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161745 Tested-by: Jenkins Reviewed-by: Caolán McNamara (cherry picked from commit 2f0e5ccaddc4d38c0372fa5ee28ab0c616e6f0c9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161761 Reviewed-by: Xisco Fauli diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx index 50eb60c88d18..7789dfdc3a9e 100644 --- a/sc/inc/refupdatecontext.hxx +++ b/sc/inc/refupdatecontext.hxx @@ -113,7 +113,7 @@ struct RefUpdateResult */ bool mbNameModified; -SCTAB nTab; +SCTAB mnTab; RefUpdateResult(); }; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 04ee4e6fc239..13859539f385 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -598,12 +598,12 @@ void ScConditionEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) { sc::RefUpdateResult aResFinal; -aResFinal.nTab = aSrcPos.Tab(); +aResFinal.mnTab = aSrcPos.Tab(); if (pFormula1) { sc::RefUpdateResult aRes = pFormula1->AdjustReferenceOnMovedTab(rCxt, aSrcPos); if (aRes.mbValueChanged) -aResFinal.nTab = aRes.nTab; +aResFinal.mnTab = aRes.mnTab; pFCell1.reset(); } @@ -611,12 +611,12 @@ void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) { sc::RefUpdateResult aRes = pFormula2->AdjustReferenceOnMovedTab(rCxt, aSrcPos); if (aRes.mbValueChanged) -aResFinal.nTab = aRes.nTab; +aResFinal.mnTab = aRes.mnTab; pFCell2.reset(); } -if (aResFinal.nTab != aSrcPos.Tab()) -aSrcPos.SetTab(aResFinal.nTab); +if (aResFinal.mnTab != aSrcPos.Tab()) +aSrcPos.SetTab(aResFinal.mnTab); StartListening(); } diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx index 8faf1f105505..0ce3f175e48f 100644 --- a/sc/source/core/data/refupdatecontext.cxx +++ b/sc/source/core/data/refupdatecontext.cxx @@ -96,7 +96,8 @@ ColumnBlockPosition* RefUpdateContext::getBlockPosition(SCTAB nTab, SCCOL nCol) return mpBlockPos ? mpBlockPos->getBlockPosition(nTab, nCol) : nullptr; } -RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false), mbNameModified(false) {} +RefUpdateResult::RefUpdateResult() +: mbValueChanged(false), mbReferenceModified(false), mbNameModified(false), mnTab(-1) {} RefUpdateInsertTabContext::RefUpdateInsertTabContext(ScDocument& rDoc, SCTAB nInsertPos, SCTAB nSheets) : mrDoc(rDoc), mnInsertPos(nInsertPos), mnSheets(nSheets) {} diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index f927f2389450..25c5b6f05f79 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -4420,7 +4420,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( const sc::RefUpdate { aRes.mbReferenceModified = true; aRes.mbValueChanged = true; -aRes.nTab = aNewPos.Tab(); // this sets the new tab position used when deleting +aRes.mnTab = aNewPos.Tab(); // this sets the new tab position used when deleting } TokenPointers aPtrs( pCode.get(), nLen, pRPN, nRPN);
core.git: Branch 'libreoffice-24-2' - sc/inc sc/source
sc/inc/refupdatecontext.hxx |2 ++ sc/source/core/data/conditio.cxx | 15 --- sc/source/core/tool/token.cxx|4 3 files changed, 18 insertions(+), 3 deletions(-) New commits: commit 5653238332deac00affa4fa913354b3c8384dab9 Author: Matt K AuthorDate: Mon Jan 1 11:44:35 2024 -0600 Commit: Xisco Fauli CommitDate: Tue Jan 9 09:54:44 2024 +0100 tdf#73678 Prevent conditional formatting from being lost in Calc The problem is that when a Calc tab sheet is moved from one position to another, the ScConditionEntry aSrcPos member variable isn't updated, and therefore when deleting a blank sheet in front of a data sheet the deletion still thinks it's looking at the correct sheet but it is now out-of-date and as such the conditional formatting references are invalidated such that all math operations are tested against 0.0 instead of the actual formula value for the condtional formatting, which has the side effect of updating cells colors that should be uncolored as per the conditional formats set on them. The fix is to update this aSrcPos member variable of ScConditionEntry via the call to ScTokenArray::AdjustReferenceOnMovedTab from ScConditionEntry::UpdateMoveTab, which is called on tab sheet move. This way, the aSrcPos variable is up to date when ScConditionEntry::UpdateDeleteTab is called, which is called on tab sheet delete. Change-Id: I3bbc8111bb1685d6f7f307a15c852c6657f37b3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160234 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 0ba4e0483bacd698a227d0d18422fc6a08055c28) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161754 Reviewed-by: Xisco Fauli diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx index 1c50c7a2c0d1..50eb60c88d18 100644 --- a/sc/inc/refupdatecontext.hxx +++ b/sc/inc/refupdatecontext.hxx @@ -113,6 +113,8 @@ struct RefUpdateResult */ bool mbNameModified; +SCTAB nTab; + RefUpdateResult(); }; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 93094e929bf4..04ee4e6fc239 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -595,20 +595,29 @@ void ScConditionEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) StartListening(); } -void ScConditionEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) +void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) { +sc::RefUpdateResult aResFinal; +aResFinal.nTab = aSrcPos.Tab(); if (pFormula1) { -pFormula1->AdjustReferenceOnMovedTab(rCxt, aSrcPos); +sc::RefUpdateResult aRes = pFormula1->AdjustReferenceOnMovedTab(rCxt, aSrcPos); +if (aRes.mbValueChanged) +aResFinal.nTab = aRes.nTab; pFCell1.reset(); } if (pFormula2) { -pFormula2->AdjustReferenceOnMovedTab(rCxt, aSrcPos); +sc::RefUpdateResult aRes = pFormula2->AdjustReferenceOnMovedTab(rCxt, aSrcPos); +if (aRes.mbValueChanged) +aResFinal.nTab = aRes.nTab; pFCell2.reset(); } +if (aResFinal.nTab != aSrcPos.Tab()) +aSrcPos.SetTab(aResFinal.nTab); + StartListening(); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 8abf686f2510..f927f2389450 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -4417,7 +4417,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( const sc::RefUpdate ScAddress aNewPos = rOldPos; if (adjustTabOnMove(aNewPos, rCxt)) +{ aRes.mbReferenceModified = true; +aRes.mbValueChanged = true; +aRes.nTab = aNewPos.Tab(); // this sets the new tab position used when deleting +} TokenPointers aPtrs( pCode.get(), nLen, pRPN, nRPN); for (size_t j=0; j<2; ++j)
core.git: Branch 'libreoffice-24-2' - sc/inc sc/source
sc/inc/document.hxx |4 ++-- sc/source/core/data/documen8.cxx |7 +-- sc/source/ui/view/viewfun3.cxx |3 --- 3 files changed, 7 insertions(+), 7 deletions(-) New commits: commit 74174bd7ce9c09f8fe3c61e4d0b9d6441a1088c8 Author: Caolán McNamara AuthorDate: Sun Jan 7 13:37:57 2024 + Commit: Adolfo Jayme Barrientos CommitDate: Mon Jan 8 07:27:23 2024 +0100 Resolves: tdf#159046 hang on export of math objects in cells regression from: commit a9d6b6ef049dd41c91a30c03df0ba38ba8dcada8 Date: Thu Oct 5 14:12:51 2023 +0100 crash copying text + chart to clipboard with InputOptions::TextWysiwyg of true, the mxPoolHelper is still null when trying to create a Printer to use as a reference device revert that, and use a different simpler workaround for the original crash case. Change-Id: I74cec710aec033e1652e637ed056dae1c261aa98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161750 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 11b65e9262c0..09747bb2c0e7 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2708,8 +2708,6 @@ public: const ScTable* FetchTable( SCTAB nTab ) const; ScRefCellValue GetRefCellValue( const ScAddress& rPos ); - -void SharePooledResources( const ScDocument* pSrcDoc ); private: ScRefCellValue GetRefCellValue( const ScAddress& rPos, sc::ColumnBlockPosition& rBlockPos ); @@ -2719,6 +2717,8 @@ private: SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const; void ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve ); +void SharePooledResources( const ScDocument* pSrcDoc ); + void EndListeningIntersectedGroup( sc::EndListeningContext& rCxt, const ScAddress& rPos, std::vector* pGroupPos ); diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 84233f4c5867..50748236ee2a 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -114,7 +114,7 @@ void ScDocument::ImplDeleteOptions() SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist) { -if ( !mpPrinter && bCreateIfNotExist ) +if (!mpPrinter && bCreateIfNotExist && mxPoolHelper) { auto pSet = std::make_uniqueGetInputOptions().GetTextWysiwyg() ) +{ pRefDevice = GetPrinter(); -else +SAL_WARN_IF(!pRefDevice, "sc", "unable to get a printer, fallback to virdev"); +} +if (!pRefDevice) pRefDevice = GetVirtualDevice_100th_mm(); return pRefDevice; } diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 8aea1ebbd66d..7a6403237b89 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -242,9 +242,6 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* pClipDoc, const ScRangeList& if ( pSysClipDoc && bIncludeObjects ) { bool bAnyOle = rDoc.HasOLEObjectsInArea( aRange ); -// There are optional paths (e.g. bAnyOle and InputOptions().GetTextWysiwyg true) -// which dereference pSysClipDoc->mxPoolHelper so ensure that is set here. -pSysClipDoc->SharePooledResources(); // Update ScGlobal::xDrawClipDocShellRef. ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle, pSysClipDoc ) ); }
core.git: Branch 'libreoffice-24-2' - sc/inc sc/source
sc/inc/column.hxx | 37 +- sc/inc/table.hxx | 35 + sc/source/core/data/column.cxx | 84 - sc/source/core/data/table2.cxx | 68 - 4 files changed, 81 insertions(+), 143 deletions(-) New commits: commit 9826f6175bda0d5812ac1cdf22431973524ec0f6 Author: Mike Kaganski AuthorDate: Sat Dec 30 18:08:56 2023 +0600 Commit: Xisco Fauli CommitDate: Wed Jan 3 10:23:45 2024 +0100 tdf#158254: generalize and use algorithm to apply with allocation Commit 17bcf1073bf21088b9845e36fe735622d8f88fd7 (introduce ScColumnData for ScColumn/ScTable code sharing, 2022-05-05) implemented an algorithm to only allocate needed amount of columns, and/or apply to default data when needed. It was done for ApplySelectionCache, ChangeSelectionIndent, ClearSelectionItems. Yet, many other functions need the same approach. This change introduces ScTable::ApplyWithAllocation template, which allows to use this algorithm uniformly to any operation on a selection, which ultimately applies to ScColumnData. The code in the functions mentioned above is replaced with its use; and ApplySelectionStyle is fixed using it. Change-Id: Ic8890d9980fcb01b61bb83b355c623f866a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161441 Tested-by: Jenkins Reviewed-by: Mike Kaganski Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161535 diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 914199be25b5..733923b0f58c 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -144,8 +144,9 @@ public: const ScPatternAttr*GetPattern( SCROW nRow ) const; const ScPatternAttr*GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const; -SCROW ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged, - SCCOL nCol ); +voidApplySelectionStyle(const ScStyleSheet& rStyle, SCROW nTop, SCROW nBottom); +voidApplySelectionCache(ScItemPoolCache* pCache, SCROW nStartRow, SCROW nEndRow, +ScEditDataArray* pDataArray, bool* pIsChanged); voidApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const ScPatternAttr& rPatAttr, ScEditDataArray* pDataArray = nullptr, bool* const pIsChanged = nullptr); @@ -167,12 +168,17 @@ public: boolIsAllAttrEqual( const ScColumnData& rCol, SCROW nStartRow, SCROW nEndRow ) const; -voidClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark, SCCOL nCol ); -voidChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark, SCCOL nCol ); +voidClearSelectionItems(const sal_uInt16* pWhich, SCROW nStartRow, SCROW nEndRow); +voidChangeSelectionIndent(bool bIncrement, SCROW nStartRow, SCROW nEndRow); boolTestInsertRow( SCSIZE nSize ) const; voidInsertRow( SCROW nStartRow, SCSIZE nSize ); voidDeleteRow( SCROW nStartRow, SCSIZE nSize ); + +// Applies a function to the selected ranges. +// The function looks like +// ApplyDataFunc(ScColumnData& applyTo, SCROW nTop, SCROW nBottom) +template void Apply(const ScMarkData&, SCCOL, ApplyDataFunc); }; // Use protected inheritance to prevent publishing some internal ScColumnData @@ -548,7 +554,6 @@ public: const ScPatternAttr& rPattern, SvNumFormatType nNewType ); voidApplyStyle( SCROW nRow, const ScStyleSheet* rStyle ); -voidApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark); voidApplySelectionLineStyle( const ScMarkData& rMark, const ::editeng::SvxBorderLine* pLine, bool bColorOnly ); voidAddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex ); @@ -575,12 +580,8 @@ public: voidRemoveProtected( SCROW nStartRow, SCROW nEndRow ); -SCROW ApplySelectionCache( ScItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged ); void DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark, bool bBroadcast ); -voidClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); -voidChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); - tools::Long GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY, const Fraction& rZoomX, const Fraction& rZoomY, @@ -1067,4 +1068,22 @@ inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize) pAttrArray->DeleteRow( nStartRow, nSize ); } +template +void