core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source sc/uiconfig

2024-04-02 Thread codewithvk (via logerrit)
 sc/inc/strings.hrc|   14 
 sc/source/ui/condformat/condformateasydlg.cxx |   75 --
 sc/source/ui/inc/condformateasydlg.hxx|1 
 sc/uiconfig/scalc/ui/conditionaleasydialog.ui |   28 -
 4 files changed, 87 insertions(+), 31 deletions(-)

New commits:
commit b2ae21c9da28d79839c48768e7ed0b2cf734cf30
Author: codewithvk 
AuthorDate: Mon Mar 25 22:42:25 2024 +0530
Commit: Tomaž Vajngerl 
CommitDate: Wed Apr 3 06:08:49 2024 +0200

Conditional Formatting: Adding More Specified Dialogues

We have added additional single conditional dialogues to enhance the 
conditional formatting options for conditions such as duplicates, N elements, 
etc.

Signed-off-by: codewithvk 
Change-Id: I46d069f259d47739ad1bc859b19513f19d414eb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165290
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit abcb07e2baf2d59904b50e9c20f8a108ab9f17de)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165325

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 2c8bacfb4bea..c11b62fa7d9b 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -399,9 +399,21 @@
 #define STR_CONDITION_NOT_EQUAL 
NC_("STR_CONDITION_NOT_EQUAL", "not equal to")
 
 #define STR_CONDITION_BETWEEN   
NC_("STR_CONDITION_BETWEEN", "between")
-
+#define STR_CONDITION_NOT_BETWEEN   
NC_("STR_CONDITION_NOT_BETWEEN", "not between")
+#define STR_CONDITION_DUPLICATE 
NC_("STR_CONDITION_DUPLICATE", "duplicate")
+#define STR_CONDITION_NOT_DUPLICATE 
NC_("STR_CONDITION_NOT_DUPLICATE", "not duplicate")
+#define STR_CONDITION_TOP_N_ELEMENTS
NC_("STR_CONDITION_TOP_N_ELEMENTS", "in top N elements")
+#define STR_CONDITION_BOTTOM_N_ELEMENTS 
NC_("STR_CONDITION_BOTTOM_N_ELEMENTS", "in bottom N elements")
+#define STR_CONDITION_TOP_N_PERCENT 
NC_("STR_CONDITION_TOP_N_PERCENT", "in top N percent")
+#define STR_CONDITION_BOTTOM_N_PERCENT  
NC_("STR_CONDITION_BOTTOM_N_PERCENT", "in bottom N percent")
+#define STR_CONDITION_ABOVE_AVERAGE 
NC_("STR_CONDITION_ABOVE_AVERAGE", "above average")
+#define STR_CONDITION_BELOW_AVERAGE 
NC_("STR_CONDITION_BELOW_AVERAGE", "below average")
+#define STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE
NC_("STR_CONDITION_ABOVE_OR_EQUAL_AVERAGE", "above or equal average")
+#define STR_CONDITION_BELOW_OR_EQUAL_AVERAGE
NC_("STR_CONDITION_BELOW_OR_EQUAL_AVERAGE", "below or equal average")
 #define STR_CONDITION_ERROR NC_("STR_CONDITION_ERROR", 
"with error ")
 #define STR_CONDITION_NOERROR   
NC_("STR_CONDITION_NOERROR", "without error ")
+#define STR_CONDITION_BEGINS_WITH   
NC_("STR_CONDITION_BEGINS_WITH", "begins with")
+#define STR_CONDITION_ENDS_WITH 
NC_("STR_CONDITION_ENDS_WITH", "ends with")
 #define STR_CONDITION_CONTAINS_TEXT 
NC_("STR_CONDITION_CONTAINS_TEXT", "containing text")
 #define STR_CONDITION_NOT_CONTAINS_TEXT 
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text")
 
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index 1fed832b9811..a6f4d2ae23b8 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -66,6 +66,7 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
 , mpDocument(>GetDocument())
 , mxNumberEntry(m_xBuilder->weld_entry("entryNumber"))
 , mxNumberEntry2(m_xBuilder->weld_entry("entryNumber2"))
+, mxAllInputs(m_xBuilder->weld_container("allInputs"))
 , mxRangeEntry(new formula::RefEdit(m_xBuilder->weld_entry("entryRange")))
 , mxButtonRangeEdit(new 
formula::RefButton(m_xBuilder->weld_button("rbassign")))
 , mxStyles(m_xBuilder->weld_combo_box("themeCombo"))
@@ -116,26 +117,62 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
 SetDescription(ScResId(STR_CONDITION_BETWEEN));
 mxNumberEntry2->show();
 break;
-// NotBetween
-// Duplicate
-// NotDuplicate
-// Direct
-// Top10
-// Bottom10
-// TopPercent
-// BottomPercent
-// AboveAverage
-// BelowAverage
-// AboveEqualAverage
-// BelowEqualAverage
+case ScConditionMode::NotBetween:
+SetDescription(ScResId(STR_CONDITION_NOT_BETWEEN));
+mxNumberEntry2->show();
+break;
+case ScConditionMode::Duplicate:
+SetDescription(ScResId(STR_CONDITION_DUPLICATE));
+mxAllInputs->hide();
+break;
+case ScConditionMode::NotDuplicate:
+

core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2024-02-01 Thread Caolán McNamara (via logerrit)
 sc/inc/fillinfo.hxx |2 +-
 sc/source/core/data/fillinfo.cxx|9 +++--
 sc/source/ui/app/inputhdl.cxx   |2 +-
 sc/source/ui/miscdlgs/datatableview.cxx |2 +-
 sc/source/ui/view/gridwin.cxx   |2 +-
 sc/source/ui/view/gridwin4.cxx  |4 ++--
 sc/source/ui/view/printfun.cxx  |6 +++---
 7 files changed, 16 insertions(+), 11 deletions(-)

New commits:
commit e4410bd37fc018c851b5ebf9cf011d59af6a2ad9
Author: Caolán McNamara 
AuthorDate: Thu Feb 1 12:47:53 2024 +
Commit: Caolán McNamara 
CommitDate: Thu Feb 1 15:12:25 2024 +0100

perf: limit to max 1024 rows in cases where we originally allocated 1024 
rows

so everywhere before:

commit a86c00414a43c5d87981ffae1018cb242c5e5e1d
Date:   Fri Jan 19 14:27:10 2024 +0200

cool#6893 reduce allocation in ScGridWindow::PaintTile

where ScTableInfo was used with no args, pass true to indicate this is
just a hint, and where it was originally passed an explicit number, pass
false for "hint" (which was just one case, the case that now passes
TopLeftTileRow, nBottomRightTileRow.

When hint is true limit to max of 1024 rows, and the apparent case
is visible in ScGridWindow::UpdateFormulaRange at

https://github.com/CollaboraOnline/online/issues/6893#issuecomment-1921141048

Change-Id: Iebe890c3ac967800b60150aaa71f7e845a021f60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162875
Reviewed-by: Szymon Kłos 
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index 30e4b7540a67..68f845df42fa 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -268,7 +268,7 @@ struct ScTableInfo
 SCSIZE  mnArrCapacity;
 boolmbPageMode;
 
-explicitScTableInfo(SCROW nStartRow, SCROW nEndRow);
+explicitScTableInfo(SCROW nStartRow, SCROW nEndRow, bool 
bHintOnly);
 ~ScTableInfo();
 ScTableInfo(const ScTableInfo&) = delete;
 const ScTableInfo& operator=(const ScTableInfo&) = delete;
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index d53637456af1..b456f9ea1ab6 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -1051,14 +1051,19 @@ void ScDocument::FillInfo(
 
 /// We seem to need to allocate three extra rows here, not sure why
 ///
-ScTableInfo::ScTableInfo(SCROW nStartRow, SCROW nEndRow)
+ScTableInfo::ScTableInfo(SCROW nStartRow, SCROW nEndRow, bool bHintOnly)
 : mnArrCount(0)
 , mnArrCapacity(nEndRow - nStartRow + 4)
 , mbPageMode(false)
 {
 assert(nStartRow >= 0);
 assert(nEndRow >= nStartRow);
-mpRowInfo.reset(new RowInfo[nEndRow - nStartRow + 4] {});
+if (bHintOnly && mnArrCapacity > 1024)
+{
+SAL_WARN("sc.core", "ScTableInfo excessive capacity: " << 
mnArrCapacity << " start: " << nStartRow << " end: " << nEndRow);
+mnArrCapacity = 1024;
+}
+mpRowInfo.reset(new RowInfo[mnArrCapacity] {});
 }
 
 ScTableInfo::~ScTableInfo()
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 1c5f0a108f69..1f5ae2869c6e 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -523,7 +523,7 @@ ReferenceMark ScInputHandler::GetReferenceMark( const 
ScViewData& rViewData, ScD
 Fraction aZoomX = rViewData.GetZoomX();
 Fraction aZoomY = rViewData.GetZoomY();
 
-ScTableInfo aTabInfo(nY1, nY2);
+ScTableInfo aTabInfo(nY1, nY2, true);
 pDocSh->GetDocument().FillInfo( aTabInfo, nX1, nY1, nX2, nY2,
 nTab, nPPTX, nPPTY, false, false );
 
diff --git a/sc/source/ui/miscdlgs/datatableview.cxx 
b/sc/source/ui/miscdlgs/datatableview.cxx
index 2ad901f4b110..e6f7373e0491 100644
--- a/sc/source/ui/miscdlgs/datatableview.cxx
+++ b/sc/source/ui/miscdlgs/datatableview.cxx
@@ -257,7 +257,7 @@ void ScDataTableView::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rec
 SCCOL nMaxVisibleCol = findColFromPos(aSize.Width() - mnScrollBarSize, 
mpDoc.get(), mnFirstVisibleCol);
 SCROW nMaxVisibleRow = findRowFromPos(aSize.Height(), mpDoc.get(), 
mnFirstVisibleRow);
 
-ScTableInfo aTableInfo(mnFirstVisibleRow, nMaxVisibleRow);
+ScTableInfo aTableInfo(mnFirstVisibleRow, nMaxVisibleRow, true);
 mpDoc->FillInfo(aTableInfo, mnFirstVisibleCol, mnFirstVisibleRow, 
nMaxVisibleCol, nMaxVisibleRow, 0, 0.0, 0.0, false, false);
 ScOutputData aOutput(, OUTTYPE_WINDOW, aTableInfo, 
mpDoc.get(), 0,
 nRowHeaderWidth, nColHeaderHeight, mnFirstVisibleCol, 
mnFirstVisibleRow, nMaxVisibleCol, nMaxVisibleRow, nPPTX, nPPTY);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0f3f9ff8b92b..3cf47209647c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ 

core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2024-01-22 Thread Noel Grandin (via logerrit)
 sc/inc/fillinfo.hxx |2 +-
 sc/source/core/data/fillinfo.cxx|   13 -
 sc/source/ui/app/inputhdl.cxx   |2 +-
 sc/source/ui/miscdlgs/datatableview.cxx |2 +-
 sc/source/ui/view/gridwin.cxx   |2 +-
 sc/source/ui/view/gridwin4.cxx  |4 ++--
 sc/source/ui/view/printfun.cxx  |6 +++---
 7 files changed, 17 insertions(+), 14 deletions(-)

New commits:
commit a86c00414a43c5d87981ffae1018cb242c5e5e1d
Author: Noel Grandin 
AuthorDate: Fri Jan 19 14:27:10 2024 +0200
Commit: Noel Grandin 
CommitDate: Mon Jan 22 12:33:07 2024 +0100

cool#6893 reduce allocation in ScGridWindow::PaintTile

the code is needlessly allocating way more rows than we need, especially
when we have page to the bottom of a large document.

Make it so we allocate exactly the number of rows we need, instead
of allocating a default large number of rows (1024).

Which reveals that we need to allocate two extra rows, not sure why.

Change-Id: I9ca38f2712480ee8c0c3254061c92e457e328416
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162277
Reviewed-by: Michael Meeks 
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162366
Tested-by: Jenkins CollaboraOffice 

diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index 81086ed358ba..30e4b7540a67 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -268,7 +268,7 @@ struct ScTableInfo
 SCSIZE  mnArrCapacity;
 boolmbPageMode;
 
-explicitScTableInfo(const SCSIZE capacity = 1024);
+explicitScTableInfo(SCROW nStartRow, SCROW nEndRow);
 ~ScTableInfo();
 ScTableInfo(const ScTableInfo&) = delete;
 const ScTableInfo& operator=(const ScTableInfo&) = delete;
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 2dc9d5960128..193211b1f3ec 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -1049,13 +1049,16 @@ void ScDocument::FillInfo(
 rArray.MirrorSelfX();
 }
 
-ScTableInfo::ScTableInfo(const SCSIZE capacity)
-: mpRowInfo(new RowInfo[capacity])
-, mnArrCount(0)
-, mnArrCapacity(capacity)
+/// We seem to need to allocate two extra rows here, not sure why
+///
+ScTableInfo::ScTableInfo(SCROW nStartRow, SCROW nEndRow)
+: mnArrCount(0)
+, mnArrCapacity(nEndRow - nStartRow + 3)
 , mbPageMode(false)
 {
-memset(static_cast(mpRowInfo.get()), 0, mnArrCapacity * 
sizeof(RowInfo));
+assert(nStartRow >= 0);
+assert(nEndRow >= nStartRow);
+mpRowInfo.reset(new RowInfo[nEndRow - nStartRow + 3] {});
 }
 
 ScTableInfo::~ScTableInfo()
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 18d6bb98b792..1c5f0a108f69 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -523,7 +523,7 @@ ReferenceMark ScInputHandler::GetReferenceMark( const 
ScViewData& rViewData, ScD
 Fraction aZoomX = rViewData.GetZoomX();
 Fraction aZoomY = rViewData.GetZoomY();
 
-ScTableInfo aTabInfo;
+ScTableInfo aTabInfo(nY1, nY2);
 pDocSh->GetDocument().FillInfo( aTabInfo, nX1, nY1, nX2, nY2,
 nTab, nPPTX, nPPTY, false, false );
 
diff --git a/sc/source/ui/miscdlgs/datatableview.cxx 
b/sc/source/ui/miscdlgs/datatableview.cxx
index 649f85bfc1a2..2ad901f4b110 100644
--- a/sc/source/ui/miscdlgs/datatableview.cxx
+++ b/sc/source/ui/miscdlgs/datatableview.cxx
@@ -257,7 +257,7 @@ void ScDataTableView::Paint(vcl::RenderContext& 
rRenderContext, const tools::Rec
 SCCOL nMaxVisibleCol = findColFromPos(aSize.Width() - mnScrollBarSize, 
mpDoc.get(), mnFirstVisibleCol);
 SCROW nMaxVisibleRow = findRowFromPos(aSize.Height(), mpDoc.get(), 
mnFirstVisibleRow);
 
-ScTableInfo aTableInfo;
+ScTableInfo aTableInfo(mnFirstVisibleRow, nMaxVisibleRow);
 mpDoc->FillInfo(aTableInfo, mnFirstVisibleCol, mnFirstVisibleRow, 
nMaxVisibleCol, nMaxVisibleRow, 0, 0.0, 0.0, false, false);
 ScOutputData aOutput(, OUTTYPE_WINDOW, aTableInfo, 
mpDoc.get(), 0,
 nRowHeaderWidth, nColHeaderHeight, mnFirstVisibleCol, 
mnFirstVisibleRow, nMaxVisibleCol, nMaxVisibleRow, nPPTX, nPPTY);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9bd88d69d10d..0f3f9ff8b92b 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5100,7 +5100,7 @@ void ScGridWindow::UpdateFormulaRange(SCCOL nX1, SCROW 
nY1, SCCOL nX2, SCROW nY2
 double nPPTX = mrViewData.GetPPTX();
 double nPPTY = mrViewData.GetPPTY();
 
-ScTableInfo aTabInfo;
+ScTableInfo aTabInfo(nY1, nY2);
 rDoc.FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, false, 
false );
 
 Fraction aZoomX = mrViewData.GetZoomX();
diff --git a/sc/source/ui/view/gridwin4.cxx 

core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2024-01-12 Thread Dennis Francis (via logerrit)
 sc/inc/colorscale.hxx  |   13 ++-
 sc/inc/conditio.hxx|   20 +++
 sc/source/core/data/colorscale.cxx |   37 +++--
 sc/source/core/data/conditio.cxx   |   63 +
 4 files changed, 113 insertions(+), 20 deletions(-)

New commits:
commit 1aa1a5340f63b31524117a3cfd6e05bee2aa1aa0
Author: Dennis Francis 
AuthorDate: Tue Oct 3 12:40:25 2023 +0530
Commit: Caolán McNamara 
CommitDate: Fri Jan 12 17:09:44 2024 +0100

sc: condfmt-perf: use a shared cache that...

is reset only when the data changes. Resetting is done only on
invalidation of associated ranges of data via a listener.

Earlier there were three separate caches that resets on every draw.

Change-Id: I1c185ece4b781bf6db7c82697cd5225d98c82651
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157508
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 6652e224fe67..f43f533e8f60 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -224,7 +224,7 @@ public:
 virtual ~ScColorFormat() override;
 
 const ScRangeList& GetRange() const;
-void SetCache(const std::vector& aValues);
+void SetCache(const std::vector& aValues) const;
 std::vector GetCache() const;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
@@ -240,14 +240,6 @@ protected:
 double getMaxValue() const;
 
 ScConditionalFormat* mpParent;
-
-private:
-
-struct ScColorFormatCache
-{
-std::vector maValues;
-};
-mutable std::unique_ptr mpCache;
 };
 
 typedef std::vector>> ScColorScaleEntries;
@@ -265,7 +257,10 @@ private:
 public:
 ScColorScaleFormat(ScDocument* pDoc);
 ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat);
+ScColorScaleFormat(const ScColorScaleFormat&) = delete;
 virtual ~ScColorScaleFormat() override;
+const ScColorScaleFormat& operator=(const ScColorScaleFormat&) = delete;
+
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 8e5af1dd3c3c..e1cf5dc2f581 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -538,6 +538,20 @@ private:
 OUString maStyleName;
 };
 
+class ScColorFormatCache final : public SvtListener
+{
+private:
+ScDocument& mrDoc;
+
+public:
+explicit ScColorFormatCache(ScDocument& rDoc, const ScRangeList& rRanges);
+virtual ~ScColorFormatCache() override;
+
+void Notify( const SfxHint& rHint ) override;
+
+std::vector maValues;
+};
+
 //  complete conditional formatting
 class SC_DLLPUBLIC ScConditionalFormat
 {
@@ -547,6 +561,8 @@ class SC_DLLPUBLIC ScConditionalFormat
 std::vector> maEntries;
 ScRangeList maRanges;// Ranges for conditional format
 
+mutable std::unique_ptr mpCache;
+
 public:
 ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
 ~ScConditionalFormat();
@@ -606,6 +622,10 @@ public:
 
 // Forced recalculation for formulas
 void CalcAll();
+
+void ResetCache() const;
+void SetCache(const std::vector& aValues) const;
+std::vector* GetCache() const;
 };
 
 class RepaintInIdle final : public Idle
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 97cc50f73829..d5d40ec2c94d 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -462,22 +462,39 @@ const ScRangeList& ScColorFormat::GetRange() const
 
 std::vector ScColorFormat::GetCache() const
 {
-std::vector empty;
-return mpCache ? mpCache->maValues : empty;
+if (!mpParent)
+return {};
+
+std::vector* pRes = mpParent->GetCache();
+if (pRes)
+return *pRes;
+
+return {};
 }
 
-void ScColorFormat::SetCache(const std::vector& aValues)
+void ScColorFormat::SetCache(const std::vector& aValues) const
 {
-mpCache.reset(new ScColorFormatCache);
-mpCache->maValues = aValues;
+if (!mpParent)
+return;
+
+mpParent->SetCache(aValues);
 }
 
 std::vector& ScColorFormat::getValues() const
 {
-if(!mpCache)
+assert(mpParent);
+
+std::vector* pCache = mpParent->GetCache();
+if (!pCache || pCache->empty())
 {
-mpCache.reset(new ScColorFormatCache);
-std::vector& rValues = mpCache->maValues;
+if (!pCache)
+{
+SetCache({});
+pCache = mpParent->GetCache();
+assert(pCache);
+}
+
+std::vector& rValues = *pCache;
 
 size_t n = GetRange().size();
 const ScRangeList& aRanges = GetRange();
@@ -515,7 +532,7 @@ std::vector& ScColorFormat::getValues() const
 std::sort(rValues.begin(), rValues.end());
 }
 
-return mpCache->maValues;
+return *pCache;
 }
 
 double 

core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2024-01-08 Thread Caolán McNamara (via logerrit)
 sc/inc/viewopti.hxx  |   30 --
 sc/source/core/data/patattr.cxx  |5 ++---
 sc/source/core/tool/viewopti.cxx |   15 +++
 sc/source/ui/app/scmod.cxx   |   15 +++
 sc/source/ui/inc/tabview.hxx |4 
 sc/source/ui/unoobj/docuno.cxx   |   19 +++
 sc/source/ui/view/gridwin4.cxx   |5 ++---
 sc/source/ui/view/tabview.cxx|7 +++
 sc/source/ui/view/tabvwshc.cxx   |5 ++---
 9 files changed, 62 insertions(+), 43 deletions(-)

New commits:
commit 754cd4309b5b055a05b57f5d25ed128c439f460b
Author: Caolán McNamara 
AuthorDate: Mon Jan 8 15:04:07 2024 +
Commit: Caolán McNamara 
CommitDate: Mon Jan 8 20:46:46 2024 +0100

Related: cool#7951 don't invalidate when creating a new view

In writer the ViewOptions are in the ViewShell and are copied when a new
ViewShell is created from that ViewShell so the dark/light-mode and doc
color are the same in a new view as the old view.

But in calc the ViewOptions exist in both the ViewShell and Document and
a new ViewShell copies from the document not the old ViewShell. Setting
the ViewOptions of a ViewShell in calc doesn't have an effect of having
the same setting in a new view in calc.

So if you create a new view from an old view you got the ViewOptions of
the document, whose light/dark mode remained as "Default" when the old
view dark/light more was set. So the mismatch triggered an invalidate.

These additions to ViewOptions are relatively new in calc, and the
desire is to get the same behaviour in calc as in writer, so move the
new additions to a separate class that belongs to the ViewShell and
copy them from the current ViewShell when creating a new ViewShell.

Change-Id: Ie4b1dbb0437763ec4c8d067179c1fbef520161e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161791
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index 4e00e068b134..7961cbc2126c 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -75,6 +75,26 @@ public:
 booloperator!= ( const ScGridOptions& rOpt ) const { 
return !(operator==(rOpt)); }
 };
 
+class SC_DLLPUBLIC ScViewRenderingOptions
+{
+public:
+ScViewRenderingOptions();
+
+const OUString& GetColorSchemeName() const { return sColorSchemeName; }
+void SetColorSchemeName( const OUString& rName ) { sColorSchemeName = 
rName; }
+
+const Color& GetDocColor() const { return aDocCol; }
+void SetDocColor(const Color& rDocColor) { aDocCol = rDocColor; }
+
+bool operator==(const ScViewRenderingOptions& rOther) const;
+
+private:
+// The name of the color scheme
+OUString sColorSchemeName;
+// The background color of the document
+Color aDocCol;
+};
+
 // Options - View
 
 class SC_DLLPUBLIC ScViewOptions
@@ -99,12 +119,6 @@ public:
 voidSetGridOptions( const ScGridOptions& rNew ) { 
aGridOpt = rNew; }
 std::unique_ptr CreateGridItem() const;
 
-const OUString& GetColorSchemeName() const { return sColorSchemeName; }
-void SetColorSchemeName( const OUString& rName ) { sColorSchemeName = 
rName; }
-
-const Color& GetDocColor() const { return aDocCol; }
-void SetDocColor(const Color& rDocColor) { aDocCol = rDocColor; }
-
 ScViewOptions&  operator=  ( const ScViewOptions& rCpy );
 booloperator== ( const ScViewOptions& rOpt ) const;
 booloperator!= ( const ScViewOptions& rOpt ) const { 
return !(operator==(rOpt)); }
@@ -115,10 +129,6 @@ private:
 Color   aGridCol;
 OUStringaGridColName;
 ScGridOptions   aGridOpt;
-// The name of the color scheme
-OUString sColorSchemeName = "Default";
-// The background color of the document
-Color aDocCol;
 };
 
 // Item for the options dialog - View
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index bd4f54ab8c5e..34cfa1c52175 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -508,9 +508,8 @@ void ScPatternAttr::fillColor(model::ComplexColor& 
rComplexColor, const SfxItemS
 ScTabViewShell* pViewShell = 
dynamic_cast(pSfxViewShell);
 if (pViewShell)
 {
-const ScViewData& pViewData = 
pViewShell->GetViewData();
-const ScViewOptions& aViewOptions = 
pViewData.GetOptions();
-aBackColor = aViewOptions.GetDocColor();
+const ScViewRenderingOptions& rViewRenderingOptions = 
pViewShell->GetViewRenderingData();
+aBackColor = rViewRenderingOptions.GetDocColor();
 }
 }
 }
diff --git 

core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2024-01-08 Thread Caolán McNamara (via logerrit)
 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 f259c295f13f3b93aa585625174a14d3aa2999fc
Author: Caolán McNamara 
AuthorDate: Sun Jan 7 13:37:57 2024 +
Commit: Miklos Vajna 
CommitDate: Mon Jan 8 11:03:42 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/+/161742
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8b91cbf49b0e..eb69570de6f8 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2709,8 +2709,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 );
 
@@ -2720,6 +2718,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 04696b7696e9..c3d660577ea1 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -113,7 +113,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 4f5dea599230..567447149937 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -244,9 +244,6 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* 
pClipDoc, const ScRangeList&
 if ( bSysClip && 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 'distro/collabora/co-23.05' - sc/inc sc/source

2023-12-31 Thread Mike Kaganski (via logerrit)
 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 7414d27cd5b39d72c1ab1db5abb9661afc3e9a97
Author: Mike Kaganski 
AuthorDate: Sat Dec 30 18:08:56 2023 +0600
Commit: Noel Grandin 
CommitDate: Sun Dec 31 13:06:07 2023 +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 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161450
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index c9546012ac34..bd24a98e8db3 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -143,8 +143,9 @@ public:
 
 const ScPatternAttr*GetPattern( SCROW nRow ) const;
 const ScPatternAttr*GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow 
) const;
-SCROW   ApplySelectionCache( SfxItemPoolCache* pCache, const 
ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged,
- SCCOL nCol );
+voidApplySelectionStyle(const ScStyleSheet& rStyle, SCROW nTop, 
SCROW nBottom);
+voidApplySelectionCache(SfxItemPoolCache* pCache, SCROW nStartRow, 
SCROW nEndRow,
+ScEditDataArray* pDataArray, bool* 
pIsChanged);
 voidApplyPatternArea( SCROW nStartRow, SCROW nEndRow, const 
ScPatternAttr& rPatAttr,
   ScEditDataArray* pDataArray = nullptr,
   bool* const pIsChanged = nullptr);
@@ -166,12 +167,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
@@ -547,7 +553,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 );
@@ -574,12 +579,8 @@ public:
 
 voidRemoveProtected( SCROW nStartRow, SCROW nEndRow );
 
-SCROW   ApplySelectionCache( SfxItemPoolCache* 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,
@@ -1063,4 +1064,22 @@ inline void ScColumnData::DeleteRow(SCROW nStartRow, 
SCSIZE nSize)
 pAttrArray->DeleteRow( 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-12-04 Thread Henry Castro (via logerrit)
 sc/inc/globstr.hrc |1 +
 sc/source/ui/view/viewfunc.cxx |5 +
 2 files changed, 6 insertions(+)

New commits:
commit eccbe3bb4ed6f0bed4e7fbacfaf50762c93f9464
Author: Henry Castro 
AuthorDate: Mon Dec 4 10:33:01 2023 -0400
Commit: Caolán McNamara 
CommitDate: Mon Dec 4 20:05:58 2023 +0100

sc: show a message dialog if insert cells fail

Use case, go to the max row and insert a row.

Signed-off-by: Henry Castro 
Change-Id: I930d7724b9c94e10e9207ec749b7249d2fee0e39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160314
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index f4afbb7de320..aff27e3608dd 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -550,6 +550,7 @@
 #define STR_UNDO_EDIT_SPARKLINE NC_("STR_UNDO_EDIT_SPARKLINE", 
"Edit Sparkline")
 #define STR_UNDO_THEME_CHANGE   NC_("STR_UNDO_THEME_CHANGE", 
"Theme Change")
 #define STR_UNDO_THEME_COLOR_CHANGE 
NC_("STR_UNDO_THEME_COLOR_CHANGE", "Theme Color Change")
+#define STR_ERR_INSERT_CELLSNC_("STR_ERR_INSERT_CELLS", 
"Failed to insert cells")
 
 #endif
 
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 13eb71acef52..15076f04a958 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1776,6 +1776,11 @@ bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool 
bRecord, bool bPartOfPaste )
 true /* 
bGroups */, GetViewData().GetTabNo());
 }
 }
+else
+{
+ErrorMessage(STR_ERR_INSERT_CELLS);
+}
+
 OUString aStartAddress =  aRange.aStart.GetColRowString();
 OUString aEndAddress = aRange.aEnd.GetColRowString();
 collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}}, 
"INSERT_CELLS");


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-11-30 Thread Caolán McNamara (via logerrit)
 sc/inc/column.hxx|1 +
 sc/inc/table.hxx |1 +
 sc/source/core/data/column.cxx   |   16 +---
 sc/source/core/data/document.cxx |   10 ++
 sc/source/core/data/table2.cxx   |   15 +++
 5 files changed, 40 insertions(+), 3 deletions(-)

New commits:
commit f0bf0a459718a910928d92fbf60eea7f2e0fc88e
Author: Caolán McNamara 
AuthorDate: Wed Nov 29 20:45:33 2023 +
Commit: Miklos Vajna 
CommitDate: Thu Nov 30 10:52:44 2023 +0100

No kit notification of note position changes on insert/delete row

while there is for insert/delete col.

Inserting/Deleting a column will explicitly update comments as part of a
bulk operation and block the drawing layer from updating any existing
captions before that. A side-effect of this is that the note captions
are generated for all comments in the moved cols when this happens.

While with a row the drawing layer is allowed update existing caption
positions and doesn't generate any new captions.

Presumably there's a missed optimization for insert/delete cols to
not generate extra captions that didn't exist before the change, but
leave that aside for now and add a UpdateNoteCaptions that just
notifies of note position changes when rows are inserted/deleted and
continue to piggy back on the note caption update for insert/delete
cols.

Change-Id: I4d76d15aee1de9ea5553e90b2051354bce02b1db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160130
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 7a2bbc30ade9..c9546012ac34 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -715,6 +715,7 @@ public:
 sc::ColumnBlockPosition& rDestBlockPos, bool 
bCloneCaption, SCROW nRowOffsetDest = 0) const;
 
 void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = 
true );
+void CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 );
 
 void UpdateDrawObjects( std::vector>& pObjects, 
SCROW nRowStart, SCROW nRowEnd );
 void UpdateDrawObjectsForRow( std::vector& pObjects, SCCOL 
nTargetCol, SCROW nTargetRow );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 4f7407809115..0384def511fb 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -508,6 +508,7 @@ public:
 SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
 void CreateAllNoteCaptions();
 void ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, bool bPreserveData );
+void CommentNotifyAddressChange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2);
 
 void GetAllNoteEntries( std::vector& rNotes ) const;
 void GetNotesInRange( const ScRange& rRange, std::vector& 
rNotes ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 45a307931347..716665a7cb8b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1813,11 +1813,13 @@ class NoteCaptionUpdater
 {
 const ScDocument* m_pDocument;
 const ScAddress m_aAddress; // 'incomplete' address consisting of tab, 
column
+bool m_bUpdateCaptionPos;  // false if we want to skip updating the 
caption pos, only useful in kit mode
 bool m_bAddressChanged;  // false if the cell anchor address is unchanged
 public:
-NoteCaptionUpdater(const ScDocument* pDocument, const ScAddress& rPos, 
bool bAddressChanged)
+NoteCaptionUpdater(const ScDocument* pDocument, const ScAddress& rPos, 
bool bUpdateCaptionPos, bool bAddressChanged)
 : m_pDocument(pDocument)
 , m_aAddress(rPos)
+, m_bUpdateCaptionPos(bUpdateCaptionPos)
 , m_bAddressChanged(bAddressChanged)
 {
 }
@@ -1828,7 +1830,8 @@ public:
 ScAddress aAddr(m_aAddress);
 aAddr.SetRow(nRow);
 
-p->UpdateCaptionPos(aAddr);
+if (m_bUpdateCaptionPos)
+p->UpdateCaptionPos(aAddr);
 
 // Notify our LOK clients
 if (m_bAddressChanged)
@@ -1841,7 +1844,14 @@ public:
 void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool 
bAddressChanged )
 {
 ScAddress aAddr(nCol, 0, nTab);
-NoteCaptionUpdater aFunc((), aAddr, bAddressChanged);
+NoteCaptionUpdater aFunc((), aAddr, true, bAddressChanged);
+sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
+}
+
+void ScColumn::CommentNotifyAddressChange( SCROW nRow1, SCROW nRow2 )
+{
+ScAddress aAddr(nCol, 0, nTab);
+NoteCaptionUpdater aFunc((), aAddr, false, true);
 sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
 }
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index fceaec1bb386..e07dcf146640 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1328,8 +1328,13 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB 
nStartTab,

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-11-07 Thread Henry Castro (via logerrit)
 sc/inc/dbdata.hxx|1 +
 sc/inc/document.hxx  |7 +++
 sc/inc/table.hxx |3 +++
 sc/source/core/data/document.cxx |7 +++
 sc/source/core/data/table4.cxx   |   34 ++
 sc/source/core/tool/dbdata.cxx   |   17 +
 sc/source/ui/view/gridwin.cxx|1 +
 sc/source/ui/view/tabvwshc.cxx   |1 +
 8 files changed, 71 insertions(+)

New commits:
commit 768433f07873eb608837630f85e7e1b375239fca
Author: Henry Castro 
AuthorDate: Mon Nov 6 07:18:48 2023 -0400
Commit: Tomaž Vajngerl 
CommitDate: Tue Nov 7 11:23:34 2023 +0100

sc: extend backcolor area

If the filter background color is selected,
the automatic selection area should include,
the attribute of background cell color too.

Signed-off-by: Henry Castro 
Change-Id: I341c602247e7f71e3c9665e1b594177d8f5553b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158991
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 482c55bc6aa4..df235ec52619 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -221,6 +221,7 @@ public:
 SCCOL nDx, SCROW nDy, SCTAB nDz);
 
 void ExtendDataArea(const ScDocument& rDoc);
+void ExtendBackColorArea(const ScDocument& rDoc);
 void CalcSaveFilteredCount(SCSIZE nNonFilteredRowCount);
 void GetFilterSelCount(SCSIZE& nSelected, SCSIZE& nTotal);
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9717c809aa31..8b91cbf49b0e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1510,6 +1510,13 @@ public:
  SCCOL& rEndCol, SCROW& rEndRow,
  bool bIncludeOld, bool bOnlyDown 
) const;
 
+/**
+ * Return the extended area containing at least all contiguous cells
+ * having background color.
+ */
+SC_DLLPUBLIC void GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& 
rStartRow,
+SCCOL& rEndCol, SCROW& rEndRow ) const;
+
 /**
  * Returns true if there is a non-empty subrange in the range given as 
input.
  * In that case it also modifies rRange to largest subrange that does not
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 3367af129c19..4f7407809115 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -627,6 +627,9 @@ public:
 voidGetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, SCROW& rEndRow,
  bool bIncludeOld, bool bOnlyDown ) const;
 
+voidGetBackColorArea( SCCOL& rStartCol, SCROW& rStartRow,
+  SCCOL& rEndCol, SCROW& rEndRow ) const;
+
 boolGetDataAreaSubrange( ScRange& rRange ) const;
 
 boolShrinkToUsedDataArea( bool& o_bShrunk, SCCOL& rStartCol, 
SCROW& rStartRow,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 4721bfeba70a..fceaec1bb386 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1104,6 +1104,13 @@ void ScDocument::GetDataArea( SCTAB nTab, SCCOL& 
rStartCol, SCROW& rStartRow,
 maTabs[nTab]->GetDataArea( rStartCol, rStartRow, rEndCol, rEndRow, 
bIncludeOld, bOnlyDown );
 }
 
+void ScDocument::GetBackColorArea( SCTAB nTab, SCCOL& rStartCol, SCROW& 
rStartRow,
+   SCCOL& rEndCol, SCROW& rEndRow ) const
+{
+if (ValidTab(nTab) && nTab < static_cast (maTabs.size()) && 
maTabs[nTab])
+maTabs[nTab]->GetBackColorArea( rStartCol, rStartRow, rEndCol, rEndRow 
);
+}
+
 bool ScDocument::GetDataAreaSubrange(ScRange& rRange) const
 {
 SCTAB nTab = rRange.aStart.Tab();
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 9c6852990efe..3ec8dc5aeab7 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1293,6 +1294,39 @@ void  ScTable::FillSparkline(bool bVertical, SCCOLROW 
nFixed,
 }
 }
 
+void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& /*rStartRow*/,
+   SCCOL& rEndCol, SCROW& rEndRow ) const
+{
+bool bExtend;
+const SvxBrushItem* pDefBackground = 
()->GetDefaultItem(ATTR_BACKGROUND);
+
+rStartCol = std::min(rStartCol, aCol.size() - 1);
+rEndCol = std::min(rEndCol, aCol.size() - 1);
+
+do
+{
+bExtend = false;
+
+if (rEndRow < rDocument.MaxRow())
+{
+for (SCCOL nCol = rStartCol; nCol <= rEndCol; ++nCol)
+{
+const ScPatternAttr* pPattern = 
ColumnData(nCol).GetPattern(rEndRow + 1);
+const SvxBrushItem* pBackground = 
>GetItem(ATTR_BACKGROUND);
+if 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-10-31 Thread Caolán McNamara (via logerrit)
 sc/inc/column.hxx  |2 +-
 sc/source/core/data/column.cxx |   28 ++--
 sc/source/core/data/table2.cxx |2 +-
 3 files changed, 24 insertions(+), 8 deletions(-)

New commits:
commit 981061e0870ac7d963d496a51238fe1f4d5d2b7c
Author: Caolán McNamara 
AuthorDate: Tue Oct 31 11:33:56 2023 +
Commit: Michael Meeks 
CommitDate: Tue Oct 31 19:08:23 2023 +0100

tell client when the cell for the comment changed

when a row/column is inserted/deleted, etc the cell the comments are
associated with changes, so broadcast that change to the clients.

https://github.com/CollaboraOnline/online/issues/7334

Change-Id: I8a3e5fc151b6ba99e68b32c3fe8804de9ba2baf4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158718
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 87d3dc730a9f..cbdf82edecbc 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -712,7 +712,7 @@ public:
 void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol,
 sc::ColumnBlockPosition& rDestBlockPos, bool 
bCloneCaption, SCROW nRowOffsetDest = 0) const;
 
-void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 );
+void UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool bAddressChanged = 
true );
 
 void UpdateDrawObjects( std::vector>& pObjects, 
SCROW nRowStart, SCROW nRowEnd );
 void UpdateDrawObjectsForRow( std::vector& pObjects, SCCOL 
nTargetCol, SCROW nTargetRow );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d2506074070b..45a307931347 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1810,22 +1811,37 @@ void resetColumnPosition(sc::CellStoreType& rCells, 
SCCOL nCol)
 
 class NoteCaptionUpdater
 {
-SCCOL mnCol;
-SCTAB mnTab;
+const ScDocument* m_pDocument;
+const ScAddress m_aAddress; // 'incomplete' address consisting of tab, 
column
+bool m_bAddressChanged;  // false if the cell anchor address is unchanged
 public:
-NoteCaptionUpdater( SCCOL nCol, SCTAB nTab ) : mnCol(nCol), mnTab(nTab) {}
+NoteCaptionUpdater(const ScDocument* pDocument, const ScAddress& rPos, 
bool bAddressChanged)
+: m_pDocument(pDocument)
+, m_aAddress(rPos)
+, m_bAddressChanged(bAddressChanged)
+{
+}
 
 void operator() ( size_t nRow, ScPostIt* p )
 {
-p->UpdateCaptionPos(ScAddress(mnCol,nRow,mnTab));
+// Create a 'complete' address object
+ScAddress aAddr(m_aAddress);
+aAddr.SetRow(nRow);
+
+p->UpdateCaptionPos(aAddr);
+
+// Notify our LOK clients
+if (m_bAddressChanged)
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Modify, 
m_pDocument, aAddr, p);
 }
 };
 
 }
 
-void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2 )
+void ScColumn::UpdateNoteCaptions( SCROW nRow1, SCROW nRow2, bool 
bAddressChanged )
 {
-NoteCaptionUpdater aFunc(nCol, nTab);
+ScAddress aAddr(nCol, 0, nTab);
+NoteCaptionUpdater aFunc((), aAddr, bAddressChanged);
 sc::ProcessNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
 }
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 53ba083929c4..21c33b222825 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1496,7 +1496,7 @@ void ScTable::CopyCaptionsToTable( SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW
 for (SCCOL i = nCol1; i <= nCol2; i++)
 {
 aCol[i].CopyCellNotesToDocument(nRow1, nRow2, 
pDestTab->CreateColumnIfNotExists(i), bCloneCaption);
-pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2);
+pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2, false /* address 
unchanged from initial create */);
 }
 }
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-10-29 Thread Szymon Kłos (via logerrit)
 sc/inc/strings.hrc|   15 +++
 sc/source/ui/condformat/condformateasydlg.cxx |   54 +++---
 sc/source/ui/inc/condformateasydlg.hxx|2 
 3 files changed, 65 insertions(+), 6 deletions(-)

New commits:
commit 7128dbd1c564bd44868b0d0b7c92d384a9c665cf
Author: Szymon Kłos 
AuthorDate: Fri Oct 27 11:53:57 2023 +0200
Commit: Szymon Kłos 
CommitDate: Sun Oct 29 09:24:43 2023 +0100

Make simple conditional formatting dialog translated

Followup for commit a9f6f63d21e368fe6bcc9080fd1ba23b0e52
sc: Add easy to use conditional formatting menu

- make strings translated
- add more conditions
- TODO: add other missing conditions

Change-Id: I0d25b3352067e7006b88f42f3401d4670b3a5061
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158552
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Paris Oplopoios 

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 24a40a41ef57..2c8bacfb4bea 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -390,4 +390,19 @@
 #define STR_A11Y_DESC_USERDEF   
NC_("subtotaloptionspage|extended_tip|lbuserdef", "Uses a custom sorting order 
that you defined in the Options dialog box at %PRODUCTNAME Calc - Sort Lists.")
 #define STR_A11Y_DESC_ANNOT NC_("extended_tip|annot", 
"Specifies that a small rectangle in the top right corner of the cell indicates 
that a comment exists. The comment will be shown only when you enable tips 
under %PRODUCTNAME - General in the Options dialog box.")
 
+// Simple conditional formatting dialog
+#define STR_CONDITION_EQUAL NC_("STR_CONDITION_EQUAL", 
"equal to")
+#define STR_CONDITION_LESS  NC_("STR_CONDITION_LESS", 
"less than")
+#define STR_CONDITION_GREATER   
NC_("STR_CONDITION_GREATER", "greater than")
+#define STR_CONDITION_EQLESS
NC_("STR_CONDITION_EQLESS", "equal or less than")
+#define STR_CONDITION_EQGREATER 
NC_("STR_CONDITION_EQGREATER", "equal or greater than")
+#define STR_CONDITION_NOT_EQUAL 
NC_("STR_CONDITION_NOT_EQUAL", "not equal to")
+
+#define STR_CONDITION_BETWEEN   
NC_("STR_CONDITION_BETWEEN", "between")
+
+#define STR_CONDITION_ERROR NC_("STR_CONDITION_ERROR", 
"with error ")
+#define STR_CONDITION_NOERROR   
NC_("STR_CONDITION_NOERROR", "without error ")
+#define STR_CONDITION_CONTAINS_TEXT 
NC_("STR_CONDITION_CONTAINS_TEXT", "containing text")
+#define STR_CONDITION_NOT_CONTAINS_TEXT 
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text")
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/condformat/condformateasydlg.cxx 
b/sc/source/ui/condformat/condformateasydlg.cxx
index 41b8a31eafd3..7e07b1a1dc19 100644
--- a/sc/source/ui/condformat/condformateasydlg.cxx
+++ b/sc/source/ui/condformat/condformateasydlg.cxx
@@ -3,7 +3,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 namespace
 {
@@ -49,6 +51,11 @@ ScTabViewShell* GetTabViewShell(const SfxBindings* pBindings)
 
 namespace sc
 {
+void ConditionalFormatEasyDialog::SetDescription(std::u16string_view 
rCondition)
+{
+mxDescription->set_label(mxDescription->get_label() + ": " + rCondition);
+}
+
 ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* 
pBindings,
  SfxChildWindow* 
pChildWindow,
  weld::Window* pParent,
@@ -91,19 +98,54 @@ 
ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings,
 mxNumberEntry2->set_increments(1, 0);
 switch (meMode)
 {
-case ScConditionMode::Greater:
-mxDescription->set_label(mxDescription->get_label() + " greater 
than ");
+case ScConditionMode::Equal:
+SetDescription(ScResId(STR_CONDITION_EQUAL));
 break;
 case ScConditionMode::Less:
-mxDescription->set_label(mxDescription->get_label() + " less than 
");
+SetDescription(ScResId(STR_CONDITION_LESS));
 break;
-case ScConditionMode::Equal:
-mxDescription->set_label(mxDescription->get_label() + " equal to 
");
+case ScConditionMode::Greater:
+SetDescription(ScResId(STR_CONDITION_GREATER));
+break;
+case ScConditionMode::EqLess:
+SetDescription(ScResId(STR_CONDITION_EQLESS));
+break;
+case ScConditionMode::EqGreater:
+SetDescription(ScResId(STR_CONDITION_EQGREATER));
+break;
+case ScConditionMode::NotEqual:
+SetDescription(ScResId(STR_CONDITION_NOT_EQUAL));
 break;
 case ScConditionMode::Between:
-

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-10-12 Thread Noel Grandin (via logerrit)
 sc/inc/attarray.hxx  |2 +-
 sc/source/core/data/attarray.cxx |9 ++---
 2 files changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 9f03693227940abc761dc8d6964baf38c67e1090
Author: Noel Grandin 
AuthorDate: Tue Oct 10 12:55:20 2023 +0200
Commit: Caolán McNamara 
CommitDate: Thu Oct 12 10:19:40 2023 +0200

cool#7330 calc perf: PaintTile's FillInfo

try to spend a little less time here, when searching twice, we can use
the index result of the first search as a hint

Change-Id: I7fc0c2fb4e5e338d2c3f8a3d642043a1b301e7b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157749
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 54d77f9a02530b8c5871e0aec9b3b4c94d82fbd3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157721
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 868118796560..672c29f41247 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -183,7 +183,7 @@ public:
 boolApplyFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
 boolRemoveFlags( SCROW nStartRow, SCROW nEndRow, ScMF nFlags );
 
-boolSearch( SCROW nRow, SCSIZE& nIndex ) const;
+boolSearch( SCROW nRow, SCSIZE& nIndex, std::optional 
nIndexHint = {} ) const;
 
 boolHasAttrib( SCROW nRow1, SCROW nRow2, HasAttrFlags nMask ) const;
 boolHasAttrib( SCROW nRow, HasAttrFlags nMask, SCROW* nStartRow = 
nullptr, SCROW* nEndRow = nullptr ) const;
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 87fa2c11ccf1..406525e862c8 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -189,9 +189,11 @@ bool ScAttrArray::Concat(SCSIZE nPos)
  *
  * Iterative implementation of Binary Search
  * The same implementation was used inside ScMarkArray::Search().
+ *
+ * @param oIndexHint, hint for the start of the search, useful when searching 
twice for successive values
  */
 
-bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
+bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex, std::optional 
oIndexHint ) const
 {
 /*auto it = std::lower_bound(mvData.begin(), mvData.end(), nRow,
 [] (const ScAttrEntry , SCROW nRow)
@@ -208,7 +210,8 @@ bool ScAttrArray::Search( SCROW nRow, SCSIZE& nIndex ) const
 
 tools::Long nHi = static_cast(mvData.size()) - 1;
 tools::Long i = 0;
-tools::Long nLo = 0;
+assert((!oIndexHint || *oIndexHint <= nHi) && "bad index hint");
+tools::Long nLo = oIndexHint ? *oIndexHint : 0;
 
 while ( nLo <= nHi )
 {
@@ -1404,7 +1407,7 @@ bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, 
HasAttrFlags nMask ) cons
 SCSIZE nEndIndex;
 Search( nRow1, nStartIndex );
 if (nRow1 != nRow2)
-Search( nRow2, nEndIndex );
+Search( nRow2, nEndIndex, /*hint*/nStartIndex );
 else
 nEndIndex = nStartIndex;
 bool bFound = false;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-10-05 Thread Caolán McNamara (via logerrit)
 sc/inc/document.hxx|4 ++--
 sc/source/ui/view/viewfun3.cxx |3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 20ca3feabe51c0173e7aec979a8cd618a0b76466
Author: Caolán McNamara 
AuthorDate: Thu Oct 5 14:12:51 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu Oct 5 17:29:46 2023 +0200

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

 #3  0x7f6d5e81ee6e in ScDocShell::GetRefDevice 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh3.cxx:471
 #4  0x7f6d5e823439 in ScDocShell::UpdateFontList 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh3.cxx:462
 #5  0x7f6d5e81dd6c in ScDocShell::InitItems 
(this=this@entry=0x4697e6e0) at libreoffice/sc/source/ui/docshell/docsh2.cxx:98
 #6  0x7f6d5e81e80b in ScDocShell::InitNew (this=0x4697e6e0, xStor=...) 
at libreoffice/sc/source/ui/docshell/docsh2.cxx:83
 #7  0x7f6d6e2ce99d in SfxObjectShell::DoInitNew 
(this=this@entry=0x4697e6e0) at libreoffice/sfx2/source/doc/objstor.cxx:470
 #8  0x7f6d5e768daf in ScTransferObj::SetDrawClipDoc 
(bAnyOle=, pDoc=std::shared_ptr (use count 2, weak 
count 0) = {...})
 at libreoffice/sc/source/ui/app/transobj.cxx:821
 #9  0x7f6d5ec4735a in ScViewFunc::CopyToClipSingleRange 
(this=0x37a257a0, pClipDoc=, rRanges=..., bCut=, 
bIncludeObjects=)
 at libreoffice/sc/source/ui/view/viewfun3.cxx:248
 #10 0x7f6d5ec48ab0 in ScViewFunc::CopyToClip 
(this=this@entry=0x37a257a0, pClipDoc=pClipDoc@entry=0x0, rRanges=..., 
bCut=bCut@entry=false, bApi=bApi@entry=false,
 bIncludeObjects=bIncludeObjects@entry=true, bStopEdit=true) at 
libreoffice/sc/source/ui/view/viewfun3.cxx:212
 #11 0x7f6d5ec48dc3 in ScViewFunc::CopyToClip 
(this=this@entry=0x37a257a0, pClipDoc=pClipDoc@entry=0x0, 
bCut=bCut@entry=false, bApi=bApi@entry=false,
 bIncludeObjects=bIncludeObjects@entry=true, 
bStopEdit=bStopEdit@entry=true) at 
libreoffice/sc/source/ui/view/viewfun3.cxx:178
 #12 0x7f6d5eb0eada in ScCellShell::ExecuteEdit (this=0x35c3d240, 
rReq=...) at libreoffice/sc/source/ui/view/cellsh1.cxx:1369

Change-Id: I1eb90a0190719a0ffe52dcdc5b0d87f5198cd5a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157611
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 262ad6e1cd8f..74da175a9a99 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2698,6 +2698,8 @@ 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 );
 
@@ -2707,8 +2709,6 @@ 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/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 567447149937..4f5dea599230 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -244,6 +244,9 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* 
pClipDoc, const ScRangeList&
 if ( bSysClip && 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 ) );
 }


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-09-06 Thread Szymon Kłos (via logerrit)
 sc/inc/document.hxx   |2 +-
 sc/source/core/data/documen8.cxx  |4 ++--
 sc/source/filter/excel/xlroot.cxx |9 ++---
 sc/source/filter/inc/xlroot.hxx   |2 +-
 4 files changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 29f72210e92e0152d52b3a1d0253fbb5d8e2dead
Author: Szymon Kłos 
AuthorDate: Tue Sep 5 16:58:22 2023 +0200
Commit: Caolán McNamara 
CommitDate: Wed Sep 6 11:10:28 2023 +0200

lok: save to xlsx changes column size

When xlsx spreadsheet was opened in LOK on
every save default column width was decreased.
This doesn't happen in non-LOK case.

Column width in Excel are defined by double value
which specifies number of '0' characters which fit
into the column.

On export we use mnCharWidth from XclRootData to
convert Calc twips size to number of characters.
In LOK case it was 102 while in non-lok case 101.

It was caused by different Reference Device used in
ScDocument::GetRefDevice() because in LOK case we
are in WYSWIG mode as introduced in
ScModelObj::initializeForTiledRendering in commit c25062f:
sc tiled rendering: Don't adjust the text width according to printer.

Let's use for export purpose the GetVirtualDevice_100th_mm()

Change-Id: I6709194d7924e8c7e0aaa75ff3901afbcc1f8c11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156576
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 97b47ee94d00..262ad6e1cd8f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2186,7 +2186,7 @@ public:
 SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
 voidSetPrinter( VclPtr const & 
pNewPrinter );
 VirtualDevice*  GetVirtualDevice_100th_mm();
-SC_DLLPUBLIC OutputDevice*  GetRefDevice(); // WYSIWYG: Printer, otherwise 
VirtualDevice...
+SC_DLLPUBLIC OutputDevice*  GetRefDevice(bool bForceVirtDev = false); // 
WYSIWYG: Printer, otherwise VirtualDevice...
 
 boolGetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
  bool bInSel, const ScMarkData& rMark) 
const;
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 94072cd2931f..04696b7696e9 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -196,11 +196,11 @@ VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
 return mpVirtualDevice_100th_mm;
 }
 
-OutputDevice* ScDocument::GetRefDevice()
+OutputDevice* ScDocument::GetRefDevice(bool bForceVirtDev)
 {
 // Create printer like ref device, see Writer...
 OutputDevice* pRefDevice = nullptr;
-if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
+if ( !bForceVirtDev && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
 pRefDevice = GetPrinter();
 else
 pRefDevice = GetVirtualDevice_100th_mm();
diff --git a/sc/source/filter/excel/xlroot.cxx 
b/sc/source/filter/excel/xlroot.cxx
index 47f5ff7806c1..b340b1b537c8 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -37,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -208,7 +210,8 @@ void XclRoot::SetTextEncoding( rtl_TextEncoding eTextEnc )
 void XclRoot::SetCharWidth( const XclFontData& rFontData )
 {
 mrData.mnCharWidth = 0;
-if( OutputDevice* pPrinter = GetPrinter() )
+bool bIsLOK = comphelper::LibreOfficeKit::isActive();
+if( OutputDevice* pPrinter = GetPrinter( bIsLOK ) )
 {
 vcl::Font aFont( rFontData.maName, Size( 0, rFontData.mnHeight ) );
 aFont.SetFamily( rFontData.GetScFamily( GetTextEncoding() ) );
@@ -299,9 +302,9 @@ ScModelObj* XclRoot::GetDocModelObj() const
 return pDocShell ? comphelper::getFromUnoTunnel( 
pDocShell->GetModel() ) : nullptr;
 }
 
-OutputDevice* XclRoot::GetPrinter() const
+OutputDevice* XclRoot::GetPrinter(bool bForceVirtDev) const
 {
-return GetDoc().GetRefDevice();
+return GetDoc().GetRefDevice(bForceVirtDev);
 }
 
 ScStyleSheetPool& XclRoot::GetStyleSheetPool() const
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 10b4554e155f..3085ee8c8516 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -204,7 +204,7 @@ public:
 /** Returns the object model of the Calc document. */
 ScModelObj* GetDocModelObj() const;
 /** Returns pointer to the printer of the Calc document. */
-OutputDevice*   GetPrinter() const;
+OutputDevice*   GetPrinter(bool bForceVirtDev = false) const;
 /** Returns the style sheet pool of the Calc document. */
 ScStyleSheetPool&   GetStyleSheetPool() const;
 /** Returns the 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source solenv/clang-format

2023-08-24 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/CommonProperties.hxx  |   20 
 sc/source/ui/unoobj/cellsuno.cxx |   37 +
 sc/source/ui/unoobj/styleuno.cxx |7 +++
 solenv/clang-format/excludelist  |1 +
 4 files changed, 37 insertions(+), 28 deletions(-)

New commits:
commit 9afe09aff71601a08511ce2e2523b621fcbe5e83
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 23 17:13:44 2023 +0900
Commit: Miklos Vajna 
CommitDate: Thu Aug 24 16:43:04 2023 +0200

sc: simplify and fix prop. mapping for cell BG and char theme color

Change-Id: I461106200d37f0c605c07095c6b5871ea89e0e20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153501
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit bcd3ca80cd1f59c4b94660daa8c3e66944caf58f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156028
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/sc/inc/CommonProperties.hxx b/sc/inc/CommonProperties.hxx
new file mode 100644
index ..2c7d1e0a080b
--- /dev/null
+++ b/sc/inc/CommonProperties.hxx
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#define CELL_BACKGROUND_COLOR_PROPERTIES \
+{ SC_UNONAME_CELLBACK, ATTR_BACKGROUND, cppu::UnoType::get(), 
0, MID_BACK_COLOR }, \
+{ SC_UNONAME_CELL_BACKGROUND_COMPLEX_COLOR, ATTR_BACKGROUND, 
cppu::UnoType::get(), 0, MID_BACKGROUND_COMPLEX_COLOR 
}, \
+
+#define CHAR_COLOR_PROPERTIES \
+{ SC_UNONAME_CCOLOR, ATTR_FONT_COLOR, cppu::UnoType::get(), 0, 
MID_COLOR_RGB }, \
+{ SC_UNONAME_CHAR_COMPLEX_COLOR, ATTR_FONT_COLOR, 
cppu::UnoType::get(), 0, MID_COMPLEX_COLOR }, \
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 19d9e4216cbb..77ed135154a5 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -137,6 +137,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -156,12 +157,10 @@ static const SfxItemPropertySet* lcl_GetCellsPropertySet()
 { SC_UNONAME_ASIANVERT,ATTR_VERTICAL_ASIAN,cppu::UnoType::get(), 
 0, 0 },
 { SC_UNONAME_BOTTBORDER,ATTR_BORDER,   
::cppu::UnoType::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
 { SC_UNONAME_BOTTBORDER2,ATTR_BORDER,  
::cppu::UnoType::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
-{ SC_UNONAME_CELLBACK, ATTR_BACKGROUND,
cppu::UnoType::get(),0, MID_BACK_COLOR },
-{ SC_UNONAME_CELL_BACKGROUND_COMPLEX_COLOR, ATTR_BACKGROUND, 
cppu::UnoType::get(), 0, MID_BACKGROUND_COMPLEX_COLOR 
},
+CELL_BACKGROUND_COLOR_PROPERTIES
 { SC_UNONAME_CELLPRO,  ATTR_PROTECTION,
cppu::UnoType::get(), 0, 0 },
 { SC_UNONAME_CELLSTYL, 
SC_WID_UNO_CELLSTYL,cppu::UnoType::get(),0, 0 },
-{ SC_UNONAME_CCOLOR,   ATTR_FONT_COLOR,
cppu::UnoType::get(),0, 0 },
-{ SC_UNONAME_CHAR_COMPLEX_COLOR,   ATTR_FONT_COLOR, 
cppu::UnoType::get(), 0, MID_BACKGROUND_COMPLEX_COLOR 
},
+CHAR_COLOR_PROPERTIES
 { SC_UNONAME_COUTL,ATTR_FONT_CONTOUR,  cppu::UnoType::get(), 
 0, 0 },
 { SC_UNONAME_CCROSS,   
ATTR_FONT_CROSSEDOUT,cppu::UnoType::get(), 0, 
MID_CROSSED_OUT },
 { SC_UNONAME_CEMPHAS,  
ATTR_FONT_EMPHASISMARK,cppu::UnoType::get(), 0, MID_EMPHASIS 
},
@@ -267,12 +266,10 @@ static const SfxItemPropertySet* lcl_GetRangePropertySet()
 { SC_UNONAME_ASIANVERT,ATTR_VERTICAL_ASIAN,cppu::UnoType::get(), 
 0, 0 },
 { SC_UNONAME_BOTTBORDER,ATTR_BORDER,   
::cppu::UnoType::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
 { SC_UNONAME_BOTTBORDER2,ATTR_BORDER,  
::cppu::UnoType::get(), 0, BOTTOM_BORDER | CONVERT_TWIPS },
-{ SC_UNONAME_CELLBACK, ATTR_BACKGROUND,
cppu::UnoType::get(),0, MID_BACK_COLOR },
-{ SC_UNONAME_CELL_BACKGROUND_COMPLEX_COLOR, ATTR_BACKGROUND, 
cppu::UnoType::get(), 0, MID_BACKGROUND_COMPLEX_COLOR 
},
+CELL_BACKGROUND_COLOR_PROPERTIES
 { SC_UNONAME_CELLPRO,  ATTR_PROTECTION,
cppu::UnoType::get(), 0, 0 },
 { SC_UNONAME_CELLSTYL, 
SC_WID_UNO_CELLSTYL,cppu::UnoType::get(),0, 0 },
-{ SC_UNONAME_CCOLOR,   ATTR_FONT_COLOR,
cppu::UnoType::get(),0, 0 },
-{ SC_UNONAME_CHAR_COMPLEX_COLOR,   ATTR_FONT_COLOR, 
cppu::UnoType::get(), 0, MID_BACKGROUND_COMPLEX_COLOR 
},
+CHAR_COLOR_PROPERTIES
 { SC_UNONAME_COUTL,ATTR_FONT_CONTOUR,  cppu::UnoType::get(), 
 0, 0 },
 { SC_UNONAME_CCROSS,   

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-06-23 Thread Noel Grandin (via logerrit)
 sc/inc/patattr.hxx  |4 +++-
 sc/source/core/data/patattr.cxx |   14 ++
 2 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 2d31337e9111ff00a6575a21ad50677c9b6c08e6
Author: Noel Grandin 
AuthorDate: Thu Jun 22 09:38:50 2023 +0200
Commit: Caolán McNamara 
CommitDate: Fri Jun 23 11:12:18 2023 +0200

Speed up scrolling through large document with lots of patterns

Cache visibility for use in ScPatternAttr::IsVisible

Change-Id: Ia248a06b876b53115bbc3017d97538bbbc03830d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153450
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 5b031f488467..d78509ca74e3 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -54,6 +54,7 @@ class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
 {
 std::optional  pName;
 mutable std::optional mxHashCode;
+mutable std::optional mxVisible;
 ScStyleSheet*  pStyle;
 sal_uInt64 mnKey;
 public:
@@ -152,11 +153,12 @@ public:
 // TODO: tdf#135215: This is a band-aid to detect changes and invalidate 
the hash,
 // a proper way would be probably to override SfxItemSet::Changed(), but 
6cb400f41df0dd10
 // hardcoded SfxSetItem to contain SfxItemSet.
-SfxItemSet& GetItemSet() { mxHashCode.reset(); return 
SfxSetItem::GetItemSet(); }
+SfxItemSet& GetItemSet() { mxHashCode.reset(); mxVisible.reset(); return 
SfxSetItem::GetItemSet(); }
 using SfxSetItem::GetItemSet;
 
 private:
 voidCalcHashCode() const;
+boolCalcVisible() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 532831f90a78..09ea27cb1e3d 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -963,6 +963,7 @@ void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* 
pEditSet )
 return;
 GetFromEditItemSet( GetItemSet(), *pEditSet );
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const
@@ -1006,6 +1007,7 @@ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* 
pOldAttrs )
 {
 rThisSet.ClearItem( nSubWhich );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 else if ( eOldState != SfxItemState::DONTCARE )
@@ -1015,6 +1017,7 @@ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* 
pOldAttrs )
 {
 rThisSet.ClearItem( nSubWhich );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 }
@@ -1036,6 +1039,7 @@ void ScPatternAttr::ClearItems( const sal_uInt16* pWhich )
 for (sal_uInt16 i=0; pWhich[i]; i++)
 rSet.ClearItem(pWhich[i]);
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 static SfxStyleSheetBase* lcl_CopyStyleToPool
@@ -1171,6 +1175,13 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* 
pDestDoc, ScDocument* pSrcD
 }
 
 bool ScPatternAttr::IsVisible() const
+{
+if (!mxVisible)
+mxVisible = CalcVisible();
+return *mxVisible;
+}
+
+bool ScPatternAttr::CalcVisible() const
 {
 const SfxItemSet& rSet = GetItemSet();
 
@@ -1252,6 +1263,7 @@ void ScPatternAttr::SetStyleSheet( ScStyleSheet* 
pNewStyle, bool bClearDirectFor
 pStyle = nullptr;
 }
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::UpdateStyleSheet(const ScDocument& rDoc)
@@ -1278,6 +1290,7 @@ void ScPatternAttr::UpdateStyleSheet(const ScDocument& 
rDoc)
 else
 pStyle = nullptr;
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::StyleToName()
@@ -1290,6 +1303,7 @@ void ScPatternAttr::StyleToName()
 pStyle = nullptr;
 GetItemSet().SetParent( nullptr );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-06-14 Thread Noel Grandin (via logerrit)
 sc/inc/docuno.hxx  |5 -
 sc/source/ui/inc/gridwin.hxx   |3 ++-
 sc/source/ui/unoobj/docuno.cxx |   33 -
 sc/source/ui/view/gridwin4.cxx |8 
 4 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit 189db43ee59cc6dea56800fdea50a5a4f9df10b1
Author: Noel Grandin 
AuthorDate: Wed Jun 14 13:01:20 2023 +0200
Commit: Caolán McNamara 
CommitDate: Wed Jun 14 21:03:39 2023 +0200

online: speed up scrolling large excel document

the expensive part is the GetTiledRenderingArea(), so lets only do that
once, instead of twice

Change-Id: I2d18bce1ff116d6d711f0908502963c9743dea8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153046
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 23de1dad63ce..a75afa2834df 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -308,7 +308,7 @@ public:
 tools::Long nTileHeight ) override;
 
 /// @see vcl::ITiledRenderable::getDocumentSize().
-virtual Size getDocumentSize() override;
+virtual Size getDocumentSize() final override;
 
 /// @see vcl::ITiledRenderable::getDataArea().
 virtual Size getDataArea(long nPart) override;
@@ -397,6 +397,9 @@ public:
 
 /// @see vcl::ITiledRenderable::getViewRenderState().
 OString getViewRenderState() override;
+
+private:
+Size getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& 
rnTiledRenderingAreaEndRow );
 };
 
 class ScDrawPagesObj final : public cppu::WeakImplHelper<
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 635dd91dc393..ddc9815c2052 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -373,7 +373,8 @@ public:
 voidPaintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
-   tools::Long nTileWidth, tools::Long nTileHeight 
);
+   tools::Long nTileWidth, tools::Long nTileHeight,
+   SCCOL nTiledRenderingAreaEndCol, SCROW 
nTiledRenderingAreaEndRow );
 
 /// @see Window::LogicInvalidate().
 void LogicInvalidate(const tools::Rectangle* pRectangle) override;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4433c6306515..ca5f80eee2c0 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -550,11 +550,19 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 //if (pGridWindow->GetOutputSizePixel() != aTileSize)
 //pGridWindow->SetOutputSizePixel(Size(nOutputWidth, nOutputHeight));
 // so instead for now, set the viewport size to document size
-Size aDocSize = getDocumentSize();
+
+// Fetch the document size and the tiled rendering area together,
+// because the tiled rendering area is not cheap to compute, and we want
+// to pass it down to ScGridWindow::PaintFile to avoid computing twice.
+SCCOL nTiledRenderingAreaEndCol = 0;
+SCROW nTiledRenderingAreaEndRow = 0;
+Size aDocSize = getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+
 pGridWindow->SetOutputSizePixel(Size(aDocSize.Width() * 
pViewData->GetPPTX(), aDocSize.Height() * pViewData->GetPPTY()));
 
 pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
-nTilePosX, nTilePosY, nTileWidth, nTileHeight );
+nTilePosX, nTilePosY, nTileWidth, nTileHeight,
+nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow );
 
 // Draw Form controls
 ScDrawLayer* pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
@@ -653,6 +661,13 @@ VclPtr ScModelObj::getDocWindow()
 }
 
 Size ScModelObj::getDocumentSize()
+{
+SCCOL nTiledRenderingAreaEndCol = 0;
+SCROW nTiledRenderingAreaEndRow = 0;
+return getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+}
+
+Size ScModelObj::getDocumentSize(SCCOL& rnTiledRenderingAreaEndCol, SCROW& 
rnTiledRenderingAreaEndRow)
 {
 Size aSize(10, 10); // minimum size
 
@@ -661,11 +676,11 @@ Size ScModelObj::getDocumentSize()
 return aSize;
 
 SCTAB nTab = pViewData->GetTabNo();
-SCCOL nEndCol = 0;
-SCROW nEndRow = 0;
+rnTiledRenderingAreaEndCol = 0;
+rnTiledRenderingAreaEndRow = 0;
 const ScDocument& rDoc = pDocShell->GetDocument();
 
-rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow);
+rDoc.GetTiledRenderingArea(nTab, rnTiledRenderingAreaEndCol, 
rnTiledRenderingAreaEndRow);
 
 const ScDocument* pThisDoc = 
 const double fPPTX = pViewData->GetPPTX();
@@ -676,8 +691,8 @@ Size ScModelObj::getDocumentSize()
 return ScViewData::ToPixel(nSize, fPPTX);
 };
 
-tools::Long nDocWidthPixel = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/inc sc/source

2023-05-16 Thread Henry Castro (via logerrit)
 sc/inc/colorscale.hxx  |2 ++
 sc/source/core/data/colorscale.cxx |   15 +++
 2 files changed, 17 insertions(+)

New commits:
commit b95e81a9b0b584b2439a34737ce269ebb372e604
Author: Henry Castro 
AuthorDate: Thu May 11 16:23:03 2023 -0400
Commit: Henry Castro 
CommitDate: Tue May 16 22:18:36 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/+/151839
Tested-by: Jenkins CollaboraOffice 

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index e78baf0871b2..90a973391995 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 1bb36712fd13..7fd48f47305d 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 'distro/collabora/co-23.05' - sc/inc sc/source

2023-05-16 Thread Henry Castro (via logerrit)
 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 da818b2b96368fa088240f9d24586d1cea7650be
Author: Henry Castro 
AuthorDate: Thu May 11 16:07:10 2023 -0400
Commit: Henry Castro 
CommitDate: Tue May 16 22:18:18 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/+/151838
Tested-by: Jenkins CollaboraOffice 

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 513eb11cf2f4..e78baf0871b2 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -229,6 +229,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 afd16ba27365..51786d3dc712 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 192dd1cea78c..1bb36712fd13 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -529,6 +529,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 8da18a4a0471..1979d8ab44dd 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)
@@ -2051,6 +2055,14 @@ void ScConditionalFormat::endRendering()
 }
 }
 
+void ScConditionalFormat::updateValues()
+{
+for(auto& rxEntry : maEntries)
+{
+rxEntry->updateValues();
+}
+}
+
 void ScConditionalFormat::CalcAll()
 {
 for(const auto& rxEntry : maEntries)
@@ -2298,6 +2310,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 4eb5671f0dc7..47b3d1634c77 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -529,7 +529,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 'distro/collabora/co-23.05' - sc/inc sc/source

2023-02-12 Thread Mike Kaganski (via logerrit)
 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 7265ebe3998e06f119aa39dc15f6af2179a5e3a1
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 16:04:46 2023 +0300
Commit: Mike Kaganski 
CommitDate: Mon Feb 13 06:57:07 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/+/146760
Tested-by: Mike Kaganski 

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;
-}
-
-if