[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/arraysumfunctor.hxx | 17 - sc/inc/kahan.hxx | 66 +-- sc/source/core/tool/arraysum.hxx | 36 --- sc/source/core/tool/arraysumSSE2.cxx |6 +-- 4 files changed, 50 insertions(+), 75 deletions(-) New commits: commit 342ba2605f84279f5dd58b8227e73d75e3b9d462 Author: Eike Rathke AuthorDate: Sun Oct 15 17:29:01 2023 +0200 Commit: Xisco Fauli CommitDate: Mon Oct 16 11:39:59 2023 +0200 Follow-up: tdf#156985 Use SC_USE_SSE2 to determine which KahanSum::add() to use Also, the CPU identifier for MSVC WIN32 is not X86 but INTEL, so actually use SSE2 there as well, which was the cause of things failing on that platform. For other platforms than Intel x86/x86_64 SSE2 is not defined, so exclude the new unit test based on that and live on with the old slightly off value. Experiments did not yield any solution that works, even using plain sumNeumaierNormal() (similar to SSE2) in the executeUnrolled() case instead of KahanSum with its m_fMem did not help, nor trying to add the internal values in different orders or with long double, au contraire the error was slightly larger. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156899 Reviewed-by: Eike Rathke Tested-by: Jenkins (cherry picked from commit 361c4f008e48b08df635839d2e5dcad7389df44a) Conflicts: sc/qa/unit/ucalc_formula2.cxx Change-Id: Ica0b2963f76c01f248799e9a809ef06eb099e722 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157964 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sc/inc/arraysumfunctor.hxx b/sc/inc/arraysumfunctor.hxx index c261c120addf..c1eabb220e27 100644 --- a/sc/inc/arraysumfunctor.hxx +++ b/sc/inc/arraysumfunctor.hxx @@ -12,29 +12,12 @@ #include #include "kahan.hxx" -#include "arraysumfunctor.hxx" #include namespace sc::op { -// Checkout available optimization options. -// Note that it turned out to be problematic to support CPU-specific code -// that's not guaranteed to be available on that specific platform (see -// git history). SSE2 is guaranteed on x86_64 and it is our baseline requirement -// for x86 on Windows, so SSE2 use is hardcoded on those platforms. -// Whenever we raise baseline to e.g. AVX, this may get -// replaced with AVX code (get it from git history). -// Do it similarly with other platforms. -#if defined(X86_64) || (defined(X86) && defined(_WIN32)) -#define SC_USE_SSE2 1 -KahanSum executeSSE2(size_t& i, size_t nSize, const double* pCurrent); -#else -#define SC_USE_SSE2 0 -#endif - /** * If no boosts available, Unrolled KahanSum. - * Most likely to use on android. */ static inline KahanSum executeUnrolled(size_t& i, size_t nSize, const double* pCurrent) { diff --git a/sc/inc/kahan.hxx b/sc/inc/kahan.hxx index ac97ae4394fa..03b05c25aa6b 100644 --- a/sc/inc/kahan.hxx +++ b/sc/inc/kahan.hxx @@ -12,6 +12,26 @@ #include #include +class KahanSum; +namespace sc::op +{ +// Checkout available optimization options. +// Note that it turned out to be problematic to support CPU-specific code +// that's not guaranteed to be available on that specific platform (see +// git commit 2d36e7f5186ba5215f2b228b98c24520bd4f2882). SSE2 is guaranteed on +// x86_64 and it is our baseline requirement for x86 on Windows, so SSE2 use is +// hardcoded on those platforms. +// Whenever we raise baseline to e.g. AVX, this may get +// replaced with AVX code (get it from mentioned git commit). +// Do it similarly with other platforms. +#if defined(X86_64) || (defined(INTEL) && defined(_WIN32)) +#define SC_USE_SSE2 1 +KahanSum executeSSE2(size_t& i, size_t nSize, const double* pCurrent); +#else +#define SC_USE_SSE2 0 +#endif +} + /** * This class provides LO with Kahan summation algorithm * About this algorithm: https://en.wikipedia.org/wiki/Kahan_summation_algorithm @@ -41,6 +61,21 @@ public: constexpr KahanSum(const KahanSum& fSum) = default; public: +/** + * Performs one step of the Neumaier sum of doubles. + * Overwrites the summand and error. + * T could be double or long double. + */ +template static inline void sumNeumaierNormal(T& sum, T& err, const double& value) +{ +T t = sum + value; +if (std::abs(sum) >= std::abs(value)) +err += (sum - t) + value; +else +err += (value - t) + sum; +sum = t; +} + /** * Adds a value to the sum using Kahan summation. * @param x_i @@ -71,32 +106,27 @@ public: */ inline void add(const KahanSum& fSum) { -#ifdef _WIN32 -// For some odd unknown reason WIN32 fails badly with the -// sum+compensation value. Continue keeping the old though slightly off -// (see tdf#156985) explicit addition of the compensation value. -add(fSum.m_fSum); -add(fSum.m_fError);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/colorscale.hxx |1 + sc/inc/conditio.hxx|5 + sc/source/core/data/colorscale.cxx |6 ++ sc/source/core/data/conditio.cxx | 20 sc/source/core/data/table2.cxx |3 +++ 5 files changed, 35 insertions(+) New commits: commit e4010b7d83244d9d51f36e22c9d9cd63eda870cb Author: Henry Castro AuthorDate: Thu May 11 16:07:10 2023 -0400 Commit: Henry Castro CommitDate: Thu Jun 29 19:30:14 2023 +0200 tdf#154477: sc: add "updateValues" method to conditional format list When copying a range cells to a clipboard, if exists a color scale conditional format from different ranges, it should update the min and max values, otherwise the color scale conditional format could not calculate min and max values due to limiting range cell copied. Signed-off-by: Henry Castro Change-Id: I660e18090a60b99ddf2b55ce1f713fd41121290e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151835 Tested-by: Jenkins (cherry picked from commit fcb348da642f7e5c41fe495cf6289f9992bfa1b9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152520 diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index fb987f5af1b5..6652e224fe67 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -231,6 +231,7 @@ public: virtual void startRendering() override; virtual void endRendering() override; +virtual void updateValues() override; protected: std::vector& getValues() const; diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index 50b74bd8721c..47f5fdb3addb 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -251,6 +251,7 @@ public: virtual void startRendering(); virtual void endRendering(); +virtual void updateValues(); protected: ScDocument* mpDoc; @@ -598,6 +599,8 @@ public: void startRendering(); void endRendering(); +void updateValues(); + // Forced recalculation for formulas void CalcAll(); }; @@ -683,6 +686,8 @@ public: void startRendering(); void endRendering(); +void updateValues(); + sal_uInt32 getMaxKey() const; /// Forced recalculation of formulas diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index e3c3780971fb..4e61dbdbc228 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -544,6 +544,12 @@ void ScColorFormat::endRendering() mpCache.reset(); } +void ScColorFormat::updateValues() +{ +getMinValue(); +getMaxValue(); +} + namespace { sal_uInt8 GetColorValue( double nVal, double nVal1, sal_uInt8 nColVal1, double nVal2, sal_uInt8 nColVal2 ) diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 54f89dd3a7b3..b70f9579d0e8 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -74,6 +74,10 @@ void ScFormatEntry::endRendering() { } +void ScFormatEntry::updateValues() +{ +} + static bool lcl_HasRelRef( ScDocument* pDoc, const ScTokenArray* pFormula, sal_uInt16 nRecursion = 0 ) { if (pFormula) @@ -2053,6 +2057,14 @@ void ScConditionalFormat::endRendering() } } +void ScConditionalFormat::updateValues() +{ +for(auto& rxEntry : maEntries) +{ +rxEntry->updateValues(); +} +} + void ScConditionalFormat::CalcAll() { for(const auto& rxEntry : maEntries) @@ -2300,6 +2312,14 @@ void ScConditionalFormatList::endRendering() } } +void ScConditionalFormatList::updateValues() +{ +for (auto const& it : m_ConditionalFormats) +{ +it->updateValues(); +} +} + void ScConditionalFormatList::clear() { m_ConditionalFormats.clear(); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 91f90dbb1ae4..910568d35720 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -532,7 +532,10 @@ void ScTable::CopyToClip( for (SCCOL i = nCol1; i <= nCol2; i++) pTable->aCol[i].RemoveProtected(nRow1, nRow2); +mpCondFormatList->startRendering(); +mpCondFormatList->updateValues(); pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->rDocument, *mpCondFormatList)); +mpCondFormatList->endRendering(); } void ScTable::CopyToClip(
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/colorscale.hxx |2 ++ sc/source/core/data/colorscale.cxx | 15 +++ 2 files changed, 17 insertions(+) New commits: commit 284ac82b1af70c8734bae6eb841ae01735bb6b41 Author: Henry Castro AuthorDate: Thu May 11 16:23:03 2023 -0400 Commit: Henry Castro CommitDate: Thu Jun 29 19:29:56 2023 +0200 tdf#154477: sc: copy cache values when clone color conditional format When clone a conditional format list, also copy the cache values that hold the min and max values, otherwise if clone occurs when copying to the clipboard the values have wrong data due to limiting range cells copied. Signed-off-by: Henry Castro Change-Id: Id9085a1488a3bde24842e0d2e062c9b425074157 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151836 Tested-by: Jenkins (cherry picked from commit c85255fd7a62bec9342fa6f2a79d1395979d54be) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152521 diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 88e35775419a..fb987f5af1b5 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -224,6 +224,8 @@ public: virtual ~ScColorFormat() override; const ScRangeList& GetRange() const; +void SetCache(const std::vector& aValues); +std::vector GetCache() const; virtual void SetParent(ScConditionalFormat* pParent) override; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 876d100840bf..e3c3780971fb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -378,6 +378,9 @@ ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleForma { maColorScales.emplace_back(new ScColorScaleEntry(pDoc, *rxEntry)); } + +auto aCache = rFormat.GetCache(); +SetCache(aCache); } ScColorFormat* ScColorScaleFormat::Clone(ScDocument* pDoc) const @@ -457,6 +460,18 @@ const ScRangeList& ScColorFormat::GetRange() const return mpParent->GetRange(); } +std::vector ScColorFormat::GetCache() const +{ +std::vector empty; +return mpCache ? mpCache->maValues : empty; +} + +void ScColorFormat::SetCache(const std::vector& aValues) +{ +mpCache.reset(new ScColorFormatCache); +mpCache->maValues = aValues; +} + std::vector& ScColorFormat::getValues() const { if(!mpCache)
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/column.hxx |6 ++ sc/source/core/data/table1.cxx | 12 +--- sc/source/core/data/table2.cxx |3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) New commits: commit 93c6fdc58d577d059968a71ae08b80096f73ef1a Author: Czeber László Ádám AuthorDate: Thu Jun 8 14:55:34 2023 +0200 Commit: Xisco Fauli CommitDate: Tue Jun 27 22:36:53 2023 +0200 tdf#153437 sc: fix broken formatting without performance regression Follow-up to commit 7be7e1ff95af485a9cb00748800d3d084f96387c "tdf#153437 sc: fix broken formatting at Undo of row/column insertion" by replacing that with a better version without performance regression. This keeps the original performance fix of commit 2e86718626a07e1656661df3ad69a64848bf4614 "don't allocate unnecessary columns when inserting a row" related to the support of 16k columns. The previous fix used extra memory to fix the broken formatting of the cells. I have now solved the error in tdf#153437 without taking extra memory. It doesn't change the reserved cells, it just deletes a row from the default attribute of the cells when deleting rows, so they don't slip. When deleting a column, the last column in the still reserved area loses its formatting. I copied the default value back here, as the other columns have this value. Change-Id: I35da1cb79ff4e3493e91d29766cc2b81412080eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152742 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit c61f5a5d55c07721f044befc1f6efa0231cd92f6) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152814 Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153494 Tested-by: Jenkins diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 949ca30dd137..87d3dc730a9f 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -171,6 +171,7 @@ public: boolTestInsertRow( SCSIZE nSize ) const; voidInsertRow( SCROW nStartRow, SCSIZE nSize ); +voidDeleteRow( SCROW nStartRow, SCSIZE nSize ); }; // Use protected inheritance to prevent publishing some internal ScColumnData @@ -1054,4 +1055,9 @@ inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize ) pAttrArray->InsertRow( nStartRow, nSize ); } +inline void ScColumnData::DeleteRow(SCROW nStartRow, SCSIZE nSize) +{ +pAttrArray->DeleteRow( nStartRow, nSize ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 6cb5384c05f9..308025656319 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1851,13 +1851,11 @@ void ScTable::UpdateReference( } else { -// When deleting row(s) or column(s), allocate the last column -// before updating the references -if (nDx < 0 || nDy < 0) -CreateColumnIfNotExists(rDocument.MaxCol()); - -for (SCCOL col : GetColumnsRange(0, rDocument.MaxCol())) -bUpdated |= CreateColumnIfNotExists(col).UpdateReference(rCxt, pUndoDoc); +for (SCCOL col : GetAllocatedColumnsRange(0, rDocument.MaxCol())) +bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc); +// When deleting row(s), delete same row from the default attribute +if (nDy < 0) +aDefaultColData.DeleteRow(nRow1+nDy, -nDy); } if ( bIncludeDraw ) diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 4eb5671f0dc7..91f90dbb1ae4 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -400,6 +400,9 @@ void ScTable::DeleteCol( { for (SCCOL nCol = nStartCol + nSize; nCol < aCol.size(); ++nCol) aCol[nCol].SwapCol(aCol[nCol - nSize]); +// When delete column(s), inicialize the last columns from the default attributes +for (SCCOL nCol = aCol.size() - nSize; nCol < aCol.size(); ++nCol) +aCol[nCol].Init(nCol, aCol[nCol].GetTab(), rDocument, false); } else {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/document.hxx |3 +- sc/inc/table.hxx |2 + sc/source/core/data/document.cxx | 12 +-- sc/source/core/data/drwlayer.cxx |7 +- sc/source/core/data/table5.cxx | 42 +++ 5 files changed, 58 insertions(+), 8 deletions(-) New commits: commit 8fec6c7f8cc24f10330d8ff9be0ef86e6974a52f Author: Balazs Varga AuthorDate: Sat Mar 25 18:57:08 2023 +0100 Commit: Xisco Fauli CommitDate: Wed Mar 29 18:49:55 2023 + Related: tdf#154005 sc ods fileopen: fix dropdown form control size Fixing the crashtesting assert/crash after the original change. Also a little clean-up. Change-Id: I35453fbc55b3d5d4064179e84755334c2d3a01ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149583 Tested-by: Jenkins Reviewed-by: Caolán McNamara Reviewed-by: Balazs Varga (cherry picked from commit 69cc8bdd5f9109804d912b52d5ee1040d6e1868f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149597 Reviewed-by: Xisco Fauli diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index f8558cc21070..97b47ee94d00 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -2035,7 +2035,8 @@ public: SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; -SCCOL CountVisibleCols(SCROW nStartCol, SCROW nEndCol, SCTAB nTab) const; +SCROW CountHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; +SCCOL CountHiddenCols(SCROW nStartCol, SCROW nEndCol, SCTAB nTab) const; SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const; boolHasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index f81e3925964e..851248a99c19 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -964,9 +964,11 @@ public: SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const; SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const; SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const; +SCROW CountHiddenRows(SCROW nStartRow, SCROW nEndRow) const; tools::Long GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true) const; SCCOL CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const; +SCCOL CountHiddenCols(SCCOL nStartCol, SCCOL nEndCol) const; SCCOLROWLastHiddenColRow(SCCOLROW nPos, bool bCol) const; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index e31e8f385592..79ce684d87be 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -4571,12 +4571,20 @@ SCROW ScDocument::CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) c return maTabs[nTab]->CountVisibleRows(nStartRow, nEndRow); } -SCCOL ScDocument::CountVisibleCols(SCROW nStartCol, SCROW nEndCol, SCTAB nTab) const +SCROW ScDocument::CountHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const { if (!ValidTab(nTab) || nTab >= static_cast(maTabs.size()) || !maTabs[nTab]) return 0; -return maTabs[nTab]->CountVisibleCols(nStartCol, nEndCol); +return maTabs[nTab]->CountHiddenRows(nStartRow, nEndRow); +} + +SCCOL ScDocument::CountHiddenCols(SCROW nStartCol, SCROW nEndCol, SCTAB nTab) const +{ +if (!ValidTab(nTab) || nTab >= static_cast(maTabs.size()) || !maTabs[nTab]) +return 0; + +return maTabs[nTab]->CountHiddenCols(nStartCol, nEndCol); } bool ScDocument::RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow, SCROW* pLastRow) const diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index e6203697a4e7..5627c8b889ec 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -708,11 +708,8 @@ void lcl_SetLogicRectFromAnchor(SdrObject* pObj, const ScDrawObjData& rAnchor, c // tdf#154005: Handle hidden row/col: remove hidden row/cols size from the ScDrawObjData shape size in case of forms if (pObj->GetObjIdentifier() == SdrObjKind::UNO && pObj->GetObjInventor() == SdrInventor::FmForm) { -nHiddenRows = ((rAnchor.maEnd.Row() - rAnchor.maStart.Row()) + 1) - -(pDoc->CountVisibleRows(rAnchor.maStart.Row(), rAnchor.maEnd.Row(), rAnchor.maStart.Tab())); - -nHiddenCols = ((rAnchor.maEnd.Col() - rAnchor.maStart.Col()) + 1) - -(pDoc->CountVisibleCols(rAnchor.maStart.Col(), rAnchor.maEnd.Col(), rAnchor.maStart.Tab())); +nHiddenRows = pDoc->CountHiddenRows(rAnchor.maStart.Row(),
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/columnspanset.hxx |1 + sc/source/core/data/columnspanset.cxx |4 2 files changed, 5 insertions(+) New commits: commit b032101f1e253e83dbed58632882853021d11647 Author: Kohei Yoshida AuthorDate: Thu Mar 2 23:29:15 2023 -0500 Commit: Kohei Yoshida CommitDate: Mon Mar 6 13:38:28 2023 + tdf#148143: Reset the position hint when flat_segment_tree gets copied std::optional stores the wrapped object as part of its memory footprint, and when it gets copied, it copy-constructs the wrapped object too. We need to be aware of this when using std::optional inside std::vector which may reallocate its internal buffer and copy the stored elements. Change-Id: Ib8fab1295388ae2ee9ef3d044943ac3c2bc8e529 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148152 Tested-by: Jenkins Reviewed-by: Kohei Yoshida (cherry picked from commit c4187189060a104cf36d8a8c9b2958b8c28cde0b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148233 diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx index d8cfc41f524b..5a3dc7645a43 100644 --- a/sc/inc/columnspanset.hxx +++ b/sc/inc/columnspanset.hxx @@ -58,6 +58,7 @@ private: ColumnSpansType::const_iterator miPos; ColumnType(SCROW nStart, SCROW nEnd, bool bInit); +ColumnType(const ColumnType& rOther); }; typedef std::vector> TableType; diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx index eb09ea26be98..bec9c8a7e270 100644 --- a/sc/source/core/data/columnspanset.cxx +++ b/sc/source/core/data/columnspanset.cxx @@ -53,6 +53,9 @@ ColRowSpan::ColRowSpan(SCCOLROW nStart, SCCOLROW nEnd) : mnStart(nStart), mnEnd( ColumnSpanSet::ColumnType::ColumnType(SCROW nStart, SCROW nEnd, bool bInit) : maSpans(nStart, nEnd+1, bInit), miPos(maSpans.begin()) {} +ColumnSpanSet::ColumnType::ColumnType(const ColumnType& rOther) : +maSpans(rOther.maSpans), miPos(maSpans.begin()) {} // NB: copying maSpans invalidates miPos - reset it + ColumnSpanSet::Action::~Action() {} void ColumnSpanSet::Action::startColumn(SCTAB /*nTab*/, SCCOL /*nCol*/) {} @@ -142,6 +145,7 @@ void ColumnSpanSet::scan( ColumnNonEmptyRangesScanner aScanner(rCol.maSpans, bVal); ParseBlock(rSrcCells.begin(), rSrcCells, aScanner, nRow1, nRow2); +rCol.miPos = rCol.maSpans.begin(); } }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/clipcontext.hxx | 15 + sc/inc/column.hxx | 19 +--- sc/inc/document.hxx |3 + sc/source/core/data/clipcontext.cxx | 47 ++ sc/source/core/data/column3.cxx | 55 +--- sc/source/core/data/column4.cxx | 18 +++ sc/source/core/data/document.cxx| 31 +--- 7 files changed, 157 insertions(+), 31 deletions(-) New commits: commit 33b6c065a1629afd36c9ae0fe5daa18b972620e5 Author: Kohei Yoshida AuthorDate: Tue Feb 21 22:16:30 2023 -0500 Commit: Kohei Yoshida CommitDate: Tue Feb 28 21:13:25 2023 + tdf#153669: Track formulas that stopped listening ... ... then have them start listening again after the copy from clipboard is complete. Note that in case the pasted cells are formula cells, those will be handled together as well. Change-Id: Ia4be814b888734267a39f7c89435011968570b7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147940 Tested-by: Jenkins Reviewed-by: Kohei Yoshida (cherry picked from commit e83c243018c1c7f6662f9a8ecdc731c5c071ea31) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147912 diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx index b09e1be78761..b3ce874a6a7f 100644 --- a/sc/inc/clipcontext.hxx +++ b/sc/inc/clipcontext.hxx @@ -12,6 +12,7 @@ #include "address.hxx" #include "cellvalue.hxx" #include "celltextattr.hxx" +#include "columnspanset.hxx" #include "Sparkline.hxx" #include @@ -45,6 +46,9 @@ public: class SC_DLLPUBLIC CopyFromClipContext final : public ClipContextBase { +/** Tracks modified formula group spans. */ +sc::ColumnSpanSet maListeningFormulaSpans; + SCCOL mnDestCol1; SCCOL mnDestCol2; SCROW mnDestRow1; @@ -101,6 +105,17 @@ public: void setDeleteFlag( InsertDeleteFlags nFlag ); InsertDeleteFlags getDeleteFlag() const; +/** + * Record a range of formula cells that need to start listening after the + * copy-from-clip is complete. + */ +void setListeningFormulaSpans( SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); + +/** + * Have the formula cells in the recorded ranges start listening. + */ +void startListeningFormulas(); + /** * Set the column size of a "single cell" row, which is used when copying * a single row of cells in a clip doc and pasting it into multiple diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 69f0d12d8273..949ca30dd137 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -22,6 +22,7 @@ #include "global.hxx" #include "address.hxx" #include "cellvalue.hxx" +#include "columnspanset.hxx" #include "rangelst.hxx" #include "types.hxx" #include "mtvelements.hxx" @@ -48,8 +49,6 @@ class CopyFromClipContext; class CopyToClipContext; class CopyToDocContext; class MixDocContext; -class ColumnSpanSet; -class SingleColumnSpanSet; struct RefUpdateContext; struct RefUpdateInsertTabContext; struct RefUpdateDeleteTabContext; @@ -837,9 +836,19 @@ private: void CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const; -void DeleteCells( -sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag, -sc::SingleColumnSpanSet& rDeleted ); +struct DeleteCellsResult +{ +/** cell ranges that have been deleted. */ +sc::SingleColumnSpanSet aDeletedRows; +/** formula cell range that has stopped listening. */ +std::vector> aFormulaRanges; + +DeleteCellsResult( const ScDocument& rDoc ); +DeleteCellsResult( const DeleteCellsResult& ) = delete; +}; + +std::unique_ptr DeleteCells( +sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, SCROW nRow2, InsertDeleteFlags nDelFlag ); /** * Get all non-grouped formula cells and formula cell groups in the whole diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 20e42a999ac8..4873307ea01d 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1672,6 +1672,9 @@ public: SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, SCCOL nDx, SCROW& rClipStartRow, SCROW nClipEndRow); +void StartListeningFromClip( +sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt, +SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ); void StartListeningFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, const ScMarkData& rMark, InsertDeleteFlags nInsFlag ); diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx index d291c7c91f49..ce6974d42334 100644 --- a/sc/source/core/data/clipcontext.cxx +++ b/sc/source/core/data/clipcontext.cxx @@ -21,6 +21,7 @@ #include
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/stlpool.hxx |2 + sc/source/core/data/stlpool.cxx | 10 sc/source/core/tool/interpr2.cxx | 45 ++- sc/source/ui/docshell/docsh4.cxx |6 - 4 files changed, 44 insertions(+), 19 deletions(-) New commits: commit fed875f35be3204a7d77bf315a07caaa3bf635e9 Author: Mike Kaganski AuthorDate: Fri Feb 10 16:04:46 2023 +0300 Commit: Adolfo Jayme Barrientos CommitDate: Mon Feb 13 00:04:19 2023 + tdf#153510: STYLE: try harder to detect when there's nothing to do 1. Find the real style names early, to avoid re-triggering style application when STYLE arguments use wrong case; 2. Also check a (rare) case when both immediate and delayed styles are the same as currently applied. Change-Id: Id8ab2e321ede6d0f8f05ac5d1e63ade0212e5865 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146775 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit 208a4ecafafa97ea7fcc5a135fa8160e91ea0a74) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146765 Reviewed-by: Adolfo Jayme Barrientos diff --git a/sc/inc/stlpool.hxx b/sc/inc/stlpool.hxx index f4e3ac757094..51694a405202 100644 --- a/sc/inc/stlpool.hxx +++ b/sc/inc/stlpool.hxx @@ -51,6 +51,8 @@ public: boolHasStandardStyles() const { return bHasStandardStyles; } ScStyleSheet* FindCaseIns( const OUString& rName, SfxStyleFamily eFam ); +// Finds Para style with given name case-insensitively, or STR_STYLENAME_STANDARD +ScStyleSheet* FindAutoStyle(const OUString& rName); virtual SfxStyleSheetBase& Make( const OUString&, SfxStyleFamily eFam, SfxStyleSearchBits nMask = SfxStyleSearchBits::All) override; diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index b08b6c2203c9..8f554896ff21 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -424,6 +424,16 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFami return first; } +ScStyleSheet* ScStyleSheetPool::FindAutoStyle(const OUString& rName) +{ +ScStyleSheet* pStyleSheet = FindCaseIns(rName, SfxStyleFamily::Para); +if (!pStyleSheet) +if (auto pFound = Find(ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para)) +if (pFound->isScStyleSheet()) // we do not know what kind of sheets we have +pStyleSheet = static_cast(pFound); +return pStyleSheet; +} + void ScStyleSheetPool::setAllParaStandard() { SfxStyleSheetBase* pSheet = First(SfxStyleFamily::Para); diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index c8015598891f..7826522a89bf 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -2595,38 +2596,54 @@ void ScInterpreter::ScStyle() if (!MustHaveParamCount(nParamCount, 1, 3)) return; -OUString aStyle2; // Template after timer +OUString aStyle2; // Style after timer if (nParamCount >= 3) aStyle2 = GetString().getString(); tools::Long nTimeOut = 0; // timeout if (nParamCount >= 2) nTimeOut = static_cast(GetDouble()*1000.0); -OUString aStyle1 = GetString().getString(); // Template for immediate +OUString aStyle1 = GetString().getString(); // Style for immediate if (nTimeOut < 0) nTimeOut = 0; -// Execute request to apply template +// Execute request to apply style if ( !mrDoc.IsClipOrUndo() ) { SfxObjectShell* pShell = mrDoc.GetDocumentShell(); if (pShell) { +// Normalize style names right here, making sure that character case is correct, +// and that we only apply anything when there's something to apply +auto pPool = mrDoc.GetStyleSheetPool(); +if (!aStyle1.isEmpty()) +{ +if (auto pNewStyle = pPool->FindAutoStyle(aStyle1)) +aStyle1 = pNewStyle->GetName(); +else +aStyle1.clear(); +} +if (!aStyle2.isEmpty()) +{ +if (auto pNewStyle = pPool->FindAutoStyle(aStyle2)) +aStyle2 = pNewStyle->GetName(); +else +aStyle2.clear(); +} // notify object shell directly! -bool bNotify = true; -if (aStyle2.isEmpty()) +if (!aStyle1.isEmpty() || !aStyle2.isEmpty()) { const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), aPos.Row(), aPos.Tab()); -if (pStyle && pStyle->GetName() == aStyle1) -bNotify = false; -}
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/validat.hxx |4 sc/source/core/data/validat.cxx | 196 +++- 2 files changed, 79 insertions(+), 121 deletions(-) New commits: commit a5e765e67ef6527486771caaf6c89962136ec07e Author: Balazs Varga AuthorDate: Tue Jan 31 14:21:31 2023 +0100 Commit: Xisco Fauli CommitDate: Fri Feb 10 11:50:59 2023 + Related: tdf#150098 sc validation: allowing formulas for validity test Clean-up and a little optimization. Change-Id: Ib56d959188912f4b18acb5466ce55bc7b5b4ee4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146391 Tested-by: Jenkins Reviewed-by: Balazs Varga (cherry picked from commit d8ae6d1388f28c405c4de2dfe93dbfe2d8acd470) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146696 Reviewed-by: Xisco Fauli diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx index 79eb9b75a334..6f64b842daba 100644 --- a/sc/inc/validat.hxx +++ b/sc/inc/validat.hxx @@ -152,6 +152,10 @@ public: bool IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos ) const; +/** Test, if formula is valid. */ +bool isFormulaResultsValidatable(const OUString& rTest, const ScAddress& rPos, SvNumberFormatter* pFormatter, +OUString& rStrResult, double& nVal, sal_uInt32& nFormat, bool& bIsVal) const; + // TRUE -> break bool DoError(weld::Window* pParent, const OUString& rInput, const ScAddress& rPos) const; void DoCalcError( ScFormulaCell* pCell ) const; diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 2d6194baf588..4db07b09abc7 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -444,67 +444,12 @@ bool ScValidationData::IsDataValidCustom( if (rTest[0] == '=') { -std::optional pFCell(std::in_place, *mpDoc, rPos, rTest, true); -pFCell->SetLimitString(true); - -bool bColRowName = pFCell->HasColRowName(); -if (bColRowName) -{ -// ColRowName from RPN-Code? -if (pFCell->GetCode()->GetCodeLen() <= 1) -{ // ==1: area -// ==0: would be an area if... -OUString aBraced = "(" + rTest + ")"; -pFCell.emplace(*mpDoc, rPos, aBraced, true); -pFCell->SetLimitString(true); -} -else -bColRowName = false; -} - -FormulaError nErrCode = pFCell->GetErrCode(); -if (nErrCode == FormulaError::NONE || pFCell->IsMatrix()) -{ -pFormatter = mpDoc->GetFormatTable(); -const Color* pColor; -if (pFCell->IsMatrix()) -{ -rStrResult = pFCell->GetString().getString(); -} -else if (pFCell->IsValue()) -{ -nVal = pFCell->GetValue(); -nFormat = pFormatter->GetStandardFormat(nVal, 0, -pFCell->GetFormatType(), ScGlobal::eLnge); -pFormatter->GetOutputString(nVal, nFormat, rStrResult, ); -bIsVal = true; -} -else -{ -nFormat = pFormatter->GetStandardFormat( -pFCell->GetFormatType(), ScGlobal::eLnge); -pFormatter->GetOutputString(pFCell->GetString().getString(), nFormat, -rStrResult, ); -// Indicate it's a string, so a number string doesn't look numeric. -// Escape embedded quotation marks first by doubling them, as -// usual. Actually the result can be copy-pasted from the result -// box as literal into a formula expression. -rStrResult = "\"" + rStrResult.replaceAll("\"", "\"\"") + "\""; -} - -ScRange aTestRange; -if (bColRowName || (aTestRange.Parse(rTest, *mpDoc) & ScRefFlags::VALID)) -rStrResult += " ..."; -// area - -// check whether empty cells are allowed -if (rStrResult.isEmpty()) -return IsIgnoreBlank(); -} -else -{ +if (!isFormulaResultsValidatable(rTest, rPos, pFormatter, rStrResult, nVal, nFormat, bIsVal)) return false; -} + +// check whether empty cells are allowed +if (rStrResult.isEmpty()) +return IsIgnoreBlank(); } else { @@ -599,69 +544,14 @@ bool ScValidationData::IsDataValid( OUString rStrResult = ""; bool bIsVal = false; -if (rTest[0] == '=') // formulas do not pass the validity test +if (rTest[0] == '=') { -std::optional pFCell(std::in_place, *mpDoc, rPos, rTest, true); -pFCell->SetLimitString(true); - -bool bColRowName = pFCell->HasColRowName(); -if (bColRowName) -{ -// ColRowName from RPN-Code? -if (pFCell->GetCode()->GetCodeLen()
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/inc sc/source
sc/inc/globstr.hrc |2 +- sc/source/ui/docshell/docsh4.cxx |5 - 2 files changed, 5 insertions(+), 2 deletions(-) New commits: commit a9fec0cec3a67eb62e5f923914a9789915e5c15b Author: Caolán McNamara AuthorDate: Sun Dec 11 16:23:07 2022 + Commit: Caolán McNamara CommitDate: Sun Dec 11 19:25:39 2022 + reuse RID_SECURITY_WARNING_TITLE for update links infobar Change-Id: Ifbfb10ee373b8eca8e1019f999ac8e545f180c97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143929 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc index 9aaf84c8af7a..e1f1a485eed0 100644 --- a/sc/inc/globstr.hrc +++ b/sc/inc/globstr.hrc @@ -345,7 +345,7 @@ #define STR_DOC_PRINTED NC_("STR_DOC_PRINTED", "Printed") #define STR_BY NC_("STR_BY", "by") #define STR_ON NC_("STR_ON", "on") -#define STR_RELOAD_TABLES NC_("STR_RELOAD_TABLES", "Security Warning: Automatic update of external links has been disabled.") +#define STR_RELOAD_TABLES NC_("STR_RELOAD_TABLES", "Automatic update of external links has been disabled.") #define STR_REIMPORT_AFTER_LOAD NC_("STR_REIMPORT_AFTER_LOAD", "This file contains queries. The results of these queries were not saved.\nDo you want these queries to be repeated?") #define STR_INSERT_FULL NC_("STR_INSERT_FULL", "Filled cells cannot be shifted\nbeyond the sheet.") #define STR_TABINSERT_ERROR NC_("STR_TABINSERT_ERROR", "The table could not be inserted.") diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 4c27228b1219..04b605edb57a 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -32,6 +32,8 @@ using namespace ::com::sun::star; #include #include #include +#include +#include #include #include #include @@ -539,7 +541,8 @@ void ScDocShell::Execute( SfxRequest& rReq ) if (pViewFrame) { pViewFrame->RemoveInfoBar(u"enablecontent"); -auto pInfoBar = pViewFrame->AppendInfoBar("enablecontent", "", ScResId(STR_RELOAD_TABLES), InfobarType::WARNING); +auto pInfoBar = pViewFrame->AppendInfoBar("enablecontent", SfxResId(RID_SECURITY_WARNING_TITLE), + ScResId(STR_RELOAD_TABLES), InfobarType::WARNING); if (pInfoBar) { weld::Button& rHelpBtn = pInfoBar->addButton();