[Libreoffice-commits] core.git: sc/inc sc/source

2023-12-05 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 fd11b63244f784b336690d9096cd3f820cdbb9ee
Author: Henry Castro 
AuthorDate: Mon Dec 4 10:33:01 2023 -0400
Commit: Caolán McNamara 
CommitDate: Tue Dec 5 12:59:14 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 
(cherry picked from commit eccbe3bb4ed6f0bed4e7fbacfaf50762c93f9464)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160183
Tested-by: Jenkins

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index e8e45fc01b2e..8b07dc508edd 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -566,6 +566,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 98d2a1ebbe42..0b8b0865f0fc 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1786,6 +1786,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: sc/inc sc/source

2023-11-29 Thread Henry Castro (via logerrit)
 sc/inc/column.hxx   |2 +
 sc/source/core/data/column3.cxx |   60 
 sc/source/core/data/table3.cxx  |6 
 3 files changed, 68 insertions(+)

New commits:
commit 8b2369236dea7d6863c2df3d4ce5e356c9c8010c
Author: Henry Castro 
AuthorDate: Thu Nov 23 11:49:15 2023 -0400
Commit: Henry Castro 
CommitDate: Wed Nov 29 12:05:25 2023 +0100

sc: fix back color filter entries

The function "GetFilterEntries" iterates only that contains cell
data value entries, the background color filter feature requires
to iterate background color attribute which is not stored in multi
type vector cells.

Signed-off-by: Henry Castro 
Change-Id: I372db48d2399f62712f642eefdbfea8885b09f58
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159864
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 826eae46095b2184554565bab1792e96964a720f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159905
Tested-by: Jenkins

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 26ef79da2e6d..cefd03fd388e 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -599,6 +599,8 @@ public:
 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW 
nEndRow,
 ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow );
 
+void GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntries& 
rFilterEntries );
+
 bool GetDataEntries( SCROW nRow, std::set& rStrings) const;
 
 void UpdateInsertTabAbs(SCTAB nNewPos);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 054e334edb06..a0b0c639a003 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2701,6 +2701,66 @@ void ScColumn::GetFilterEntries(
 sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, 
aFunc);
 }
 
+void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, 
ScFilterEntries& rFilterEntries)
+{
+Color aBackColor;
+bool bCondBackColor = false;
+ScAddress aCell(GetCol(), 0, GetTab());
+ScConditionalFormat* pCondFormat = nullptr;
+
+const SfxItemSet* pCondSet = nullptr;
+const SvxBrushItem* pBrush = nullptr;
+const ScPatternAttr* pPattern = nullptr;
+const ScColorScaleFormat* pColFormat = nullptr;
+
+if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2))
+return;
+
+while (nRow1 <= nRow2)
+{
+aCell.SetRow(nRow1);
+pPattern = GetDoc().GetPattern(aCell.Col(), aCell.Row(), aCell.Tab());
+if (pPattern)
+{
+if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
+{
+pCondSet = GetDoc().GetCondResult(GetCol(), nRow1, GetTab());
+pBrush = >GetItem(ATTR_BACKGROUND, pCondSet);
+aBackColor = pBrush->GetColor();
+bCondBackColor = true;
+}
+}
+
+pCondFormat = GetDoc().GetCondFormat(aCell.Col(), aCell.Row(), 
aCell.Tab());
+if (pCondFormat)
+{
+for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++)
+{
+auto aEntry = pCondFormat->GetEntry(nFormat);
+if (aEntry->GetType() == ScFormatEntry::Type::Colorscale)
+{
+pColFormat = static_cast(aEntry);
+std::optional oColor = pColFormat->GetColor(aCell);
+if (oColor)
+{
+aBackColor = *oColor;
+bCondBackColor = true;
+}
+}
+}
+}
+
+if (!bCondBackColor)
+{
+pBrush = GetDoc().GetAttr(aCell, ATTR_BACKGROUND);
+aBackColor = pBrush->GetColor();
+}
+
+rFilterEntries.addBackgroundColor(aBackColor);
+nRow1++;
+}
+}
+
 namespace {
 
 /**
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 71cf80bcef38..359cc5dcc4f5 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3018,6 +3018,12 @@ void ScTable::GetFilterEntries( SCCOL nCol, SCROW nRow1, 
SCROW nRow2, ScFilterEn
 sc::ColumnBlockConstPosition aBlockPos;
 aCol[nCol].InitBlockPosition(aBlockPos);
 aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, 
bFiltering, false /*bFilteredRow*/);
+
+SCROW nLastRow = aBlockPos.miCellPos->position;
+if (nLastRow < nRow2)
+{
+aCol[nCol].GetBackColorFilterEntries(nLastRow, nRow2, rFilterEntries);
+}
 }
 
 void ScTable::GetFilteredFilterEntries(


[Libreoffice-commits] core.git: sc/inc sc/source svl/source

2023-11-19 Thread Armin Le Grand (allotropia) (via logerrit)
 sc/inc/patattr.hxx   |6 -
 sc/source/core/data/attarray.cxx |   13 +++
 sc/source/core/data/global.cxx   |   12 +++
 sc/source/core/data/patattr.cxx  |  128 +++
 svl/source/items/itemset.cxx |  108 
 5 files changed, 152 insertions(+), 115 deletions(-)

New commits:
commit f566a73adcf170d103b0561c7ea2871596af7142
Author: Armin Le Grand (allotropia) 
AuthorDate: Fri Nov 17 17:17:23 2023 +0100
Commit: Armin Le Grand 
CommitDate: Sun Nov 19 12:57:54 2023 +0100

Fix performance regression with ScPatternAttr/SC

Due to the paradigm item change the test
  make CppunitTest_sc_tablesheetobj
with CPPUNIT_TEST_NAME
  sc_apitest::ScTableSheetObj::testSheetCellRangeProperties
got much slower. Unfortunately it did not break, so got unnoted.

I took a look now. First I intended to add some hashing in an
std::unordered_set using that hash values at ScPatternAttr, but
that is not even possible due to other data in that item that needs
to be compared. I had the impression that it was 'somehow' hashed
before, but after debugging the version before that change I
noted that also the list of existing items was linearly compared
to the new entry, using the operator==.
Thus the problem was not due to not hashing, but due to the
ScPatternAttr::operator==. That uses the hash (not changed),
but no longer finds equal entries.
This is because the hash code is made up from the SfxPoolItemPtrs
in the SfxItemSet, so when all are equal we can be sure the SfxItemSet
content is equal.
To use this the other way around is *not* correct: Even with
not all ptrs equal the SfxItemSets can still be equal, simply
by one SfxItemSet using another, but identical incarnation of
an item. Thuis means that ScPatternAttr::operator== does not
detect all cases of equality.
This worked in most cases before since most items were
'pooled' and thus much effort was used to ensure their uniqueness,
but even before the paradigm item change an item type could be
flagged as non-poolable. In that case, this already could fail
but with no too bad consequences (just one more copy of
an ScPatternAttr would stay).
So I fixed that mainly in adapting and optimizing
ScPatternAttr::operator==. The results are (same machine, same
compiler, dbg version, metioned test):

Version before item paradigm change:
user0m50,778s

Version after item paradigm change:
user20m13,944s

Version with memcmp:
user0m48,845s

Version with hash:
user0m48,710s

Since that hash does nothing else than to buffer the comparison of
those item pointers I just tried to use memcmp instead, as is already
used in other places (same file, ScPatternAttr::FastEqualPatternSets,
also SfxItemSet::operator==). As can be seen above it makes practically
no difference (memcomp even slightly faster).
Since that hash is only used in ScPatternAttr::operator== and is same
speed (memcomp linearly compares 56 SfxPoolItem ptrs) I decided to
remove it. It needs quite some spaces to be reset and re-calculated
which are not needed anymore. The calculation is based on dividing
the number of items by 4, so we are good with 56, but if someone has/
will adapt the items used by ScPatternAttr it is easy to forget to
adapt this, and not easy to change the alghorithm  when it's not a
multiple of 4.

I also optimized/overhauled SfxItemSet::operator== (or better: the
SfxItemSet::Equals used by it). It is now better readable, too.

I also adapted ScAttrArray::AddCondFormat to not always incarnate/
delete ScPatternAttr instances, only when needed. This also helps
a bit and could be done in more places.

All in all it is really necessary to cleanup SC's usage of
ScPatternAttr - there are quite some possibilities to make that
cleaner and faster. In principle it's a huge 'compromize' to use
item functionailty to have a possibly 'cheap' maximum shared
SfxItemSet at a Cell.

Decided to make SfxItemSet::operator== even faster for the case
of unequal ranges by iterating over ranges of local SfxItemSet
and incremented offset. Still accesses to 2nd SfxItemSet will be
the expensive ones using the iterated WhichID.

Added two more things to SfxItemSet::operator==: We can return
early when both have no items set. For the unequal-ranges compare
I added an early-exit when Count() items were compared.

Looked at the errors that indeed do trigger the assert in
ScPatternAttr::operator== and hint to incarnations of ScPatternAttr
that do not use the needed range ATTR_PATTERN_START, ATTR_PATTERN_END.
Hunted down to come from ScViewFunc::ApplyAttributes and there from
some Dialogs, so seems some SC 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-11-11 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 4abe6c83e76f825319e8b2a0c0b8b8e92177da65
Author: Henry Castro 
AuthorDate: Mon Nov 6 07:18:48 2023 -0400
Commit: Caolán McNamara 
CommitDate: Sat Nov 11 20:27:29 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 
(cherry picked from commit 768433f07873eb608837630f85e7e1b375239fca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159238
Tested-by: Jenkins

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 1cff7a3ce4e4..11b65e9262c0 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1512,6 +1512,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 68b4c614c68b..8907bde5a150 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -641,6 +641,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 6225e92781b9..0b4ae5ca0da8 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1081,6 +1081,13 @@ void ScDocument::GetDataArea( SCTAB nTab, SCCOL& 
rStartCol, SCROW& rStartRow,
 pTable->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 d8a4cf584132..62b9dbb9e006 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 = 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-11-10 Thread Andreas Heinisch (via logerrit)
 sc/inc/viewopti.hxx|2 ++
 sc/source/core/tool/viewopti.cxx   |1 +
 sc/source/ui/inc/mvtabdlg.hxx  |3 ---
 sc/source/ui/miscdlgs/mvtabdlg.cxx |   16 ++--
 4 files changed, 13 insertions(+), 9 deletions(-)

New commits:
commit bb79936ec808712f53bc48663a485875571ba643
Author: Andreas Heinisch 
AuthorDate: Fri Nov 10 12:00:46 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Fri Nov 10 16:59:29 2023 +0100

tdf#96854 - De-static-ize last used option for copy/move sheet

Change-Id: Iafb12b51f166f9485f1658c406a98e5db5b246ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159292
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index 489a3e8c81da..beb0530e88a5 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -45,6 +45,8 @@ enum ScViewOption
 VOPT_ANCHOR,
 VOPT_PAGEBREAKS,
 VOPT_SUMMARY,
+// tdf#96854 - move/copy sheet dialog: last used option for action (true: 
copy, false: move)
+VOPT_COPY_SHEET,
 VOPT_THEMEDCURSOR,
 };
 
diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx
index 80d8915effb9..a91f0cef8bf9 100644
--- a/sc/source/core/tool/viewopti.cxx
+++ b/sc/source/core/tool/viewopti.cxx
@@ -107,6 +107,7 @@ void ScViewOptions::SetDefaults()
 aOptArr[ VOPT_ANCHOR   ] = true;
 aOptArr[ VOPT_PAGEBREAKS   ] = true;
 aOptArr[ VOPT_SUMMARY  ] = true;
+aOptArr[ VOPT_COPY_SHEET   ] = false;
 aOptArr[ VOPT_THEMEDCURSOR ] = false;
 
 aModeArr[VOBJ_TYPE_OLE ]  = VOBJ_MODE_SHOW;
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 665d3cd46085..c6e89ab9fed0 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -61,9 +61,6 @@ private:
 boolbRenameTable:1;
 boolmbEverEdited:1;
 
-// tdf#96854 - remember last used option for copy/move sheet
-static bool mbRememeberedCopy;
-
 std::unique_ptr m_xBtnMove;
 std::unique_ptr m_xBtnCopy;
 std::unique_ptr m_xFtDoc;
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx 
b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 12c4e4d54bcc..afacdc48b46e 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -26,9 +26,7 @@
 #include 
 #include 
 #include 
-
-// tdf#96854 - remember last used option for copy/move sheet
-bool ScMoveTableDlg::mbRememeberedCopy = false;
+#include 
 
 ScMoveTableDlg::ScMoveTableDlg(weld::Window* pParent, OUString aDefault)
 : GenericDialogController(pParent, "modules/scalc/ui/movecopysheet.ui", 
"MoveCopySheetDialog")
@@ -193,8 +191,11 @@ void ScMoveTableDlg::Init()
 m_xEdTabName->connect_changed(LINK(this, ScMoveTableDlg, CheckNameHdl));
 
 // tdf#96854 - remember last used option for copy/move sheet
-m_xBtnMove->set_active(!mbRememeberedCopy);
-m_xBtnCopy->set_active(mbRememeberedCopy);
+const bool bIsCopyActive
+= 
ScTabViewShell::GetActiveViewShell()->GetViewData().GetOptions().GetOption(
+VOPT_COPY_SHEET);
+m_xBtnMove->set_active(!bIsCopyActive);
+m_xBtnCopy->set_active(bIsCopyActive);
 m_xEdTabName->set_sensitive(false);
 m_xFtWarn->hide();
 InitDocListBox();
@@ -250,7 +251,10 @@ void ScMoveTableDlg::SetOkBtnLabel()
 // tdf#139464 Write "Copy" or "Move" on OK button
 m_xBtnOk->set_label(bIsCopyActive ? m_xBtnCopy->get_label() : 
m_xBtnMove->get_label());
 // tdf#96854 - remember last used option for copy/move sheet
-mbRememeberedCopy = bIsCopyActive;
+ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ScViewOptions aViewOpt(pScViewShell->GetViewData().GetOptions());
+aViewOpt.SetOption(VOPT_COPY_SHEET, bIsCopyActive);
+pScViewShell->GetViewData().SetOptions(aViewOpt);
 }
 
 // Handler:


[Libreoffice-commits] core.git: sc/inc sc/source

2023-11-09 Thread Noel Grandin (via logerrit)
 sc/inc/compiler.hxx  |4 ++--
 sc/source/core/tool/compiler.cxx |6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 4d263b48a1353804816a55433f2ee90e96be1e32
Author: Noel Grandin 
AuthorDate: Wed Nov 8 13:32:17 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 9 17:53:14 2023 +0100

loplugin:fieldcast in ScCompiler::TableRefEntry

Change-Id: I5d02daa209b735fbc0dcd10fd45056d586837d05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159211
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index fbf5073743e1..9cff881db62d 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -307,9 +307,9 @@ private:
 
 struct TableRefEntry
 {
-ScTokenRef  mxToken;
+boost::intrusive_ptr mxToken;
 sal_uInt16  mnLevel;
-TableRefEntry( formula::FormulaToken* p ) : mxToken(p), mnLevel(0) {}
+TableRefEntry( ScTableRefToken* p ) : mxToken(p), mnLevel(0) {}
 };
 std::vector maTableRefs; /// "stack" of currently 
active ocTableRef tokens
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 2a5491f4666b..63b1f0969225 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3999,7 +3999,7 @@ bool ScCompiler::ParseTableRefItem( const OUString& rName 
)
 {
 // Only called when there actually is a current TableRef, hence
 // accessing maTableRefs.back() is safe.
-ScTableRefToken* p = 
dynamic_cast(maTableRefs.back().mxToken.get());
+ScTableRefToken* p = maTableRefs.back().mxToken.get();
 assert(p);  // not a ScTableRefToken can't be
 
 switch ((*iLook).second)
@@ -4067,7 +4067,7 @@ bool ScCompiler::ParseTableRefColumn( const OUString& 
rName )
 {
 // Only called when there actually is a current TableRef, hence
 // accessing maTableRefs.back() is safe.
-ScTableRefToken* p = 
dynamic_cast(maTableRefs.back().mxToken.get());
+ScTableRefToken* p = maTableRefs.back().mxToken.get();
 assert(p);  // not a ScTableRefToken can't be
 
 ScDBData* pDBData = rDoc.GetDBCollection()->getNamedDBs().findByIndex( 
p->GetIndex());
@@ -4918,7 +4918,7 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 const FormulaToken* pPrev = pArr->PeekPrev( nIdx);
 if (pPrev && pPrev->GetOpCode() == ocDBArea)
 {
-FormulaToken* pTableRefToken = new ScTableRefToken( 
pPrev->GetIndex(), ScTableRefToken::TABLE);
+ScTableRefToken* pTableRefToken = new ScTableRefToken( 
pPrev->GetIndex(), ScTableRefToken::TABLE);
 maTableRefs.emplace_back( pTableRefToken);
 // pPrev may be dead hereafter.
 static_cast(pArr)->ReplaceToken( nIdx, 
pTableRefToken,


[Libreoffice-commits] core.git: sc/inc sc/source

2023-11-01 Thread Noel Grandin (via logerrit)
 sc/inc/postit.hxx   |2 +-
 sc/source/core/data/postit.cxx  |4 ++--
 sc/source/filter/excel/xiescher.cxx |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 35975f9ea30e9ec8ac9276f90874ffe272001038
Author: Noel Grandin 
AuthorDate: Wed Nov 1 10:39:45 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Nov 1 13:09:25 2023 +0100

pass SfxItemSet by const & to CreateNoteFromObjectData

Because in an upcoming patch the CloneAsValue() call in
XclImpNoteObj::DoPreProcessSdrObj will stop working, because the
underlying SfxItemSet will no longer be an SfxAllItemSet

Change-Id: I8361a1b1c1c64cff49c736812fbfb2597ab41140
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158750
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index df114eaf64a5..5e7f6f81d16f 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -246,7 +246,7 @@ public:
  */
 static ScPostIt*CreateNoteFromObjectData(
 ScDocument& rDoc, const ScAddress& rPos,
-SfxItemSet&& oItemSet, const OUString& rStyleName,
+const SfxItemSet& rItemSet, const OUString& 
rStyleName,
 const OutlinerParaObject& rOutlinerObj,
 const tools::Rectangle& rCaptionRect, bool bShown 
);
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index e46836f12e53..fa84f0212b81 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -957,14 +957,14 @@ ScNoteData ScNoteUtil::CreateNoteData(ScDocument& rDoc, 
const ScAddress& rPos,
 }
 
 ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
-ScDocument& rDoc, const ScAddress& rPos, SfxItemSet&& rItemSet, const 
OUString& rStyleName,
+ScDocument& rDoc, const ScAddress& rPos, const SfxItemSet& rItemSet, 
const OUString& rStyleName,
 const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& 
rCaptionRect,
 bool bShown )
 {
 ScNoteData aNoteData(CreateNoteData(rDoc, rPos, rCaptionRect, bShown));
 ScCaptionInitData& rInitData = *aNoteData.mxInitData;
 rInitData.mxOutlinerObj = rOutlinerObj;
-rInitData.moItemSet.emplace(std::move(rItemSet));
+rInitData.moItemSet.emplace(rItemSet);
 rInitData.maStyleName = 
ScStyleNameConversion::ProgrammaticToDisplayName(rStyleName, 
SfxStyleFamily::Frame);
 
 return InsertNote(rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/);
diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index 3f5969cead78..62e35213a045 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1876,7 +1876,7 @@ void XclImpNoteObj::DoPreProcessSdrObj( 
XclImpDffConverter& rDffConv, SdrObject&
 // create cell note with all data from drawing object
 ScNoteUtil::CreateNoteFromObjectData(
 GetDoc(), maScPos,
-rSdrObj.GetMergedItemSet().CloneAsValue(), // new 
object on heap expected
+rSdrObj.GetMergedItemSet(),
 OUString(), *pOutlinerObj,
 rSdrObj.GetLogicRect(),
 ::get_flag( mnNoteFlags, EXC_NOTE_VISIBLE ) );


[Libreoffice-commits] core.git: 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 c15c1d87fceb782d76b5984f576d03a63c609ae5
Author: Caolán McNamara 
AuthorDate: Tue Oct 31 11:33:56 2023 +
Commit: Caolán McNamara 
CommitDate: Tue Oct 31 17:15:30 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/+/158720
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 0f30f64cb672..26ef79da2e6d 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -714,7 +714,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 fea2f84e5be0..7ffd5ae9c735 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 
@@ -1808,22 +1809,37 @@ void resetColumnPosition(sc::CellStoreType& rCells, 
SCCOL nCol)
 
 class NoteCaptionUpdater
 {
-SCCOL mnCol;
-SCTAB mnTab;
+const ScDocument& m_rDocument;
+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& rDocument, const ScAddress& rPos, 
bool bAddressChanged)
+: m_rDocument(rDocument)
+, 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_rDocument, 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(GetDoc(), 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 31a0d6f1dd1e..978bd00ecbac 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1491,7 +1491,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: sc/inc sc/source

2023-10-27 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 47ee01c28701e22e55a9ef7d66e0836c5a0a5899
Author: Szymon Kłos 
AuthorDate: Fri Oct 27 11:53:57 2023 +0200
Commit: Szymon Kłos 
CommitDate: Fri Oct 27 22:21:03 2023 +0200

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/+/158536
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 74c15b5b698b..d58777176e52 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -396,4 +396,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 8ddb297269dc..c371861ac355 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,
@@ -89,19 +96,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: sc/inc sc/source

2023-10-18 Thread Laurent Balland (via logerrit)
 sc/inc/globstr.hrc |   14 
+-
 sc/inc/strings.hrc |2 -
 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx |2 -
 sc/source/ui/view/cellsh.cxx   |   12 
 4 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 9a0018a356c89baf600a72eed8ee4ac927815b9b
Author: Laurent Balland 
AuthorDate: Wed Feb 22 23:01:01 2023 +0100
Commit: Laurent Balland 
CommitDate: Wed Oct 18 17:03:07 2023 +0200

Replace $baz by %foo for sanity checks

Tools for sanity-checks like
https://docs.weblate.org/en/latest/user/checks.html#percent-placeholders
looks for percent instead of dollar
Try to align with %1 as suggested by Chistian Lohmaier

Change-Id: I97d353f452316b939f2eaf7d30e68b9aab9f83e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147493
Tested-by: Jenkins
Reviewed-by: Laurent Balland 

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 2b949cba8264..e8e45fc01b2e 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -157,14 +157,14 @@
 #define STR_PIVOT_GROUP NC_("STR_PIVOT_GROUP", "Group")
 #define STR_PIVOT_ROW_LABELSNC_("STR_PIVOT_ROW_LABELS", 
"Row Labels")
 #define STR_PIVOT_COL_LABELSNC_("STR_PIVOT_COL_LABELS", 
"Column Labels")
-/* To translators: $1 == will be replaced by STR_SELCOUNT_ROWARG, and $2 by 
STR_SELCOUNT_COLARG
+/* %1 will be replaced by STR_SELCOUNT_ROWARG, and %2 by STR_SELCOUNT_COLARG
e.g. Selected: 1 row, 2 columns */
-#define STR_SELCOUNTNC_("STR_SELCOUNT", "Selected: 
$1, $2")
-// To translators: STR_SELCOUNT_ROWARG is $1 of STR_SELCOUNT. $1 of 
STR_SELCOUNT_ROWARG is number of rows
-#define STR_SELCOUNT_ROWARG NNC_("STR_SELCOUNT_ROWARG", 
"$1 row", "$1 rows")
-// To translators: STR_SELCOUNT_COLARG is $1 of STR_SELCOUNT. $1 of 
STR_SELCOUNT_ROWARG is number of columns
-#define STR_SELCOUNT_COLARG NNC_("STR_SELCOUNT_COLARG", 
"$1 column", "$1 columns")
-#define STR_FILTER_SELCOUNT NC_("STR_FILTER_SELCOUNT", "$1 
of $2 records found")
+#define STR_SELCOUNTNC_("STR_SELCOUNT", "Selected: 
%1, %2")
+// STR_SELCOUNT_ROWARG is %1 of STR_SELCOUNT. %d of STR_SELCOUNT_ROWARG is 
number of rows
+#define STR_SELCOUNT_ROWARG NNC_("STR_SELCOUNT_ROWARG", 
"%d row", "%d rows")
+// STR_SELCOUNT_COLARG is %2 of STR_SELCOUNT. %d of STR_SELCOUNT_ROWARG is 
number of columns
+#define STR_SELCOUNT_COLARG NNC_("STR_SELCOUNT_COLARG", 
"%d column", "%d columns")
+#define STR_FILTER_SELCOUNT NC_("STR_FILTER_SELCOUNT", "%1 
of %2 records found")
 #define STR_COLUMN  NC_("STR_COLUMN", "Column")
 #define STR_ROW NC_("STR_ROW", "Row")
 #define STR_PAGENC_("STR_PAGE", "Page")
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index b40ed197be4b..74c15b5b698b 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -259,7 +259,7 @@
 #define STRID_CALC_FIRST_QUARTILE   
NC_("STRID_CALC_FIRST_QUARTILE", "First Quartile")
 #define STRID_CALC_THIRD_QUARTILE   
NC_("STRID_CALC_THIRD_QUARTILE", "Third Quartile")
 /* RandomNumberGeneratorDialog */
-#define STR_UNDO_DISTRIBUTION_TEMPLATE  
NC_("STR_UNDO_DISTRIBUTION_TEMPLATE", "Random ($(DISTRIBUTION))")
+#define STR_UNDO_DISTRIBUTION_TEMPLATE  
NC_("STR_UNDO_DISTRIBUTION_TEMPLATE", "Random (%1)")
 #define STR_DISTRIBUTION_UNIFORM_REAL   
NC_("STR_DISTRIBUTION_UNIFORM_REAL", "Uniform")
 #define STR_DISTRIBUTION_UNIFORM_INTEGER
NC_("STR_DISTRIBUTION_UNIFORM_INTEGER", "Uniform Integer")
 #define STR_DISTRIBUTION_NORMAL 
NC_("STR_DISTRIBUTION_NORMAL", "Normal")
diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx 
b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
index 2490ebf47301..38894160eff1 100644
--- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
@@ -262,7 +262,7 @@ void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& 
randomGenerator, Transl
 {
 OUString aUndo = ScResId(STR_UNDO_DISTRIBUTION_TEMPLATE);
 OUString aDistributionName = ScResId(pDistributionStringId);
-aUndo = aUndo.replaceAll("$(DISTRIBUTION)",  aDistributionName);
+aUndo = aUndo.replaceAll("%1",  aDistributionName);
 
 ScDocShell* pDocShell = mrViewData.GetDocShell();
 SfxUndoManager* pUndoManager = pDocShell->GetUndoManager();
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 34c87d0e61c6..1a866df3c881 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-10-12 Thread Noel Grandin (via logerrit)
 sc/inc/broadcast.hxx  |   15 ---
 sc/source/core/data/broadcast.cxx |   33 ++---
 2 files changed, 14 insertions(+), 34 deletions(-)

New commits:
commit b9b57133125179a88f7f68e14ef6cde85ed1
Author: Noel Grandin 
AuthorDate: Wed Oct 11 11:39:22 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 12 08:54:26 2023 +0200

no need for these enums in BroadcasterState

the std::variant already knows which alternative it stores

Change-Id: I3838d83959cf6a97876aba3543179338ba088ccc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157819
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/broadcast.hxx b/sc/inc/broadcast.hxx
index b095f819acb7..55b1e64f0c9a 100644
--- a/sc/inc/broadcast.hxx
+++ b/sc/inc/broadcast.hxx
@@ -24,24 +24,10 @@ class FormulaGroupAreaListener;
 
 struct BroadcasterState
 {
-enum class CellListenerType
-{
-FormulaCell,
-Generic,
-};
-
-enum class AreaListenerType
-{
-FormulaCell,
-FormulaGroup,
-Generic,
-};
-
 struct CellListener
 {
 using DataType = std::variant;
 
-CellListenerType eType;
 DataType pData;
 
 CellListener(const ScFormulaCell* p);
@@ -53,7 +39,6 @@ struct BroadcasterState
 using DataType = std::variant;
 
-AreaListenerType eType;
 DataType pData;
 
 AreaListener(const ScFormulaCell* p);
diff --git a/sc/source/core/data/broadcast.cxx 
b/sc/source/core/data/broadcast.cxx
index c0cd0c29edca..d76591692f15 100644
--- a/sc/source/core/data/broadcast.cxx
+++ b/sc/source/core/data/broadcast.cxx
@@ -14,32 +14,27 @@
 namespace sc
 {
 BroadcasterState::CellListener::CellListener(const ScFormulaCell* p)
-: eType(CellListenerType::FormulaCell)
-, pData(p)
+: pData(p)
 {
 }
 
 BroadcasterState::CellListener::CellListener(const SvtListener* p)
-: eType(CellListenerType::Generic)
-, pData(p)
+: pData(p)
 {
 }
 
 BroadcasterState::AreaListener::AreaListener(const ScFormulaCell* p)
-: eType(AreaListenerType::FormulaCell)
-, pData(p)
+: pData(p)
 {
 }
 
 BroadcasterState::AreaListener::AreaListener(const 
sc::FormulaGroupAreaListener* p)
-: eType(AreaListenerType::FormulaGroup)
-, pData(p)
+: pData(p)
 {
 }
 
 BroadcasterState::AreaListener::AreaListener(const SvtListener* p)
-: eType(AreaListenerType::Generic)
-, pData(p)
+: pData(p)
 {
 }
 
@@ -52,7 +47,7 @@ bool BroadcasterState::hasFormulaCellListener(const 
ScAddress& rBroadcasterPos,
 
 for (const auto& rLis : it->second)
 {
-if (rLis.eType == CellListenerType::FormulaCell)
+if (rLis.pData.index() == 0)
 {
 auto pFC = std::get(rLis.pData);
 if (pFC->aPos == rFormulaPos)
@@ -72,7 +67,7 @@ bool BroadcasterState::hasFormulaCellListener(const ScRange& 
rBroadcasterRange,
 
 for (const auto& rLis : it->second)
 {
-if (rLis.eType == AreaListenerType::FormulaCell)
+if (rLis.pData.index() == 0)
 {
 auto pFC = std::get(rLis.pData);
 if (pFC->aPos == rFormulaPos)
@@ -99,16 +94,16 @@ void BroadcasterState::dump(std::ostream& rStrm, const 
ScDocument* pDoc) const
 
 for (const auto& rLis : rListeners)
 {
-switch (rLis.eType)
+switch (rLis.pData.index())
 {
-case BroadcasterState::CellListenerType::FormulaCell:
+case 0:
 {
 auto* pFC = std::get(rLis.pData);
 rStrm << "  - type: formula-cell\n";
 rStrm << "position: " << pFC->aPos.Format(nPosFlags, 
pDoc) << std::endl;
 break;
 }
-case BroadcasterState::CellListenerType::Generic:
+case 1:
 {
 rStrm << "  - type: unknown" << std::endl;
 break;
@@ -127,16 +122,16 @@ void BroadcasterState::dump(std::ostream& rStrm, const 
ScDocument* pDoc) const
 
 for (const auto& rLis : rListeners)
 {
-switch (rLis.eType)
+switch (rLis.pData.index())
 {
-case BroadcasterState::AreaListenerType::FormulaCell:
+case 0:
 {
 auto* pFC = std::get(rLis.pData);
 rStrm << "  - type: formula-cell\n";
 rStrm << "position: " << pFC->aPos.Format(nPosFlags, 
pDoc) << std::endl;
 break;
 }
-case BroadcasterState::AreaListenerType::FormulaGroup:
+case 1:
 {
 auto* pFGL = std::get(rLis.pData);
 
@@ -150,7 +145,7 @@ void BroadcasterState::dump(std::ostream& rStrm, const 
ScDocument* pDoc) const
 }
 break;
 }
- 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-10-10 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 6c247c2c867281181d3d35157bca5e72a3c0bca8
Author: Noel Grandin 
AuthorDate: Tue Oct 10 12:55:20 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Oct 11 07:28:20 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 

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index cbc8f7cfe2f9..521f3b7bb1d6 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 2efd31c7675f..b6d062b93d66 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -190,9 +190,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)
@@ -209,7 +211,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 )
 {
@@ -1405,7 +1408,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: sc/inc sc/source

2023-10-06 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 48c0ada1745be2cd817d5bd8a912530028fa8419
Author: Caolán McNamara 
AuthorDate: Thu Oct 5 14:12:51 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Oct 6 09:29:33 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/+/157594
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index dbaf26c4e33d..f473034ea039 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2695,6 +2695,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 );
 
@@ -2704,8 +2706,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 7a6403237b89..8aea1ebbd66d 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -242,6 +242,9 @@ bool ScViewFunc::CopyToClipSingleRange( ScDocument* 
pClipDoc, const ScRangeList&
 if ( pSysClipDoc && bIncludeObjects )
 {
 bool bAnyOle = rDoc.HasOLEObjectsInArea( aRange );
+// There are optional paths (e.g. bAnyOle and 
InputOptions().GetTextWysiwyg true)
+// which dereference pSysClipDoc->mxPoolHelper so ensure that is set 
here.
+pSysClipDoc->SharePooledResources();
 // Update ScGlobal::xDrawClipDocShellRef.
 ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( 
bAnyOle, pSysClipDoc ) );
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2023-09-15 Thread Noel Grandin (via logerrit)
 sc/inc/arealink.hxx  |2 
 sc/inc/document.hxx  |8 +-
 sc/inc/tablink.hxx   |2 
 sc/source/core/data/SolverSettings.cxx   |2 
 sc/source/core/data/attarray.cxx |1 
 sc/source/core/data/bcaslot.cxx  |3 
 sc/source/core/data/dociter.cxx  |1 
 sc/source/core/data/documen2.cxx |4 -
 sc/source/core/data/documen3.cxx |1 
 sc/source/core/data/documen4.cxx |1 
 sc/source/core/data/documen5.cxx |3 
 sc/source/core/data/documen8.cxx |5 -
 sc/source/core/data/documen9.cxx |3 
 sc/source/core/data/document.cxx |   10 +-
 sc/source/core/data/document10.cxx   |2 
 sc/source/core/data/drwlayer.cxx |5 -
 sc/source/core/data/simpleformulacalc.cxx|1 
 sc/source/core/data/table1.cxx   |1 
 sc/source/core/data/table2.cxx   |4 -
 sc/source/core/data/validat.cxx  |5 -
 sc/source/core/tool/addinlis.cxx |1 
 sc/source/core/tool/address.cxx  |1 
 sc/source/core/tool/adiasync.cxx |1 
 sc/source/core/tool/chgtrack.cxx |3 
 sc/source/core/tool/compiler.cxx |3 
 sc/source/core/tool/detfunc.cxx  |2 
 sc/source/core/tool/editutil.cxx |3 
 sc/source/core/tool/formulalogger.cxx|3 
 sc/source/core/tool/formulaparserpool.cxx|5 -
 sc/source/core/tool/interpr1.cxx |3 
 sc/source/core/tool/interpr2.cxx |3 
 sc/source/core/tool/interpr4.cxx |5 -
 sc/source/core/tool/progress.cxx |1 
 sc/source/filter/dif/difexp.cxx  |1 
 sc/source/filter/dif/difimp.cxx  |1 
 sc/source/filter/excel/excdoc.cxx|7 +
 sc/source/filter/excel/excform8.cxx  |1 
 sc/source/filter/excel/excimp8.cxx   |7 +
 sc/source/filter/excel/expop2.cxx|6 -
 sc/source/filter/excel/impop.cxx |5 -
 sc/source/filter/excel/namebuff.cxx  |1 
 sc/source/filter/excel/read.cxx  |1 
 sc/source/filter/excel/xecontent.cxx |3 
 sc/source/filter/excel/xehelper.cxx  |1 
 sc/source/filter/excel/xeroot.cxx|3 
 sc/source/filter/excel/xichart.cxx   |5 -
 sc/source/filter/excel/xicontent.cxx |1 
 sc/source/filter/excel/xiescher.cxx  |   15 ++-
 sc/source/filter/excel/xilink.cxx|1 
 sc/source/filter/excel/xistyle.cxx   |   11 +-
 sc/source/filter/excel/xlroot.cxx|7 +
 sc/source/filter/html/htmlexp.cxx|3 
 sc/source/filter/html/htmlpars.cxx   |   13 +--
 sc/source/filter/inc/xlroot.hxx  |3 
 sc/source/filter/lotus/filter.cxx|1 
 sc/source/filter/lotus/lotread.cxx   |1 
 sc/source/filter/oox/excelfilter.cxx |2 
 sc/source/filter/oox/workbookhelper.cxx  |2 
 sc/source/filter/rtf/eeimpars.cxx|1 
 sc/source/filter/xcl97/xcl97esc.cxx  |1 
 sc/source/filter/xml/XMLTableSourceContext.cxx   |1 
 sc/source/filter/xml/xmlcelli.cxx|1 
 sc/source/filter/xml/xmlimprt.cxx|4 -
 sc/source/filter/xml/xmlwrap.cxx |4 -
 sc/source/ui/Accessibility/AccessibleCellBase.cxx|   42 +--
 sc/source/ui/Accessibility/AccessibleDocument.cxx|2 
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |2 
 sc/source/ui/Accessibility/AccessibleEditObject.cxx  |8 +-
 sc/source/ui/Accessibility/AccessibleText.cxx|8 +-
 sc/source/ui/app/inputhdl.cxx|2 
 sc/source/ui/dataprovider/csvdataprovider.cxx   

[Libreoffice-commits] core.git: sc/inc sc/source

2023-09-08 Thread Noel Grandin (via logerrit)
 sc/inc/miscuno.hxx   |8 
 sc/source/core/data/dpoutput.cxx |2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

New commits:
commit 7585667c83578e7f073409b2b94a4d34e7124115
Author: Noel Grandin 
AuthorDate: Fri Sep 8 11:30:25 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 8 13:12:05 2023 +0200

replace ScUnoHelpFunctions::VectorToSequence..

with the more standard comphelper::containerToSequence

Change-Id: I29a67e52e7c25c2d67b0cd617acc7068737bad5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156702
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/miscuno.hxx b/sc/inc/miscuno.hxx
index 1a17e7afe7ea..362212c1564b 100644
--- a/sc/inc/miscuno.hxx
+++ b/sc/inc/miscuno.hxx
@@ -195,14 +195,6 @@ public:
 SetOptionalPropertyValue(rPropSet, rPropName, any);
 }
 
-template
-static css::uno::Sequence VectorToSequence( const 
std::vector& rVector )
-{
-if (rVector.empty())
-return css::uno::Sequence();
-
-return css::uno::Sequence([0], 
static_cast(rVector.size()));
-}
 private:
 static sal_Int32GetEnumPropertyImpl( const css::uno::Reference< 
css::beans::XPropertySet>& xProp,
 const OUString& rName, sal_Int32 
nDefault );
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index c964dda14c7a..c74f43d10bd7 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -501,7 +501,7 @@ uno::Sequence 
getVisiblePageMembersAsResults( const uno::Re
 // All members are visible.  Return empty result.
 return uno::Sequence();
 
-return ScUnoHelpFunctions::VectorToSequence(aRes);
+return comphelper::containerToSequence(aRes);
 }
 
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2023-09-07 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 2c3b690a900082a242e1a6494ac35338f5e8aad4
Author: Szymon Kłos 
AuthorDate: Tue Sep 5 16:58:22 2023 +0200
Commit: Szymon Kłos 
CommitDate: Thu Sep 7 12:41:50 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 
(cherry picked from commit 29f72210e92e0152d52b3a1d0253fbb5d8e2dead)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156604
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5e9163b28fd4..94ff88b23d17 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 3d4d2ecc4b47..d77cb2204b60 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 587b7cff6612..0b61f9e17e7d 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 
@@ -207,7 +209,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() ) );
@@ -298,9 +301,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*   

[Libreoffice-commits] core.git: sc/inc sc/source

2023-08-15 Thread Noel Grandin (via logerrit)
 sc/inc/sheetdata.hxx   |   18 +-
 sc/source/filter/xml/sheetdata.cxx |   14 +++---
 sc/source/filter/xml/xmlbodyi.cxx  |6 +++---
 sc/source/filter/xml/xmlexprt.cxx  |   26 +-
 sc/source/filter/xml/xmlexprt.hxx  |4 ++--
 sc/source/filter/xml/xmlimprt.cxx  |6 +++---
 sc/source/filter/xml/xmlimprt.hxx  |2 +-
 sc/source/filter/xml/xmltabi.hxx   |2 +-
 8 files changed, 39 insertions(+), 39 deletions(-)

New commits:
commit 3039737af6d6e539c652f0d4b25303c30713836e
Author: Noel Grandin 
AuthorDate: Mon Aug 14 19:33:06 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Aug 15 09:36:14 2023 +0200

use sal_uInt64 when dealing with stream position

Change-Id: I1efda255a7ab1e90ad3a41cb36c72384743a7980
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155677
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/sheetdata.hxx b/sc/inc/sheetdata.hxx
index 55dba5a28234..5d27c55f902d 100644
--- a/sc/inc/sheetdata.hxx
+++ b/sc/inc/sheetdata.hxx
@@ -32,8 +32,8 @@ enum class XmlStyleFamily;
 
 struct ScStreamEntry
 {
-sal_Int32   mnStartOffset;
-sal_Int32   mnEndOffset;
+sal_Int64   mnStartOffset;
+sal_Int64   mnEndOffset;
 
 ScStreamEntry() :
 mnStartOffset(-1),
@@ -41,7 +41,7 @@ struct ScStreamEntry
 {
 }
 
-ScStreamEntry( sal_Int32 nStart, sal_Int32 nEnd ) :
+ScStreamEntry( sal_Int64 nStart, sal_Int64 nEnd ) :
 mnStartOffset(nStart),
 mnEndOffset(nEnd)
 {
@@ -119,7 +119,7 @@ class ScSheetSaveData
 std::vector maStreamEntries;
 std::vector maSaveEntries;
 SCTAB   mnStartTab;
-sal_Int32   mnStartOffset;
+sal_Int64   mnStartOffset;
 
 ScNoteStyleEntrymaPreviousNote;
 
@@ -142,17 +142,17 @@ public:
 voidBlockSheet( SCTAB nTab );
 boolIsSheetBlocked( SCTAB nTab ) const;
 
-voidAddStreamPos( SCTAB nTab, sal_Int32 nStartOffset, sal_Int32 
nEndOffset );
-voidGetStreamPos( SCTAB nTab, sal_Int32& rStartOffset, sal_Int32& 
rEndOffset ) const;
+voidAddStreamPos( SCTAB nTab, sal_Int64 nStartOffset, sal_Int64 
nEndOffset );
+voidGetStreamPos( SCTAB nTab, sal_Int64& rStartOffset, sal_Int64& 
rEndOffset ) const;
 boolHasStreamPos( SCTAB nTab ) const;
 
-voidStartStreamPos( SCTAB nTab, sal_Int32 nStartOffset );
-voidEndStreamPos( sal_Int32 nEndOffset );
+voidStartStreamPos( SCTAB nTab, sal_Int64 nStartOffset );
+voidEndStreamPos( sal_Int64 nEndOffset );
 
 boolHasStartPos() const { return mnStartTab >= 0; }
 
 voidResetSaveEntries();
-voidAddSavePos( SCTAB nTab, sal_Int32 nStartOffset, sal_Int32 
nEndOffset );
+voidAddSavePos( SCTAB nTab, sal_Int64 nStartOffset, sal_Int64 
nEndOffset );
 voidUseSaveEntries();
 
 voidStoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces );
diff --git a/sc/source/filter/xml/sheetdata.cxx 
b/sc/source/filter/xml/sheetdata.cxx
index bfd9abe5e598..4f62181e7d73 100644
--- a/sc/source/filter/xml/sheetdata.cxx
+++ b/sc/source/filter/xml/sheetdata.cxx
@@ -105,7 +105,7 @@ bool ScSheetSaveData::IsSheetBlocked( SCTAB nTab ) const
 return false;
 }
 
-void ScSheetSaveData::AddStreamPos( SCTAB nTab, sal_Int32 nStartOffset, 
sal_Int32 nEndOffset )
+void ScSheetSaveData::AddStreamPos( SCTAB nTab, sal_Int64 nStartOffset, 
sal_Int64 nEndOffset )
 {
 if ( nTab >= static_cast(maStreamEntries.size()) )
 maStreamEntries.resize( nTab + 1 );
@@ -113,7 +113,7 @@ void ScSheetSaveData::AddStreamPos( SCTAB nTab, sal_Int32 
nStartOffset, sal_Int3
 maStreamEntries[nTab] = ScStreamEntry( nStartOffset, nEndOffset );
 }
 
-void ScSheetSaveData::StartStreamPos( SCTAB nTab, sal_Int32 nStartOffset )
+void ScSheetSaveData::StartStreamPos( SCTAB nTab, sal_Int64 nStartOffset )
 {
 OSL_ENSURE( mnStartTab < 0, "StartStreamPos without EndStreamPos" );
 
@@ -121,7 +121,7 @@ void ScSheetSaveData::StartStreamPos( SCTAB nTab, sal_Int32 
nStartOffset )
 mnStartOffset = nStartOffset;
 }
 
-void ScSheetSaveData::EndStreamPos( sal_Int32 nEndOffset )
+void ScSheetSaveData::EndStreamPos( sal_Int64 nEndOffset )
 {
 if ( mnStartTab >= 0 )
 {
@@ -131,7 +131,7 @@ void ScSheetSaveData::EndStreamPos( sal_Int32 nEndOffset )
 }
 }
 
-void ScSheetSaveData::GetStreamPos( SCTAB nTab, sal_Int32& rStartOffset, 
sal_Int32& rEndOffset ) const
+void ScSheetSaveData::GetStreamPos( SCTAB nTab, sal_Int64& rStartOffset, 
sal_Int64& rEndOffset ) const
 {
 if ( nTab < static_cast(maStreamEntries.size()) )
 {
@@ -145,8 +145,8 @@ void ScSheetSaveData::GetStreamPos( SCTAB nTab, sal_Int32& 
rStartOffset, sal_Int
 
 bool ScSheetSaveData::HasStreamPos( SCTAB nTab ) const
 {
-sal_Int32 nStartOffset = 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-08-14 Thread Caolán McNamara (via logerrit)
 sc/inc/column.hxx   |3 ++-
 sc/inc/document.hxx |3 ++-
 sc/inc/formulacell.hxx  |4 +++-
 sc/inc/table.hxx|3 ++-
 sc/source/core/data/column4.cxx |   10 ++
 sc/source/core/data/document.cxx|   12 ++--
 sc/source/core/data/formulacell.cxx |   34 +++---
 sc/source/core/data/table1.cxx  |4 ++--
 8 files changed, 54 insertions(+), 19 deletions(-)

New commits:
commit 4403b4e6bac19d89afded080d80de049aaa294ca
Author: Caolán McNamara 
AuthorDate: Tue Aug 8 17:02:40 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 14 10:32:16 2023 +0200

tdf#156677 if CheckComputeDependencies failed in expanded range...

it may have left a cell the original range needed in a dirty state,
leading to an assert when the threaded calculation is attempted which
would not have happened if the attempt to expand the range wasn't
attempted.

seen in crashtesting example: forum-mso-en4-784502.xlsx

to reproduce this, load sample document

after it has loaded:

(gdb) break column4.cxx:1946
(gdb) break column4.cxx:1966

data, recalculate, recalculate hard,

the first time breakpoint #1 gets hit:

at column4.cxx:1946 NeedsInterpret is true, so cell
{nRow = 1, nCol = 0, nTab = 3 } was dirty and is set
not-dirty by Interpret. mxGroup->mbPartOfCycle is false
so this returns successfully to allow threading.

the bt to there was:

 #0  lcl_EvalDirty(mdds::mtv::soa::multi_type_vector&, 
int, int, ScDocument&, boost::intrusive_ptr const&, bool, 
bool, bool&, bool&)
 (rCells=..., nRow1=1, nRow2=4, rDoc=..., mxGroup=..., 
bThreadingDepEval=true, bSkipRunning=false, bIsDirty=@0x7fff4a16: true, 
bAllowThreading=@0x7fff4a17: true)
 at sc/source/core/data/column4.cxx:1963
 #1  0x7fff9eef70d1 in ScColumn::HandleRefArrayForParallelism(int, int, 
boost::intrusive_ptr const&) (this=0x15ee480, nRow1=1, 
nRow2=4, mxGroup=...)
 at sc/source/core/data/column4.cxx:2012
 #2  0x7fff9f8a in ScTable::HandleRefArrayForParallelism(short, 
int, int, boost::intrusive_ptr const&)
 (this=0x1eebda0, nCol=0, nRow1=1, nRow2=4, mxGroup=...) at 
sc/source/core/data/table1.cxx:2567
 #3  0x7fff9f06b691 in 
ScDocument::HandleRefArrayForParallelism(ScAddress const&, int, 
boost::intrusive_ptr const&)
 (this=0x1ba9a40, rPos=..., nLength=4, mxGroup=...) at 
sc/source/core/data/document.cxx:1792
 #4  0x7fff9f3018f7 in (anonymous 
namespace)::ScDependantsCalculator::DoIt() (this=0x7fff4eb8) at 
sc/source/core/data/formulacell.cxx:4585
 #5  0x7fff9f30085a in 
ScFormulaCell::CheckComputeDependencies(sc::FormulaLogger::GroupScope&, bool, 
int, int, bool)
 (this=0x2142cf0, rScope=..., fromFirstRow=false, nStartOffset=0, 
nEndOffset=3, bCalcDependencyOnly=false) at 
sc/source/core/data/formulacell.cxx:4720
 #6  0x7fff9f2ff392 in 
ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope&, 
bool&, bool&, int, int)
 (this=0x2142cf0, aScope=..., bDependencyComputed=@0x7fff56d7: 
false, bDependencyCheckFailed=@0x7fff56d6: false, nStartOffset=0, 
nEndOffset=3)
 at sc/source/core/data/formulacell.cxx:4829

so the CheckComputeDependencies at the start of
ScFormulaCell::InterpretFormulaGroupThreading is successful for aPos of
{nRow = 1, nCol = 1, nTab = 3 } and the cell is not dirty at that point

*however* in the following loop of
for (SCCOL nCurrCol = nColStart; nCurrCol <= nColEnd; ++nCurrCol)
in InterpretFormulaGroupThreading, CheckComputeDependencies for
column 3 is called and the breakpoint #2 is hit, in this case
mxGroup->mbPartOfCycle is true and the {nRow = 1, nCol = 0, nTab = 3 }
cell is set dirty again.

so later during the threaded calculation the cell is found dirty and the
ScFormulaCell::MaybeInterpret() asserts that
!rDocument.IsThreadedGroupCalcInProgress()

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

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index fe3b84842af2..0f30f64cb672 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -648,7 +648,8 @@ public:
 bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, 
SCROW nRow2 );
 void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2, 
svl::SharedStringPool* pPool ) const;
 formula::VectorRefArray FetchVectorRefArray( SCROW nRow1, SCROW nRow2 );
-bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2, const 
ScFormulaCellGroupRef& mxGroup );
+bool HandleRefArrayForParallelism( SCROW nRow1, SCROW nRow2,
+   const 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-08-13 Thread Caolán McNamara (via logerrit)
 sc/inc/postit.hxx   |   20 --
 sc/source/core/data/postit.cxx  |   52 -
 sc/source/filter/inc/richstring.hxx |3 +
 sc/source/filter/oox/commentsbuffer.cxx |   94 +---
 sc/source/filter/oox/richstring.cxx |   14 +++-
 sc/source/ui/docshell/docfunc.cxx   |9 +--
 sc/source/ui/inc/docfunc.hxx|   10 ++-
 7 files changed, 126 insertions(+), 76 deletions(-)

New commits:
commit 2bda87fd8758448267c447ba26f1932325a1338d
Author: Caolán McNamara 
AuthorDate: Fri Aug 11 13:29:23 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 13 18:13:20 2023 +0200

defer turning xlsx notes into SdrCaptions until activated

to improve import performance

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

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index c2a5cc9a60ad..df114eaf64a5 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -174,12 +174,20 @@ private:
 sal_uInt32  mnPostItId;
 };
 
+class GenerateNoteCaption
+{
+public:
+virtual void Generate(SdrCaptionObj& rCaptionObj) = 0;
+virtual OUString GetSimpleText() const = 0;
+virtual ~GenerateNoteCaption() {};
+};
+
 class SC_DLLPUBLIC ScNoteUtil
 {
 static ScPostIt* InsertNote(ScDocument& rDoc, const ScAddress& rPos, 
ScNoteData&& rNoteData,
 bool bAlwaysCreateCaption, sal_uInt32 
nPostItId);
 
-static ScNoteData CreateNoteData(ScDocument& rDoc, const ScAddress& rPos, 
const OutlinerParaObject& rOutlinerObj,
+static ScNoteData CreateNoteData(ScDocument& rDoc, const ScAddress& rPos,
  const tools::Rectangle& rCaptionRect, 
bool bShown);
 public:
 
@@ -242,13 +250,11 @@ public:
 const OutlinerParaObject& rOutlinerObj,
 const tools::Rectangle& rCaptionRect, bool bShown 
);
 
-// similar to above, except rPropertyNames/rPropertyValues contain the
-// uno properties for the caption object formatting.
-static ScPostIt*CreateNoteFromObjectProperties(
+// similar to above, except xGenerator is a functor to apply import
+// properties to the caption object to finalize it on demand
+static ScPostIt*CreateNoteFromGenerator(
 ScDocument& rDoc, const ScAddress& rPos,
-const css::uno::Sequence& rPropertyNames,
-const css::uno::Sequence& 
rPropertyValues,
-const OutlinerParaObject& rOutlinerObj,
+std::unique_ptr xGenerator,
 const tools::Rectangle& rCaptionRect, bool bShown 
);
 
 /** Creates a cell note based on the passed string and inserts it into the
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index cdcc03e4999d..b631d7659d99 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -424,15 +424,11 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& 
rDoc, const ScAddress& r
 
 } // namespace
 
-
 struct ScCaptionInitData
 {
 std::optional< SfxItemSet > moItemSet;  /// Caption object formatting.
-
-uno::Sequence maPropertyNames; /// Alternative import filter 
Caption object formatting property names
-uno::Sequence maPropertyValues; /// Alternative import filter 
Caption object formatting property values
-
 std::optional< OutlinerParaObject > mxOutlinerObj; /// Text object with 
all text portion formatting.
+std::unique_ptr< GenerateNoteCaption > mxGenerator; /// Operator to 
generate Caption Object from import data
 OUStringmaStyleName;/// Drawing style associated with 
the caption object.
 OUStringmaSimpleText;   /// Simple text without formatting.
 Point   maCaptionOffset;/// Caption position relative to 
cell corner.
@@ -658,13 +654,18 @@ void ScPostIt::CreateCaptionFromInitData( const 
ScAddress& rPos ) const
 bool bWasLocked = 
maNoteData.mxCaption->getSdrModelFromSdrObject().isLocked();
 maNoteData.mxCaption->getSdrModelFromSdrObject().setLock(true);
 
-// transfer ownership of outliner object to caption, or set simple text
-OSL_ENSURE( xInitData->mxOutlinerObj || !xInitData->maSimpleText.isEmpty(),
-"ScPostIt::CreateCaptionFromInitData - need either outliner para 
object or simple text" );
-if (xInitData->mxOutlinerObj)
-maNoteData.mxCaption->SetOutlinerParaObject( 
std::move(xInitData->mxOutlinerObj) );
+if (xInitData->mxGenerator)
+xInitData->mxGenerator->Generate(*maNoteData.mxCaption);
 else
-maNoteData.mxCaption->SetText( xInitData->maSimpleText );
+{
+// transfer ownership of outliner object to caption, or set simple text
+  

[Libreoffice-commits] core.git: sc/inc sc/source

2023-08-12 Thread Caolán McNamara (via logerrit)
 sc/inc/postit.hxx  |9 +
 sc/source/core/data/postit.cxx |   27 +++
 2 files changed, 36 insertions(+)

New commits:
commit 3cc72a1880d1fe2507892eabeb979aa0938dadc5
Author: Caolán McNamara 
AuthorDate: Fri Aug 11 13:14:36 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sat Aug 12 17:22:21 2023 +0200

add a CreateNoteFromObjectProperties

which an importer can use to insert a note and defer instantiating an
SdrCaption until the user activates it

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

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index c6ac3b5a4bd4..c2a5cc9a60ad 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -242,6 +242,15 @@ public:
 const OutlinerParaObject& rOutlinerObj,
 const tools::Rectangle& rCaptionRect, bool bShown 
);
 
+// similar to above, except rPropertyNames/rPropertyValues contain the
+// uno properties for the caption object formatting.
+static ScPostIt*CreateNoteFromObjectProperties(
+ScDocument& rDoc, const ScAddress& rPos,
+const css::uno::Sequence& rPropertyNames,
+const css::uno::Sequence& 
rPropertyValues,
+const OutlinerParaObject& rOutlinerObj,
+const tools::Rectangle& rCaptionRect, bool bShown 
);
+
 /** Creates a cell note based on the passed string and inserts it into the
 document.
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 378323338eb1..cdcc03e4999d 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -427,6 +428,10 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& 
rDoc, const ScAddress& r
 struct ScCaptionInitData
 {
 std::optional< SfxItemSet > moItemSet;  /// Caption object formatting.
+
+uno::Sequence maPropertyNames; /// Alternative import filter 
Caption object formatting property names
+uno::Sequence maPropertyValues; /// Alternative import filter 
Caption object formatting property values
+
 std::optional< OutlinerParaObject > mxOutlinerObj; /// Text object with 
all text portion formatting.
 OUStringmaStyleName;/// Drawing style associated with 
the caption object.
 OUStringmaSimpleText;   /// Simple text without formatting.
@@ -679,6 +684,13 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& 
rPos ) const
 ScCaptionUtil::SetExtraItems(*maNoteData.mxCaption, 
*xInitData->moItemSet);
 }
 
+if (xInitData->maPropertyNames.getLength())
+{
+rtl::Reference 
xAnnoShape(dynamic_cast(maNoteData.mxCaption->getUnoShape().get()));
 // SvxShapeText
+assert(xAnnoShape && "will not be null");
+
static_cast(xAnnoShape.get())->setPropertyValues(xInitData->maPropertyNames,
 xInitData->maPropertyValues);
+}
+
 // set position and size of the caption object
 if( xInitData->mbDefaultPosSize )
 {
@@ -964,6 +976,21 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
 return InsertNote(rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/);
 }
 
+ScPostIt* ScNoteUtil::CreateNoteFromObjectProperties(
+ScDocument& rDoc, const ScAddress& rPos,
+const uno::Sequence& rPropertyNames,
+const uno::Sequence& rPropertyValues,
+const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& 
rCaptionRect,
+bool bShown )
+{
+ScNoteData aNoteData(CreateNoteData(rDoc, rPos, rOutlinerObj, 
rCaptionRect, bShown));
+ScCaptionInitData& rInitData = *aNoteData.mxInitData;
+rInitData.maPropertyNames = rPropertyNames;
+rInitData.maPropertyValues = rPropertyValues;
+
+return InsertNote(rDoc, rPos, std::move(aNoteData), 
/*bAlwaysCreateCaption*/false, 0/*nPostItId*/);
+}
+
 ScPostIt* ScNoteUtil::InsertNote(ScDocument& rDoc, const ScAddress& rPos, 
ScNoteData&& rNoteData,
  bool bAlwaysCreateCaption, sal_uInt32 
nPostItId)
 {


[Libreoffice-commits] core.git: sc/inc sc/source sc/uiconfig

2023-07-25 Thread Laurent Balland (via logerrit)
 sc/inc/filter.hxx |6 ++-
 sc/inc/scabstdlg.hxx  |1 
 sc/source/filter/html/htmlimp.cxx |9 +++--
 sc/source/filter/inc/eeimport.hxx |3 +
 sc/source/filter/inc/ftools.hxx   |2 -
 sc/source/filter/inc/htmlimp.hxx  |3 +
 sc/source/filter/rtf/eeimpars.cxx |7 +++-
 sc/source/ui/attrdlg/scdlgfact.cxx|5 +++
 sc/source/ui/attrdlg/scdlgfact.hxx|1 
 sc/source/ui/dbgui/textimportoptions.cxx  |   36 +++---
 sc/source/ui/docshell/docsh.cxx   |9 +++--
 sc/source/ui/docshell/impex.cxx   |3 +
 sc/source/ui/inc/textimportoptions.hxx|8 +++--
 sc/source/ui/unoobj/filtuno.cxx   |2 +
 sc/source/ui/view/viewfun5.cxx|4 ++
 sc/uiconfig/scalc/ui/textimportoptions.ui |   47 --
 16 files changed, 114 insertions(+), 32 deletions(-)

New commits:
commit 5ae709d8519dd6d0de265d516c6158ccbdf4882e
Author: Laurent Balland 
AuthorDate: Sun Jun 4 19:03:16 2023 +0200
Commit: Laurent Balland 
CommitDate: Tue Jul 25 21:44:36 2023 +0200

follow tdf#154131 Treat also HMTL import

Add Detect numbers in scientific notation option to HTML paste
Still need some qa tests

Change-Id: I553404a01ab2a61566b861b3c01d14bdc0c46668
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152591
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/filter.hxx b/sc/inc/filter.hxx
index 7a71b89c503e..6bceb74b69d0 100644
--- a/sc/inc/filter.hxx
+++ b/sc/inc/filter.hxx
@@ -50,7 +50,8 @@ class ScEEAbsImport {
 virtual ScRange GetRange() = 0;
 virtual voidWriteToDocument(
 bool bSizeColsRows = false, double nOutputFactor = 1.0,
-SvNumberFormatter* pFormatter = nullptr, bool bConvertDate = true ) = 
0;
+SvNumberFormatter* pFormatter = nullptr, bool bConvertDate = true,
+bool bConvertScientific = true ) = 0;
 };
 
 class SAL_DLLPUBLIC_RTTI ScFormatFilterPlugin {
@@ -67,7 +68,8 @@ class SAL_DLLPUBLIC_RTTI ScFormatFilterPlugin {
  const rtl_TextEncoding eSrc ) = 0;
 virtual ErrCode ScImportRTF( SvStream&, const OUString& rBaseURL, 
ScDocument*, ScRange& rRange ) = 0;
 virtual ErrCode ScImportHTML( SvStream&, const OUString& rBaseURL, 
ScDocument*, ScRange& rRange, double nOutputFactor,
-   bool bCalcWidthHeight, SvNumberFormatter* 
pFormatter, bool bConvertDate ) = 0;
+   bool bCalcWidthHeight, SvNumberFormatter* 
pFormatter, bool bConvertDate,
+   bool bConvertScientific ) = 0;
 
 // various import helpers
 virtual std::unique_ptr CreateRTFImport( ScDocument* pDoc, 
const ScRange& rRange ) = 0;
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index a06a435e7d5e..7a94af5f6fe9 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -394,6 +394,7 @@ protected:
 public:
 virtual LanguageType GetLanguageType() const = 0;
 virtual bool IsDateConversionSet() const = 0;
+virtual bool IsScientificConversionSet() const = 0;
 virtual bool IsKeepAskingSet() const = 0;
 };
 
diff --git a/sc/source/filter/html/htmlimp.cxx 
b/sc/source/filter/html/htmlimp.cxx
index 12e98a9ef018..3168a02fc4eb 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -45,13 +45,13 @@
 
 ErrCode ScFormatFilterPluginImpl::ScImportHTML( SvStream , const 
OUString& rBaseURL, ScDocument *pDoc,
 ScRange& rRange, double nOutputFactor, bool bCalcWidthHeight, 
SvNumberFormatter* pFormatter,
-bool bConvertDate )
+bool bConvertDate, bool bConvertScientific )
 {
 ScHTMLImport aImp( pDoc, rBaseURL, rRange, bCalcWidthHeight );
 ErrCode nErr = aImp.Read( rStream, rBaseURL );
 ScRange aR = aImp.GetRange();
 rRange.aEnd = aR.aEnd;
-aImp.WriteToDocument( true, nOutputFactor, pFormatter, bConvertDate );
+aImp.WriteToDocument( true, nOutputFactor, pFormatter, bConvertDate, 
bConvertScientific );
 return nErr;
 }
 
@@ -112,9 +112,10 @@ void ScHTMLImport::InsertRangeName( ScDocument& rDoc, 
const OUString& rName, con
 }
 
 void ScHTMLImport::WriteToDocument(
-bool bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, 
bool bConvertDate )
+bool bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, 
bool bConvertDate,
+bool bConvertScientific )
 {
-ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, 
bConvertDate );
+ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, 
bConvertDate, bConvertScientific );
 
 const ScHTMLParser* pParser = static_cast(mpParser.get());
 const ScHTMLTable* pGlobTable = pParser->GetGlobalTable();
diff --git a/sc/source/filter/inc/eeimport.hxx 
b/sc/source/filter/inc/eeimport.hxx
index d4ddc31f40c2..0d0466eb8909 100644
--- 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-07-24 Thread Czeber László Ádám (via logerrit)
 sc/inc/attarray.hxx  |2 -
 sc/inc/column.hxx|6 ++--
 sc/source/core/data/attarray.cxx |   56 +++
 sc/source/core/data/table1.cxx   |   12 ++--
 4 files changed, 47 insertions(+), 29 deletions(-)

New commits:
commit 87ca7d2f146be2c309fc6fd36f9154f3ea4e4bd8
Author: Czeber László Ádám 
AuthorDate: Mon Jun 19 11:02:23 2023 +0200
Commit: Eike Rathke 
CommitDate: Tue Jul 25 00:32:30 2023 +0200

tdf#93315 sc: Only 84 empty row show in the Print Preview

Change in Calc behaviour, dropping the 84 line limit.
This way, if all rows or columns are bordered, only up to the last
cell containing data is displayed in the Print Preview. In other
cases, all bordered cells are visible.

Change-Id: I7d874a093d76d5ed92b1b63b645b97582d52629e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153256
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 868118796560..cbc8f7cfe2f9 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -203,7 +203,7 @@ public:
 boolIsEmpty() const;
 
 boolGetFirstVisibleAttr( SCROW& rFirstRow ) const;
-boolGetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const;
+boolGetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool 
bSkipEmpty ) const;
 boolHasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
 boolIsVisibleEqual( const ScAttrArray& rOther,
 SCROW nStartRow, SCROW nEndRow ) const;
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4b64537e1705..fe3b84842af2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -313,7 +313,7 @@ public:
 boolHasSelectionMatrixFragment(const ScMarkData& rMark, const 
ScRangeList& rRangeList) const;
 
 boolGetFirstVisibleAttr( SCROW& rFirstRow ) const;
-boolGetLastVisibleAttr( SCROW& rLastRow ) const;
+boolGetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) const;
 boolHasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const;
 boolIsVisibleAttrEqual( const ScColumn& rCol, SCROW nStartRow, SCROW 
nEndRow ) const;
 
@@ -890,11 +890,11 @@ inline bool ScColumn::GetFirstVisibleAttr( SCROW& 
rFirstRow ) const
 return pAttrArray->GetFirstVisibleAttr( rFirstRow );
 }
 
-inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow ) const
+inline bool ScColumn::GetLastVisibleAttr( SCROW& rLastRow, bool bSkipEmpty ) 
const
 {
 // row of last cell is needed
 SCROW nLastData = GetLastDataPos();// always including notes, 0 if none
-return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData );
+return pAttrArray->GetLastVisibleAttr( rLastRow, nLastData, bSkipEmpty );
 }
 
 inline bool ScColumn::HasVisibleAttrIn( SCROW nStartRow, SCROW nEndRow ) const
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 87fa2c11ccf1..02b6b9d793ed 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -1942,7 +1942,7 @@ bool ScAttrArray::GetFirstVisibleAttr( SCROW& rFirstRow ) 
const
 
 const SCROW SC_VISATTR_STOP = 84;
 
-bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData ) const
+bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, SCROW nLastData, bool 
bSkipEmpty ) const
 {
 if ( mvData.empty() )
 {
@@ -1971,31 +1971,43 @@ bool ScAttrArray::GetLastVisibleAttr( SCROW& rLastRow, 
SCROW nLastData ) const
 rLastRow = nLastData;
 return false;
 }
-
-// Find a run below last data row.
+// tdf#93315: If "Suppress output of empty pages" in Calc Options is not 
checked, show empty
+// (containing only empty data cells) page in the document
 bool bFound = false;
-Search( nLastData, nPos );
-while ( nPos < mvData.size() )
+if (bSkipEmpty)
+{
+Search( nLastData, nPos );
+while ( nPos < mvData.size() )
+{
+// find range of visually equal formats
+SCSIZE nEndPos = nPos;
+while ( nEndPos < mvData.size()-1 &&
+
mvData[nEndPos].pPattern->IsVisibleEqual(*mvData[nEndPos+1].pPattern))
+++nEndPos;
+SCROW nAttrStartRow = ( nPos > 0 ) ? ( mvData[nPos-1].nEndRow + 1) 
: 0;
+if ( nAttrStartRow <= nLastData )
+nAttrStartRow = nLastData + 1;
+SCROW nAttrSize = mvData[nEndPos].nEndRow + 1 - nAttrStartRow;
+if ( nAttrSize >= SC_VISATTR_STOP )
+break;  // while, ignore this range and below
+else if ( mvData[nEndPos].pPattern->IsVisible() )
+{
+rLastRow = mvData[nEndPos].nEndRow;
+bFound = true;
+}
+nPos = nEndPos + 1;
+}
+}
+else
 {
-// find range of visually equal formats
-SCSIZE nEndPos = nPos;
-while ( nEndPos < 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-07-12 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/document.hxx |1 
 sc/source/core/data/documen2.cxx|   93 -
 sc/source/core/data/documen3.cxx|  312 ++
 sc/source/core/data/documen4.cxx|   63 -
 sc/source/core/data/documen5.cxx|8 
 sc/source/core/data/documen6.cxx|2 
 sc/source/core/data/documen7.cxx|   24 
 sc/source/core/data/documen8.cxx|4 
 sc/source/core/data/documen9.cxx|   16 
 sc/source/core/data/document.cxx| 1793 
 sc/source/core/data/document10.cxx  |2 
 sc/source/core/data/formulacell.cxx |2 
 12 files changed, 1056 insertions(+), 1264 deletions(-)

New commits:
commit 3cc198a0706b25c42cc8dae7e25635cbd911ac02
Author: Tomaž Vajngerl 
AuthorDate: Sun Jul 9 00:41:12 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Jul 13 07:25:42 2023 +0200

sc: remove duplicated table validity checks and other duplications

Remove the duplicated table validity checks and replace them with
FetchTable(..) call, which returns nullptr if the table is not
valid and available, or the table itself. This simpifies the code
all around.

When only the check if the table is available is needed, use
HasTable(..) in those cases.

The call TableExists(..) is identical to HasTable(..) and has been
removed.

Finally use GetTableCount(), which return a SCTAB type for the number
of tables is used instead of static_cast(maTabs.size())
that was used all over the code.

Change-Id: Ibfd9777b1350ba8e0cbe577783db81589f95591c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154225
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 27499ca9f105..157a49099184 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2620,7 +2620,6 @@ public:
 voidConvertFormulaToValue( const ScRange& rRange, 
sc::TableValues* pUndo );
 voidSwapNonEmpty( sc::TableValues& rValues );
 voidfinalizeOutlineImport();
-boolTableExists( SCTAB nTab ) const;
 
 // Returns the given column range, first allocating all the columns if 
necessary.
 SC_DLLPUBLIC ScColumnsRange GetWritableColumnsRange(SCTAB nTab, SCCOL 
nColBegin, SCCOL nColEnd);
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index e5d5df5a94cb..42f971c82cfb 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -528,19 +528,19 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, const 
ScMarkData* pMarks )
 {
 InitClipPtrs(pSourceDoc);
 
-for (SCTAB i = 0; i < static_cast(pSourceDoc->maTabs.size()); 
i++)
+for (SCTAB i = 0; i < pSourceDoc->GetTableCount(); i++)
 if (pSourceDoc->maTabs[i])
 if (!pMarks || pMarks->GetTableSelect(i))
 {
 OUString aString = pSourceDoc->maTabs[i]->GetName();
-if ( i < static_cast(maTabs.size()) )
+if (i < GetTableCount())
 {
 maTabs[i].reset( new ScTable(*this, i, aString) );
 
 }
 else
 {
-if( i > static_cast(maTabs.size()) )
+if (i > GetTableCount())
 {
 maTabs.resize(i);
 }
@@ -560,12 +560,12 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB 
nTab )
 if (bIsClip)
 {
 InitClipPtrs(pSourceDoc);
-if (nTab >= static_cast(maTabs.size()))
+if (nTab >= GetTableCount())
 {
 maTabs.resize(nTab+1);
 }
 maTabs[nTab].reset( new ScTable(*this, nTab, "baeh") );
-if (nTab < static_cast(pSourceDoc->maTabs.size()) && 
pSourceDoc->maTabs[nTab])
+if (nTab < pSourceDoc->GetTableCount() && pSourceDoc->maTabs[nTab])
 maTabs[nTab]->SetLayoutRTL( 
pSourceDoc->maTabs[nTab]->IsLayoutRTL() );
 }
 else
@@ -577,7 +577,7 @@ void ScDocument::ResetClip( ScDocument* pSourceDoc, SCTAB 
nTab )
 void ScDocument::EnsureTable( SCTAB nTab )
 {
 bool bExtras = !bIsUndo;// Column-Widths, Row-Heights, Flags
-if (o3tl::make_unsigned(nTab) >= maTabs.size())
+if (nTab >= GetTableCount())
 maTabs.resize(nTab+1);
 
 if (!maTabs[nTab])
@@ -586,18 +586,16 @@ void ScDocument::EnsureTable( SCTAB nTab )
 
 ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos )
 {
-if (!TableExists(rPos.Tab()))
-return ScRefCellValue(); // empty
-
-return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
+if (ScTable* pTable = FetchTable(rPos.Tab()))
+return pTable->GetRefCellValue(rPos.Col(), rPos.Row());
+return ScRefCellValue(); // empty
 }
 
 ScRefCellValue ScDocument::GetRefCellValue( const 

[Libreoffice-commits] core.git: sc/inc sc/source solenv/clang-format

2023-06-25 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 bcd3ca80cd1f59c4b94660daa8c3e66944caf58f
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 23 17:13:44 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 25 17:36:00 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 

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 371ea346d364..d6a836fdc8d9 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,   
ATTR_FONT_CROSSEDOUT,cppu::UnoType::get(), 0, 
MID_CROSSED_OUT },
 { SC_UNONAME_CEMPHAS,  
ATTR_FONT_EMPHASISMARK,cppu::UnoType::get(), 0, MID_EMPHASIS 
},
@@ -379,12 +376,10 @@ 

[Libreoffice-commits] core.git: 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 8ec8d592e31aebe19075e9f89c4c2c7abcf8d420
Author: Noel Grandin 
AuthorDate: Thu Jun 22 09:38:50 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Jun 23 10:36:53 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/+/153482
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index ba15cfb1dd27..4d7df0c6ac23 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:
@@ -184,11 +185,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 706ab6ae5c19..199d41ab25f1 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -981,6 +981,7 @@ void ScPatternAttr::GetFromEditItemSet( const SfxItemSet* 
pEditSet )
 return;
 GetFromEditItemSet( GetItemSet(), *pEditSet );
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::FillEditParaItems( SfxItemSet* pEditSet ) const
@@ -1024,6 +1025,7 @@ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* 
pOldAttrs )
 {
 rThisSet.ClearItem( nSubWhich );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 else if ( eOldState != SfxItemState::DONTCARE )
@@ -1033,6 +1035,7 @@ void ScPatternAttr::DeleteUnchanged( const ScPatternAttr* 
pOldAttrs )
 {
 rThisSet.ClearItem( nSubWhich );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 }
@@ -1054,6 +1057,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
@@ -1189,6 +1193,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();
 
@@ -1312,6 +1323,7 @@ void ScPatternAttr::SetStyleSheet( ScStyleSheet* 
pNewStyle, bool bClearDirectFor
 pStyle = nullptr;
 }
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::UpdateStyleSheet(const ScDocument& rDoc)
@@ -1338,6 +1350,7 @@ void ScPatternAttr::UpdateStyleSheet(const ScDocument& 
rDoc)
 else
 pStyle = nullptr;
 mxHashCode.reset();
+mxVisible.reset();
 }
 
 void ScPatternAttr::StyleToName()
@@ -1350,6 +1363,7 @@ void ScPatternAttr::StyleToName()
 pStyle = nullptr;
 GetItemSet().SetParent( nullptr );
 mxHashCode.reset();
+mxVisible.reset();
 }
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-06-17 Thread Eike Rathke (via logerrit)
 sc/inc/table.hxx |8 +-
 sc/source/core/data/documen3.cxx |3 -
 sc/source/core/data/table4.cxx   |  117 ---
 3 files changed, 81 insertions(+), 47 deletions(-)

New commits:
commit 30c48379c7b791edc615e7691691e344baa455a3
Author: Eike Rathke 
AuthorDate: Sat Jun 17 01:05:48 2023 +0200
Commit: Eike Rathke 
CommitDate: Sat Jun 17 16:10:08 2023 +0200

Resolves: tdf#153517 Use tools::Duration for FillSeries with (date+)time

Change-Id: I18567fdac512ee786ce4b0785b01b2ae6da7450e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153203
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index a2cc60f9d70e..0662053cb89c 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -715,7 +715,8 @@ public:
  sc::UpdatedRangeNames& rIndexes) const;
 voidFill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 sal_uInt64 nFillCount, FillDir eFillDir, FillCmd 
eFillCmd, FillDateCmd eFillDateCmd,
-double nStepValue, double nMaxValue, ScProgress* 
pProgress);
+double nStepValue, const tools::Duration& 
rDurationStep,
+double nMaxValue, ScProgress* pProgress);
 OUStringGetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW 
nEndY );
 
 void UpdateSelectionFunction( ScFunctionData& rData, const ScMarkData& 
rMark );
@@ -1191,13 +1192,14 @@ private:
 voidFillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 sal_uInt64 nFillCount, FillDir eFillDir, 
FillCmd eFillCmd,
 FillDateCmd eFillDateCmd,
-double nStepValue, double nMaxValue, 
sal_uInt16 nMinDigits,
+double nStepValue, const tools::Duration& 
rDurationStep,
+double nMaxValue, sal_uInt16 nMinDigits,
 bool bAttribs, ScProgress* pProgress,
 bool bSkipOverlappedCells = false,
 std::vector* pNonOverlappedCellIdx 
= nullptr);
 voidFillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2,
 FillCmd& rCmd, FillDateCmd& rDateCmd,
-double& rInc, sal_uInt16& rMinDigits,
+double& rInc, tools::Duration& rDuration, 
sal_uInt16& rMinDigits,
 ScUserListData*& rListData, sal_uInt16& 
rListIndex,
 bool bHasFiltered, bool& rSkipOverlappedCells,
 std::vector& rNonOverlappedCellIdx 
);
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index b1cf5fe81b8c..8d0d2ba9a665 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1171,7 +1172,7 @@ void ScDocument::Fill(SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2, ScProg
 {
 maTabs[rTab]->Fill(nCol1, nRow1, nCol2, nRow2,
 nFillCount, eFillDir, eFillCmd, eFillDateCmd,
-nStepValue, nMaxValue, pProgress);
+nStepValue, tools::Duration(), nMaxValue, 
pProgress);
 RefreshAutoFilter(aRange.aStart.Col(), aRange.aStart.Row(), 
aRange.aEnd.Col(), aRange.aEnd.Row(), rTab);
 }
 }
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 10c27f8d2c84..9c6852990efe 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -215,32 +216,20 @@ double approxDiff( double a, double b )
 return rtl::math::round(c, -std::max(nExp, nExpArg));
 }
 
-double approxTimeDiff( double a, double b )
+double approxTypedDiff( double a, double b, bool bTime, tools::Duration& 
rDuration )
 {
-// Scale to hours, round to "nanohours" (multiple nanoseconds), scale back.
-// Get back 0.0417 instead of 0.04166700621136 or
-// 0.0414241347 (raw a-b) for one hour, or worse the approxDiff()
-// 0.0416665997 value. Though there is no such correct value,
-// IEEE-754 nearest values are
-// 0.041664353702032030923874117434024810791015625
-// (0x3FA5) and
-// 0.04167129259593593815225176513195037841796875
-// (0x3FA6).
-// This works also for a diff of seconds, unless corner cases would be
-// discovered, which would make it necessary to ditch the floating point
-// and convert to/from time structure values instead.
-return rtl::math::round((a - b) * 24, 9) / 24;
-}
-

[Libreoffice-commits] core.git: 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 51819767d341950dfd67448a6cbbf8c1add45f6c
Author: Noel Grandin 
AuthorDate: Wed Jun 14 13:01:20 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Jun 14 20:53:11 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/+/153026
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

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 1358fb8ec56d..cf744dd97bec 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: sc/inc sc/source

2023-06-09 Thread Czeber László Ádám (via logerrit)
 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 dd8e061406fac581d399da088c7f0187278035dc
Author: Czeber László Ádám 
AuthorDate: Thu Jun 8 14:55:34 2023 +0200
Commit: László Németh 
CommitDate: Fri Jun 9 15:41:38 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 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 5c42f02794ab..4b64537e1705 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -172,6 +172,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
@@ -1057,4 +1058,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 99e0c5f39b0d..c5d4de055f8d 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1849,13 +1849,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 b3a5b9aee9b9..b35caa7459bb 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: sc/inc sc/source

2023-06-07 Thread Stephan Bergmann (via logerrit)
 sc/inc/patattr.hxx  |2 +-
 sc/source/core/data/patattr.cxx |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit eb1ec67d4e3f1992d7f31d824f06e48df8429540
Author: Stephan Bergmann 
AuthorDate: Wed Jun 7 11:25:21 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Wed Jun 7 13:33:06 2023 +0200

Avoid signed integer overflow

For whatever reason e5fe8434110c1299527a0d03bf450e1b6d08ca57 "use a SIMD
friendly hashcode for ScPatternAttr" had changed ScPatternAttr::mxHashCode 
from
sizt_t to sal_Int32, better use unsigned sal_uInt32 to avoid

> /sc/source/core/data/patattr.cxx:1444:17: runtime error: signed integer 
overflow: 31 * 887503681 cannot be represented in type 'int'

during e.g. CppunitTest_chart2_geometry
()

Change-Id: Ia561b245431d812f43586013477208426aa1cc11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152697
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 067193136fb9..49cae62994b4 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -53,7 +53,7 @@ enum ScAutoFontColorMode
 class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
 {
 std::optional  pName;
-mutable std::optional mxHashCode;
+mutable std::optional mxHashCode;
 ScStyleSheet*  pStyle;
 sal_uInt64 mnKey;
 public:
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index d2be666aa349..2b347365f0c2 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1435,10 +1435,10 @@ void ScPatternAttr::CalcHashCode() const
 // This is an unrolled hash function so the compiler/CPU can execute it in 
parallel,
 // because we hit this hard when loading documents with lots of styles.
 // Set up seed so that an empty pattern does not have an (invalid) hash of 
0.
-sal_Int32 h1 = 1;
-sal_Int32 h2 = 1;
-sal_Int32 h3 = 1;
-sal_Int32 h4 = 1;
+sal_uInt32 h1 = 1;
+sal_uInt32 h2 = 1;
+sal_uInt32 h3 = 1;
+sal_uInt32 h4 = 1;
 for (auto it = rSet.GetItems_Impl(), end = rSet.GetItems_Impl() + 
(compareSize / 4 * 4); it != end; )
 {
 h1 = 31 * h1 + reinterpret_cast(*it);


[Libreoffice-commits] core.git: sc/inc sc/source

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

New commits:
commit e5fe8434110c1299527a0d03bf450e1b6d08ca57
Author: Noel Grandin 
AuthorDate: Thu Jun 1 14:35:24 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jun 6 18:19:39 2023 +0200

use a SIMD friendly hashcode for ScPatternAttr

which shaves 5% off load time of a large sheet with lots of formats.

We are calculating a hash over a decent sized array of pointers, so
unroll the loop and reduce data-dependencies to give the compiler (and
the CPU) a chance to do work in parallel

Change-Id: I3d58fcf547c9280437295b9c9ec10aff16419afc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152443
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 5b031f488467..067193136fb9 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -53,7 +53,7 @@ enum ScAutoFontColorMode
 class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
 {
 std::optional  pName;
-mutable std::optional mxHashCode;
+mutable std::optional mxHashCode;
 ScStyleSheet*  pStyle;
 sal_uInt64 mnKey;
 public:
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 532831f90a78..d2be666aa349 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -64,7 +65,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -1432,8 +1432,25 @@ void ScPatternAttr::CalcHashCode() const
 mxHashCode = 0; // invalid
 return;
 }
-mxHashCode = 1; // Set up seed so that an empty pattern does not have an 
(invalid) hash of 0.
-boost::hash_range(*mxHashCode, rSet.GetItems_Impl(), rSet.GetItems_Impl() 
+ compareSize);
+// This is an unrolled hash function so the compiler/CPU can execute it in 
parallel,
+// because we hit this hard when loading documents with lots of styles.
+// Set up seed so that an empty pattern does not have an (invalid) hash of 
0.
+sal_Int32 h1 = 1;
+sal_Int32 h2 = 1;
+sal_Int32 h3 = 1;
+sal_Int32 h4 = 1;
+for (auto it = rSet.GetItems_Impl(), end = rSet.GetItems_Impl() + 
(compareSize / 4 * 4); it != end; )
+{
+h1 = 31 * h1 + reinterpret_cast(*it);
+++it;
+h2 = 31 * h2 + reinterpret_cast(*it);
+++it;
+h3 = 31 * h3 + reinterpret_cast(*it);
+++it;
+h4 = 31 * h4 + reinterpret_cast(*it);
+++it;
+}
+mxHashCode = h1 + h2 + h3 + h4;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: sc/inc sc/source

2023-06-04 Thread Mike Kaganski (via logerrit)
 sc/inc/userlist.hxx  |5 ++---
 sc/source/core/tool/userlist.cxx |   12 +---
 2 files changed, 7 insertions(+), 10 deletions(-)

New commits:
commit 4900217e74e29c8e19c9a697883c21cbd50c9dbc
Author: Mike Kaganski 
AuthorDate: Sun Jun 4 16:22:38 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun Jun 4 19:56:38 2023 +0200

Move uppercase to SubStr ctor

Change-Id: Ifeeaead20e3ad37705fea04a6c3b9efa4339ddc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152543
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index b421c33370db..5f913bc47dae 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -30,15 +30,14 @@
  */
 class SC_DLLPUBLIC ScUserListData final
 {
-public:
+private:
 struct SAL_DLLPRIVATE SubStr
 {
 OUString maReal;
 OUString maUpper;
-SubStr(OUString aReal, OUString aUpper);
+SubStr(OUString&& aReal);
 };
 
-private:
 std::vector maSubStrings;
 OUString aStr;
 
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index b91d3ba3819a..b1030eca6293 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -17,7 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
+#include 
+
 #include 
 
 #include 
@@ -29,8 +30,8 @@
 #include 
 #include 
 
-ScUserListData::SubStr::SubStr(OUString aReal, OUString aUpper) :
-maReal(std::move(aReal)), maUpper(std::move(aUpper)) {}
+ScUserListData::SubStr::SubStr(OUString&& aReal) :
+maReal(std::move(aReal)), 
maUpper(ScGlobal::getCharClass().uppercase(maReal)) {}
 
 void ScUserListData::InitTokens()
 {
@@ -40,10 +41,7 @@ void ScUserListData::InitTokens()
 {
 OUString aSub = aStr.getToken(0, ScGlobal::cListDelimiter, nIndex);
 if (!aSub.isEmpty())
-{
-OUString aUpStr = ScGlobal::getCharClass().uppercase(aSub);
-maSubStrings.emplace_back(aSub, aUpStr);
-}
+maSubStrings.emplace_back(std::move(aSub));
 } while (nIndex >= 0);
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-06-04 Thread Mike Kaganski (via logerrit)
 sc/inc/userlist.hxx  |3 ---
 sc/source/core/tool/userlist.cxx |   17 ++---
 2 files changed, 2 insertions(+), 18 deletions(-)

New commits:
commit 83eee0095c337e454acd5368f70855e34ec4a174
Author: Mike Kaganski 
AuthorDate: Sun Jun 4 14:34:47 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun Jun 4 16:50:36 2023 +0200

ScUserListData::InitTokens can't produce different splits

... for the same input, because ScGlobal::cListDelimiter is a constant.
This means, that the copy ctor and assignment operator can be default,
and ScUserListData comparison can be simplified.

Change-Id: I500892ab592fd0dd24550c5189151f670efed4d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152541
Reviewed-by: Noel Grandin 
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index 1cf759e463e7..b421c33370db 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -46,9 +46,6 @@ private:
 
 public:
 ScUserListData(OUString aStr);
-// Copy ctor and assignment operator re-initialize tokens. Is this 
intended on copy?
-ScUserListData(const ScUserListData& rData);
-ScUserListData& operator=(const ScUserListData& rData);
 
 const OUString& GetString() const { return aStr; }
 void SetString(const OUString& rStr);
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index 984b51c1058e..b91d3ba3819a 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -34,12 +34,11 @@ ScUserListData::SubStr::SubStr(OUString aReal, OUString 
aUpper) :
 
 void ScUserListData::InitTokens()
 {
-sal_Unicode cSep = ScGlobal::cListDelimiter;
 maSubStrings.clear();
 sal_Int32 nIndex = 0;
 do
 {
-OUString aSub = aStr.getToken(0, cSep, nIndex);
+OUString aSub = aStr.getToken(0, ScGlobal::cListDelimiter, nIndex);
 if (!aSub.isEmpty())
 {
 OUString aUpStr = ScGlobal::getCharClass().uppercase(aSub);
@@ -54,18 +53,6 @@ ScUserListData::ScUserListData(OUString _aStr) :
 InitTokens();
 }
 
-ScUserListData::ScUserListData(const ScUserListData& rData) :
-aStr(rData.aStr)
-{
-InitTokens();
-}
-
-ScUserListData& ScUserListData::operator=(const ScUserListData& rData)
-{
-SetString(rData.aStr);
-return *this;
-}
-
 void ScUserListData::SetString( const OUString& rStr )
 {
 aStr = rStr;
@@ -249,7 +236,7 @@ bool ScUserList::operator==( const ScUserList& r ) const
 {
 return std::equal(maData.begin(), maData.end(), r.maData.begin(), 
r.maData.end(),
 [](const ScUserListData& lhs, const ScUserListData& rhs) {
-return (lhs.GetString() == rhs.GetString()) && (lhs.GetSubCount() 
== rhs.GetSubCount());
+return lhs.GetString() == rhs.GetString();
 });
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-06-04 Thread Mike Kaganski (via logerrit)
 sc/inc/userlist.hxx  |5 +-
 sc/source/core/tool/userlist.cxx |   67 ++-
 2 files changed, 14 insertions(+), 58 deletions(-)

New commits:
commit 7bbec0dfaac7b4a579c963e0724f5355da2b8df8
Author: Mike Kaganski 
AuthorDate: Sun Jun 4 13:50:45 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun Jun 4 14:56:12 2023 +0200

Simplify a bit

Change-Id: Iaea9a425fc93adc716bdb4944244a14175cf7538
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152540
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index 80968361ceac..1cf759e463e7 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -39,8 +39,7 @@ public:
 };
 
 private:
-typedef std::vector SubStringsType;
-SubStringsType maSubStrings;
+std::vector maSubStrings;
 OUString aStr;
 
 SAL_DLLPRIVATE void InitTokens();
@@ -53,7 +52,7 @@ public:
 
 const OUString& GetString() const { return aStr; }
 void SetString(const OUString& rStr);
-size_t GetSubCount() const;
+size_t GetSubCount() const { return maSubStrings.size(); }
 bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, bool& 
bMatchCase) const;
 OUString GetSubStr(sal_uInt16 nIndex) const;
 sal_Int32 Compare(const OUString& rSubStr1, const OUString& rSubStr2) 
const;
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index f38a16d98f12..984b51c1058e 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -29,22 +29,6 @@
 #include 
 #include 
 
-namespace {
-
-class FindByName
-{
-const OUString& mrName;
-bool mbUpper;
-public:
-FindByName(const OUString& rName, bool bUpper) : mrName(rName), 
mbUpper(bUpper) {}
-bool operator() (const ScUserListData::SubStr& r) const
-{
-return mbUpper ? r.maUpper == mrName : r.maReal == mrName;
-}
-};
-
-}
-
 ScUserListData::SubStr::SubStr(OUString aReal, OUString aUpper) :
 maReal(std::move(aReal)), maUpper(std::move(aUpper)) {}
 
@@ -52,37 +36,16 @@ void ScUserListData::InitTokens()
 {
 sal_Unicode cSep = ScGlobal::cListDelimiter;
 maSubStrings.clear();
-const sal_Unicode* p = aStr.getStr();
-const sal_Unicode* p0 = p;
-sal_Int32 nLen = 0;
-bool bFirst = true;
-for (sal_Int32 i = 0, n = aStr.getLength(); i < n; ++i, ++p, ++nLen)
+sal_Int32 nIndex = 0;
+do
 {
-if (bFirst)
+OUString aSub = aStr.getToken(0, cSep, nIndex);
+if (!aSub.isEmpty())
 {
-// very first character, or the first character after a separator.
-p0 = p;
-nLen = 0;
-bFirst = false;
-}
-if (*p == cSep)
-{
-if (nLen)
-{
-OUString aSub(p0, nLen);
-OUString aUpStr = ScGlobal::getCharClass().uppercase(aSub);
-maSubStrings.emplace_back(aSub, aUpStr);
-}
-bFirst = true;
+OUString aUpStr = ScGlobal::getCharClass().uppercase(aSub);
+maSubStrings.emplace_back(aSub, aUpStr);
 }
-}
-
-if (nLen)
-{
-OUString aSub(p0, nLen);
-OUString aUpStr = ScGlobal::getCharClass().uppercase(aSub);
-maSubStrings.emplace_back(aSub, aUpStr);
-}
+} while (nIndex >= 0);
 }
 
 ScUserListData::ScUserListData(OUString _aStr) :
@@ -109,16 +72,11 @@ void ScUserListData::SetString( const OUString& rStr )
 InitTokens();
 }
 
-size_t ScUserListData::GetSubCount() const
-{
-return maSubStrings.size();
-}
-
 bool ScUserListData::GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, 
bool& bMatchCase) const
 {
 // First, case sensitive search.
-SubStringsType::const_iterator itr = ::std::find_if(
-maSubStrings.begin(), maSubStrings.end(), FindByName(rSubStr, false));
+auto itr = ::std::find_if(maSubStrings.begin(), maSubStrings.end(),
+  [](const SubStr& item) { return 
item.maReal == rSubStr; });
 if (itr != maSubStrings.end())
 {
 rIndex = ::std::distance(maSubStrings.begin(), itr);
@@ -127,16 +85,15 @@ bool ScUserListData::GetSubIndex(const OUString& rSubStr, 
sal_uInt16& rIndex, bo
 }
 
 // When that fails, do a case insensitive search.
+bMatchCase = false;
 OUString aUpStr = ScGlobal::getCharClass().uppercase(rSubStr);
-itr = ::std::find_if(
-maSubStrings.begin(), maSubStrings.end(), FindByName(aUpStr, true));
+itr = ::std::find_if(maSubStrings.begin(), maSubStrings.end(),
+ [](const SubStr& item) { return item.maUpper 
== aUpStr; });
 if (itr != maSubStrings.end())
 {
 rIndex = ::std::distance(maSubStrings.begin(), itr);
-bMatchCase = false;
 return true;
 }
-bMatchCase = false;
 return false;
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-06-04 Thread Mike Kaganski (via logerrit)
 sc/inc/userlist.hxx  |3 ++-
 sc/source/core/tool/appoptio.cxx |   12 +++-
 sc/source/core/tool/userlist.cxx |   21 +
 3 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit 182974354e4536af568dfb05a7400e48a2fe1032
Author: Mike Kaganski 
AuthorDate: Sun Jun 4 12:58:46 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Jun 4 14:17:35 2023 +0200

Optimize ScAppCfg::ReadSortListCfg

Do not initialize defaults when using custom user list.

Change-Id: I8428a20b65182011a25325f0b7298ea51998346b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152587
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index 7625ad15f5ee..80968361ceac 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -69,9 +69,10 @@ class SC_DLLPUBLIC ScUserList
 DataType maData;
 
 public:
-ScUserList();
+explicit ScUserList(bool initDefault = true);
 ScUserList(const ScUserList& r) = default;
 
+void AddDefaults();
 void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); }
 
 const ScUserListData* GetData(const OUString& rSubStr) const;
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 16a0c4cb9174..9dbc85f310ae 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -407,16 +407,18 @@ void ScAppCfg::ReadSortListCfg()
 
 if (Sequence aSeq; aValues[SCSORTLISTOPT_LIST] >>= aSeq)
 {
-ScUserList aList;
+ScUserList aList(false); // Do not init defaults
 
-//  if setting is "default", keep default values from ScUserList ctor
+//  if setting is "default", keep default values
 //TODO: mark "default" in a safe way
 const bool bDefault = (aSeq.getLength() == 1 && aSeq[0] == "NULL");
 
-if (!bDefault)
+if (bDefault)
+{
+aList.AddDefaults();
+}
+else
 {
-aList.clear();
-
 for (const OUString& rStr : std::as_const(aSeq))
 {
 aList.emplace_back(rStr);
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index 4540ad3ea0f6..f38a16d98f12 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -200,20 +200,18 @@ sal_Int32 ScUserListData::ICompare(const OUString& 
rSubStr1, const OUString& rSu
 return ScGlobal::GetTransliteration().compareString( rSubStr1, 
rSubStr2 );
 }
 
-ScUserList::ScUserList()
+ScUserList::ScUserList(bool initDefault)
 {
-using namespace ::com::sun::star;
+if (initDefault)
+AddDefaults();
+}
 
+void ScUserList::AddDefaults()
+{
 sal_Unicode cDelimiter = ScGlobal::cListDelimiter;
-uno::Sequence< i18n::CalendarItem2 > xCal;
-
-const uno::Sequence< i18n::Calendar2 > xCalendars(
-ScGlobal::getLocaleData().getAllCalendars() );
-
-for ( const auto& rCalendar : xCalendars )
+for (const auto& rCalendar : ScGlobal::getLocaleData().getAllCalendars())
 {
-xCal = rCalendar.Days;
-if ( xCal.hasElements() )
+if (const auto& xCal = rCalendar.Days; xCal.hasElements())
 {
 OUStringBuffer aDayShortBuf(32), aDayLongBuf(64);
 sal_Int32 i;
@@ -244,8 +242,7 @@ ScUserList::ScUserList()
 emplace_back(aDayLong);
 }
 
-xCal = rCalendar.Months;
-if ( xCal.hasElements() )
+if (const auto& xCal = rCalendar.Months; xCal.hasElements())
 {
 OUStringBuffer aMonthShortBuf(128), aMonthLongBuf(128);
 sal_Int32 i;


[Libreoffice-commits] core.git: sc/inc sc/source

2023-05-17 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 c85255fd7a62bec9342fa6f2a79d1395979d54be
Author: Henry Castro 
AuthorDate: Thu May 11 16:23:03 2023 -0400
Commit: Henry Castro 
CommitDate: Wed May 17 15:57:02 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

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: sc/inc sc/source

2023-05-10 Thread Caolán McNamara (via logerrit)
 sc/inc/documentlinkmgr.hxx|1 +
 sc/inc/globstr.hrc|2 ++
 sc/source/ui/docshell/docsh4.cxx  |   17 -
 sc/source/ui/docshell/documentlinkmgr.cxx |   18 ++
 4 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit a580a69a1e579755f726ffcd2a31a6f4f42c7100
Author: Caolán McNamara 
AuthorDate: Wed May 10 16:38:08 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed May 10 22:29:02 2023 +0200

reinforce the infobar warning when there are both external links...

and WEBSERVICE present. This information is also shown in the
"help" in the infobar

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

diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx
index e37719a3431c..de36ec40fa81 100644
--- a/sc/inc/documentlinkmgr.hxx
+++ b/sc/inc/documentlinkmgr.hxx
@@ -54,6 +54,7 @@ public:
 
 bool hasDdeLinks() const;
 bool hasDdeOrOleOrWebServiceLinks() const;
+bool hasExternalRefLinks() const;
 
 bool updateDdeOrOleOrWebServiceLinks(weld::Window* pWin);
 
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 01e1ab47219b..600cf9354fc0 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -359,6 +359,8 @@
 #define STR_BY  NC_("STR_BY", "by")
 #define STR_ON  NC_("STR_ON", "on")
 #define STR_RELOAD_TABLES   NC_("STR_RELOAD_TABLES", 
"Automatic update of external links has been disabled.")
+#define STR_TRUST_DOCUMENT_WARNING  
NC_("STR_TRUST_DOCUMENT_WARNING", "Are you sure you trust this document?")
+#define STR_WEBSERVICE_WITH_LINKS_WARNING   
NC_("STR_WEBSERVICE_WITH_LINKS_WARNING", "Links to remote locations can be 
constructed that transmit local data to the remote server.")
 #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 611d6537456e..1a344af959fd 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -199,8 +199,23 @@ void ScDocShell::ReloadAllLinks()
 m_pDocument->UpdateAreaLinks();
 }
 
-IMPL_LINK_NOARG( ScDocShell, ReloadAllLinksHdl, weld::Button&, void )
+IMPL_LINK( ScDocShell, ReloadAllLinksHdl, weld::Button&, rButton, void )
 {
+ScDocument& rDoc = GetDocument();
+if (rDoc.HasLinkFormulaNeedingCheck() && 
rDoc.GetDocLinkManager().hasExternalRefLinks())
+{
+// If we have WEBSERVICE/Dde link and other external links in the 
document, it might indicate some
+// exfiltration attempt, add *another* warning about this on top of 
the "Security Warning"
+// shown in the infobar before they got here.
+std::unique_ptr 
xQueryBox(Application::CreateMessageDialog(,
+   
VclMessageType::Warning, VclButtonsType::YesNo,
+   
ScResId(STR_TRUST_DOCUMENT_WARNING)));
+
xQueryBox->set_secondary_text(ScResId(STR_WEBSERVICE_WITH_LINKS_WARNING));
+xQueryBox->set_default_response(RET_NO);
+if (xQueryBox->run() != RET_YES)
+return;
+}
+
 ReloadAllLinks();
 
 ScTabViewShell* pViewSh = GetBestViewShell();
diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx 
b/sc/source/ui/docshell/documentlinkmgr.cxx
index 79a86d08b438..0fb89cfa0d18 100644
--- a/sc/source/ui/docshell/documentlinkmgr.cxx
+++ b/sc/source/ui/docshell/documentlinkmgr.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -153,6 +154,23 @@ bool 
DocumentLinkManager::hasDdeOrOleOrWebServiceLinks(bool bDde, bool bOle, boo
 return false;
 }
 
+bool DocumentLinkManager::hasExternalRefLinks() const
+{
+sfx2::LinkManager* pMgr = mpImpl->mpLinkManager;
+if (!pMgr)
+return false;
+
+const sfx2::SvBaseLinks& rLinks = pMgr->GetLinks();
+for (const auto & rLink : rLinks)
+{
+sfx2::SvBaseLink* pBase = rLink.get();
+if (dynamic_cast(pBase))
+return true;
+}
+
+return false;
+}
+
 bool DocumentLinkManager::updateDdeOrOleOrWebServiceLinks(weld::Window* pWin)
 {
 sfx2::LinkManager* pMgr = mpImpl->mpLinkManager;


[Libreoffice-commits] core.git: sc/inc sc/source sc/uiconfig

2023-05-05 Thread Bartosz Kosiorek (via logerrit)
 sc/inc/strings.hrc |3 
 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx |   32 
+++---
 sc/uiconfig/scalc/ui/randomnumbergenerator.ui  |1 
 3 files changed, 28 insertions(+), 8 deletions(-)

New commits:
commit 793cc7d2ef5967af90a6810e597e1e12bd42777c
Author: Bartosz Kosiorek 
AuthorDate: Fri May 5 20:15:19 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat May 6 03:54:25 2023 +0200

tdf#154872 Add Poisson distribution to Random Number Generators

Change-Id: I325a76423a98a405dfb0f69fbd89eb9253c36390
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151439
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index e860263424be..6c85b3d617da 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -266,9 +266,10 @@
 #define STR_DISTRIBUTION_CAUCHY 
NC_("STR_DISTRIBUTION_CAUCHY", "Cauchy")
 #define STR_DISTRIBUTION_BERNOULLI  
NC_("STR_DISTRIBUTION_BERNOULLI", "Bernoulli")
 #define STR_DISTRIBUTION_BINOMIAL   
NC_("STR_DISTRIBUTION_BINOMIAL", "Binomial")
-#define STR_DISTRIBUTION_NEGATIVE_BINOMIAL  
NC_("STR_DISTRIBUTION_NEGATIVE_BINOMIAL", "Negative Binomial")
 #define STR_DISTRIBUTION_CHI_SQUARED
NC_("STR_DISTRIBUTION_CHI_SQUARED", "Chi Squared")
 #define STR_DISTRIBUTION_GEOMETRIC  
NC_("STR_DISTRIBUTION_GEOMETRIC", "Geometric")
+#define STR_DISTRIBUTION_NEGATIVE_BINOMIAL  
NC_("STR_DISTRIBUTION_NEGATIVE_BINOMIAL", "Negative Binomial")
+#define STR_DISTRIBUTION_POISSON
NC_("STR_DISTRIBUTION_POISSON", "Poisson")
 #define STR_RNG_PARAMETER_MINIMUM   
NC_("STR_RNG_PARAMETER_MINIMUM", "Minimum")
 #define STR_RNG_PARAMETER_MAXIMUM   
NC_("STR_RNG_PARAMETER_MAXIMUM", "Maximum")
 #define STR_RNG_PARAMETER_MEAN  
NC_("STR_RNG_PARAMETER_MEAN", "Mean")
diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx 
b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
index 91b43cbe0433..2490ebf47301 100644
--- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
@@ -36,6 +36,7 @@ const sal_Int64 DIST_CHI_SQUARED = 5;
 const sal_Int64 DIST_GEOMETRIC   = 6;
 const sal_Int64 DIST_NEGATIVE_BINOMIAL   = 7;
 const sal_Int64 DIST_UNIFORM_INTEGER = 8;
+const sal_Int64 DIST_POISSON = 9;
 
 const sal_Int64 PRECISION   = 1;
 const sal_Int64 DIGITS  = 4;
@@ -225,13 +226,6 @@ void 
ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
 GenerateNumbers(rng, STR_DISTRIBUTION_BINOMIAL, aDecimalPlaces);
 break;
 }
-case DIST_NEGATIVE_BINOMIAL:
-{
-std::negative_binomial_distribution<> 
distribution(parameterInteger2, parameter1);
-auto rng = std::bind(distribution, seed);
-GenerateNumbers(rng, STR_DISTRIBUTION_NEGATIVE_BINOMIAL, 
aDecimalPlaces);
-break;
-}
 case DIST_CHI_SQUARED:
 {
 std::chi_squared_distribution<> distribution(parameter1);
@@ -246,6 +240,20 @@ void 
ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
 GenerateNumbers(rng, STR_DISTRIBUTION_GEOMETRIC, aDecimalPlaces);
 break;
 }
+case DIST_NEGATIVE_BINOMIAL:
+{
+std::negative_binomial_distribution<> 
distribution(parameterInteger2, parameter1);
+auto rng = std::bind(distribution, seed);
+GenerateNumbers(rng, STR_DISTRIBUTION_NEGATIVE_BINOMIAL, 
aDecimalPlaces);
+break;
+}
+case DIST_POISSON:
+{
+std::poisson_distribution<> distribution(parameter1);
+auto rng = std::bind(distribution, seed);
+GenerateNumbers(rng, STR_DISTRIBUTION_POISSON, aDecimalPlaces);
+break;
+}
 }
 }
 
@@ -476,6 +484,16 @@ IMPL_LINK_NOARG(ScRandomNumberGeneratorDialog, 
DistributionChanged, weld::ComboB
 mxParameter2Value->hide();
 break;
 }
+case DIST_POISSON:
+{
+mxParameter1Text->set_label(ScResId(STR_RNG_PARAMETER_MEAN));
+mxParameter1Value->set_value(PRECISION);
+mxParameter1Value->set_increments(1000, 1);
+mxParameter1Value->set_min(1000);
+mxParameter2Text->hide();
+mxParameter2Value->hide();
+break;
+}
 }
 }
 
diff --git a/sc/uiconfig/scalc/ui/randomnumbergenerator.ui 
b/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
index e6f8f93ba214..d9481046bd8f 100644
--- a/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
+++ b/sc/uiconfig/scalc/ui/randomnumbergenerator.ui
@@ -240,6 +240,7 @@
   Chi Squared
  

[Libreoffice-commits] core.git: sc/inc sc/source

2023-04-24 Thread Arvind K (via logerrit)
 sc/inc/strings.hrc|4 
 sc/source/ui/dbgui/tpsort.cxx |   18 ++
 sc/source/ui/inc/tpsort.hxx   |4 
 3 files changed, 26 insertions(+)

New commits:
commit b7dfed873d79417fff83410760fec84567b534e9
Author: Arvind K 
AuthorDate: Fri Apr 14 23:49:51 2023 +0530
Commit: Andreas Heinisch 
CommitDate: Mon Apr 24 10:39:20 2023 +0200

tdf#139544 change boundary columns to rows in sort dialog

Change-Id: I7f525bea42e6efd3c7c4b62a21d2638b676cd836
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150432
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index f7d33399faa2..e860263424be 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -129,6 +129,10 @@
 #define SCSTR_FORMULA_SYNTAX_XL_R1C1
NC_("SCSTR_FORMULA_SYNTAX_XL_R1C1", "Excel R1C1")
 #define SCSTR_COL_LABEL NC_("SCSTR_COL_LABEL", 
"Range contains column la~bels" )
 #define SCSTR_ROW_LABEL NC_("SCSTR_ROW_LABEL", 
"Range contains ~row labels" )
+#define SCSTR_NOTES_COL_LABEL   
NC_("SCSTR_INCLUDE_NOTES_COL_LABEL","Include boundary column(s) containing only 
comments")
+#define SCSTR_NOTES_ROW_LABEL   
NC_("SCSTR_INCLUDE_NOTES_ROW_LABEL","Include boundary row(s) containing only 
comments")
+#define SCSTR_IMAGES_COL_LABEL  
NC_("SCSTR_INCLUDE_IMAGES_COL_LABEL","Include boundary column(s) containing 
only images")
+#define SCSTR_IMAGES_ROW_LABEL  
NC_("SCSTR_INCLUDE_IMAGES_ROW_LABEL","Include boundary row(s) containing only 
images")
 #define SCSTR_VALERRNC_("SCSTR_VALERR", 
"Invalid value" )
 #define STR_NOFORMULASPECIFIED  
NC_("STR_NOFORMULASPECIFIED", "No formula specified." )
 #define STR_NOCOLROWNC_("STR_NOCOLROW", 
"Neither row or column specified." )
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 88d6cf6472e2..c137ec4cf898 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -492,6 +492,10 @@ void ScTabPageSortFields::AddSortKey( sal_uInt16 nItem )
 ScTabPageSortOptions::ScTabPageSortOptions(weld::Container* pPage, 
weld::DialogController* pController, const SfxItemSet& rArgSet)
 : SfxTabPage(pPage, pController, "modules/scalc/ui/sortoptionspage.ui", 
"SortOptionsPage", )
 , aStrUndefined(ScResId(SCSTR_UNDEFINED))
+, aStrCommentsRowLabel(ScResId(SCSTR_NOTES_ROW_LABEL))
+, aStrCommentsColLabel(ScResId(SCSTR_NOTES_COL_LABEL))
+, aStrImgRowLabel(ScResId(SCSTR_IMAGES_ROW_LABEL))
+, aStrImgColLabel(ScResId(SCSTR_IMAGES_COL_LABEL))
 , nWhichSort(rArgSet.GetPool()->GetWhich(SID_SORT))
 , aSortData(rArgSet.Get(nWhichSort).GetSortData())
 , pViewData(nullptr)
@@ -557,6 +561,9 @@ void ScTabPageSortOptions::Init()
 m_xEdOutPos->set_text(OUString());
 }
 
+m_xBtnIncComments->set_label(aStrCommentsColLabel);
+m_xBtnIncImages->set_label(aStrImgColLabel);
+
 FillUserSortListBox();
 
 //  get available languages
@@ -681,6 +688,17 @@ void ScTabPageSortOptions::ActivatePage( const SfxItemSet& 
rSet )
 ScSortDlg* pDlg = static_cast(GetDialogController());
 if (!pDlg)
 return;
+
+if (aSortData.bByRow)
+{
+m_xBtnIncComments->set_label(aStrCommentsRowLabel);
+m_xBtnIncImages->set_label(aStrImgRowLabel);
+}
+else
+{
+m_xBtnIncComments->set_label(aStrCommentsColLabel);
+m_xBtnIncImages->set_label(aStrImgColLabel);
+}
 }
 
 DeactivateRC ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index 4e6a36ca9da5..1c9d27926b1c 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -113,6 +113,10 @@ protected:
 
 private:
 OUStringaStrUndefined;
+OUStringaStrCommentsRowLabel;
+OUStringaStrCommentsColLabel;
+OUStringaStrImgRowLabel;
+OUStringaStrImgColLabel;
 
 TypedWhichId nWhichSort;
 ScSortParam aSortData;


[Libreoffice-commits] core.git: sc/inc sc/source

2023-04-20 Thread Eike Rathke (via logerrit)
 sc/inc/globstr.hrc |1 +
 sc/source/core/data/global.cxx |4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit df8ae4fddb77f5621f651f05e72f8c2bd4ae111b
Author: Eike Rathke 
AuthorDate: Wed Apr 19 21:45:22 2023 +0200
Commit: Eike Rathke 
CommitDate: Thu Apr 20 14:32:46 2023 +0200

Related: tdf#154915 #NULL! is not an "Internal syntactical error"

... but "Error: No code or intersection".

Change-Id: I8c161e6553084fc849092f689273cbe181033e22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150654
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 16fce3f32974..0aa8d010f9df 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -239,6 +239,7 @@
 #define STR_NO_MACRONC_("STR_NO_MACRO", "#MACRO?")
 #define STR_LONG_ERR_NO_MACRO   NC_("STR_LONG_ERR_NO_MACRO", 
"Error: Macro not found")
 #define STR_LONG_ERR_SYNTAX NC_("STR_LONG_ERR_SYNTAX", 
"Internal syntactical error")
+#define STR_LONG_ERR_NO_CODENC_("STR_LONG_ERR_NO_CODE", 
"Error: No code or intersection")
 #define STR_LONG_ERR_ILL_ARGNC_("STR_LONG_ERR_ILL_ARG", 
"Error: Invalid argument")
 #define STR_LONG_ERR_ILL_PARNC_("STR_LONG_ERR_ILL_PAR", 
"Error in parameter list")
 #define STR_LONG_ERR_ILL_CHAR   NC_("STR_LONG_ERR_ILL_CHAR", 
"Error: Invalid character")
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 61c873737dc1..02167599e926 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -391,9 +391,11 @@ OUString ScGlobal::GetLongErrorString(FormulaError nErr)
 case FormulaError::UnknownOpCode:
 case FormulaError::UnknownStackVariable:
 case FormulaError::UnknownToken:
-case FormulaError::NoCode:
 pErrNumber = STR_LONG_ERR_SYNTAX;
 break;
+case FormulaError::NoCode:
+pErrNumber = STR_LONG_ERR_NO_CODE;
+break;
 case FormulaError::CircularReference:
 pErrNumber = STR_LONG_ERR_CIRC_REF;
 break;


[Libreoffice-commits] core.git: sc/inc sc/source sc/uiconfig

2023-04-04 Thread Heiko Tietze (via logerrit)
 sc/inc/viewopti.hxx|4 -
 sc/source/core/tool/viewopti.cxx   |4 +
 sc/source/ui/inc/tpview.hxx|2 
 sc/source/ui/optdlg/tpview.cxx |   34 
 sc/source/ui/view/viewdata.cxx |   17 
 sc/uiconfig/scalc/ui/tpviewpage.ui |   75 +
 6 files changed, 15 insertions(+), 121 deletions(-)

New commits:
commit 2039fd382af9d110bd68be8629ab757b3617926a
Author: Heiko Tietze 
AuthorDate: Wed Mar 29 15:12:58 2023 +0200
Commit: Heiko Tietze 
CommitDate: Tue Apr 4 10:53:56 2023 +0200

Resolves tdf#154446 - Remove redundant option for grid line color

Change-Id: I41d39b763e651f90660f2a451ed0a9b473ead206
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149715
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 

diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index cd641198753b..b90e1b65f076 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -59,10 +59,6 @@ enum ScVObjType
 #define MAX_OPT sal_uInt16(VOPT_CLIPMARKS)+1
 #define MAX_TYPEsal_uInt16(VOBJ_TYPE_DRAW)+1
 
-// SC_STD_GRIDCOLOR is obsolete since tdf#152184 since GridColor == COL_AUTO
-// converts now to either light or dark but still used on options > view > 
visual aids
-#define SC_STD_GRIDCOLORCOL_LIGHTGRAY
-
 // SvxGrid options with standard operators
 
 class ScGridOptions : public SvxOptionsGrid
diff --git a/sc/source/core/tool/viewopti.cxx b/sc/source/core/tool/viewopti.cxx
index 6079323f13e7..f243289653cd 100644
--- a/sc/source/core/tool/viewopti.cxx
+++ b/sc/source/core/tool/viewopti.cxx
@@ -22,6 +22,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -111,7 +113,7 @@ void ScViewOptions::SetDefaults()
 aModeArr[VOBJ_TYPE_CHART] = VOBJ_MODE_SHOW;
 aModeArr[VOBJ_TYPE_DRAW ] = VOBJ_MODE_SHOW;
 
-aGridCol = SC_STD_GRIDCOLOR;
+aGridCol = svtools::ColorConfig().GetColorValue( svtools::CALCGRID 
).nColor;
 
 aGridOpt.SetDefaults();
 }
diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx
index 7be90de5aceb..ad485b361580 100644
--- a/sc/source/ui/inc/tpview.hxx
+++ b/sc/source/ui/inc/tpview.hxx
@@ -29,8 +29,6 @@ class ScTpContentOptions : public SfxTabPage
 std::unique_ptr m_xLocalOptions;
 
 std::unique_ptr m_xGridLB;
-std::unique_ptr m_xColorFT;
-std::unique_ptr m_xColorLB;
 std::unique_ptr m_xBreakCB;
 std::unique_ptr m_xGuideLineCB;
 
diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx
index 926436864e79..f83ce9f033a5 100644
--- a/sc/source/ui/optdlg/tpview.cxx
+++ b/sc/source/ui/optdlg/tpview.cxx
@@ -30,15 +30,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 ScTpContentOptions::ScTpContentOptions(weld::Container* pPage, 
weld::DialogController* pController, const SfxItemSet&  rArgSet)
 : SfxTabPage(pPage, pController, "modules/scalc/ui/tpviewpage.ui", 
"TpViewPage", )
 , m_xGridLB(m_xBuilder->weld_combo_box("grid"))
-, m_xColorFT(m_xBuilder->weld_label("color_label"))
-, m_xColorLB(new ColorListBox(m_xBuilder->weld_menu_button("color"),
-[this]{ return GetDialogController()->getDialog(); }))
 , m_xBreakCB(m_xBuilder->weld_check_button("break"))
 , m_xGuideLineCB(m_xBuilder->weld_check_button("guideline"))
 , m_xFormulaCB(m_xBuilder->weld_check_button("formula"))
@@ -88,14 +84,10 @@ ScTpContentOptions::ScTpContentOptions(weld::Container* 
pPage, weld::DialogContr
 m_xRowColHeaderCB->connect_toggled(aCBHdl);
 m_xSummaryCB->connect_toggled(aCBHdl);
 m_xThemedCursorRB->connect_toggled(aCBHdl);
-
-m_xColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
-m_xColorLB->SetAutoDisplayColor(SC_STD_GRIDCOLOR);
 }
 
 ScTpContentOptions::~ScTpContentOptions()
 {
-m_xColorLB.reset();
 }
 
 std::unique_ptr ScTpContentOptions::Create( weld::Container* 
pPage, weld::DialogController* pController,
@@ -123,19 +115,11 @@ boolScTpContentOptions::FillItemSet( SfxItemSet* 
rCoreSet )
 m_xVScrollCB->get_state_changed_from_saved() ||
 m_xTblRegCB->get_state_changed_from_saved() ||
 m_xOutlineCB->get_state_changed_from_saved() ||
-m_xColorLB->IsValueChangedFromSaved() ||
 m_xBreakCB->get_state_changed_from_saved() ||
 m_xSummaryCB->get_state_changed_from_saved() ||
 m_xThemedCursorRB->get_state_changed_from_saved() ||
 m_xGuideLineCB->get_state_changed_from_saved())
 {
-NamedColor aNamedColor = m_xColorLB->GetSelectedEntry();
-if (aNamedColor.first == COL_AUTO)
-{
-aNamedColor.first = SC_STD_GRIDCOLOR;
-aNamedColor.second.clear();
-}
-m_xLocalOptions->SetGridColor(aNamedColor.first, aNamedColor.second);
 rCoreSet->Put(ScTpViewItem(*m_xLocalOptions));
 bRet = true;
 }
@@ -211,7 +195,6 @@ voidScTpContentOptions::Reset( const SfxItemSet* 
rCoreSet )
 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-03-30 Thread Maxim Monastirsky (via logerrit)
 sc/inc/bitmaps.hlst|1 +
 sc/inc/scstyles.hrc|9 +
 sc/source/ui/app/scmod.cxx |5 +
 3 files changed, 15 insertions(+)

New commits:
commit 1b463f697405e64a03378fb38a32172c4d3c25e6
Author: Maxim Monastirsky 
AuthorDate: Fri Mar 17 14:56:04 2023 +0200
Commit: Maxim Monastirsky 
CommitDate: Thu Mar 30 22:43:36 2023 +

sc drawstyles: Enable the UI

I believe it's in a usable state now. But keep in
mind that the work isn't finished yet. For example,
there is only one base default style, and the work to
support styles for comments wasn't merged yet.

Change-Id: I1ad3a4803ad91773906743e19a35405d5cd3255d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149754
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/inc/bitmaps.hlst b/sc/inc/bitmaps.hlst
index 1b24f4b28851..422ed5ddeb63 100644
--- a/sc/inc/bitmaps.hlst
+++ b/sc/inc/bitmaps.hlst
@@ -61,6 +61,7 @@ inline constexpr OUStringLiteral RID_BMP_INPUT_OK = 
u"sc/res/sc26051.png";
 
 inline constexpr OUStringLiteral BMP_STYLES_FAMILY_CELL = u"sc/res/sf01.png";
 inline constexpr OUStringLiteral BMP_STYLES_FAMILY_PAGE = u"sc/res/sf02.png";
+inline constexpr OUStringLiteral BMP_STYLES_FAMILY_GRAPHICS = 
u"sd/res/sf01.png";
 
 inline constexpr OUStringLiteral BMP_ICON_SET_CIRCLES1_GRAY = 
u"sc/res/icon-set-circles1-gray.png";
 inline constexpr OUStringLiteral BMP_ICON_SET_CIRCLES1_GREEN = 
u"sc/res/icon-set-circles1-green.png";
diff --git a/sc/inc/scstyles.hrc b/sc/inc/scstyles.hrc
index 4e4c449d69c9..224f2cd475ac 100644
--- a/sc/inc/scstyles.hrc
+++ b/sc/inc/scstyles.hrc
@@ -41,4 +41,13 @@ const std::pair 
RID_PAGESTYLEFAMILY[] =
 { {}, SfxStyleSearchBits::Auto }
 };
 
+const std::pair RID_GRAPHICSTYLEFAMILY[] =
+{
+{ NC_("RID_GRAPHICSTYLEFAMILY", "All Styles") , 
SfxStyleSearchBits::AllVisible },
+{ NC_("RID_GRAPHICSTYLEFAMILY", "Hidden Styles") , 
SfxStyleSearchBits::Hidden },
+{ NC_("RID_GRAPHICSTYLEFAMILY", "Applied Styles") , 
SfxStyleSearchBits::Used },
+{ NC_("RID_GRAPHICSTYLEFAMILY", "Custom Styles") , 
SfxStyleSearchBits::UserDefined },
+{ {}, SfxStyleSearchBits::Auto }
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 18aa0845088c..2f84555fd3ca 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -2308,6 +2308,11 @@ std::optional 
ScModule::CreateStyleFamilies()
 BMP_STYLES_FAMILY_PAGE,
 RID_PAGESTYLEFAMILY, 
SC_MOD()->GetResLocale()));
 
+aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Frame,
+
ScResId(STR_STYLE_FAMILY_GRAPHICS),
+BMP_STYLES_FAMILY_GRAPHICS,
+RID_GRAPHICSTYLEFAMILY, 
SC_MOD()->GetResLocale()));
+
 return aStyleFamilies;
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-03-26 Thread Balazs Varga (via logerrit)
 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 69cc8bdd5f9109804d912b52d5ee1040d6e1868f
Author: Balazs Varga 
AuthorDate: Sat Mar 25 18:57:08 2023 +0100
Commit: Balazs Varga 
CommitDate: Sun Mar 26 16:37:32 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 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f044eaf77f78..285fcf1a7d31 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2036,7 +2036,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 5eefb5f95c38..cbce92da3998 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -971,9 +971,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 b295e68f69e0..afec7f072b3c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4561,12 +4561,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 653571cabd38..359bf3b1e7be 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -713,11 +713,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(), 
rAnchor.maEnd.Row(), rAnchor.maStart.Tab());
+nHiddenCols = pDoc->CountHiddenCols(rAnchor.maStart.Col(), 
rAnchor.maEnd.Col(), rAnchor.maStart.Tab());
 }
 
 // In 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-03-19 Thread Maxim Monastirsky (via logerrit)
 sc/inc/document.hxx  |1 -
 sc/source/core/data/docpool.cxx  |1 +
 sc/source/core/data/documen2.cxx |2 +-
 sc/source/core/data/documen9.cxx |   18 --
 4 files changed, 2 insertions(+), 20 deletions(-)

New commits:
commit ba58d80a1a9c30e58b20184135e81cc1851bdd75
Author: Maxim Monastirsky 
AuthorDate: Sun Mar 19 00:16:00 2023 +0200
Commit: Maxim Monastirsky 
CommitDate: Sun Mar 19 17:40:26 2023 +

sc drawstyles: Delay the destruction of SdrItemPool

Nowadays SfxItemPool_Impl::mpSecondary is ref counted, so
there is no fear in destroying the draw layer before the doc
pool.

This kind of change is needed for drawing styles, as their
item set references the SdrItemPool with a raw pointer, but
they are destroyed as part of the styles pool, much later
than the draw layer.

Change-Id: I169bbacfbdbec2121217b13293b6f495898fe2e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149090
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 137b786e8c8b..9c6e376acca5 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2673,7 +2673,6 @@ private:
 voidImplCreateOptions(); // Suggestion: switch to on-demand?
 voidImplDeleteOptions();
 
-voidDeleteDrawLayer();
 SC_DLLPUBLIC bool   DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool 
bSetVer ) const;
 
 voidUpdateDrawPrinter();
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index e0a07582e453..47c485e4f139 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -327,6 +327,7 @@ ScDocumentPool::ScDocumentPool()
 ScDocumentPool::~ScDocumentPool()
 {
 Delete();
+SetSecondaryPool(nullptr);
 
 for ( sal_uInt16 i=0; i < ATTR_ENDINDEX-ATTR_STARTINDEX+1; i++ )
 {
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a7ea162177a9..fa979a953cb8 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -386,7 +386,7 @@ ScDocument::~ScDocument()
 pDBCollection.reset();
 pSelectionAttr.reset();
 apTemporaryChartLock.reset();
-DeleteDrawLayer();
+mpDrawLayer.reset();
 mpPrinter.disposeAndClear();
 ImplDeleteOptions();
 pConsolidateDlgData.reset();
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index b471a9a0f0f6..e6a6501c46e4 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -226,24 +226,6 @@ IMPL_LINK( ScDocument, GetUserDefinedColor, sal_uInt16, 
nColorIndex, Color* )
 return 
const_cast(&(xColorList->GetColor(nColorIndex)->GetColor()));
 }
 
-void ScDocument::DeleteDrawLayer()
-{
-ScMutationGuard aGuard(*this, ScMutationGuardFlags::CORE);
-
-// remove DrawingLayer's SfxItemPool from Calc's SfxItemPool where
-// it is registered as secondary pool
-if (mxPoolHelper.is() && !IsClipOrUndo()) //Using IsClipOrUndo as a proxy 
for SharePooledResources called
-{
-ScDocumentPool* pLocalPool = mxPoolHelper->GetDocPool();
-
-if(pLocalPool && pLocalPool->GetSecondaryPool())
-{
-pLocalPool->SetSecondaryPool(nullptr);
-}
-}
-mpDrawLayer.reset();
-}
-
 bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer 
) const
 {
 return mpDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer );


[Libreoffice-commits] core.git: sc/inc sc/source sc/uiconfig

2023-03-08 Thread Grigory A. Mozhaev (via logerrit)
 sc/inc/ViewSettingsSequenceDefines.hxx |   31 +++---
 sc/inc/unonames.hxx|1 
 sc/inc/viewopti.hxx|1 
 sc/source/core/tool/viewopti.cxx   |   21 ++---
 sc/source/ui/inc/output.hxx|1 
 sc/source/ui/inc/tpview.hxx|1 
 sc/source/ui/optdlg/tpview.cxx |6 ++
 sc/source/ui/unoobj/confuno.cxx|5 ++
 sc/source/ui/unoobj/viewuno.cxx|4 +
 sc/source/ui/view/gridwin4.cxx |3 +
 sc/source/ui/view/gridwin5.cxx |   25 +++
 sc/source/ui/view/output.cxx   |   72 +
 sc/source/ui/view/viewdata.cxx |4 +
 sc/uiconfig/scalc/ui/tpviewpage.ui |   22 --
 14 files changed, 172 insertions(+), 25 deletions(-)

New commits:
commit 3fcf9f864f9d12fdb0ade4741127c81cec74378a
Author: Grigory A. Mozhaev 
AuthorDate: Mon Feb 27 16:03:39 2023 +0300
Commit: Heiko Tietze 
CommitDate: Wed Mar 8 10:51:42 2023 +

tdf#97551 Added marker and hint for formula to Calc

Added option "Formula indicator and hint" to LibreOffice Calc > View 
section (near to "Comment indicator"). This option turned off by default to 
avoid interfere existing UX.

Indicator displays in the bottom-left corner as blue triangle marker if 
cells contains formula (correctly reacts on cells merging and different sizing).

Hint displays when user hover cursor over the cell that contains the 
formula (uses already built-in mechanics for help tooltip).

More details about request and discussion of the feature in Bugzilla.

Change-Id: I8f3e368d4fdad362b819b4ce2fd6b0c32b5c1c0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147914
Tested-by: Jenkins
Tested-by: Heiko Tietze 
Reviewed-by: Heiko Tietze 

diff --git a/sc/inc/ViewSettingsSequenceDefines.hxx 
b/sc/inc/ViewSettingsSequenceDefines.hxx
index f22c4df5e05b..501a87cc1854 100644
--- a/sc/inc/ViewSettingsSequenceDefines.hxx
+++ b/sc/inc/ViewSettingsSequenceDefines.hxx
@@ -36,21 +36,22 @@
 #define SC_PAGE_BREAK_PREVIEW   7
 #define SC_SHOWZERO 8
 #define SC_SHOWNOTES9
-#define SC_SHOWGRID 10
-#define SC_GRIDCOLOR11
-#define SC_SHOWPAGEBR   12
-#define SC_COLROWHDR13
-#define SC_SHEETTABS14
-#define SC_OUTLSYMB 15
-#define SC_VALUE_HIGHLIGHTING   16
-#define SC_SNAPTORASTER 17
-#define SC_RASTERVIS18
-#define SC_RASTERRESX   19
-#define SC_RASTERRESY   20
-#define SC_RASTERSUBX   21
-#define SC_RASTERSUBY   22
-#define SC_RASTERSYNC   23
-#define SC_FORMULA_BAR_HEIGHT   24
+#define SC_SHOWFORMULASMARKS10
+#define SC_SHOWGRID 11
+#define SC_GRIDCOLOR12
+#define SC_SHOWPAGEBR   13
+#define SC_COLROWHDR14
+#define SC_SHEETTABS15
+#define SC_OUTLSYMB 16
+#define SC_VALUE_HIGHLIGHTING   17
+#define SC_SNAPTORASTER 18
+#define SC_RASTERVIS19
+#define SC_RASTERRESX   20
+#define SC_RASTERRESY   21
+#define SC_RASTERSUBX   22
+#define SC_RASTERSUBY   23
+#define SC_RASTERSYNC   24
+#define SC_FORMULA_BAR_HEIGHT   25
 
 // this are the defines for the position of the settings in the
 // TableViewSettingsSequence
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index bdd37e666871..abb09c334c10 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -550,6 +550,7 @@ inline constexpr OUStringLiteral SC_UNO_SHOWFORM
 = u"ShowFormulas";
 inline constexpr OUStringLiteral SC_UNO_SHOWGRID = u"ShowGrid";
 inline constexpr OUStringLiteral SC_UNO_SHOWHELP = 
u"ShowHelpLines";
 inline constexpr OUStringLiteral SC_UNO_SHOWNOTES= u"ShowNotes";
+inline constexpr OUStringLiteral SC_UNO_SHOWFORMULASMARKS= 
u"ShowFormulasMarks";
 inline constexpr OUStringLiteral SC_UNO_SHOWOBJ  = u"ShowObjects";
 inline constexpr OUStringLiteral SC_UNO_SHOWPAGEBR   = 
u"ShowPageBreaks";
 inline constexpr OUStringLiteral SC_UNO_SHOWZERO = 
u"ShowZeroValues";
diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx
index 79819e7ca324..b5a15f016e1b 100644
--- a/sc/inc/viewopti.hxx
+++ b/sc/inc/viewopti.hxx
@@ -33,6 +33,7 @@ enum ScViewOption
 VOPT_NULLVALS,
 VOPT_SYNTAX,
 VOPT_NOTES,
+VOPT_FORMULAS_MARKS,
 VOPT_VSCROLL,
 VOPT_HSCROLL,
 VOPT_TABCONTROLS,
diff --git 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-03-03 Thread Kohei Yoshida (via logerrit)
 sc/inc/columnspanset.hxx  |1 +
 sc/source/core/data/columnspanset.cxx |4 
 2 files changed, 5 insertions(+)

New commits:
commit c4187189060a104cf36d8a8c9b2958b8c28cde0b
Author: Kohei Yoshida 
AuthorDate: Thu Mar 2 23:29:15 2023 -0500
Commit: Kohei Yoshida 
CommitDate: Fri Mar 3 16:10:21 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 

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: sc/inc sc/source

2023-02-27 Thread Kohei Yoshida (via logerrit)
 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 e83c243018c1c7f6662f9a8ecdc731c5c071ea31
Author: Kohei Yoshida 
AuthorDate: Tue Feb 21 22:16:30 2023 -0500
Commit: Kohei Yoshida 
CommitDate: Tue Feb 28 03:46:24 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 

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 c6b2f2289ddb..092d9ba0d9a9 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 
 #include 
 #include 
+#include 
 
 namespace sc {
 
@@ -113,6 +114,52 @@ InsertDeleteFlags CopyFromClipContext::getDeleteFlag() 
const

[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-24 Thread Noel Grandin (via logerrit)
 sc/inc/docpool.hxx  |4 
 sc/source/core/data/column.cxx  |2 --
 sc/source/core/data/column3.cxx |2 ++
 3 files changed, 2 insertions(+), 6 deletions(-)

New commits:
commit 3900f16e6939ba40f41b3ccd56a28f8275de318d
Author: Noel Grandin 
AuthorDate: Fri Feb 24 09:20:29 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Feb 24 12:37:38 2023 +

improved fix for CppunitTest_sc_uicalc

Revert the previous fix
(commit 0714dfe7fdb0cd3a49d4eb0e771da8eb4aa84d7a)
and implement a better fix, was just a stale pointer

Change-Id: I34006c2f387e2a16bcecef56ac9fb46a9669ebbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147620
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/docpool.hxx b/sc/inc/docpool.hxx
index 9a2e24796e80..9280fb3602b0 100644
--- a/sc/inc/docpool.hxx
+++ b/sc/inc/docpool.hxx
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include "scdllapi.h"
-#include 
 
 class ScStyleSheet;
 class ScDocument;
@@ -33,9 +32,6 @@ class SC_DLLPUBLIC ScDocumentPool final : public SfxItemPool
 sal_uInt64 mnCurrentMaxKey;
 
 public:
-// used when doing loading in parallel to prevent concurrent mutation of 
the pool
-std::mutex maPoolMutex;
-
 ScDocumentPool();
 private:
 virtual ~ScDocumentPool() override;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d2506074070b..fea2f84e5be0 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -624,8 +624,6 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& 
rAttr )
 
 ScDocumentPool* pDocPool = GetDoc().GetPool();
 
-std::unique_lock aGuard(pDocPool->maPoolMutex);
-
 const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow );
 ScPatternAttr aTemp(*pOldPattern);
 aTemp.GetItemSet().Put(rAttr);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index d92318134098..b0e22f98b3d1 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -867,6 +867,8 @@ bool ScColumn::UpdateScriptType( sc::CellTextAttr& rAttr, 
SCROW nRow, sc::CellSt
 
 SvNumberFormatter* pFormatter = rDocument.GetFormatTable();
 
+// fetch the pattern again, it might have changed under us
+pPattern = GetPattern(nRow);
 const Color* pColor;
 sal_uInt32 nFormat = pPattern->GetNumberFormat(pFormatter, pCondSet);
 OUString aStr = ScCellFormat::GetString(aCell, nFormat, , 
*pFormatter, rDocument);


[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-23 Thread Noel Grandin (via logerrit)
 sc/inc/docpool.hxx |4 
 sc/source/core/data/column.cxx |2 ++
 2 files changed, 6 insertions(+)

New commits:
commit cacd5a0cd263dbf072d5ad36dc651ad1e7df5826
Author: Noel Grandin 
AuthorDate: Thu Feb 23 14:03:58 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Feb 23 15:52:29 2023 +

attempted fix for CppunitTest_sc_uicalc

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
include/svl/setitem.hxx:47:51 in
=
==357324==ERROR: AddressSanitizer: heap-use-after-free on address 
0x60c001c9c340 at pc 0x7fa4bb883389 bp 0x7ffc2482f5f0 sp 0x7ffc2482f5e8
READ of size 2 at 0x60c001c9c340 thread T0
#1 in SfxItemSet::Get(unsigned short, bool) const 
svl/source/items/itemset.cxx:801:26
#2 in SfxUInt32Item const& 
SfxItemSet::Get(TypedWhichId, bool) const 
include/svl/itemset.hxx:102:38
#3 in (anonymous namespace)::getNumberFormatKey(SfxItemSet const&) 
sc/source/core/data/patattr.cxx:1291:17
#4 in ScPatternAttr::GetNumberFormat(SvNumberFormatter*, SfxItemSet 
const*) const sc/source/core/data/patattr.cxx:1335:19
#5 in ScColumn::UpdateScriptType() 
sc/source/core/data/column3.cxx:871:36
#6 in ScColumn::GetRangeScriptType(...) 
sc/source/core/data/column2.cxx:2338:17
#7 in ScTable::GetRangeScriptType(sc::ColumnBlockPosition&, short, int, 
int) sc/source/core/data/table1.cxx:2487:23
#8 in ScDocument::GetRangeScriptType(sc::ColumnBlockPosition&, 
ScAddress const&, int) sc/source/core/data/documen6.cxx:189:32
#9 in (anonymous namespace)::ScriptTypeAggregator::execute(ScAddress 
const&, int, bool) sc/source/core/data/documen6.cxx:175:31
#10 in sc::ColumnSpanSet::executeAction(ScDocument&, 
sc::ColumnSpanSet::Action&) const sc/source/core/data/columnspanset.cxx:176:20
#11 in ScDocument::GetRangeScriptType(ScRangeList const&) 
sc/source/core/data/documen6.cxx:206:10
#12 in ScViewFunc::GetSelectionScriptType() 
sc/source/ui/view/viewfunc.cxx:898:24
#13 in ScFormatShell::GetAttrState(SfxItemSet&) 
sc/source/ui/view/formatsh.cxx:2001:34
...
#61 in main2() sal/cppunittester/cppunittester.cxx:483:16

0x60c001c9c340 is located 64 bytes inside of 120-byte region 
[0x60c001c9c300,0x60c001c9c378)
freed by thread T0 here:
#0 in operator delete(void*, unsigned long) 
/home/noel/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:164:3
#1 in ScPatternAttr::~ScPatternAttr() sc/inc/patattr.hxx:53:20
#2 in SfxItemPool::Remove(SfxPoolItem const&) 
svl/source/items/itempool.cxx:805:13
#3 in ScAttrArray::SetPatternAreaImpl(int, int, ScPatternAttr const*, 
bool, ScEditDataArray*, bool) sc/source/core/data/attarray.cxx:574:31
#4 in ScAttrArray::SetPattern(int, ScPatternAttr const*, bool) 
sc/inc/attarray.hxx:148:7
#5 in ScColumn::ApplyAttr(int, SfxPoolItem const&) 
sc/source/core/data/column.cxx:633:21
#6 in ScColumn::SetNumberFormat(int, unsigned int) 
sc/source/core/data/column2.cxx:3282:5
#7 in ScTable::SetNumberFormat(short, int, unsigned int) 
sc/source/core/data/table2.cxx:2278:35
#8 in ScDocument::SetNumberFormat(ScAddress const&, unsigned int) 
sc/source/core/data/document.cxx:3739:19
#9 in ScFormulaCell::InterpretTail(ScInterpreterContext&, 
ScFormulaCell::ScInterpretTailParameter) 
sc/source/core/data/formulacell.cxx:2157:31
#10 in ScFormulaCell::Interpret(int, int) 
sc/source/core/data/formulacell.cxx:1619:13
#11 in ScFormulaCell::MaybeInterpret() sc/inc/formulacell.hxx:468:17
#12 in ScFormulaCell::IsValue() 
sc/source/core/data/formulacell.cxx:2760:5
#13 in lcl_GetCellContent(ScRefCellValue&, bool, double&, 
rtl::OUString&, ScDocument const*) sc/source/core/data/conditio.cxx:744:40
#14 in ScConditionEntry::IsCellValid(ScRefCellValue&, ScAddress const&) 
const sc/source/core/data/conditio.cxx:1243:17
#15 in ScConditionalFormat::GetCellStyle(ScRefCellValue&, ScAddress 
const&) const sc/source/core/data/conditio.cxx:1812:24
#16 in ScDocument::GetCondResult(ScRefCellValue&, ScAddress const&, 
ScConditionalFormatList const&, o3tl::sorted_vector, o3tl::find_unique, true> const&) const 
sc/source/core/data/documen4.cxx:828:41
#17 in ScColumn::UpdateScriptType(sc::CellTextAttr&, int, 
mdds::mtv::soa::detail::iterator_base::iterator_trait>&)
 sc/source/core/data/column3.cxx:865:30
#18 in ScColumn::GetRangeScriptType(int, 
mdds::mtv::soa::detail::iterator_base::iterator_trait>
 const&) sc/source/core/data/column2.cxx:2338:17
#19 in ScTable::GetRangeScriptType(sc::ColumnBlockPosition&, short, 
int, int)
sc/source/core/data/table1.cxx:2487:23

previously allocated by thread T60 here:
#0 in operator new(unsigned long) 
/home/noel/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:95:3
#1 in 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-14 Thread Noel Grandin (via logerrit)
 sc/inc/fielduno.hxx  |5 ++---
 sc/source/ui/unoobj/fielduno.cxx |   26 +++---
 2 files changed, 17 insertions(+), 14 deletions(-)

New commits:
commit 93059e2b164bd5eea4898519e45f1001f299c4ae
Author: Noel Grandin 
AuthorDate: Tue Feb 14 10:26:18 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Feb 14 14:24:44 2023 +

osl::Mutex->std::mutex in ScCellFieldsObj

Change-Id: I7e9a95d093573d786b97f79f9f3b1f18c424fd8e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146973
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index fc5ae6d15446..7cf455c7bcc3 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -61,9 +60,9 @@ private:
 ScAddress   aCellPos;
 std::unique_ptr mpEditSource;
 /// List of refresh listeners.
-
std::unique_ptr>
 mpRefreshListeners;
+
std::unique_ptr>
 mpRefreshListeners;
 /// mutex to lock the InterfaceContainerHelper
-osl::Mutex  aMutex;
+std::mutex  aMutex;
 
 css::uno::Reference
 GetObjectByIndex_Impl(sal_Int32 Index) const;
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index afc27560c1fe..2a05a24fab75 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -276,21 +276,24 @@ ScCellFieldsObj::ScCellFieldsObj(
 
 ScCellFieldsObj::~ScCellFieldsObj()
 {
-SolarMutexGuard g;
+{
+SolarMutexGuard g;
 
-if (pDocShell)
-pDocShell->GetDocument().RemoveUnoObject(*this);
+if (pDocShell)
+pDocShell->GetDocument().RemoveUnoObject(*this);
 
-mpEditSource.reset();
+mpEditSource.reset();
+}
 
 // increment refcount to prevent double call off dtor
 osl_atomic_increment( _refCount );
 
+std::unique_lock g(aMutex);
 if (mpRefreshListeners)
 {
 lang::EventObject aEvent;
 aEvent.Source.set(static_cast(this));
-mpRefreshListeners->disposeAndClear(aEvent);
+mpRefreshListeners->disposeAndClear(g, aEvent);
 mpRefreshListeners.reset();
 }
 }
@@ -383,12 +386,13 @@ void SAL_CALL ScCellFieldsObj::removeContainerListener(
 // XRefreshable
 void SAL_CALL ScCellFieldsObj::refresh(  )
 {
+std::unique_lock g(aMutex);
 if (mpRefreshListeners)
 {
 //  Call all listeners.
 lang::EventObject aEvent;
 aEvent.Source.set(uno::Reference< util::XRefreshable >(this));
-mpRefreshListeners->notifyEach( ::XRefreshListener::refreshed, 
aEvent );
+mpRefreshListeners->notifyEach( g, ::XRefreshListener::refreshed, 
aEvent );
 }
 }
 
@@ -396,10 +400,10 @@ void SAL_CALL ScCellFieldsObj::addRefreshListener( const 
uno::Reference< util::X
 {
 if (xListener.is())
 {
-SolarMutexGuard aGuard;
+std::unique_lock g(aMutex);
 if (!mpRefreshListeners)
-mpRefreshListeners.reset( new 
comphelper::OInterfaceContainerHelper3(aMutex) );
-mpRefreshListeners->addInterface(xListener);
+mpRefreshListeners.reset( new 
comphelper::OInterfaceContainerHelper4() );
+mpRefreshListeners->addInterface(g, xListener);
 }
 }
 
@@ -407,9 +411,9 @@ void SAL_CALL ScCellFieldsObj::removeRefreshListener( const 
uno::ReferenceremoveInterface(xListener);
+mpRefreshListeners->removeInterface(g, xListener);
 }
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-10 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 208a4ecafafa97ea7fcc5a135fa8160e91ea0a74
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 16:04:46 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Feb 10 16:33:20 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 

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 (bNotify)
-{
-ScRange aRange(aPos);
-ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 );
-

[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-08 Thread Noel Grandin (via logerrit)
 sc/inc/externalrefmgr.hxx|4 ++-
 sc/source/ui/docshell/externalrefmgr.cxx |   41 +--
 2 files changed, 26 insertions(+), 19 deletions(-)

New commits:
commit 6f1dd12d808a41ca70d4a33787f1bdff9d44a5ac
Author: Noel Grandin 
AuthorDate: Thu Feb 2 09:32:43 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Feb 8 17:30:59 2023 +

osl::Mutex->std::mutex in ScExternalRefCache

Change-Id: I3736683d0a7d20694ac2375016c722b4233fdcae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146555
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 02a0b28e11f1..238c4a1d0f57 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -34,6 +34,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -360,9 +361,10 @@ private:
 };
 typedef std::unordered_map  DocDataType;
 DocItem* getDocItem(sal_uInt16 nFileId) const;
+DocItem* getDocItem(std::unique_lock& rGuard, sal_uInt16 
nFileId) const;
 
 private:
-mutable osl::Mutex maMtxDocs;
+mutable std::mutex maMtxDocs;
 mutable DocDataType maDocs;
 const ScDocument& mrDoc;
 };
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx 
b/sc/source/ui/docshell/externalrefmgr.cxx
index 933cc1ad5b11..7ba8527db28a 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -491,7 +491,7 @@ ScExternalRefCache::~ScExternalRefCache() {}
 
 const OUString* ScExternalRefCache::getRealTableName(sal_uInt16 nFileId, const 
OUString& rTabName) const
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
 DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
 if (itrDoc == maDocs.end())
@@ -513,7 +513,7 @@ const OUString* 
ScExternalRefCache::getRealTableName(sal_uInt16 nFileId, const O
 
 const OUString* ScExternalRefCache::getRealRangeName(sal_uInt16 nFileId, const 
OUString& rRangeName) const
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
 DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
 if (itrDoc == maDocs.end())
@@ -535,7 +535,7 @@ const OUString* 
ScExternalRefCache::getRealRangeName(sal_uInt16 nFileId, const O
 ScExternalRefCache::TokenRef ScExternalRefCache::getCellData(
 sal_uInt16 nFileId, const OUString& rTabName, SCCOL nCol, SCROW nRow, 
sal_uInt32* pnFmtIndex)
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
 DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
 if (itrDoc == maDocs.end())
@@ -565,7 +565,7 @@ ScExternalRefCache::TokenRef 
ScExternalRefCache::getCellData(
 ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
 sal_uInt16 nFileId, const OUString& rTabName, const ScRange& rRange)
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
 DocDataType::iterator itrDoc = maDocs.find(nFileId);
 if (itrDoc == maDocs.end())
@@ -735,9 +735,9 @@ ScExternalRefCache::TokenArrayRef 
ScExternalRefCache::getCellRangeData(
 
 ScExternalRefCache::TokenArrayRef 
ScExternalRefCache::getRangeNameTokens(sal_uInt16 nFileId, const OUString& 
rName)
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
-DocItem* pDoc = getDocItem(nFileId);
+DocItem* pDoc = getDocItem(aGuard, nFileId);
 if (!pDoc)
 return TokenArrayRef();
 
@@ -752,9 +752,9 @@ ScExternalRefCache::TokenArrayRef 
ScExternalRefCache::getRangeNameTokens(sal_uIn
 
 void ScExternalRefCache::setRangeNameTokens(sal_uInt16 nFileId, const 
OUString& rName, TokenArrayRef pArray)
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
-DocItem* pDoc = getDocItem(nFileId);
+DocItem* pDoc = getDocItem(aGuard, nFileId);
 if (!pDoc)
 return;
 
@@ -766,9 +766,9 @@ void ScExternalRefCache::setRangeNameTokens(sal_uInt16 
nFileId, const OUString&
 
 bool ScExternalRefCache::isValidRangeName(sal_uInt16 nFileId, const OUString& 
rName) const
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
-DocItem* pDoc = getDocItem(nFileId);
+DocItem* pDoc = getDocItem(aGuard, nFileId);
 if (!pDoc)
 return false;
 
@@ -779,9 +779,9 @@ bool ScExternalRefCache::isValidRangeName(sal_uInt16 
nFileId, const OUString& rN
 
 void ScExternalRefCache::setRangeName(sal_uInt16 nFileId, const OUString& 
rName)
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
-DocItem* pDoc = getDocItem(nFileId);
+DocItem* pDoc = getDocItem(aGuard, nFileId);
 if (!pDoc)
 return;
 
@@ -1103,7 +1103,7 @@ SCTAB ScExternalRefCache::getTabSpan( sal_uInt16 nFileId, 
const OUString& rStart
 
 void ScExternalRefCache::getAllNumberFormats(vector& rNumFmts) 
const
 {
-osl::MutexGuard aGuard();
+std::unique_lock aGuard(maMtxDocs);
 
 using ::std::sort;
 using ::std::unique;
@@ 

[Libreoffice-commits] core.git: sc/inc sc/source

2023-02-05 Thread Balazs Varga (via logerrit)
 sc/inc/validat.hxx  |4 
 sc/source/core/data/validat.cxx |  196 +++-
 2 files changed, 79 insertions(+), 121 deletions(-)

New commits:
commit d8ae6d1388f28c405c4de2dfe93dbfe2d8acd470
Author: Balazs Varga 
AuthorDate: Tue Jan 31 14:21:31 2023 +0100
Commit: Balazs Varga 
CommitDate: Sun Feb 5 10:31:26 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 

diff --git a/sc/inc/validat.hxx b/sc/inc/validat.hxx
index f28da4a1c50b..af43e37cc123 100644
--- a/sc/inc/validat.hxx
+++ b/sc/inc/validat.hxx
@@ -156,6 +156,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 2cdafa132594..8fb0f9f7924a 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -447,67 +447,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
 {
@@ -602,69 +547,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() <= 1)
-{   // ==1: area
-// ==0: would be an area if...
-OUString aBraced = "(" + rTest + ")";
-

[Libreoffice-commits] core.git: sc/inc sc/source

2023-01-22 Thread Noel Grandin (via logerrit)
 sc/inc/styleuno.hxx  |5 -
 sc/source/ui/unoobj/styleuno.cxx |6 +-
 2 files changed, 1 insertion(+), 10 deletions(-)

New commits:
commit b127033bf40fb912c35bfb8a659227b749a40ac2
Author: Noel Grandin 
AuthorDate: Sat Jan 21 21:18:28 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Jan 23 07:27:58 2023 +

XUnoTunnel->dynamic_cast in ScStyleObj

Change-Id: I1021cddc87546635b147bbdf5f48948565815873
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145983
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/styleuno.hxx b/sc/inc/styleuno.hxx
index b09a95b71960..d19feed3563a 100644
--- a/sc/inc/styleuno.hxx
+++ b/sc/inc/styleuno.hxx
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -161,7 +160,6 @@ class ScStyleObj final : public ::cppu::WeakImplHelper<
 css::beans::XMultiPropertySet,
 css::beans::XPropertyState,
 css::beans::XMultiPropertyStates,
-css::lang::XUnoTunnel,
 css::lang::XServiceInfo >,
 public SfxListener
 {
@@ -262,9 +260,6 @@ public:
 virtual OUString SAL_CALL getImplementationName() override;
 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
-
-// XUnoTunnel
-UNO3_GETIMPLEMENTATION_DECL(ScStyleObj)
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index 4e60223ad0df..cddff8c73d00 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -677,7 +677,7 @@ void SAL_CALL ScStyleFamilyObj::insertByName( const 
OUString& aName, const uno::
 uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
 if ( xInterface.is() )
 {
-ScStyleObj* pStyleObj = comphelper::getFromUnoTunnel( 
xInterface );
+ScStyleObj* pStyleObj = dynamic_cast( xInterface.get() );
 if ( pStyleObj && pStyleObj->GetFamily() == eFamily &&
 !pStyleObj->IsInserted() )  // not yet inserted?
 {
@@ -962,10 +962,6 @@ ScStyleObj::~ScStyleObj()
 pDocShell->GetDocument().RemoveUnoObject(*this);
 }
 
-// XUnoTunnel
-
-UNO3_GETIMPLEMENTATION_IMPL(ScStyleObj);
-
 void ScStyleObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
 {
 //  reference update does not matter here


[Libreoffice-commits] core.git: sc/inc sc/source

2023-01-22 Thread Noel Grandin (via logerrit)
 sc/inc/datauno.hxx   |5 -
 sc/source/ui/unoobj/cellsuno.cxx |2 +-
 sc/source/ui/unoobj/datauno.cxx  |4 
 3 files changed, 1 insertion(+), 10 deletions(-)

New commits:
commit 2f141c05a7205db660e79673ad2676e19d50583d
Author: Noel Grandin 
AuthorDate: Sat Jan 21 14:46:57 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Jan 23 06:34:10 2023 +

XUnoTunnel->dynamic_cast in ScSubTotalDescriptorBase

Change-Id: I45b15bf9a9be2de82b86701cd3af5c4f8c6fff13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145980
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index 528496380806..f2ee6b674129 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -110,7 +109,6 @@ class ScSubTotalDescriptorBase : public 
cppu::WeakImplHelper<
 css::container::XEnumerationAccess,
 css::container::XIndexAccess,
 css::beans::XPropertySet,
-css::lang::XUnoTunnel,
 css::lang::XServiceInfo >
 {
 private:
@@ -160,9 +158,6 @@ public:
 virtual void SAL_CALL   removeVetoableChangeListener( const OUString& 
PropertyName,
 const css::uno::Reference< 
css::beans::XVetoableChangeListener >& aListener ) override;
 
-// XUnoTunnel
-UNO3_GETIMPLEMENTATION_DECL(ScSubTotalDescriptorBase)
-
 // XServiceInfo
 virtual OUString SAL_CALL getImplementationName() override;
 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 5d44da0d8fca..69f4cbd5e61f 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5526,7 +5526,7 @@ void SAL_CALL ScCellRangeObj::applySubTotals(
 
 ScDocShell* pDocSh = GetDocShell();
 ScSubTotalDescriptorBase* pImp =
-comphelper::getFromUnoTunnel( xDescriptor );
+dynamic_cast( xDescriptor.get() );
 
 if (!(pDocSh && pImp))
 return;
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index ee285d662b7c..5d4dc4761cbd 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -731,10 +731,6 @@ uno::Any SAL_CALL 
ScSubTotalDescriptorBase::getPropertyValue( const OUString& aP
 
 SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSubTotalDescriptorBase )
 
-// XUnoTunnel
-
-UNO3_GETIMPLEMENTATION_IMPL(ScSubTotalDescriptorBase);
-
 ScSubTotalDescriptor::ScSubTotalDescriptor()
 {
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2023-01-17 Thread Noel Grandin (via logerrit)
 sc/inc/dapiuno.hxx|   13 ++---
 sc/source/filter/oox/pivottablebuffer.cxx |2 +-
 sc/source/ui/unoobj/dapiuno.cxx   |   16 +---
 3 files changed, 4 insertions(+), 27 deletions(-)

New commits:
commit 8446cac7d39d3f09f9dd0d5b513ceb96184b0da8
Author: Noel Grandin 
AuthorDate: Mon Jan 16 14:02:15 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jan 17 14:45:46 2023 +

XUnoTunnel->dynamic_cast in ScDataPilotDescriptorBase

Change-Id: I493d3fbd5eabb70804bd44affefdd705118f8185
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145635
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index e10cf45f97e1..88c24ce1a4dc 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -26,7 +26,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -128,13 +127,11 @@ public:
 };
 
 //  ScDataPilotDescriptorBase is never instantiated directly
-class SAL_DLLPUBLIC_RTTI ScDataPilotDescriptorBase :
-  public cppu::WeakImplHelper<
+class SC_DLLPUBLIC ScDataPilotDescriptorBase : public cppu::WeakImplHelper<
 css::sheet::XDataPilotDescriptor,
 css::beans::XPropertySet,
 
css::sheet::XDataPilotDataLayoutFieldSupplier,
-css::lang::XServiceInfo,
-css::lang::XUnoTunnel>,
+css::lang::XServiceInfo>,
   public SfxListener
 {
 private:
@@ -193,12 +190,6 @@ public:
 virtual css::uno::Reference< css::sheet::XDataPilotField >
 SAL_CALL getDataLayoutField() override;
 
-// XUnoTunnel
-virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence<
-sal_Int8 >& aIdentifier ) override;
-
-SC_DLLPUBLIC static const css::uno::Sequence& getUnoTunnelId();
-
 // XServiceInfo is in derived classes
 };
 
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index d57c17571282..e936d0fadd87 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -1241,7 +1241,7 @@ void PivotTable::finalizeImport()
 mxDPDescriptor->setTag( maDefModel.maTag );
 
 // TODO: This is a hack. Eventually we need to convert the whole thing 
to the internal API.
-auto pImpl = 
comphelper::getFromUnoTunnel(mxDPDescriptor);
+auto pImpl = 
dynamic_cast(mxDPDescriptor.get());
 if (!pImpl)
 return;
 
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 4be1c767fad0..7247b655bf23 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -414,7 +414,7 @@ void SAL_CALL ScDataPilotTablesObj::insertNewByName( const 
OUString& aNewName,
 if (!pDocShell)
 throw RuntimeException("DocShell is null", 
static_cast(this));
 
-auto pImp = comphelper::getFromUnoTunnel( 
xDescriptor );
+auto pImp = dynamic_cast( xDescriptor.get() );
 if (!pImp)
 throw RuntimeException("Failed to get ScDataPilotDescriptor", 
static_cast(this));
 
@@ -973,20 +973,6 @@ Reference< XDataPilotField > SAL_CALL 
ScDataPilotDescriptorBase::getDataLayoutFi
 return nullptr;
 }
 
-// XUnoTunnel
-
-sal_Int64 SAL_CALL ScDataPilotDescriptorBase::getSomething(
-const Sequence& rId )
-{
-return comphelper::getSomethingImpl(rId, this);
-}
-
-const Sequence& ScDataPilotDescriptorBase::getUnoTunnelId()
-{
-static const comphelper::UnoIdInit theScDataPilotDescriptorBaseUnoTunnelId;
-return theScDataPilotDescriptorBaseUnoTunnelId.getSeq();
-}
-
 ScDataPilotTableObj::ScDataPilotTableObj(ScDocShell& rDocSh, SCTAB nT, 
OUString aN) :
 ScDataPilotDescriptorBase( rDocSh ),
 nTab( nT ),


[Libreoffice-commits] core.git: sc/inc sc/source

2023-01-17 Thread Noel Grandin (via logerrit)
 sc/inc/nameuno.hxx  |7 ---
 sc/source/ui/unoobj/nameuno.cxx |   14 --
 sc/source/ui/vba/vbaname.cxx|4 ++--
 3 files changed, 2 insertions(+), 23 deletions(-)

New commits:
commit 87d0f136dede84f694240f55a958d94e3d0fe9ce
Author: Noel Grandin 
AuthorDate: Mon Jan 16 14:05:19 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jan 17 11:28:43 2023 +

XUnoTunnel->dynamic_cast in ScNamedRangeObj

Change-Id: Ib298d8ba676f5a6ddf3fe9b7a49dc45c46d7adbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145636
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/nameuno.hxx b/sc/inc/nameuno.hxx
index 4cd5423cfc0b..ee37dc365d2f 100644
--- a/sc/inc/nameuno.hxx
+++ b/sc/inc/nameuno.hxx
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -47,7 +46,6 @@ class SC_DLLPUBLIC ScNamedRangeObj final : public 
::cppu::WeakImplHelper<
 css::sheet::XFormulaTokens,
 css::sheet::XCellRangeReferrer,
 css::beans::XPropertySet,
-css::lang::XUnoTunnel,
 css::lang::XServiceInfo >,
 public SfxListener
 {
@@ -109,11 +107,6 @@ public:
 virtual void SAL_CALL   removeVetoableChangeListener( const OUString& 
PropertyName,
 const css::uno::Reference< 
css::beans::XVetoableChangeListener >& aListener ) override;
 
-/// XUnoTunnel
-virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< 
sal_Int8 >& aIdentifier ) override;
-
-static const css::uno::Sequence& getUnoTunnelId();
-
 /// XServiceInfo
 virtual OUString SAL_CALL getImplementationName() override;
 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 6d6a56a6d85b..a49748b1a951 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -419,20 +419,6 @@ uno::Sequence SAL_CALL 
ScNamedRangeObj::getSupportedServiceNames()
 return {SCNAMEDRANGEOBJ_SERVICE, SCLINKTARGET_SERVICE};
 }
 
-// XUnoTunnel
-
-sal_Int64 SAL_CALL ScNamedRangeObj::getSomething(
-const uno::Sequence& rId )
-{
-return comphelper::getSomethingImpl(rId, this);
-}
-
-const uno::Sequence& ScNamedRangeObj::getUnoTunnelId()
-{
-static const comphelper::UnoIdInit theScNamedRangeObjUnoTunnelId;
-return theScNamedRangeObjUnoTunnelId.getSeq();
-}
-
 ScNamedRangesObj::ScNamedRangesObj(ScDocShell* pDocSh) :
 mbModifyAndBroadcast(true),
 pDocShell( pDocSh )
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index ec0dbe982d28..98a242401e7d 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -87,7 +87,7 @@ ScVbaName::setVisible( sal_Bool /*bVisible*/ )
 
 OUString ScVbaName::getContent( const formula::FormulaGrammar::Grammar 
eGrammar )
 {
-ScNamedRangeObj* pNamedRange = comphelper::getFromUnoTunnel< 
ScNamedRangeObj >( mxNamedRange );
+ScNamedRangeObj* pNamedRange = dynamic_cast< ScNamedRangeObj* >( 
mxNamedRange.get() );
 OUString aContent;
 if ( pNamedRange )
 {
@@ -105,7 +105,7 @@ void  ScVbaName::setContent( const OUString& rContent, 
const formula::FormulaGra
 OUString sContent( rContent );
 if (sContent.startsWith("="))
 sContent = sContent.copy(1);
-ScNamedRangeObj* pNamedRange = comphelper::getFromUnoTunnel< 
ScNamedRangeObj >( mxNamedRange );
+ScNamedRangeObj* pNamedRange = dynamic_cast< ScNamedRangeObj* >( 
mxNamedRange.get() );
 
 // We should be able to do the below by just setting calling SetCode on 
pNamedRange
 // right?


[Libreoffice-commits] core.git: sc/inc sc/source

2023-01-05 Thread Arnaud VERSINI (via logerrit)
 sc/inc/compiler.hxx  |1 -
 sc/source/core/tool/compiler.cxx |   12 +---
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 3ab8349a37215d8e355e79b93d66f631144e7c57
Author: Arnaud VERSINI 
AuthorDate: Sat Dec 31 19:22:03 2022 +0100
Commit: Eike Rathke 
CommitDate: Thu Jan 5 22:13:35 2023 +

sc : use std::mutex for CharClass initialisation

Change-Id: I0427109da1bfed1d3d467455ab1ab3c68569f60b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144886
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0097486c223c..fbf5073743e1 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -258,7 +258,6 @@ public:
 
 private:
 
-static osl::Mutex   maMutex;
 static const CharClass  *pCharClassEnglish; // character 
classification for en_US locale
 static const CharClass  *pCharClassLocalized;   // character 
classification for UI locale
 static const Convention *pConventions[ 
formula::FormulaGrammar::CONV_LAST ];
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 371ee5aad209..f3861e4ddbbe 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -21,6 +21,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -77,7 +78,6 @@ using namespace formula;
 using namespace ::com::sun::star;
 using ::std::vector;
 
-osl::Mutex  ScCompiler::maMutex;
 const CharClass*ScCompiler::pCharClassEnglish = nullptr;
 const CharClass*ScCompiler::pCharClassLocalized = nullptr;
 const ScCompiler::Convention*   ScCompiler::pConventions[ ]   = { nullptr, 
nullptr, nullptr, nullptr, nullptr, nullptr };
@@ -222,11 +222,17 @@ bool ScCompiler::IsEnglishSymbol( const OUString& rName )
 return !aIntName.isEmpty();   // no valid function name
 }
 
+static std::mutex& getCharClassMutex()
+{
+static std::mutex aMutex;
+return aMutex;
+}
+
 const CharClass* ScCompiler::GetCharClassEnglish()
 {
 if (!pCharClassEnglish)
 {
-osl::MutexGuard aGuard(maMutex);
+std::scoped_lock aGuard(getCharClassMutex());
 if (!pCharClassEnglish)
 {
 pCharClassEnglish = new CharClass( 
::comphelper::getProcessComponentContext(),
@@ -242,7 +248,7 @@ const CharClass* ScCompiler::GetCharClassLocalized()
 {
 // Switching UI language requires restart; if not, we would have to
 // keep track of that.
-osl::MutexGuard aGuard(maMutex);
+std::scoped_lock aGuard(getCharClassMutex());
 if (!pCharClassLocalized)
 {
 pCharClassLocalized = new CharClass( 
::comphelper::getProcessComponentContext(),


[Libreoffice-commits] core.git: sc/inc sc/source

2022-12-22 Thread Rafael Lima (via logerrit)
 sc/inc/globstr.hrc |9 -
 sc/source/core/data/table3.cxx |   26 +-
 2 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit f5b3bfbded8ea8d4a0b854a62c82b66747b45833
Author: Rafael Lima 
AuthorDate: Wed Dec 21 14:10:32 2022 +
Commit: Olivier Hallot 
CommitDate: Thu Dec 22 08:11:29 2022 +

tdf#152535 Provide better localization for "Grand" subtotal strings

As discussed in the bug report, having the word "Grand" hardcoded first in 
subtotals is not great for translation, since for some languages the 
translation of "grand" would come second.

This patch creates separate strings for each case of Grand, f.i. "Grand 
Count", "Grand Sum" and so on. Now each of them will have their own translation.

Change-Id: Ib875bc1a7b2fcc8934ad85bfe09374f8d9d9a179
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144666
Tested-by: Jenkins
Reviewed-by: Olivier Hallot 

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index e1f1a485eed0..19e99d1c47d0 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -138,7 +138,6 @@
 #define STR_MSSG_SOLVE_2NC_("STR_MSSG_SOLVE_2", "Goal 
Seek failed.\n\n")
 #define STR_MSSG_SOLVE_3NC_("STR_MSSG_SOLVE_3", 
"Insert the closest value (")
 #define STR_MSSG_SOLVE_4NC_("STR_MSSG_SOLVE_4", ") 
into the variable cell anyway?")
-#define STR_TABLE_GRAND NC_("STR_TABLE_GRAND", "Grand")
 #define STR_TABLE_ERGEBNIS  NC_("STR_TABLE_ERGEBNIS", 
"Result")
 #define STR_UNDO_SPELLING   NC_("STR_UNDO_SPELLING", 
"Spellcheck")
 #define STR_TABLE_AND   NC_("STR_TABLE_AND", "AND")
@@ -196,6 +195,14 @@
 #define STR_FUN_TEXT_PRODUCTNC_("STR_FUN_TEXT_PRODUCT", 
"Product")
 #define STR_FUN_TEXT_STDDEV NC_("STR_FUN_TEXT_STDDEV", 
"StDev")
 #define STR_FUN_TEXT_VARNC_("STR_FUN_TEXT_VAR", "Var")
+#define STR_TABLE_GRAND_AVG NC_("STR_TABLE_GRAND_AVG", 
"Grand Average")
+#define STR_TABLE_GRAND_COUNT   NC_("STR_TABLE_GRAND_COUNT", 
"Grand Count")
+#define STR_TABLE_GRAND_MAX NC_("STR_TABLE_GRAND_MAX", 
"Grand Max")
+#define STR_TABLE_GRAND_MIN NC_("STR_TABLE_GRAND_MIN", 
"Grand Min")
+#define STR_TABLE_GRAND_PRODUCT NC_("STR_TABLE_GRAND_PRODUCT", 
"Grand Product")
+#define STR_TABLE_GRAND_STDDEV  NC_("STR_TABLE_GRAND_STDDEV", 
"Grand StdDev")
+#define STR_TABLE_GRAND_SUM NC_("STR_TABLE_GRAND_SUM", 
"Grand Sum")
+#define STR_TABLE_GRAND_VAR NC_("STR_TABLE_GRAND_VAR", 
"Grand Var")
 #define STR_NOCHARTATCURSOR NC_("STR_NOCHARTATCURSOR", "No 
chart found at this position.")
 #define STR_PIVOT_NOTFOUND  NC_("STR_PIVOT_NOTFOUND", "No 
pivot table found at this position.")
 #define STR_EMPTYDATA   NC_("STR_EMPTYDATA", "(empty)")
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bdf16a69aad4..a535726fd8fc 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2058,6 +2058,30 @@ static TranslateId lcl_GetSubTotalStrId(int id)
 }
 }
 
+// Gets the string used for "Grand" results
+static TranslateId lcl_GetGrandSubTotalStrId(int id)
+{
+switch ( id )
+{
+case SUBTOTAL_FUNC_AVE: return STR_TABLE_GRAND_AVG;
+case SUBTOTAL_FUNC_CNT:
+case SUBTOTAL_FUNC_CNT2:return STR_TABLE_GRAND_COUNT;
+case SUBTOTAL_FUNC_MAX: return STR_TABLE_GRAND_MAX;
+case SUBTOTAL_FUNC_MIN: return STR_TABLE_GRAND_MIN;
+case SUBTOTAL_FUNC_PROD:return STR_TABLE_GRAND_PRODUCT;
+case SUBTOTAL_FUNC_STD:
+case SUBTOTAL_FUNC_STDP:return STR_TABLE_GRAND_STDDEV;
+case SUBTOTAL_FUNC_SUM: return STR_TABLE_GRAND_SUM;
+case SUBTOTAL_FUNC_VAR:
+case SUBTOTAL_FUNC_VARP:return STR_TABLE_GRAND_VAR;
+default:
+{
+ return STR_EMPTYDATA;
+// added to avoid warnings
+}
+}
+}
+
 //  new intermediate results
 //  rParam.nRow2 is changed!
 
@@ -2264,7 +2288,7 @@ bool ScTable::DoSubTotals( ScSubTotalParam& rParam )
 DBShowRow(aRowEntry.nDestRow, true);
 
 // insert label
-OUString label = ScResId(STR_TABLE_GRAND) + " " + 
ScResId(lcl_GetSubTotalStrId(pResFunc[0]));
+OUString label = 
ScResId(lcl_GetGrandSubTotalStrId(pResFunc[0]));
 SetString(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, 
nTab, label);
 ApplyStyle(nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, 
pStyle);
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-12-11 Thread Caolán McNamara (via logerrit)
 sc/inc/globstr.hrc   |2 +-
 sc/source/ui/docshell/docsh4.cxx |5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 4af3a2998dd36a940f741b335e8327da2a4dead9
Author: Caolán McNamara 
AuthorDate: Sun Dec 11 16:23:07 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Dec 11 19:25:32 2022 +

reuse RID_SECURITY_WARNING_TITLE for update links infobar

Change-Id: Ifbfb10ee373b8eca8e1019f999ac8e545f180c97
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143942
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();


[Libreoffice-commits] core.git: sc/inc sc/source

2022-12-08 Thread Eike Rathke (via logerrit)
 sc/inc/document.hxx |2 ++
 sc/source/core/data/clipcontext.cxx |8 ++--
 sc/source/core/data/column4.cxx |5 +
 sc/source/core/data/documen2.cxx|   11 +++
 4 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 17b302b092b5c90552720097fe87c8eedc8f83df
Author: Eike Rathke 
AuthorDate: Wed Dec 7 22:05:15 2022 +0100
Commit: Eike Rathke 
CommitDate: Thu Dec 8 12:24:47 2022 +

Related: tdf#120190 Factor out ScDocument::CreateSharedStringTextObject()

Change-Id: I51c1244406e30f5a3893eac42aed65fc92ab1d38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143805
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cd7e08b0dde4..20e42a999ac8 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2510,6 +2510,8 @@ public:
 SC_DLLPUBLIC ScFieldEditEngine& GetEditEngine();
 SC_DLLPUBLIC ScNoteEditEngine&  GetNoteEngine();
 
+std::unique_ptr CreateSharedStringTextObject( const 
svl::SharedString& rSS );
+
 std::unique_ptr const & 
GetRefreshTimerControlAddress() const
{ return pRefreshTimerControl; }
 
diff --git a/sc/source/core/data/clipcontext.cxx 
b/sc/source/core/data/clipcontext.cxx
index ee97d315077b..d291c7c91f49 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -253,12 +253,8 @@ void CopyFromClipContext::setSingleCell( const ScAddress& 
rSrcPos, const ScColum
 // Turn this into a string or edit cell.
 if (rSrcCell.getFormula()->IsMultilineResult())
 {
-// TODO : Add shared string support to the edit engine to
-// make this process simpler.
-ScFieldEditEngine& rEngine = mrDestDoc.GetEditEngine();
-
rEngine.SetTextCurrentDefaults(rSrcCell.getFormula()->GetString().getString());
-std::unique_ptr 
pObj(rEngine.CreateTextObject());
-pObj->NormalizeString(mrDestDoc.GetSharedStringPool());
+std::unique_ptr 
pObj(mrDestDoc.CreateSharedStringTextObject(
+rSrcCell.getFormula()->GetString()));
 rSrcCell.set(*pObj);
 }
 else
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 83123dffd88b..0de5deff335c 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -501,10 +501,7 @@ public:
 case sc::FormulaResultValue::String:
 if (aRes.mbMultiLine)
 {
-ScFieldEditEngine& rEngine = mrDoc.GetEditEngine();
-rEngine.SetTextCurrentDefaults(aRes.maString.getString());
-std::unique_ptr 
pObj(rEngine.CreateTextObject());
-pObj->NormalizeString(mrDoc.GetSharedStringPool());
+std::unique_ptr 
pObj(mrDoc.CreateSharedStringTextObject(aRes.maString));
 maResValues.setValue(nRow, std::move(pObj));
 }
 else
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index af4629d7aef3..e21da4be599b 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -511,6 +511,17 @@ ScNoteEditEngine& ScDocument::GetNoteEngine()
 return *mpNoteEngine;
 }
 
+std::unique_ptr ScDocument::CreateSharedStringTextObject( 
const svl::SharedString& rSS )
+{
+/* TODO: Add shared string support to the edit engine to make this process
+ * simpler. */
+ScFieldEditEngine& rEngine = GetEditEngine();
+rEngine.SetTextCurrentDefaults( rSS.getString());
+std::unique_ptr pObj( rEngine.CreateTextObject());
+pObj->NormalizeString( GetSharedStringPool());
+return pObj;
+}
+
 void ScDocument::ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks )
 {
 if (bIsClip)


[Libreoffice-commits] core.git: sc/inc sc/source

2022-12-07 Thread Eike Rathke (via logerrit)
 sc/inc/cellvalues.hxx |3 +++
 sc/inc/formularesult.hxx  |3 ++-
 sc/source/core/data/cellvalues.cxx|7 +++
 sc/source/core/data/column4.cxx   |   22 ++
 sc/source/core/tool/formularesult.cxx |4 ++--
 5 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 40a59e3e58de1c3f60ae52d09fbc386399f8f122
Author: Eike Rathke 
AuthorDate: Wed Dec 7 21:22:41 2022 +0100
Commit: Eike Rathke 
CommitDate: Wed Dec 7 23:41:51 2022 +

Resolves: tdf#120190 Handle multiline string in Formula to Value conversion

... as usual as EditTextObject.

Change-Id: Iddb52593851dcf371318f29318902ae8d4b483d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143801
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/cellvalues.hxx b/sc/inc/cellvalues.hxx
index 0043d65270e6..352a152ec891 100644
--- a/sc/inc/cellvalues.hxx
+++ b/sc/inc/cellvalues.hxx
@@ -15,6 +15,7 @@
 
 class ScColumn;
 class ScFormulaCell;
+class EditTextObject;
 
 namespace svl
 {
@@ -69,6 +70,8 @@ public:
 void reset(size_t nSize);
 void setValue(size_t nRow, double fVal);
 void setValue(size_t nRow, const svl::SharedString& rStr);
+/// Takes ownership of pEditText.
+void setValue(size_t nRow, std::unique_ptr pEditText);
 
 void swap(CellValues& r);
 
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index ff036a78bcb3..581d9a4bba3d 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -35,12 +35,13 @@ struct FormulaResultValue
 
 double mfValue;
 svl::SharedString maString;
+bool mbMultiLine = false;
 Type meType;
 FormulaError mnError;
 
 FormulaResultValue();
 FormulaResultValue( double fValue );
-FormulaResultValue( svl::SharedString aStr );
+FormulaResultValue( svl::SharedString aStr, bool bMultiLine );
 FormulaResultValue( FormulaError nErr );
 };
 
diff --git a/sc/source/core/data/cellvalues.cxx 
b/sc/source/core/data/cellvalues.cxx
index 290dc0d091a9..d23d7a9eccca 100644
--- a/sc/source/core/data/cellvalues.cxx
+++ b/sc/source/core/data/cellvalues.cxx
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -147,6 +148,12 @@ void CellValues::setValue( size_t nRow, const 
svl::SharedString& rStr )
 mpImpl->miAttrPos = mpImpl->maCellTextAttrs.set(mpImpl->miAttrPos, nRow, 
sc::CellTextAttr());
 }
 
+void CellValues::setValue( size_t nRow, std::unique_ptr 
pEditText )
+{
+mpImpl->miCellPos = mpImpl->maCells.set(mpImpl->miCellPos, nRow, 
pEditText.release());
+mpImpl->miAttrPos = mpImpl->maCellTextAttrs.set(mpImpl->miAttrPos, nRow, 
sc::CellTextAttr());
+}
+
 void CellValues::swap( CellValues& r )
 {
 std::swap(mpImpl, r.mpImpl);
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index ce982e920f8c..83123dffd88b 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -478,13 +479,15 @@ namespace {
 class ConvertFormulaToValueHandler
 {
 sc::CellValues maResValues;
+ScDocument& mrDoc;
 bool mbModified;
 
 public:
-ConvertFormulaToValueHandler(ScSheetLimits const & rSheetLimits) :
+ConvertFormulaToValueHandler(ScDocument& rDoc) :
+mrDoc(rDoc),
 mbModified(false)
 {
-maResValues.reset(rSheetLimits.GetMaxRowCount());
+maResValues.reset(mrDoc.GetSheetLimits().GetMaxRowCount());
 }
 
 void operator() ( size_t nRow, const ScFormulaCell* pCell )
@@ -496,7 +499,18 @@ public:
 maResValues.setValue(nRow, aRes.mfValue);
 break;
 case sc::FormulaResultValue::String:
-maResValues.setValue(nRow, aRes.maString);
+if (aRes.mbMultiLine)
+{
+ScFieldEditEngine& rEngine = mrDoc.GetEditEngine();
+rEngine.SetTextCurrentDefaults(aRes.maString.getString());
+std::unique_ptr 
pObj(rEngine.CreateTextObject());
+pObj->NormalizeString(mrDoc.GetSharedStringPool());
+maResValues.setValue(nRow, std::move(pObj));
+}
+else
+{
+maResValues.setValue(nRow, aRes.maString);
+}
 break;
 case sc::FormulaResultValue::Error:
 case sc::FormulaResultValue::Invalid:
@@ -528,7 +542,7 @@ void ScColumn::ConvertFormulaToValue(
 sc::SharedFormulaUtil::splitFormulaCellGroups(GetDoc(), maCells, aBounds);
 
 // Parse all formulas within the range and store their results into 
temporary storage.
-ConvertFormulaToValueHandler aFunc(GetDoc().GetSheetLimits());
+ConvertFormulaToValueHandler aFunc(GetDoc());
 sc::ParseFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
 if (!aFunc.isModified())
 // No formula 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-11-30 Thread offtkp (via logerrit)
 sc/inc/dbdata.hxx   |   10 +-
 sc/source/core/tool/dbdata.cxx  |   17 ++---
 sc/source/filter/excel/xedbdata.cxx |5 +++--
 sc/source/filter/inc/tablecolumnsbuffer.hxx |4 
 sc/source/filter/oox/tablecolumnsbuffer.cxx |   11 ++-
 5 files changed, 40 insertions(+), 7 deletions(-)

New commits:
commit 933e045422957e15cad47ef925d4f9a852c826b1
Author: offtkp 
AuthorDate: Thu Nov 17 16:41:42 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Nov 30 14:24:10 2022 +0100

xlsx: Import table column attribute XML_totalsRowFunction

Import table column attribute totalsRowFunction and also export it,
which fixes a warning when roundtripped on a different office suite.

Change-Id: Icc76fc310aef3bd51bcefebece57f962a56b7cca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142843
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 0e8d53830e53..482c55bc6aa4 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -43,6 +43,11 @@ enum class ScDBDataPortion
 AREA///< entire area
 };
 
+struct TableColumnAttributes
+{
+std::optional maTotalsFunction = std::nullopt;
+};
+
 /** Container base class to provide selected access for ScDBData. */
 class ScDBDataContainerBase
 {
@@ -93,6 +98,7 @@ private:
 boolbModified;  ///< is set/cleared for/by(?) 
UpdateReference
 
 ::std::vector< OUString > maTableColumnNames;   ///< names of table columns
+::std::vector< TableColumnAttributes > maTableColumnAttributes; ///< 
attributes of table columns
 boolmbTableColumnNamesDirty;
 SCSIZE  nFilteredRowCount;
 
@@ -147,6 +153,8 @@ public:
 voidEndTableColumnNamesListener();
 SC_DLLPUBLIC void SetTableColumnNames( ::std::vector< OUString >&& rNames 
);
 SC_DLLPUBLIC const ::std::vector< OUString >& GetTableColumnNames() const 
{ return maTableColumnNames; }
+SC_DLLPUBLIC void SetTableColumnAttributes( ::std::vector< 
TableColumnAttributes >&& rAttributes );
+SC_DLLPUBLIC const ::std::vector< TableColumnAttributes >& 
GetTableColumnAttributes() const { return maTableColumnAttributes; }
 boolAreTableColumnNamesDirty() const { return 
mbTableColumnNamesDirty; }
 
 /** Refresh/update the column names with the header row's cell contents. */
@@ -218,7 +226,7 @@ public:
 
 private:
 
-void AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx, 
SCCOL nCol1,
+void AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, SCCOL nDx, 
SCCOL nCol1,
 SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 );
 void InvalidateTableColumnNames( bool bSwapToEmptyNames );
 };
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index cf518d0e2890..dc10d6a0503e 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -609,7 +609,7 @@ bool ScDBData::UpdateReference(const ScDocument* pDoc, 
UpdateRefMode eUpdateRefM
 if (bDoUpdate && eRet != UR_INVALID)
 {
 // MoveTo() invalidates column names via SetArea(); adjust, remember 
and set new.
-AdjustTableColumnNames( eUpdateRefMode, nDx, nCol1, nOldCol1, 
nOldCol2, theCol1, theCol2);
+AdjustTableColumnAttributes( eUpdateRefMode, nDx, nCol1, nOldCol1, 
nOldCol2, theCol1, theCol2);
 ::std::vector aNames( maTableColumnNames);
 bool bTableColumnNamesDirty = mbTableColumnNamesDirty;
 // tdf#48025, tdf#141946: update the column index of the filter 
criteria,
@@ -686,7 +686,12 @@ void ScDBData::SetTableColumnNames( ::std::vector< 
OUString >&& rNames )
 mbTableColumnNamesDirty = false;
 }
 
-void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL 
nDx, SCCOL nCol1,
+void ScDBData::SetTableColumnAttributes( ::std::vector< TableColumnAttributes 
>&& rAttributes )
+{
+maTableColumnAttributes = std::move(rAttributes);
+}
+
+void ScDBData::AdjustTableColumnAttributes( UpdateRefMode eUpdateRefMode, 
SCCOL nDx, SCCOL nCol1,
 SCCOL nOldCol1, SCCOL nOldCol2, SCCOL nNewCol1, SCCOL nNewCol2 )
 {
 if (maTableColumnNames.empty())
@@ -698,6 +703,7 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode 
eUpdateRefMode, SCCOL nDx,
 return; // not moved or entirely moved, nothing to do
 
 ::std::vector aNewNames;
+::std::vector aNewAttributes;
 if (eUpdateRefMode == URM_INSDEL)
 {
 if (nDx > 0)
@@ -714,22 +720,27 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode 
eUpdateRefMode, SCCOL nDx,
 if (nDx > 0)
 n += nDx;
 aNewNames.resize(n);
+aNewAttributes.resize(n);
+maTableColumnAttributes.resize(n);
 // Copy head.
 for (size_t i = 0; i < nHead; ++i)
 {
 aNewNames[i] = maTableColumnNames[i];
+  

[Libreoffice-commits] core.git: sc/inc sc/source

2022-11-13 Thread Eike Rathke (via logerrit)
 sc/inc/interpretercontext.hxx  |4 ++--
 sc/source/core/data/documen2.cxx   |2 +-
 sc/source/core/tool/interpretercontext.cxx |   12 
 3 files changed, 11 insertions(+), 7 deletions(-)

New commits:
commit dffeb48f25123b16e60aed5aa4abaeefa92f83a1
Author: Eike Rathke 
AuthorDate: Sun Nov 13 01:41:11 2022 +0100
Commit: Eike Rathke 
CommitDate: Sun Nov 13 16:26:56 2022 +0100

Clear only lookup caches of calling document

It is the same for always reused interpreter context slots but
does not hurt and prepares for when more than one document is to
be cached.

Change-Id: Icc8532080f618b9a50627a6e551dfb28803d3c34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142643
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 4ecb1ed9de1a..39d528cb6ca9 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -82,7 +82,7 @@ private:
 void ResetTokens();
 void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* 
pFormatter);
 void Cleanup();
-void ClearLookupCache();
+void ClearLookupCache(const ScDocument* pDoc);
 void initFormatTable();
 SvNumberFormatter* mpFormatter;
 mutable NFIndexAndFmtType maNFTypeCache;
@@ -135,7 +135,7 @@ class ScInterpreterContextPool
 
 public:
 // Only to be used to clear lookup cache in all pool elements
-static void ClearLookupCaches();
+static void ClearLookupCaches(const ScDocument* pDoc);
 };
 
 class ScThreadedInterpreterContextGetterGuard
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index f784d510fe6c..af4629d7aef3 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1280,7 +1280,7 @@ void ScDocument::ClearLookupCaches()
 GetNonThreadedContext().mxScLookupCache.reset();
 mxScSortedRangeCache->aCacheMap.clear();
 // Clear lookup cache in all interpreter-contexts in the 
(threaded/non-threaded) pools.
-ScInterpreterContextPool::ClearLookupCaches();
+ScInterpreterContextPool::ClearLookupCaches(this);
 }
 
 bool ScDocument::IsCellInChangeTrack(const ScAddress ,Color 
*pColCellBorder)
diff --git a/sc/source/core/tool/interpretercontext.cxx 
b/sc/source/core/tool/interpretercontext.cxx
index e66a8b977446..deb6f6d0ed5b 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -74,7 +74,11 @@ void ScInterpreterContext::Cleanup()
 ResetTokens();
 }
 
-void ScInterpreterContext::ClearLookupCache() { mxScLookupCache.reset(); }
+void ScInterpreterContext::ClearLookupCache(const ScDocument* pDoc)
+{
+if (pDoc == mpDoc)
+mxScLookupCache.reset();
+}
 
 SvNumFormatType ScInterpreterContext::GetNumberFormatType(sal_uInt32 nFIndex) 
const
 {
@@ -161,12 +165,12 @@ void ScInterpreterContextPool::ReturnToPool()
 }
 
 // static
-void ScInterpreterContextPool::ClearLookupCaches()
+void ScInterpreterContextPool::ClearLookupCaches(const ScDocument* pDoc)
 {
 for (auto& rPtr : aThreadedInterpreterPool.maPool)
-rPtr->ClearLookupCache();
+rPtr->ClearLookupCache(pDoc);
 for (auto& rPtr : aNonThreadedInterpreterPool.maPool)
-rPtr->ClearLookupCache();
+rPtr->ClearLookupCache(pDoc);
 }
 
 /* ScThreadedInterpreterContextGetterGuard */


[Libreoffice-commits] core.git: sc/inc sc/source

2022-10-18 Thread Noel Grandin (via logerrit)
 sc/inc/chart2uno.hxx  |9 +-
 sc/source/ui/unoobj/chart2uno.cxx |  130 --
 2 files changed, 74 insertions(+), 65 deletions(-)

New commits:
commit 03ef97c7605f4d3f537d5a1f31c2f131a439578d
Author: Noel Grandin 
AuthorDate: Tue Oct 18 14:16:08 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Oct 18 19:07:00 2022 +0200

tdf#131910 speed up chart display

the chart2 module likes cloning ScChart2DataSequence, which can take a
long time if we have lots of data, so share the data via shared_ptr

Change-Id: I4b0948610810c41a8569b97c58b2b52e8e3190f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141501
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/chart2uno.hxx b/sc/inc/chart2uno.hxx
index a5e4f53b032f..a8ac4422464e 100644
--- a/sc/inc/chart2uno.hxx
+++ b/sc/inc/chart2uno.hxx
@@ -205,6 +205,7 @@ public:
 ::std::vector&& rTokens, bool bIncludeHiddenCells );
 
 virtual ~ScChart2DataSequence() override;
+ScChart2DataSequence(ScDocument* pDoc, const ScChart2DataSequence&);
 ScChart2DataSequence(const ScChart2DataSequence&) = delete;
 ScChart2DataSequence& operator=(const ScChart2DataSequence&) = delete;
 
@@ -324,8 +325,6 @@ private:
 
 void StopListeningToAllExternalRefs();
 
-void CopyData(const ScChart2DataSequence& r);
-
 private:
 
 // data array
@@ -350,8 +349,10 @@ private:
 ScChart2DataSequence& mrParent;
 };
 
-/** This vector contains the cached data which was calculated with 
BuildDataCache(). */
-std::vector   m_aDataArray;
+/** This vector contains the cached data which was calculated with 
BuildDataCache().
+We use a shared_ptr because chart likes to Clone this class, which is 
very
+expensive when we have lots of data. */
+std::shared_ptr> m_xDataArray;
 
 /**
  * Cached data for getData.  We may also need to cache data for the
diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index 729249790a9d..58ca25ae854e 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2409,7 +2409,8 @@ void ScChart2DataSequence::HiddenRangeListener::notify()
 ScChart2DataSequence::ScChart2DataSequence( ScDocument* pDoc,
 vector&& rTokens,
 bool bIncludeHiddenCells )
-: m_bIncludeHiddenCells( bIncludeHiddenCells)
+: m_xDataArray(new std::vector)
+, m_bIncludeHiddenCells( bIncludeHiddenCells)
 , m_nObjectId( 0 )
 , m_pDocument( pDoc)
 , m_aTokens(std::move(rTokens))
@@ -2439,6 +2440,54 @@ ScChart2DataSequence::ScChart2DataSequence( ScDocument* 
pDoc,
 //  m_aIdentifier += OUString::valueOf( ++nID);
 }
 
+/** called from Clone() */
+ScChart2DataSequence::ScChart2DataSequence(ScDocument* pDoc, const 
ScChart2DataSequence& r)
+: m_xDataArray(r.m_xDataArray)
+, m_aHiddenValues(r.m_aHiddenValues)
+, m_aRole(r.m_aRole)
+, m_bIncludeHiddenCells( r.m_bIncludeHiddenCells)
+, m_nObjectId( 0 )
+, m_pDocument( pDoc)
+, m_aPropSet(lcl_GetDataSequencePropertyMap())
+, m_bGotDataChangedHint(false)
+, m_bExtDataRebuildQueued(false)
+, mbTimeBased(false)
+, mnTimeBasedStart(0)
+, mnTimeBasedEnd(0)
+, mnCurrentTab(0)
+{
+assert(pDoc);
+
+// Clone tokens.
+m_aTokens.reserve(r.m_aTokens.size());
+for (const auto& rxToken : m_aTokens)
+{
+ScTokenRef p(rxToken->Clone());
+m_aTokens.push_back(p);
+}
+
+m_pDocument->AddUnoObject( *this);
+m_nObjectId = m_pDocument->GetNewUnoId();
+
+if (r.m_oRangeIndices)
+m_oRangeIndices = *r.m_oRangeIndices;
+
+if (!r.m_pExtRefListener)
+return;
+
+// Re-register all external files that the old instance was
+// listening to.
+
+ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
+m_pExtRefListener.reset(new ExternalRefListener(*this, m_pDocument));
+const std::unordered_set& rFileIds = 
r.m_pExtRefListener->getAllFileIds();
+for (const auto& rFileId : rFileIds)
+{
+pRefMgr->addLinkListener(rFileId, m_pExtRefListener.get());
+m_pExtRefListener->addFileId(rFileId);
+}
+}
+
 ScChart2DataSequence::~ScChart2DataSequence()
 {
 SolarMutexGuard g;
@@ -2492,7 +2541,7 @@ void ScChart2DataSequence::BuildDataCache()
 {
 m_bExtDataRebuildQueued = false;
 
-if (!m_aDataArray.empty())
+if (!m_xDataArray->empty())
 return;
 
 StopListeningToAllExternalRefs();
@@ -2569,7 +2618,7 @@ void ScChart2DataSequence::BuildDataCache()
 
 aItem.mAddress = ScAddress(nCol, nRow, nTab);
 
-m_aDataArray.push_back(std::move(aItem));
+m_xDataArray->push_back(std::move(aItem));
 ++nDataCount;
 }
 }
@@ -2590,7 +2639,7 @@ void ScChart2DataSequence::RebuildDataCache()
 {
 if 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-29 Thread Luboš Luňák (via logerrit)
 sc/inc/table.hxx   |8 
 sc/source/core/data/table4.cxx |8 
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 1c53f5b6647dcffa57012990d342b21eaff19888
Author: Luboš Luňák 
AuthorDate: Thu Sep 29 14:22:00 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Sep 29 16:19:18 2022 +0200

introduce ScTable::GetColumnData() (tdf#151182)

This is intended to handle possibly unallocated columns similarly
to CreateColumnIfNotExists(), but unlike that one this one does not
allocate, if the column is not allocated then the default column
data is returned. This is intended for reading of columns.

Change-Id: Ic3b637eb3d16bac69ebc7ecd389973407db4f7fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140737
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 4d4e7a2f7830..a9d2ad71bd39 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -294,6 +294,14 @@ public:
 }
 // out-of-line the cold part of the function
 void CreateColumnIfNotExistsImpl( const SCCOL nScCol );
+
+ScColumnData& GetColumnData( SCCOL nCol )
+{
+if( nCol >= aCol.size())
+return aDefaultColData;
+return aCol[nCol];
+}
+
 sal_uInt64  GetCellCount() const;
 sal_uInt64  GetWeightedCount() const;
 sal_uInt64  GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 6cf97e5d9caf..77f17feaa8f3 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -910,9 +910,9 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 if ( bGetPattern )
 {
 if (bVertical)  // rInner&:=nRow, rOuter&:=nCol
-pSrcPattern = 
aCol[nCol].GetPattern(static_cast(nAtSrc));
+pSrcPattern = 
GetColumnData(nCol).GetPattern(static_cast(nAtSrc));
 else// rInner&:=nCol, rOuter&:=nRow
-pSrcPattern = 
aCol[nAtSrc].GetPattern(static_cast(nRow));
+pSrcPattern = 
GetColumnData(nAtSrc).GetPattern(static_cast(nRow));
 bGetPattern = false;
 pStyleSheet = pSrcPattern->GetStyleSheet();
 // do transfer ATTR_MERGE / ATTR_MERGE_FLAG
@@ -1894,7 +1894,7 @@ void ScTable::FillAutoSimple(
 return;
 }
 const SvNumFormatType nFormatType = 
rDocument.GetFormatTable()->GetType(
-aCol[rCol].GetNumberFormat( 
rDocument.GetNonThreadedContext(), nSource));
+GetColumnData(rCol).GetNumberFormat( 
rDocument.GetNonThreadedContext(), nSource));
 bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
 bPercentCell = (nFormatType == SvNumFormatType::PERCENT);
 
@@ -1903,7 +1903,7 @@ void ScTable::FillAutoSimple(
 {
 aSrcCell = GetCellValue(nSource, rRow);
 const SvNumFormatType nFormatType = 
rDocument.GetFormatTable()->GetType(
-aCol[nSource].GetNumberFormat( 
rDocument.GetNonThreadedContext(), rRow));
+GetColumnData(nSource).GetNumberFormat( 
rDocument.GetNonThreadedContext(), rRow));
 bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
 bPercentCell = (nFormatType == SvNumFormatType::PERCENT);
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-23 Thread Taichi Haradaguchi (via logerrit)
 sc/inc/strings.hrc |2 +-
 sc/source/ui/dbgui/filtdlg.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 93e0ce447ce2e913995800d45614dfc74d80b2b5
Author: Taichi Haradaguchi <20001...@ymail.ne.jp>
AuthorDate: Wed Sep 14 23:10:31 2022 +0900
Commit: Julien Nabet 
CommitDate: Fri Sep 23 21:54:57 2022 +0200

Rename #define

Rename SCSTR_FILTER_TEXT_COLOR_COND to SCSTR_FILTER_FONT_COLOR_COND 
according to UI string changes (https://gerrit.libreoffice.org/c/core/+/137087).

Change-Id: I34a707e4924299fccbbb3dcd9580de100221a012
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139943
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 1d45fc0d7647..24a40a41ef57 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -39,7 +39,7 @@
 #define SCSTR_FILTER_COLOR  NC_("SCSTR_FILTER_COLOR", 
"Filter by Color")
 #define SCSTR_FILTER_CONDITION  
NC_("SCSTR_FILTER_CONDITION", "Filter by Condition")
 // This must match the translation of the same strings of 
standardfilterdialog|cond
-#define SCSTR_FILTER_TEXT_COLOR_COND
NC_("STANDARDFILTERDIALOG_COND", "Font color")
+#define SCSTR_FILTER_FONT_COLOR_COND
NC_("STANDARDFILTERDIALOG_COND", "Font color")
 #define SCSTR_FILTER_BACKGROUND_COLOR_COND  
NC_("STANDARDFILTERDIALOG_COND", "Background color")
 #define SCSTR_FILTER_NO_FILL
NC_("SCSTR_FILTER_NO_FILL", "No Fill")
 #define SCSTR_FILTER_AUTOMATIC_COLOR
NC_("SCSTR_FILTER_AUTOMATIC_COLOR", "Automatic")
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
index 2af41567082d..dd6060021e7e 100644
--- a/sc/source/ui/dbgui/filtdlg.cxx
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -59,7 +59,7 @@ ScFilterDlg::ScFilterDlg(SfxBindings* pB, SfxChildWindow* 
pCW, weld::Window* pPa
 , aStrEmpty(ScResId(SCSTR_FILTER_EMPTY))
 , aStrNotEmpty(ScResId(SCSTR_FILTER_NOTEMPTY))
 , aStrColumn(ScResId(SCSTR_COLUMN_LETTER))
-, aStrTextColor(ScResId(SCSTR_FILTER_TEXT_COLOR_COND))
+, aStrTextColor(ScResId(SCSTR_FILTER_FONT_COLOR_COND))
 , aStrBackgroundColor(ScResId(SCSTR_FILTER_BACKGROUND_COLOR_COND))
 , nWhichQuery(rArgSet.GetPool()->GetWhich(SID_QUERY))
 , theQueryData(static_cast(rArgSet.Get(nWhichQuery)).GetQueryData())


[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-14 Thread Eike Rathke (via logerrit)
 sc/inc/addincol.hxx  |4 +++-
 sc/source/core/tool/addincol.cxx |8 +---
 sc/source/core/tool/interpr4.cxx |2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit a56e5434a4ed453b55b8f060ed18404d77a9fb10
Author: Eike Rathke 
AuthorDate: Wed Sep 14 00:19:04 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Sep 14 09:01:20 2022 +0200

Resolves: tdf#150926 Add-In result svl::SharedString needs to be interned

Change-Id: If582e7e1bf818dcf9eaddd5313aa21f5768a578f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139886
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index ee5ecb44e300..2ae05aa31585 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -44,6 +44,7 @@ class SfxObjectShell;
 class ScUnoAddInFuncData;
 class ScFuncDesc;
 class LanguageTag;
+class ScDocument;
 
 typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > 
ScAddInHashMap;
 
@@ -198,6 +199,7 @@ private:
 css::uno::Sequence aArgs;
 css::uno::Sequence aVarArg;
 css::uno::Reference xCaller;
+ScDocument& mrDoc;
 boolbValidCount;
 // result:
 FormulaErrornErrCode;
@@ -211,7 +213,7 @@ private:
 
 public:
 // exact name
-ScUnoAddInCall( ScUnoAddInCollection& rColl, const 
OUString& rName,
+ScUnoAddInCall( ScDocument& rDoc, ScUnoAddInCollection& 
rColl, const OUString& rName,
 tools::Long nParamCount );
 ~ScUnoAddInCall();
 
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 1ffb1e5bc1d7..bf7d8652de1b 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -61,6 +61,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace com::sun::star;
@@ -1283,8 +1284,9 @@ bool ScUnoAddInCollection::FillFunctionDescFromData( 
const ScUnoAddInFuncData& r
 return true;
 }
 
-ScUnoAddInCall::ScUnoAddInCall( ScUnoAddInCollection& rColl, const OUString& 
rName,
+ScUnoAddInCall::ScUnoAddInCall( ScDocument& rDoc, ScUnoAddInCollection& rColl, 
const OUString& rName,
 tools::Long nParamCount ) :
+mrDoc( rDoc ),
 bValidCount( false ),
 nErrCode( FormulaError::NoCode ),  // before function was called
 bHasString( true ),
@@ -1637,13 +1639,13 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes 
)
 for (sal_Int32 nCol=0; nColPutString(
-svl::SharedString(pColArr[nCol]),
+
mrDoc.GetSharedStringPool().intern(pColArr[nCol]),
 static_cast(nCol), 
static_cast(nRow));
 }
 for (sal_Int32 nCol=nColCount; nColPutString(
-svl::SharedString(OUString()),
+svl::SharedString::getEmptyString(),
 static_cast(nCol), 
static_cast(nRow));
 }
 }
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bace28f68a53..bc16f32badb1 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2734,7 +2734,7 @@ void ScInterpreter::ScExternal()
 //  bLocalFirst=false in FindFunction, cFunc should be the stored
 //  internal name
 
-ScUnoAddInCall aCall( *ScGlobal::GetAddInCollection(), aUnoName, 
nParamCount );
+ScUnoAddInCall aCall( mrDoc, *ScGlobal::GetAddInCollection(), 
aUnoName, nParamCount );
 
 if ( !aCall.ValidParamCount() )
 SetError( FormulaError::IllegalParameter );


[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-09 Thread Caolán McNamara (via logerrit)
 sc/inc/dociter.hxx   |2 +-
 sc/source/core/data/dociter.cxx  |6 +++---
 sc/source/core/tool/interpr1.cxx |4 ++--
 sc/source/core/tool/interpr6.cxx |2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit e00a86699b89913a80b15eeea33dd0fac64299d0
Author: Caolán McNamara 
AuthorDate: Thu Sep 8 10:32:42 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Sep 9 20:56:07 2022 +0200

GetCurNumFmtInfo is always called with the same context as given in ctor

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

diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 55a2040f1d1b..c8b51b9e24ff 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -87,7 +87,7 @@ public:
 ScDocument& rDocument, const ScRange& rRange, SubtotalFlags 
nSubTotalFlags = SubtotalFlags::NONE,
 bool bTextAsZero = false );
 
-void GetCurNumFmtInfo( const ScInterpreterContext& rContext, 
SvNumFormatType& nType, sal_uInt32& nIndex );
+void GetCurNumFmtInfo( SvNumFormatType& nType, sal_uInt32& nIndex );
 
 /// Does NOT reset rValue if no value found!
 bool GetFirst( double& rValue, FormulaError& rErr );
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 97d40d82fd98..0fb2fec32673 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -252,14 +252,14 @@ bool ScValueIterator::GetThis(double& rValue, 
FormulaError& rErr)
 }
 }
 
-void ScValueIterator::GetCurNumFmtInfo( const ScInterpreterContext& rContext, 
SvNumFormatType& nType, sal_uInt32& nIndex )
+void ScValueIterator::GetCurNumFmtInfo( SvNumFormatType& nType, sal_uInt32& 
nIndex )
 {
 if (!bNumValid && mnTab < mrDoc.GetTableCount())
 {
 SCROW nCurRow = GetRow();
 const ScColumn* pCol = &(mrDoc.maTabs[mnTab])->aCol[mnCol];
-nNumFmtIndex = pCol->GetNumberFormat(rContext, nCurRow);
-nNumFmtType = rContext.GetNumberFormatType( nNumFmtIndex );
+nNumFmtIndex = pCol->GetNumberFormat(mrContext, nCurRow);
+nNumFmtType = mrContext.GetNumberFormatType( nNumFmtIndex );
 bNumValid = true;
 }
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 8a7a0ac0093b..279d33f29cae 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3697,7 +3697,7 @@ void ScInterpreter::ScMin( bool bTextAsZero )
 {
 if (nMin > nVal)
 nMin = nVal;
-aValIter.GetCurNumFmtInfo( mrContext, nFuncFmtType, 
nFuncFmtIndex );
+aValIter.GetCurNumFmtInfo( nFuncFmtType, nFuncFmtIndex );
 while ((nErr == FormulaError::NONE) && 
aValIter.GetNext(nVal, nErr))
 {
 if (nMin > nVal)
@@ -3854,7 +3854,7 @@ void ScInterpreter::ScMax( bool bTextAsZero )
 {
 if (nMax < nVal)
 nMax = nVal;
-aValIter.GetCurNumFmtInfo( mrContext, nFuncFmtType, 
nFuncFmtIndex );
+aValIter.GetCurNumFmtInfo( nFuncFmtType, nFuncFmtIndex );
 while ((nErr == FormulaError::NONE) && 
aValIter.GetNext(nVal, nErr))
 {
 if (nMax < nVal)
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 9f8fcb6a9661..13f19895e00a 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -788,7 +788,7 @@ void ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
 if (aValIter.GetFirst(fVal, nErr))
 {
 // placed the loop on the inside for performance 
reasons:
-aValIter.GetCurNumFmtInfo( mrContext, nFuncFmtType, 
nFuncFmtIndex );
+aValIter.GetCurNumFmtInfo( nFuncFmtType, nFuncFmtIndex 
);
 switch( eFunc )
 {
 case ifAVERAGE:


[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-09 Thread Eike Rathke (via logerrit)
 sc/inc/rangeutl.hxx  |9 +
 sc/source/core/tool/rangenam.cxx |4 ++--
 sc/source/core/tool/rangeutl.cxx |2 +-
 sc/source/core/tool/token.cxx|4 ++--
 4 files changed, 14 insertions(+), 5 deletions(-)

New commits:
commit 9a6c350d8dff4b5228ec7451006115e387f819f2
Author: Eike Rathke 
AuthorDate: Fri Sep 9 12:54:14 2022 +0200
Commit: Eike Rathke 
CommitDate: Fri Sep 9 15:53:46 2022 +0200

Resolves: tdf#150312 Move base-cell-address to a valid sheet upon deletion

... and adjust references accordingly. For
ScTokenArray::AdjustReferenceOnDeletedTab() that now also moves
the base of the first deleted sheet not only after, which was a
one-off before.

Change-Id: I4c19e8b8a7318ba03b6a7d0b2dfaae5d05a51a29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139720
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx
index 33f531444280..4524226e43ca 100644
--- a/sc/inc/rangeutl.hxx
+++ b/sc/inc/rangeutl.hxx
@@ -276,6 +276,15 @@ struct SC_DLLPUBLIC ScRangeUpdater
 ScRangeUpdater() = delete;
 
 static void UpdateInsertTab(ScAddress& rAddr, const 
sc::RefUpdateInsertTabContext& rCxt);
+
+/** This is for the base-cell-address of a defined name or conditional
+format, not for references. A sheet position on or after the start of
+the deleted range is moved towards the beginning by the amount of
+deleted sheets, within the deleted range to the front of that or set to
+0 (as there is always at least one sheet in a document) if the position
+would result in a negative value, e.g. if position was 0 and (only)
+sheet 0 is deleted it would had become -1.
+ */
 static void UpdateDeleteTab(ScAddress& rAddr, const 
sc::RefUpdateDeleteTabContext& rCxt);
 };
 
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 66cdf2b74c9e..b5578ca26590 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -407,8 +408,7 @@ void ScRangeData::UpdateDeleteTab( 
sc::RefUpdateDeleteTabContext& rCxt, SCTAB nL
 if (aRes.mbReferenceModified)
 rCxt.maUpdatedNames.setUpdatedName(nLocalTab, nIndex);
 
-if (rCxt.mnDeletePos <= aPos.Tab())
-aPos.IncTab(-rCxt.mnSheets);
+ScRangeUpdater::UpdateDeleteTab( aPos, rCxt);
 }
 
 void ScRangeData::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB 
nLocalTab )
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index c5901c834b40..6eb1cf52ff48 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -1061,7 +1061,7 @@ void ScRangeUpdater::UpdateDeleteTab(ScAddress& rAddr, 
const sc::RefUpdateDelete
 {
 if (rCxt.mnDeletePos <= rAddr.Tab())
 {
-rAddr.IncTab(-rCxt.mnSheets);
+rAddr.SetTab( std::max(0, rAddr.Tab() - rCxt.mnSheets));
 }
 }
 
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1ad3df0889ef..4315f017e67c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4234,8 +4235,7 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnDeletedTab( const sc::RefUpda
 {
 sc::RefUpdateResult aRes;
 ScAddress aNewPos = rOldPos;
-if (rCxt.mnDeletePos < rOldPos.Tab())
-aNewPos.IncTab(-1*rCxt.mnSheets);
+ScRangeUpdater::UpdateDeleteTab( aNewPos, rCxt);
 
 TokenPointers aPtrs( pCode.get(), nLen, pRPN, nRPN);
 for (size_t j=0; j<2; ++j)


[Libreoffice-commits] core.git: sc/inc sc/source

2022-09-02 Thread Noel Grandin (via logerrit)
 sc/inc/formulacell.hxx  |4 ++--
 sc/source/core/data/formulacell.cxx |   18 ++
 2 files changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 7d5beaabeac4e474512337b086690257daeefc96
Author: Noel Grandin 
AuthorDate: Thu Sep 1 21:45:18 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 2 19:05:50 2022 +0200

no need to use unique_ptr for this map in sc::FormulaGroupAreaListener

map is already a node based data structure, so the values will stay
in the same place in memory

Change-Id: If9bc02d702fd5ba9994e606744b63494fbe20edd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139237
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index ddd12a04e6ac..e4bc41772e0e 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -34,6 +34,7 @@
 #include "formulalogger.hxx"
 #include "formularesult.hxx"
 #include "tokenarray.hxx"
+#include "grouparealistener.hxx"
 
 namespace sc {
 
@@ -44,7 +45,6 @@ struct RefUpdateInsertTabContext;
 struct RefUpdateDeleteTabContext;
 struct RefUpdateMoveTabContext;
 class CompileFormulaContext;
-class FormulaGroupAreaListener;
 class UpdatedRangeNames;
 
 }
@@ -65,7 +65,7 @@ struct AreaListenerKey
 bool operator < ( const AreaListenerKey& r ) const;
 };
 
-typedef std::map> AreaListenersType;
+typedef std::map 
AreaListenersType;
 
 struct SC_DLLPUBLIC ScFormulaCellGroup
 {
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 0bad3e6b73d1..9754ab340188 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -553,23 +553,25 @@ sc::FormulaGroupAreaListener* 
ScFormulaCellGroup::getAreaListener(
 if (it == m_AreaListeners.end() || m_AreaListeners.key_comp()(aKey, 
it->first))
 {
 // Insert a new one.
-it = m_AreaListeners.insert(
-it, std::make_pair(aKey, 
std::make_unique(
-rRange, (*ppTopCell)->GetDocument(), (*ppTopCell)->aPos, 
mnLength, bStartFixed, bEndFixed)));
+it = m_AreaListeners.emplace_hint(
+ it, std::piecewise_construct,
+ std::forward_as_tuple(aKey),
+ std::forward_as_tuple(
+rRange, (*ppTopCell)->GetDocument(), (*ppTopCell)->aPos, 
mnLength, bStartFixed, bEndFixed));
 }
 
-return it->second.get();
+return >second;
 }
 
 void ScFormulaCellGroup::endAllGroupListening( ScDocument& rDoc )
 {
-for (const auto& rEntry : m_AreaListeners)
+for (auto& rEntry : m_AreaListeners)
 {
-sc::FormulaGroupAreaListener *const pListener = rEntry.second.get();
-ScRange aListenRange = pListener->getListeningRange();
+sc::FormulaGroupAreaListener& rListener = rEntry.second;
+ScRange aListenRange = rListener.getListeningRange();
 // This "always listen" special range is never grouped.
 bool bGroupListening = (aListenRange != BCA_LISTEN_ALWAYS);
-rDoc.EndListeningArea(aListenRange, bGroupListening, pListener);
+rDoc.EndListeningArea(aListenRange, bGroupListening, );
 }
 
 m_AreaListeners.clear();


[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-30 Thread Eike Rathke (via logerrit)
 sc/inc/global.hxx  |   15 +++
 sc/source/core/data/global.cxx |   37 +
 sc/source/ui/app/inputhdl.cxx  |   41 -
 sc/source/ui/inc/inputhdl.hxx  |9 -
 4 files changed, 56 insertions(+), 46 deletions(-)

New commits:
commit 5a16cd1123003d6f72d84983292cf96c7fb49d60
Author: Eike Rathke 
AuthorDate: Mon Aug 29 21:39:19 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Aug 30 11:48:54 2022 +0200

Move input handler function names to ScGlobal static

... as there is only one function list and
InputHandlerFunctionNames can be shared instead of each
ScInputHandler holding their own copy.

Change-Id: Id82b2020f8846456ce7464daa83feb6915792aa2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139012
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 8401ca4c6f7e..3be19f89dcc1 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "address.hxx"
+#include "typedstrdata.hxx"
 #include 
 #include 
 #include 
@@ -455,6 +456,17 @@ struct ScImportParam
 booloperator==  ( const ScImportParam& r ) const;
 };
 
+// Formula data replacement character for a pair of parentheses at end of
+// function name, to force sorting parentheses before all other characters.
+// Collation may treat parentheses differently.
+constexpr sal_Unicode cParenthesesReplacement = 0x0001;
+struct InputHandlerFunctionNames
+{
+ScTypedCaseStrSet   maFunctionData;
+ScTypedCaseStrSet   maFunctionDataPara;
+std::set   maFunctionChar;
+};
+
 class ScDocShell;
 class SvxSearchItem;
 class ScAutoFormat;
@@ -523,6 +535,8 @@ class ScGlobal
 
 static std::atomic pSharedStringPoolPurge;
 
+static InputHandlerFunctionNames maInputHandlerFunctionNames;
+
 static void InitPPT();
 
 public:
@@ -595,6 +609,7 @@ public:
 static ScFunctionList*  GetStarCalcFunctionList();
 static ScFunctionMgr*   GetStarCalcFunctionMgr();
 static void ResetFunctionList();
+static const InputHandlerFunctionNames& GetInputHandlerFunctionNames();
 
 static OUString GetErrorString(FormulaError nErrNumber);
 static OUString GetLongErrorString(FormulaError nErrNumber);
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 46277a807db0..58b3a1e70281 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -119,6 +119,9 @@ sal_uInt16 nScFillModeMouseModifier = 0; //FIXME: And this
 
 bool ScGlobal::bThreadedGroupCalcInProgress = false;
 
+InputHandlerFunctionNames ScGlobal::maInputHandlerFunctionNames;
+
+
 // Static functions
 
 bool ScGlobal::HasAttrChanged( const SfxItemSet&  rNewAttrs,
@@ -641,6 +644,40 @@ void ScGlobal::ResetFunctionList()
 // FunctionMgr has pointers into FunctionList, must also be updated
 xStarCalcFunctionMgr.reset();
 xStarCalcFunctionList.reset();
+// Building new names also needs InputHandler data to be refreshed.
+maInputHandlerFunctionNames = InputHandlerFunctionNames();
+}
+
+const InputHandlerFunctionNames& ScGlobal::GetInputHandlerFunctionNames()
+{
+if (maInputHandlerFunctionNames.maFunctionData.empty())
+{
+const OUString aParenthesesReplacement( cParenthesesReplacement);
+const ScFunctionList* pFuncList = GetStarCalcFunctionList();
+const sal_uInt32 nListCount = pFuncList->GetCount();
+const CharClass* pCharClass = 
(SC_MOD()->GetFormulaOptions().GetUseEnglishFuncName()
+? ScCompiler::GetCharClassEnglish()
+: ScCompiler::GetCharClassLocalized());
+for (sal_uInt32 i=0; i < nListCount; ++i)
+{
+const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
+if ( pDesc->mxFuncName )
+{
+OUString 
aFuncName(pCharClass->uppercase(*(pDesc->mxFuncName)));
+// fdo#75264 fill maFormulaChar with all characters used in 
formula names
+for (sal_Int32 j = 0; j < aFuncName.getLength(); j++)
+
maInputHandlerFunctionNames.maFunctionChar.insert(aFuncName[j]);
+maInputHandlerFunctionNames.maFunctionData.insert(
+ScTypedStrData(*(pDesc->mxFuncName) + 
aParenthesesReplacement, 0.0, 0.0,
+ScTypedStrData::Standard));
+pDesc->initArgumentInfo();
+OUString aEntry = pDesc->getSignature();
+maInputHandlerFunctionNames.maFunctionDataPara.insert(
+ScTypedStrData(aEntry, 0.0, 0.0, 
ScTypedStrData::Standard));
+}
+}
+}
+return maInputHandlerFunctionNames;
 }
 
 ScUnitConverter* ScGlobal::GetUnitConverter()
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-26 Thread Eike Rathke (via logerrit)
 sc/inc/funcdesc.hxx  |3 ++
 sc/source/core/data/funcdesc.cxx |3 +-
 sc/source/ui/app/inputhdl.cxx|   48 ---
 sc/source/ui/inc/inputhdl.hxx|   16 +
 4 files changed, 47 insertions(+), 23 deletions(-)

New commits:
commit 1581a631464254bbc428649c35b23c79df837ed2
Author: Eike Rathke 
AuthorDate: Sat Aug 27 01:10:36 2022 +0200
Commit: Eike Rathke 
CommitDate: Sat Aug 27 02:57:46 2022 +0200

Do not gather function data over and over again for each formula input

The function list changes only if switched to/from English
function names or if reset for AddIn config and only then needs to
be rebuilt. In all other cases simply reuse a once obtained data
set and only append the dynamic document content.

Change-Id: I5b1d14205e2933010a1b4382c985594d75802742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138890
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index 0f37e924d941..01829417e485 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -253,9 +253,12 @@ public:
 
 const ScFuncDesc* GetFunction( sal_uInt32 nIndex ) const;
 
+bool IsEnglishFunctionNames() const { return mbEnglishFunctionNames; }
+
 private:
 ::std::vector aFunctionList; /**< List of functions */
 ::std::vector::iterator aFunctionListIter; /**< 
position in function list */
+bool mbEnglishFunctionNames;
 };
 
 /**
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index c8045e6c1abf..1fa47a5db718 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -398,6 +398,7 @@ bool ScFuncDesc::compareByName(const ScFuncDesc* a, const 
ScFuncDesc* b)
 #define ENTRY(CODE) CODE, SAL_N_ELEMENTS(CODE)
 
 ScFunctionList::ScFunctionList( bool bEnglishFunctionNames )
+: mbEnglishFunctionNames( bEnglishFunctionNames )
 {
 sal_Int32  nMaxFuncNameLen = 0; // Length of longest function name
 
@@ -958,7 +959,7 @@ ScFunctionList::ScFunctionList( bool bEnglishFunctionNames )
 pDesc = new ScFuncDesc;
 pDesc->nFIndex = nNextId++;
 
-if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc, 
bEnglishFunctionNames ) )
+if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc, 
mbEnglishFunctionNames ) )
 {
 tmpFuncVector.push_back(pDesc);
 nStrLen = pDesc->mxFuncName->getLength();
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index de0a49e692bb..8f095d4ecaa7 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1020,30 +1020,42 @@ void ScInputHandler::GetFormulaData()
 else
 pFormulaDataPara.reset( new ScTypedCaseStrSet );
 
-const CharClass* pCharClass = 
(SC_MOD()->GetFormulaOptions().GetUseEnglishFuncName()
-   ? ScCompiler::GetCharClassEnglish()
-   : ScCompiler::GetCharClassLocalized());
-
 const OUString aParenthesesReplacement( cParenthesesReplacement);
 const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
-sal_uInt32 nListCount = pFuncList->GetCount();
-for(sal_uInt32 i=0;iGetFunction( i );
-if ( pDesc->mxFuncName )
+const sal_uInt32 nListCount = pFuncList->GetCount();
+if (maFunctionNames.mnListCount != nListCount
+|| maFunctionNames.mbEnglishFunctionNames != 
pFuncList->IsEnglishFunctionNames())
+{
+if (maFunctionNames.mnListCount)
+maFunctionNames = FunctionNames();
+maFunctionNames.mnListCount = nListCount;
+maFunctionNames.mbEnglishFunctionNames = 
pFuncList->IsEnglishFunctionNames();
+const CharClass* pCharClass = (maFunctionNames.mbEnglishFunctionNames
+? ScCompiler::GetCharClassEnglish()
+: ScCompiler::GetCharClassLocalized());
+for (sal_uInt32 i=0; i < nListCount; ++i)
 {
-OUString aFuncName(pCharClass->uppercase(*(pDesc->mxFuncName)));
-// fdo#75264 fill maFormulaChar with all characters used in 
formula names
-for (sal_Int32 j = 0; j < aFuncName.getLength(); j++)
-maFormulaChar.insert(aFuncName[j]);
-pFormulaData->insert(ScTypedStrData(*(pDesc->mxFuncName) + 
aParenthesesReplacement, 0.0, 0.0,
-ScTypedStrData::Standard));
-pDesc->initArgumentInfo();
-OUString aEntry = pDesc->getSignature();
-pFormulaDataPara->insert(ScTypedStrData(aEntry, 0.0, 0.0, 
ScTypedStrData::Standard));
+const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
+if ( pDesc->mxFuncName )
+{
+OUString 
aFuncName(pCharClass->uppercase(*(pDesc->mxFuncName)));
+// fdo#75264 fill maFormulaChar with all characters used in 
formula names
+

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-25 Thread Luboš Luňák (via logerrit)
 sc/inc/column.hxx  |2 -
 sc/inc/document.hxx|4 ++-
 sc/inc/formulacell.hxx |2 +
 sc/inc/rangecache.hxx  |2 -
 sc/inc/table.hxx   |2 -
 sc/source/core/data/column3.cxx|   44 +
 sc/source/core/data/documen2.cxx   |   11 ++---
 sc/source/core/data/document.cxx   |   13 +++---
 sc/source/core/data/table1.cxx |7 -
 sc/source/core/tool/rangecache.cxx |6 -
 10 files changed, 65 insertions(+), 28 deletions(-)

New commits:
commit b1b2083ec2ebde32d2c3f7ee2f2e3d2cc75721d8
Author: Luboš Luňák 
AuthorDate: Tue Aug 23 19:47:50 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Aug 25 09:47:35 2022 +0200

try harder to ensure InterpretCellsIfNeeded() interprets (tdf#150499)

ScFormulaCell::Interpret() tries to interpret the whole formula group
(or the given range of it), but it's not guaranteed, and possibly
just the called cell will be interpreted. So if a specific range
really needs to be interpreted, handle that case.

Change-Id: I7fb563ae471eefd49e5bb6c92b6aff98c42a440e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138741
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4cc57f418e91..69f0d12d8273 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -719,7 +719,7 @@ public:
 bool IsDrawObjectsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
 
 void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
-void InterpretCellsIfNeeded( SCROW nRow1, SCROW nRow2 );
+bool InterpretCellsIfNeeded( SCROW nRow1, SCROW nRow2 );
 
 static void JoinNewFormulaCell( const sc::CellStoreType::position_type& 
aPos, ScFormulaCell& rCell );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7866b5a3cf9c..4dab1da8158b 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1363,7 +1363,9 @@ public:
 void  SetTableOpDirty( const ScRange& );  // for Interpreter 
TableOp
 void  InterpretDirtyCells( const ScRangeList& rRanges );
 // Interprets cells that have NeedsInterpret(), i.e. the same like calling 
MaybeInterpret() on them.
-void  InterpretCellsIfNeeded( const ScRangeList& rRanges );
+// Returns false if some couldn't be interpreted (i.e. they still have 
NeedsInterpret()).
+// Useful to ensure that the given cells will not need interpreting.
+bool  InterpretCellsIfNeeded( const ScRangeList& rRanges );
 SC_DLLPUBLIC void CalcAll();
 SC_DLLPUBLIC void CalcAfterLoad( bool bStartListening = true );
 void  CompileAll();
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 013a0058ba5d..789353efce9f 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -261,6 +261,8 @@ public:
 void CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rProgress ); 
   // compile temporary string tokens
 void CalcAfterLoad( sc::CompileFormulaContext& rCxt, bool bStartListening 
);
 boolMarkUsedExternalReferences();
+// Returns true if the cell was interpreted as part of the formula group.
+// The parameters may limit which subset of the formula group should be 
interepreted, if possible.
 bool Interpret(SCROW nStartOffset = -1, SCROW nEndOffset = -1);
 bool IsIterCell() const { return bIsIterCell; }
 sal_uInt16 GetSeenInIteration() const { return nSeenInIteration; }
diff --git a/sc/inc/rangecache.hxx b/sc/inc/rangecache.hxx
index 7490a570f20a..c65e8653a458 100644
--- a/sc/inc/rangecache.hxx
+++ b/sc/inc/rangecache.hxx
@@ -46,7 +46,7 @@ class ScSortedRangeCache final : public SvtListener
 public:
 /// MUST be new'd because Notify() deletes.
 ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, const 
ScQueryParam& param,
-   ScInterpreterContext* context);
+   ScInterpreterContext* context, bool invalid = false);
 
 /// Returns if the cache is usable.
 bool isValid() const { return mValid; }
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c6c3bd031cb3..d8daa1b03f4a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -1057,7 +1057,7 @@ public:
 void FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2, svl::SharedStringPool* pPool ) const;
 
 void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 );
-void InterpretCellsIfNeeded( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 );
+bool InterpretCellsIfNeeded( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 );
 
 void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, 
size_t nLen );
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 6956951cf765..b93e3afb47fc 100644
--- a/sc/source/core/data/column3.cxx
+++ 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-24 Thread Eike Rathke (via logerrit)
 sc/inc/compiler.hxx  |2 +-
 sc/source/core/tool/compiler.cxx |8 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 65747afbb644607c0d2a1fbf354a1a080292b285
Author: Eike Rathke 
AuthorDate: Tue Aug 23 15:40:09 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Aug 23 22:09:48 2022 +0200

Make static ScCompiler::GetCharClassLocalized() public as well

... and mutex guard it.

Change-Id: Ief9c6deaf7974ac43c7ae439a0fb73c29eced283
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138733
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 5f6c521d11cf..965232485049 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -378,8 +378,8 @@ private:
 
 bool HasPossibleNamedRangeConflict(SCTAB nTab) const;
 
-static const CharClass* GetCharClassLocalized();
 public:
+static const CharClass* GetCharClassLocalized();
 static const CharClass* GetCharClassEnglish();
 
 public:
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index d4ee9a19fd14..ecd1dfed63f6 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -242,8 +242,12 @@ const CharClass* ScCompiler::GetCharClassLocalized()
 {
 // Switching UI language requires restart; if not, we would have to
 // keep track of that.
-pCharClassLocalized = new CharClass(
-::comphelper::getProcessComponentContext(), 
Application::GetSettings().GetUILanguageTag());
+osl::MutexGuard aGuard(maMutex);
+if (!pCharClassLocalized)
+{
+pCharClassLocalized = new CharClass( 
::comphelper::getProcessComponentContext(),
+Application::GetSettings().GetUILanguageTag());
+}
 }
 return pCharClassLocalized;
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-11 Thread Noel Grandin (via logerrit)
 sc/inc/formularesult.hxx  |   14 --
 sc/source/core/tool/formularesult.cxx |9 +++--
 2 files changed, 3 insertions(+), 20 deletions(-)

New commits:
commit 0dffa005544ca29c8726aa008fadfccc5520e791
Author: Noel Grandin 
AuthorDate: Thu Aug 11 12:14:13 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Aug 11 20:37:17 2022 +0200

fix tsan data-race

this check is not necessary, we are using a 32/64 bit counter (depending
on platform) for some years now

WARNING: ThreadSanitizer: data race (pid=90197)
  Atomic write of size 4 at 0x7b08002f474c by thread T90:
#0 ScInterpreter::Interpret() interpr4.cxx:? (libsclo.so+0xb99c26)
#1 ScFormulaCell::InterpretTail(ScInterpreterContext&, 
ScFormulaCell::ScInterpretTailParameter) ??:? (libsclo.so+0x95bfeb)
#2 ScColumn::CalculateInThread(ScInterpreterContext&, int, unsigned 
long, unsigned long, unsigned int, unsigned int) column2.cxx:? 
(libsclo.so+0x754eea)
#3 ScTable::CalculateInColumnInThread(ScInterpreterContext&, short, 
short, int, int, unsigned int, unsigned int) table1.cxx:? (libsclo.so+0x9e692b)
#4 ScDocument::CalculateInColumnInThread(ScInterpreterContext&, ScRange 
const&, unsigned int, unsigned int) documen8.cxx:? (libsclo.so+0x83479f)
#5 
ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope&, 
bool&, bool&, int, int)::Executor::doWork() formulacell.cxx:? 
(libsclo.so+0x96b5e1)
#6 comphelper::ThreadPool::ThreadWorker::execute() threadpool.cxx:? 
(libcomphelper.so+0x1cb0a1)
#7 non-virtual thunk to salhelper::Thread::run() ??:? 
(libuno_salhelpergcc3.so.3+0x67f7)
#8 threadFunc thread.cxx:? (libuno_salhelpergcc3.so.3+0x6aae)
#9 osl_thread_start_Impl(void*) thread.cxx:? (libuno_sal.so.3+0x86245)

  Previous read of size 4 at 0x7b08002f474c by thread T89:
#0 ScFormulaResult::SetToken(formula::FormulaToken const*) 
formularesult.cxx:? (libsclo.so+0xb0e11f)
#1 ScFormulaResult::Assign(ScFormulaResult const&) formularesult.cxx:? 
(libsclo.so+0xb0e837)
#2 ScFormulaCell::InterpretTail(ScInterpreterContext&, 
ScFormulaCell::ScInterpretTailParameter) ??:? (libsclo.so+0x95caa3)
#3 ScColumn::CalculateInThread(ScInterpreterContext&, int, unsigned 
long, unsigned long, unsigned int, unsigned int) column2.cxx:? 
(libsclo.so+0x754eea)
#4 ScTable::CalculateInColumnInThread(ScInterpreterContext&, short, 
short, int, int, unsigned int, unsigned int) table1.cxx:? (libsclo.so+0x9e692b)
#5 ScDocument::CalculateInColumnInThread(ScInterpreterContext&, ScRange 
const&, unsigned int, unsigned int) documen8.cxx:? (libsclo.so+0x83479f)
#6 
ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope&, 
bool&, bool&, int, int)::Executor::doWork() formulacell.cxx:? 
(libsclo.so+0x96b5e1)
#7 comphelper::ThreadPool::ThreadWorker::execute() threadpool.cxx:? 
(libcomphelper.so+0x1cb0a1)
#8 non-virtual thunk to salhelper::Thread::run() ??:? 
(libuno_salhelpergcc3.so.3+0x67f7)
#9 threadFunc thread.cxx:? (libuno_salhelpergcc3.so.3+0x6aae)
#10 osl_thread_start_Impl(void*) thread.cxx:? (libuno_sal.so.3+0x86245)

Change-Id: I3e51db3a8a0a18fee1647657369ecebf5de108e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138137
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 52be625b7b82..ff036a78bcb3 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -55,20 +55,6 @@ class ScFormulaResult
 static const Multiline MULTILINE_FALSE   = 1;
 static const Multiline MULTILINE_TRUE= 2;
 
-// Clone token if the 16-bit only reference counter is nearing it's
-// capacity during fill or copy, leaving 4k for temporary passing
-// around. (That should be enough for all times (TM) ;-)
-static const sal_uInt16 MAX_TOKENREF_COUNT = 0xf000;
-static void IncrementTokenRef( const formula::FormulaToken* & rp )
-{
-if (rp)
-{
-if (rp->GetRef() >= MAX_TOKENREF_COUNT)
-rp = rp->Clone();
-rp->IncRef();
-}
-}
-
 union
 {
 double  mfValue;// double result direct for performance 
and memory consumption
diff --git a/sc/source/core/tool/formularesult.cxx 
b/sc/source/core/tool/formularesult.cxx
index d4b146dfe3bd..31b13af8fea8 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -52,12 +52,8 @@ ScFormulaResult::ScFormulaResult( const ScFormulaResult & r 
) :
 const ScMatrixFormulaCellToken* pMatFormula =
 r.GetMatrixFormulaCellToken();
 if (pMatFormula)
-{
 mpToken = new ScMatrixFormulaCellToken( *pMatFormula);
-mpToken->IncRef();
-}
-else
-

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-09 Thread Eike Rathke (via logerrit)
 sc/inc/compiler.hxx  |4 +++-
 sc/source/core/tool/addincol.cxx |7 ---
 sc/source/core/tool/compiler.cxx |   10 +++---
 3 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 33c8c9d0dc8e76bc7dacb92175047a89f7d39a3c
Author: Eike Rathke 
AuthorDate: Mon Aug 8 20:52:25 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Aug 9 10:21:34 2022 +0200

Use CharClass::uppercase() for AddIns' English UI names, tdf#135993 
follow-up

... instead of OUString::toAsciiUpperCase(). English names should
consist of ASCII alphanumeric only, but we don't know what an
AddIn's author comes up with. Lookup in ScCompiler is done with
CharClass as well.

For this, use the static ScCompiler::GetCharClassEnglish()
instance made public and guard creation with a mutex.

Change-Id: Icb79d49d4c7339c8d01b141de2a34715d794dd92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138004
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 0cd48fccc92e..5f6c521d11cf 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -257,6 +257,7 @@ public:
 
 private:
 
+static osl::Mutex   maMutex;
 static const CharClass  *pCharClassEnglish; // character 
classification for en_US locale
 static const CharClass  *pCharClassLocalized;   // character 
classification for UI locale
 static const Convention *pConventions[ 
formula::FormulaGrammar::CONV_LAST ];
@@ -377,8 +378,9 @@ private:
 
 bool HasPossibleNamedRangeConflict(SCTAB nTab) const;
 
-static const CharClass* GetCharClassEnglish();
 static const CharClass* GetCharClassLocalized();
+public:
+static const CharClass* GetCharClassEnglish();
 
 public:
 ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos,
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index cc444e808e9c..1ffb1e5bc1d7 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace com::sun::star;
@@ -142,7 +143,7 @@ void ScUnoAddInFuncData::SetCompNames( ::std::vector< 
ScUnoAddInFuncData::Locali
 void ScUnoAddInFuncData::SetEnglishName( const OUString& rEnglishName )
 {
 if (!rEnglishName.isEmpty())
-aUpperEnglish = rEnglishName.toAsciiUpperCase();
+aUpperEnglish = 
ScCompiler::GetCharClassEnglish()->uppercase(rEnglishName);
 else
 {
 // A dumb fallback to not have an empty name, mainly just for the
@@ -558,7 +559,7 @@ void ScUnoAddInCollection::ReadConfiguration()
 else
 {
 pEnglishHashMap->emplace(
-aEnglishName.toAsciiUpperCase(),
+
ScCompiler::GetCharClassEnglish()->uppercase(aEnglishName),
 pData );
 }
 pData->SetEnglishName(aEnglishName);// takes care of 
handling empty
@@ -950,7 +951,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const 
uno::Reference&
 else
 {
 pEnglishHashMap->emplace(
-aEnglishName.toAsciiUpperCase(),
+
ScCompiler::GetCharClassEnglish()->uppercase(aEnglishName),
 pData );
 }
 pData->SetEnglishName(aEnglishName);// takes care of 
handling empty
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 2b1d70280926..d4ee9a19fd14 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -77,6 +77,7 @@ using namespace formula;
 using namespace ::com::sun::star;
 using ::std::vector;
 
+osl::Mutex  ScCompiler::maMutex;
 const CharClass*ScCompiler::pCharClassEnglish = nullptr;
 const CharClass*ScCompiler::pCharClassLocalized = nullptr;
 const ScCompiler::Convention*   ScCompiler::pConventions[ ]   = { nullptr, 
nullptr, nullptr, nullptr, nullptr, nullptr };
@@ -225,9 +226,12 @@ const CharClass* ScCompiler::GetCharClassEnglish()
 {
 if (!pCharClassEnglish)
 {
-css::lang::Locale aLocale( "en", "US", "");
-pCharClassEnglish = new CharClass(
-::comphelper::getProcessComponentContext(), LanguageTag( 
aLocale));
+osl::MutexGuard aGuard(maMutex);
+if (!pCharClassEnglish)
+{
+pCharClassEnglish = new CharClass( 
::comphelper::getProcessComponentContext(),
+LanguageTag( LANGUAGE_ENGLISH_US));
+}
 }
 return pCharClassEnglish;
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-07 Thread Noel Grandin (via logerrit)
 sc/inc/PivotTableDataSequence.hxx  |7 -
 sc/inc/Sparkline.hxx   |5 
 sc/inc/SparklineCell.hxx   |5 
 sc/inc/SparklineGroup.hxx  |2 
 sc/inc/TablePivotChart.hxx |2 
 sc/inc/addincol.hxx|   13 +-
 sc/inc/arealink.hxx|6 -
 sc/inc/callform.hxx|4 
 sc/inc/cellsuno.hxx|6 -
 sc/inc/chartlis.hxx|4 
 sc/inc/chartpos.hxx|2 
 sc/inc/chartuno.hxx|2 
 sc/inc/chgtrack.hxx|   14 +-
 sc/inc/conditio.hxx|4 
 sc/inc/dapiuno.hxx |   15 +-
 sc/inc/datamapper.hxx  |2 
 sc/inc/datauno.hxx |2 
 sc/inc/defaultsoptions.hxx |2 
 sc/inc/dpdimsave.hxx   |   10 -
 sc/inc/dpgroup.hxx |2 
 sc/inc/dpobject.hxx|6 -
 sc/inc/dpoutput.hxx|2 
 sc/inc/dpresfilter.hxx |2 
 sc/inc/dpsave.hxx  |4 
 sc/inc/drwlayer.hxx|2 
 sc/inc/externalrefmgr.hxx  |2 
 sc/inc/fielduno.hxx|4 
 sc/inc/fmtuno.hxx  |2 
 sc/inc/formulaopt.hxx  |2 
 sc/inc/formularesult.hxx   |2 
 sc/inc/hints.hxx   |6 -
 sc/inc/linkuno.hxx |8 -
 sc/inc/listenercalls.hxx   |9 -
 sc/inc/listenercontext.hxx |4 
 sc/inc/matrixoperators.hxx |3 
 sc/inc/miscuno.hxx |6 -
 sc/inc/nameuno.hxx |4 
 sc/inc/orcusxml.hxx|2 
 sc/inc/pivot.hxx   |2 
 sc/inc/postit.hxx  |2 
 sc/inc/reffind.hxx |2 
 sc/inc/sheetdata.hxx   |   21 +--
 sc/inc/styleuno.hxx|2 
 sc/inc/tablink.hxx |8 -
 sc/inc/targuno.hxx |2 
 sc/inc/textuno.hxx |4 
 sc/inc/token.hxx   |   12 +-
 sc/inc/typedstrdata.hxx|2 
 sc/inc/unoreflist.hxx  |7 -
 sc/inc/userlist.hxx|4 
 sc/inc/xmlwrap.hxx |2 
 sc/source/core/data/column2.cxx|3 
 sc/source/core/data/conditio.cxx   |9 -
 sc/source/core/data/dpdimsave.cxx  |   29 ++---
 sc/source/core/data/dpgroup.cxx|5 
 sc/source/core/data/dpobject.cxx   |   27 ++--
 sc/source/core/data/dpoutput.cxx   |9 -
 sc/source/core/data/dpresfilter.cxx|5 
 sc/source/core/data/dpsave.cxx |9 -
 sc/source/core/data/drwlayer.cxx   |5 
 sc/source/core/data/listenercontext.cxx|9 -
 sc/source/core/data/pivot2.cxx |5 
 sc/source/core/data/postit.cxx |   11 +
 sc/source/core/inc/addinlis.hxx|2 
 sc/source/core/inc/ddelink.hxx |2 
 sc/source/core/inc/doubleref.hxx   |2 
 sc/source/core/inc/webservicelink.hxx  |2 
 sc/source/core/opencl/formulagroupcl.cxx   |   17 +--
 sc/source/core/opencl/opbase.cxx   |   23 ++--
 sc/source/core/opencl/opbase.hxx   |   10 -
 sc/source/core/tool/addincol.cxx   |   17 +--
 sc/source/core/tool/addinlis.cxx   |5 
 sc/source/core/tool/callform.cxx   |   11 +
 sc/source/core/tool/chartlis.cxx   |   15 +-
 sc/source/core/tool/chartpos.cxx   |5 
 sc/source/core/tool/chgtrack.cxx   |   27 ++--
 sc/source/core/tool/dbdata.cxx |4 
 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-06 Thread Eike Rathke (via logerrit)
 sc/inc/addincol.hxx  |   10 +-
 sc/inc/funcdesc.hxx  |2 -
 sc/source/core/data/funcdesc.cxx |4 +-
 sc/source/core/data/global.cxx   |3 +
 sc/source/core/tool/addincol.cxx |   59 +++
 5 files changed, 48 insertions(+), 30 deletions(-)

New commits:
commit d778c6fd5c2ba8e27df46ec9e183a61ad29e30d5
Author: Eike Rathke 
AuthorDate: Fri Aug 5 19:46:07 2022 +0200
Commit: Eike Rathke 
CommitDate: Sat Aug 6 19:37:55 2022 +0200

Resolves: tdf#135993 Create ScFunctionList and ScFuncDesc with English names

Used in Function Wizard and formula tooltips. Without, no matching
name is found for AddIn English name and no
tooltip/description/arguments are displayed.

Change-Id: Ib0cf419c476dae495467c444f1ee1f84a55633a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137883
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 14af12006637..bb89f8d3c87a 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -87,6 +87,7 @@ private:
 OUStringaLocalName; ///< for display
 OUStringaUpperName; ///< for entering formulas
 OUStringaUpperLocal;///< for entering formulas
+OUStringaUpperEnglish;  ///< for Function Wizard and 
tooltips
 OUStringaDescription;
 css::uno::Reference< css::reflection::XIdlMethod> xFunction;
 css::uno::Any   aObject;
@@ -113,6 +114,7 @@ public:
 const OUString&  GetLocalName() const{ return aLocalName; }
 const OUString&  GetUpperName() const{ return aUpperName; }
 const OUString&  GetUpperLocal() const   { return aUpperLocal; }
+const OUString&  GetUpperEnglish() const { return aUpperEnglish; }
 const css::uno::Reference< css::reflection::XIdlMethod>&   GetFunction() 
const
 { return xFunction; }
 const css::uno::Any& GetObject() const   { return aObject; }
@@ -132,6 +134,9 @@ public:
 voidSetArguments( tools::Long nNewCount, const ScAddInArgDesc* 
pNewDescs );
 voidSetCallerPos( tools::Long nNewPos );
 voidSetCompNames( ::std::vector< LocalizedName >&& rNew );
+
+/// Takes care of handling an empty name *after* upper local name was set.
+voidSetEnglishName( const OUString& rEnglishName );
 };
 
 class SC_DLLPUBLIC ScUnoAddInCollection
@@ -175,9 +180,10 @@ public:
 voidLocalizeString( OUString& rName );///< modify 
rName - input: exact name
 
 tools::LongGetFuncCount();
-boolFillFunctionDesc( tools::Long nFunc, ScFuncDesc& rDesc 
);
+boolFillFunctionDesc( tools::Long nFunc, ScFuncDesc& 
rDesc, bool bEnglishFunctionNames );
 
-static bool FillFunctionDescFromData( const ScUnoAddInFuncData& 
rFuncData, ScFuncDesc& rDesc );
+static bool FillFunctionDescFromData( const ScUnoAddInFuncData& 
rFuncData, ScFuncDesc& rDesc,
+  bool bEnglishFunctionNames );
   /// leave rRetExcelName unchanged, if no matching name is 
found
 boolGetExcelName( const OUString& rCalcName, LanguageType 
eDestLang, OUString& rRetExcelName );
   /// leave rRetCalcName unchanged, if no matching name is 
found
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index 58c6957316b3..0f37e924d941 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -241,7 +241,7 @@ public:
 class ScFunctionList
 {
 public:
-ScFunctionList();
+explicit ScFunctionList( bool bEnglishFunctionNames );
 ~ScFunctionList();
 
 sal_uInt32 GetCount() const
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index dfbfd9a3a78e..c8045e6c1abf 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -397,7 +397,7 @@ bool ScFuncDesc::compareByName(const ScFuncDesc* a, const 
ScFuncDesc* b)
 
 #define ENTRY(CODE) CODE, SAL_N_ELEMENTS(CODE)
 
-ScFunctionList::ScFunctionList()
+ScFunctionList::ScFunctionList( bool bEnglishFunctionNames )
 {
 sal_Int32  nMaxFuncNameLen = 0; // Length of longest function name
 
@@ -958,7 +958,7 @@ ScFunctionList::ScFunctionList()
 pDesc = new ScFuncDesc;
 pDesc->nFIndex = nNextId++;
 
-if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc ) )
+if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc, 
bEnglishFunctionNames ) )
 {
 tmpFuncVector.push_back(pDesc);
 nStrLen = pDesc->mxFuncName->getLength();
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index a338c0c76c31..46277a807db0 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -74,6 +74,7 @@
 #include 
 #include 
 #include 
+#include 
 
 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-02 Thread Eike Rathke (via logerrit)
 sc/inc/addincol.hxx  |3 ++-
 sc/source/core/tool/addincol.cxx |   12 ++--
 sc/source/core/tool/compiler.cxx |6 --
 3 files changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 86b2bfd34a4f07c54f03c8c8dfe48e0810834628
Author: Eike Rathke 
AuthorDate: Tue Aug 2 22:34:46 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Aug 3 00:08:18 2022 +0200

Avoid multiple conversions to LanguageTag, specifically in loops

Change-Id: I47a969d7476df32e0c9d525d416467c59358d9ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137712
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 2602624da287..14af12006637 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -42,6 +42,7 @@ namespace com::sun::star::uno { class XInterface; }
 class SfxObjectShell;
 class ScUnoAddInFuncData;
 class ScFuncDesc;
+class LanguageTag;
 
 typedef std::unordered_map< OUString, const ScUnoAddInFuncData* > 
ScAddInHashMap;
 
@@ -123,7 +124,7 @@ public:
 const OString&  GetHelpId() const   { return sHelpId; }
 
 const ::std::vector< LocalizedName >&  GetCompNames() const;
-boolGetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName,
+boolGetExcelName( const LanguageTag& rDestLang, 
OUString& rRetExcelName,
   bool bFallbackToAny = true ) const;
 
 voidSetFunction( const css::uno::Reference< 
css::reflection::XIdlMethod>& rNewFunc,
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 7ccf8b6c5c32..ea2184233f62 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -138,13 +138,12 @@ void ScUnoAddInFuncData::SetCompNames( ::std::vector< 
ScUnoAddInFuncData::Locali
 bCompInitialized = true;
 }
 
-bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName, bool bFallbackToAny ) const
+bool ScUnoAddInFuncData::GetExcelName( const LanguageTag& rDestLang, OUString& 
rRetExcelName, bool bFallbackToAny ) const
 {
 const ::std::vector& rCompNames = GetCompNames();
 if ( !rCompNames.empty() )
 {
-LanguageTag aLanguageTag( eDestLang);
-const OUString& aSearch( aLanguageTag.getBcp47());
+const OUString& aSearch( rDestLang.getBcp47());
 
 // First, check exact match without fallback overhead.
 ::std::vector::const_iterator itNames = 
std::find_if(rCompNames.begin(), rCompNames.end(),
@@ -157,7 +156,7 @@ bool ScUnoAddInFuncData::GetExcelName( LanguageType 
eDestLang, OUString& rRetExc
 
 // Second, try match of fallback search with fallback locales,
 // appending also 'en-US' and 'en' to search if not queried.
-::std::vector< OUString > aFallbackSearch( 
aLanguageTag.getFallbackStrings( true));
+::std::vector< OUString > aFallbackSearch( 
rDestLang.getFallbackStrings( true));
 if (aSearch != "en-US")
 {
 aFallbackSearch.emplace_back("en-US");
@@ -582,7 +581,7 @@ bool ScUnoAddInCollection::GetExcelName( const OUString& 
rCalcName,
 {
 const ScUnoAddInFuncData* pFuncData = GetFuncData( rCalcName );
 if ( pFuncData )
-return pFuncData->GetExcelName( eDestLang, rRetExcelName);
+return pFuncData->GetExcelName( LanguageTag( eDestLang), 
rRetExcelName);
 return false;
 }
 
@@ -770,6 +769,7 @@ void ScUnoAddInCollection::ReadFromAddIn( const 
uno::Reference&
 if ( !pEnglishHashMap )
 pEnglishHashMap.reset( new ScAddInHashMap );
 
+const LanguageTag aEnglishLanguageTag(LANGUAGE_ENGLISH_US);
 const uno::Reference* pArray = 
aMethods.getConstArray();
 for (tools::Long nFuncPos=0; nFuncPos&
 pData );
 
 OUString aEnglishName;
-if (!pData->GetExcelName( LANGUAGE_ENGLISH_US, 
aEnglishName, false /*bFallbackToAny*/))
+if (!pData->GetExcelName( aEnglishLanguageTag, 
aEnglishName, false /*bFallbackToAny*/))
 SAL_WARN("sc.core", "no English name for " << 
aLocalName << " " << aFuncName);
 else
 {
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 14ae448f06b9..0de38ad001b2 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -148,6 +148,7 @@ void ScCompiler::fillFromAddInCollectionUpperName( const 
NonConstOpCodeMapPtr& x
 
 void ScCompiler::fillFromAddInCollectionEnglishName( const 
NonConstOpCodeMapPtr& xMap ) const
 {
+const LanguageTag aEnglishLanguageTag(LANGUAGE_ENGLISH_US);
 ScUnoAddInCollection* pColl = ScGlobal::GetAddInCollection();
 tools::Long nCount = pColl->GetFuncCount();
 for (tools::Long i=0; i < nCount; ++i)
@@ -156,7 +157,7 @@ void ScCompiler::fillFromAddInCollectionEnglishName( const 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-08-02 Thread Eike Rathke (via logerrit)
 sc/inc/addincol.hxx  |4 ++
 sc/source/core/tool/addincol.cxx |   57 +--
 2 files changed, 52 insertions(+), 9 deletions(-)

New commits:
commit 8dc76b13458fac1a30787f8bbab117a4a9508ab5
Author: Eike Rathke 
AuthorDate: Tue Aug 2 21:39:56 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Aug 2 22:32:54 2022 +0200

Resolves: tdf#150203 Gather AddIn English names and provide for 
FunctionAccess

This works at least for the bundled AddIns from scaddins/. It may
for others if en-US compatibility function names are provided, if
not the local name will be continued to be used.

Change-Id: I09e23f731c0f3d9753ef355ab59c2005bc567464
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137708
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 9366e31b68ff..2602624da287 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -123,7 +123,8 @@ public:
 const OString&  GetHelpId() const   { return sHelpId; }
 
 const ::std::vector< LocalizedName >&  GetCompNames() const;
-boolGetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName ) const;
+boolGetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName,
+  bool bFallbackToAny = true ) const;
 
 voidSetFunction( const css::uno::Reference< 
css::reflection::XIdlMethod>& rNewFunc,
  const css::uno::Any& rNewObj );
@@ -140,6 +141,7 @@ private:
 std::unique_ptr   pExactHashMap;  ///< exact 
internal name
 std::unique_ptr   pNameHashMap;   ///< internal 
name upper
 std::unique_ptr   pLocalHashMap;  ///< localized 
name upper
+std::unique_ptr   pEnglishHashMap;///< English 
name upper
 boolbInitialized;
 
 voidInitialize();
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index addb1512806f..7ccf8b6c5c32 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -138,7 +138,7 @@ void ScUnoAddInFuncData::SetCompNames( ::std::vector< 
ScUnoAddInFuncData::Locali
 bCompInitialized = true;
 }
 
-bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName ) const
+bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& 
rRetExcelName, bool bFallbackToAny ) const
 {
 const ::std::vector& rCompNames = GetCompNames();
 if ( !rCompNames.empty() )
@@ -180,9 +180,12 @@ bool ScUnoAddInFuncData::GetExcelName( LanguageType 
eDestLang, OUString& rRetExc
 }
 }
 
-// Third, last resort, use first (default) entry.
-rRetExcelName = rCompNames[0].maName;
-return true;
+if (bFallbackToAny)
+{
+// Third, last resort, use first (default) entry.
+rRetExcelName = rCompNames[0].maName;
+return true;
+}
 }
 return false;
 }
@@ -226,6 +229,7 @@ void ScUnoAddInCollection::Clear()
 pExactHashMap.reset();
 pNameHashMap.reset();
 pLocalHashMap.reset();
+pEnglishHashMap.reset();
 ppFuncData.reset();
 nFuncCount = 0;
 
@@ -380,6 +384,8 @@ void ScUnoAddInCollection::ReadConfiguration()
 pNameHashMap.reset( new ScAddInHashMap );
 if ( !pLocalHashMap )
 pLocalHashMap.reset( new ScAddInHashMap );
+if ( !pEnglishHashMap )
+pEnglishHashMap.reset( new ScAddInHashMap );
 
 //TODO: get the function information in a single call for all 
functions?
 
@@ -395,6 +401,7 @@ void ScUnoAddInCollection::ReadConfiguration()
 
 if ( pExactHashMap->find( aFuncName ) == pExactHashMap->end() )
 {
+OUString aEnglishName;
 OUString aLocalName;
 OUString aDescription;
 sal_uInt16 nCategory = ID_FUNCTION_GRP_ADDINS;
@@ -441,6 +448,11 @@ void ScUnoAddInCollection::ReadConfiguration()
 OUString aName;
 rConfig.Value >>= aName;
 aCompNames.emplace_back( aLocale, aName);
+// Accept 'en' and 'en-...' but prefer 'en-US'.
+if (aLocale == "en-US")
+aEnglishName = aName;
+else if (aEnglishName.isEmpty() && (aLocale == 
"en" || aLocale.startsWith("en-")))
+aEnglishName = aName;
 }
 }
 }
@@ -527,6 +539,15 @@ void ScUnoAddInCollection::ReadConfiguration()
 pLocalHashMap->emplace(
 pData->GetUpperLocal(),
 pData );
+
+if (aEnglishName.isEmpty())
+SAL_WARN("sc.core", "no 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-07-27 Thread Eike Rathke (via logerrit)
 sc/inc/column.hxx   |2 --
 sc/source/core/data/column.cxx  |1 -
 sc/source/core/data/column3.cxx |   10 +-
 3 files changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 3172472aa749defc68f51e3436a089f49a496e8b
Author: Eike Rathke 
AuthorDate: Wed Jul 27 18:21:20 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Jul 27 20:38:19 2022 +0200

Unnecessary to remember mbFiltering at column, tdf#140968 tdf#140978 
follow-up

It's inviting confusion and only needed for FilterEntriesHandler,
so pass it there.

Change-Id: I8056bf8e8f563b28358c46b19071e7caa69c88a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137513
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ba964cdfee89..4cc57f418e91 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -203,7 +203,6 @@ class ScColumn : protected ScColumnData
 SCCOL   nCol;
 SCTAB   nTab;
 
-bool mbFiltering : 1; // it is true if there is a filtering in the column
 bool mbEmptyBroadcastersPending : 1; // a broadcaster not removed during 
EnableDelayDeletingBroadcasters()
 
 friend class ScDocument;// for FillInfo
@@ -254,7 +253,6 @@ public:
 using ScColumnData::GetDoc;
 SCTAB GetTab() const { return nTab; }
 SCCOL GetCol() const { return nCol; }
-bool HasFiltering() const { return mbFiltering; }
 sc::CellStoreType& GetCellStore() { return maCells; }
 const sc::CellStoreType& GetCellStore() const { return maCells; }
 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 7ebba48b5792..fea2f84e5be0 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -88,7 +88,6 @@ ScColumn::ScColumn(ScSheetLimits const & rSheetLimits) :
 mnBlkCountFormula(0),
 nCol( 0 ),
 nTab( 0 ),
-mbFiltering( false ),
 mbEmptyBroadcastersPending( false )
 {
 maCells.resize(rSheetLimits.GetMaxRowCount());
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ceb06b11b481..6956951cf765 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2488,13 +2488,14 @@ class FilterEntriesHandler
 {
 ScColumn& mrColumn;
 ScFilterEntries& mrFilterEntries;
+bool mbFiltering;
 bool mbFilteredRow;
 
 void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell)
 {
 SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
 sal_uLong nFormat = 
mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
-OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, 
*pFormatter, mrColumn.GetDoc(), mrColumn.HasFiltering());
+OUString aStr = ScCellFormat::GetInputString(rCell, nFormat, 
*pFormatter, mrColumn.GetDoc(), mbFiltering);
 
 // Colors
 ScAddress aPos(rColumn.GetCol(), nRow, rColumn.GetTab());
@@ -2624,8 +2625,8 @@ class FilterEntriesHandler
 }
 
 public:
-FilterEntriesHandler(ScColumn& rColumn, ScFilterEntries& rFilterEntries, 
bool bFilteredRow) :
-mrColumn(rColumn), mrFilterEntries(rFilterEntries), 
mbFilteredRow(bFilteredRow) {}
+FilterEntriesHandler(ScColumn& rColumn, ScFilterEntries& rFilterEntries, 
bool bFiltering, bool bFilteredRow) :
+mrColumn(rColumn), mrFilterEntries(rFilterEntries), 
mbFiltering(bFiltering), mbFilteredRow(bFilteredRow) {}
 
 void operator() (size_t nRow, double fVal)
 {
@@ -2673,8 +2674,7 @@ void ScColumn::GetFilterEntries(
 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
 ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow )
 {
-mbFiltering = bFiltering;
-FilterEntriesHandler aFunc(*this, rFilterEntries, bFilteredRow);
+FilterEntriesHandler aFunc(*this, rFilterEntries, bFiltering, 
bFilteredRow);
 rBlockPos.miCellPos =
 sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, 
aFunc);
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-07-27 Thread Eike Rathke (via logerrit)
 sc/inc/column.hxx   |2 --
 sc/source/core/data/column3.cxx |   14 +++---
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 2085e90fe8ac129bc4dbac4612d1ea7544335dae
Author: Eike Rathke 
AuthorDate: Wed Jul 27 18:01:11 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Jul 27 20:19:45 2022 +0200

FilteredRow is not a property of the column, tdf#117276 follow-up

It's only needed in the FilterEntriesHandler, so pass it there.

Change-Id: I5554ad13a43ccce6aafbba82b33418f060173a43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137512
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index a67a166646e2..ba964cdfee89 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -204,7 +204,6 @@ class ScColumn : protected ScColumnData
 SCTAB   nTab;
 
 bool mbFiltering : 1; // it is true if there is a filtering in the column
-bool mbFilteredRow : 1; // it is true if the actual row of the filtered 
column is hidden
 bool mbEmptyBroadcastersPending : 1; // a broadcaster not removed during 
EnableDelayDeletingBroadcasters()
 
 friend class ScDocument;// for FillInfo
@@ -256,7 +255,6 @@ public:
 SCTAB GetTab() const { return nTab; }
 SCCOL GetCol() const { return nCol; }
 bool HasFiltering() const { return mbFiltering; }
-bool IsFilteredRow() const { return mbFilteredRow; }
 sc::CellStoreType& GetCellStore() { return maCells; }
 const sc::CellStoreType& GetCellStore() const { return maCells; }
 sc::CellTextAttrStoreType& GetCellAttrStore() { return maCellTextAttrs; }
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1d255233bf58..ceb06b11b481 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2488,6 +2488,7 @@ class FilterEntriesHandler
 {
 ScColumn& mrColumn;
 ScFilterEntries& mrFilterEntries;
+bool mbFilteredRow;
 
 void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell)
 {
@@ -2559,7 +2560,7 @@ class FilterEntriesHandler
 
 if (rCell.hasString())
 {
-mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), 0.0, 
0.0, ScTypedStrData::Standard, false, mrColumn.IsFilteredRow()));
+mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), 0.0, 
0.0, ScTypedStrData::Standard, false, mbFilteredRow));
 return;
 }
 
@@ -2617,14 +2618,14 @@ class FilterEntriesHandler
 }
 // store the formatted/rounded value for filtering
 if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0 && !bDate)
-mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), fVal, 
rColumn.GetDoc().RoundValueAsShown(fVal, nFormat), ScTypedStrData::Value, 
bDate, mrColumn.IsFilteredRow()));
+mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), fVal, 
rColumn.GetDoc().RoundValueAsShown(fVal, nFormat), ScTypedStrData::Value, 
bDate, mbFilteredRow));
 else
-mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), fVal, 
fVal, ScTypedStrData::Value, bDate, mrColumn.IsFilteredRow()));
+mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), fVal, 
fVal, ScTypedStrData::Value, bDate, mbFilteredRow));
 }
 
 public:
-FilterEntriesHandler(ScColumn& rColumn, ScFilterEntries& rFilterEntries) :
-mrColumn(rColumn), mrFilterEntries(rFilterEntries) {}
+FilterEntriesHandler(ScColumn& rColumn, ScFilterEntries& rFilterEntries, 
bool bFilteredRow) :
+mrColumn(rColumn), mrFilterEntries(rFilterEntries), 
mbFilteredRow(bFilteredRow) {}
 
 void operator() (size_t nRow, double fVal)
 {
@@ -2673,8 +2674,7 @@ void ScColumn::GetFilterEntries(
 ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow )
 {
 mbFiltering = bFiltering;
-mbFilteredRow = bFilteredRow;
-FilterEntriesHandler aFunc(*this, rFilterEntries);
+FilterEntriesHandler aFunc(*this, rFilterEntries, bFilteredRow);
 rBlockPos.miCellPos =
 sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, 
aFunc);
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-07-27 Thread Eike Rathke (via logerrit)
 sc/inc/column.hxx   |2 +-
 sc/source/core/data/column3.cxx |4 ++--
 sc/source/core/data/table3.cxx  |6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 19533948370dc1ccd7334dbe1a8b7fc8330b10c0
Author: Eike Rathke 
AuthorDate: Wed Jul 27 17:40:31 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Jul 27 19:44:34 2022 +0200

Name FilteredRow what it is, not hidden; tdf#117276 follow-up

Also avoid defaulted parameter, it's only one more place to
change.

Change-Id: I64468fcd7085eff7a49bd0c359fdf14a31058af6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137511
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 56aa1f9fc65e..a67a166646e2 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -600,7 +600,7 @@ public:
 
 void GetFilterEntries(
 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW 
nEndRow,
-ScFilterEntries& rFilterEntries, bool bFiltering, bool bHiddenRow = 
false );
+ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow );
 
 bool GetDataEntries( SCROW nRow, std::set& rStrings) const;
 
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ebbefb03b714..1d255233bf58 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2670,10 +2670,10 @@ public:
 
 void ScColumn::GetFilterEntries(
 sc::ColumnBlockConstPosition& rBlockPos, SCROW nStartRow, SCROW nEndRow,
-ScFilterEntries& rFilterEntries, bool bFiltering, bool bHiddenRow )
+ScFilterEntries& rFilterEntries, bool bFiltering, bool bFilteredRow )
 {
 mbFiltering = bFiltering;
-mbFilteredRow = bHiddenRow;
+mbFilteredRow = bFilteredRow;
 FilterEntriesHandler aFunc(*this, rFilterEntries);
 rBlockPos.miCellPos =
 sc::ParseAll(rBlockPos.miCellPos, maCells, nStartRow, nEndRow, aFunc, 
aFunc);
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 52b4a0500a46..5a128152ad46 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2978,7 +2978,7 @@ void ScTable::GetFilterEntries( SCCOL nCol, SCROW nRow1, 
SCROW nRow2, ScFilterEn
 
 sc::ColumnBlockConstPosition aBlockPos;
 aCol[nCol].InitBlockPosition(aBlockPos);
-aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, 
bFiltering);
+aCol[nCol].GetFilterEntries(aBlockPos, nRow1, nRow2, rFilterEntries, 
bFiltering, false /*bFilteredRow*/);
 }
 
 void ScTable::GetFilteredFilterEntries(
@@ -3000,11 +3000,11 @@ void ScTable::GetFilteredFilterEntries(
 {
 if (queryEvaluator.ValidQuery(j))
 {
-aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, 
bFiltering, false/*bHiddenRow*/);
+aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, 
bFiltering, false/*bFilteredRow*/);
 }
 else
 {
-aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, 
bFiltering, true/*bHiddenRow*/);
+aCol[nCol].GetFilterEntries(aBlockPos, j, j, rFilterEntries, 
bFiltering, true/*bFilteredRow*/);
 }
 }
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-26 Thread Luboš Luňák (via logerrit)
 sc/inc/document.hxx   |2 +-
 sc/source/filter/oox/pivottablebuffer.cxx |   12 
 2 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 5a9c4fc41ec42161ff89c946248f03f16fae7d24
Author: Luboš Luňák 
AuthorDate: Fri Jun 24 11:30:51 2022 +0200
Commit: Luboš Luňák 
CommitDate: Sun Jun 26 20:26:13 2022 +0200

more efficient recalculations from xlsx import of pivot tables

The import of pivot tables in xlsx triggers recalculations, even
though it's not necessary. Fixing that properly seems complex given
how ScDPObject is designed, so at least ensure the calculation is
efficient (formula grouping is otherwise done only after pivot
table import). This can especially noticeable for formulas where
groups make a big difference (e.g. COUNTIFS uses ScSortedRangeCache
only for formula groups).

Change-Id: I8dbdf854880707a9707cdc9dc3d73fc1d6b6b000
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136362
Tested-by: Luboš Luňák 
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cf9be32b9332..959960e15e03 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2557,7 +2557,7 @@ public:
  */
 void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector& 
rRows );
 void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
-void RegroupFormulaCells( const ScRange& range );
+SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range );
 
 formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
 formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index 6d73e26928a9..71ecbb49f947 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -1459,6 +1459,18 @@ PivotTable& PivotTableBuffer::createPivotTable()
 
 void PivotTableBuffer::finalizeImport()
 {
+if(maTables.empty())
+return;
+
+// Create formula groups. This needs to be done before pivot tables, 
because
+// import may lead to calling ScDPObject::GetSource(), which calls 
ScDPObject::CreateObjects(),
+// which will ensure all the cells are not dirty, causing recalculation 
even though
+// ScDPObject::GetSource() doesn't need it. And the recalculation is 
slower without formula
+// groups set up. Fixing that properly seems quite complex, given that 
do-everything approach
+// of ScDPObject, so at least ensure the calculation is efficient.
+ScDocument& rDoc = getDocImport().getDoc();
+rDoc.RegroupFormulaCells( ScRange( 0, 0, 0, rDoc.MaxCol(), rDoc.MaxRow(), 
rDoc.GetMaxTableNumber()));
+
 maTables.forEachMem( ::finalizeImport );
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-25 Thread Noel Grandin (via logerrit)
 sc/inc/document.hxx  |3 +--
 sc/inc/table.hxx |2 +-
 sc/source/core/data/document.cxx |4 ++--
 sc/source/core/data/table2.cxx   |   31 ---
 sc/source/ui/view/viewdata.cxx   |   30 ++
 5 files changed, 26 insertions(+), 44 deletions(-)

New commits:
commit 34c6d02661949fcc9c15bd77d6e837623bbddcdb
Author: Noel Grandin 
AuthorDate: Sat Jun 25 15:44:25 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 25 21:42:46 2022 +0200

tdf#149647 LibreOffice Calc cursor not positioned correctly

Revert the offending commit
commit feec8e3c34e08b621098a17f1011dccd0b4f7f4c
reduce iteration in ScViewData::GetScrPos

Change-Id: Id1df2bf7f87e6b800b40871c1472ed466b7eb6a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136442
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 294d7deadecc..cf9be32b9332 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1972,8 +1972,7 @@ public:
  * specified height.
  */
 SCROW   GetRowForHeight( SCTAB nTab, tools::Long 
nHeight ) const;
-tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab,
-double fScale, const tools::Long* 
pnMaxHeight = nullptr ) const;
+tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, double fScale ) const;
 SC_DLLPUBLIC tools::LongGetColOffset( SCCOL nCol, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
 SC_DLLPUBLIC tools::LongGetRowOffset( SCROW nRow, SCTAB nTab, bool 
bHiddenAsZero = true ) const;
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index da1c0a4d4e98..c6c3bd031cb3 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -854,7 +854,7 @@ public:
 tools::Long GetColWidth( SCCOL nStartCol, SCCOL nEndCol ) const;
 sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow, SCROW* pEndRow, 
bool bHiddenAsZero = true ) const;
 tools::Long GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true ) const;
-tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double 
fScale, const tools::Long* pnMaxHeight = nullptr ) const;
+tools::Long GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double 
fScale ) const;
 tools::Long GetColOffset( SCCOL nCol, bool bHiddenAsZero = true ) 
const;
 tools::Long GetRowOffset( SCROW nRow, bool bHiddenAsZero = true ) 
const;
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index db6500e5b390..9c6f040961f1 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4253,7 +4253,7 @@ SCROW ScDocument::GetRowForHeight( SCTAB nTab, 
tools::Long nHeight ) const
 }
 
 tools::Long ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
-SCTAB nTab, double fScale, const tools::Long* pnMaxHeight ) const
+SCTAB nTab, double fScale ) const
 {
 // faster for a single row
 if (nStartRow == nEndRow)
@@ -4264,7 +4264,7 @@ tools::Long ScDocument::GetScaledRowHeight( SCROW 
nStartRow, SCROW nEndRow,
 return 0;
 
 if ( ValidTab(nTab) && nTab < static_cast(maTabs.size()) && 
maTabs[nTab] )
-return maTabs[nTab]->GetScaledRowHeight( nStartRow, nEndRow, fScale, 
pnMaxHeight );
+return maTabs[nTab]->GetScaledRowHeight( nStartRow, nEndRow, fScale);
 
 OSL_FAIL("wrong sheet number");
 return 0;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a8b5882a54ea..c7c8a92b03dc 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -3605,7 +3605,7 @@ tools::Long ScTable::GetRowHeight( SCROW nStartRow, SCROW 
nEndRow, bool bHiddenA
 return (nEndRow - nStartRow + 1) * 
static_cast(ScGlobal::nStdRowHeight);
 }
 
-tools::Long ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, 
double fScale, const tools::Long* pnMaxHeight ) const
+tools::Long ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, 
double fScale ) const
 {
 OSL_ENSURE(ValidRow(nStartRow) && ValidRow(nEndRow),"wrong row number");
 
@@ -3632,21 +3632,8 @@ tools::Long ScTable::GetScaledRowHeight( SCROW 
nStartRow, SCROW nEndRow, double
 SCROW nSegmentEnd = std::min( nLastRow, 
aSegmentIter.getLastPos() );
 
 // round-down a single height value, multiply resulting 
(pixel) values
-const tools::Long nOneHeight = static_cast( 
nRowVal * fScale );
-// sometimes scaling results in zero height
-if (nOneHeight)
-{
-SCROW nRowsInSegment = nSegmentEnd + 1 - nRow;
-if (pnMaxHeight)
-{
-nRowsInSegment = 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-20 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx  |4 ++--
 sc/source/core/data/cellvalue.cxx |   10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 7925b4de3f9213a1aadfe7a4b1153241f264f439
Author: Noel Grandin 
AuthorDate: Mon Jun 20 12:54:44 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon Jun 20 15:05:43 2022 +0200

use std::monostate in std::variant

as suggest by llunak

Change-Id: Id22253198bff16eeb596e1a15ddaba1f6ac227d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136146
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 5cf4cb3ba57d..75e144c77252 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -31,8 +31,8 @@ struct ColumnBlockPosition;
 struct SC_DLLPUBLIC ScCellValue
 {
 private:
-/// bool is there to indicate CellType::NONE
-std::variant maData;
+/// std::monostate is there to indicate CellType::NONE
+std::variant maData;
 public:
 
 ScCellValue();
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index bf4099e023a6..44fde8c7ed03 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -280,7 +280,7 @@ ScCellValue::ScCellValue( const ScCellValue& r )
 ScCellValue::ScCellValue(ScCellValue&& r) noexcept
 : maData(std::move(r.maData))
 {
-r.maData = true; // reset to empty;
+r.maData = std::monostate(); // reset to empty;
 }
 
 ScCellValue::~ScCellValue()
@@ -318,7 +318,7 @@ void ScCellValue::clear() noexcept
 }
 
 // Reset to empty value.
-maData = true;
+maData = std::monostate();
 }
 
 void ScCellValue::set( double fValue )
@@ -475,7 +475,7 @@ void ScCellValue::release( ScDocument& rDoc, const 
ScAddress& rPos )
 rDoc.SetEmptyCell(rPos);
 }
 
-maData = true; // reset to empty
+maData = std::monostate(); // reset to empty
 }
 
 void ScCellValue::release( ScColumn& rColumn, SCROW nRow, 
sc::StartListeningType eListenType )
@@ -503,7 +503,7 @@ void ScCellValue::release( ScColumn& rColumn, SCROW nRow, 
sc::StartListeningType
 rColumn.DeleteContent(nRow);
 }
 
-maData = true; // reset to empty
+maData = std::monostate(); // reset to empty
 }
 
 OUString ScCellValue::getString( const ScDocument& rDoc ) const
@@ -532,7 +532,7 @@ ScCellValue& ScCellValue::operator=(ScCellValue&& rCell) 
noexcept
 {
 clear();
 maData = std::move(rCell.maData);
-rCell.maData = true; // reset to empty;
+rCell.maData = std::monostate(); // reset to empty;
 return *this;
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-18 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx   |   18 +--
 sc/source/core/data/cellvalue.cxx  |   54 -
 sc/source/core/data/queryevaluator.cxx |2 -
 3 files changed, 37 insertions(+), 37 deletions(-)

New commits:
commit a5d355fef3896f3109c74c153f2a34b82fe6be38
Author: Noel Grandin 
AuthorDate: Sat Jun 18 11:50:42 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 18 16:38:57 2022 +0200

clean up Sc*CellValue

after my recent commits
(*) make more fields private
(*) rename fields (remove suffix "1") now that I am sure I got
everything.

Change-Id: I0f8b9b1a534181c8b66532f9da5a0d16aa049cf0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136074
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index caf42d2c0155..5cf4cb3ba57d 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -30,8 +30,10 @@ struct ColumnBlockPosition;
  */
 struct SC_DLLPUBLIC ScCellValue
 {
+private:
 /// bool is there to indicate CellType::NONE
 std::variant maData;
+public:
 
 ScCellValue();
 ScCellValue( const ScRefCellValue& rCell );
@@ -102,17 +104,15 @@ struct SC_DLLPUBLIC ScCellValue
  */
 struct SC_DLLPUBLIC ScRefCellValue
 {
-/// bool is there to indicate CellType::NONE
-std::variant maData;
 private:
 CellType meType;
-public:
 union {
-double mfValue1;
+double mfValue;
 const svl::SharedString* mpString;
-const EditTextObject* mpEditText1;
-ScFormulaCell* mpFormula1;
+const EditTextObject* mpEditText;
+ScFormulaCell* mpFormula;
 };
+public:
 
 ScRefCellValue();
 ScRefCellValue( double fValue );
@@ -129,10 +129,10 @@ public:
 void clear();
 
 CellType getType() const { return meType; }
-double getDouble() const { assert(meType == CELLTYPE_VALUE); return 
mfValue1; }
+double getDouble() const { assert(meType == CELLTYPE_VALUE); return 
mfValue; }
 const svl::SharedString* getSharedString() const { assert(meType == 
CELLTYPE_STRING); return mpString; }
-const EditTextObject* getEditText() const { assert(meType == 
CELLTYPE_EDIT); return mpEditText1; }
-ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); 
return mpFormula1; }
+const EditTextObject* getEditText() const { assert(meType == 
CELLTYPE_EDIT); return mpEditText; }
+ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); 
return mpFormula; }
 
 /**
  * Take cell value from specified position in specified document.
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index e3786771d5e4..bf4099e023a6 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -100,7 +100,7 @@ bool equalsWithoutFormatImpl( const T& left, const T& right 
)
 return aStr1 == aStr2;
 }
 case CELLTYPE_FORMULA:
-return equalsFormulaCells(left.mpFormula1, right.mpFormula1);
+return equalsFormulaCells(left.getFormula(), right.getFormula());
 default:
 ;
 }
@@ -212,15 +212,15 @@ OUString getRawStringImpl( const CellT& rCell, const 
ScDocument& rDoc )
 switch (rCell.getType())
 {
 case CELLTYPE_VALUE:
-return OUString::number(rCell.mfValue1);
+return OUString::number(rCell.getDouble());
 case CELLTYPE_STRING:
-return rCell.mpString->getString();
+return rCell.getSharedString()->getString();
 case CELLTYPE_EDIT:
-if (rCell.mpEditText1)
-return ScEditUtil::GetString(*rCell.mpEditText1, );
+if (rCell.getEditText())
+return ScEditUtil::GetString(*rCell.getEditText(), );
 break;
 case CELLTYPE_FORMULA:
-return rCell.mpFormula1->GetRawString().getString();
+return rCell.getFormula()->GetRawString().getString();
 default:
 ;
 }
@@ -236,7 +236,7 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell )
 switch (rCell.getType())
 {
 case CELLTYPE_STRING:
-maData = *rCell.mpString;
+maData = *rCell.getSharedString();
 break;
 case CELLTYPE_EDIT:
 maData = rCell.getEditText()->Clone().release();
@@ -360,16 +360,16 @@ void ScCellValue::assign( const ScDocument& rDoc, const 
ScAddress& rPos )
 switch (aRefVal.getType())
 {
 case CELLTYPE_STRING:
-maData = *aRefVal.mpString;
+maData = *aRefVal.getSharedString();
 break;
 case CELLTYPE_EDIT:
-maData = aRefVal.mpEditText1 ? 
aRefVal.mpEditText1->Clone().release() : static_cast(nullptr);
+maData = aRefVal.getEditText() ? 
aRefVal.getEditText()->Clone().release() : 
static_cast(nullptr);
 break;
 case CELLTYPE_VALUE:
-maData 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-18 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx  |   47 +-
 sc/source/core/data/cellvalue.cxx |  256 ++
 sc/source/core/data/column4.cxx   |2 
 sc/source/core/tool/chgtrack.cxx  |2 
 4 files changed, 138 insertions(+), 169 deletions(-)

New commits:
commit 1a7913c1b57b333223b30194c67c4d8d11e583d2
Author: Noel Grandin 
AuthorDate: Wed Jun 15 09:27:31 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 18 11:36:39 2022 +0200

tdf#126109 calc slow when replacing string to number

Store SharedString inline in ScCellValue.
Shaves 10% off time.
Use std::variant to handle the complexities of correctly calling
constructor and destructor of SharedString.

Change-Id: I820de5339e31434fbdbde1a72e25abe207bf008d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135863
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 1095d32a3d39..caf42d2c0155 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -10,6 +10,8 @@
 #pragma once
 
 #include "global.hxx"
+#include 
+#include 
 
 class ScDocument;
 class ScFormulaCell;
@@ -21,12 +23,6 @@ namespace sc {
 struct ColumnBlockPosition;
 }
 
-namespace svl {
-
-class SharedString;
-
-}
-
 /**
  * Store arbitrary cell value of any kind.  It only stores cell value and
  * nothing else.  It creates a copy of the original cell value, and manages
@@ -34,15 +30,8 @@ class SharedString;
  */
 struct SC_DLLPUBLIC ScCellValue
 {
-private:
-CellType meType;
-public:
-union {
-double mfValue1;
-svl::SharedString* mpString;
-EditTextObject* mpEditText1;
-ScFormulaCell* mpFormula1;
-};
+/// bool is there to indicate CellType::NONE
+std::variant maData;
 
 ScCellValue();
 ScCellValue( const ScRefCellValue& rCell );
@@ -61,25 +50,13 @@ public:
 void set( std::unique_ptr );
 void set( ScFormulaCell* pFormula );
 
-CellType getType() const { return meType; }
-double getDouble() const { assert(meType == CELLTYPE_VALUE); return 
mfValue1; }
-svl::SharedString* getSharedString() const { assert(meType == 
CELLTYPE_STRING); return mpString; }
-EditTextObject* getEditText() const { assert(meType == CELLTYPE_EDIT); 
return mpEditText1; }
-EditTextObject* releaseEditText()
-{
-assert(meType == CELLTYPE_EDIT);
-auto p = mpEditText1;
-mpEditText1 = nullptr;
-return p;
-}
-ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); 
return mpFormula1; }
-ScFormulaCell* releaseFormula()
-{
-assert(meType == CELLTYPE_FORMULA);
-auto p = mpFormula1;
-mpFormula1 = nullptr;
-return p;
-}
+CellType getType() const;
+double getDouble() const { return std::get(maData); }
+ScFormulaCell* getFormula() const { return 
std::get(maData); }
+const svl::SharedString* getSharedString() const { return 
::get(maData); }
+EditTextObject* getEditText() const { return 
std::get(maData); }
+EditTextObject* releaseEditText() { auto p = getEditText(); maData = 
static_cast(nullptr); return p; }
+ScFormulaCell* releaseFormula() { auto p = getFormula(); maData = 
static_cast(nullptr); return p; }
 
 /**
  * Take cell value from specified position in specified document.
@@ -125,6 +102,8 @@ public:
  */
 struct SC_DLLPUBLIC ScRefCellValue
 {
+/// bool is there to indicate CellType::NONE
+std::variant maData;
 private:
 CellType meType;
 public:
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index fa246b34d04b..e3786771d5e4 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -38,17 +38,17 @@ template
 OUString getString( const T& rVal )
 {
 if (rVal.getType() == CELLTYPE_STRING)
-return rVal.mpString->getString();
+return rVal.getSharedString()->getString();
 
 if (rVal.getType() == CELLTYPE_EDIT)
 {
 OUStringBuffer aRet;
-sal_Int32 n = rVal.mpEditText1->GetParagraphCount();
+sal_Int32 n = rVal.getEditText()->GetParagraphCount();
 for (sal_Int32 i = 0; i < n; ++i)
 {
 if (i > 0)
 aRet.append('\n');
-aRet.append(rVal.mpEditText1->GetText(i));
+aRet.append(rVal.getEditText()->GetText(i));
 }
 return aRet.makeStringAndClear();
 }
@@ -107,15 +107,42 @@ bool equalsWithoutFormatImpl( const T& left, const T& 
right )
 return false;
 }
 
+bool equalsWithoutFormatImpl( const ScCellValue& left, const ScCellValue& 
right )
+{
+CellType eType1 = adjustCellType(left.getType());
+CellType eType2 = adjustCellType(right.getType());
+if (eType1 != eType2)
+return false;
+
+switch (eType1)
+{
+case CELLTYPE_NONE:
+return true;
+case CELLTYPE_VALUE:
+return left.getDouble() == 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-18 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx   |   13 +++-
 sc/inc/dociter.hxx |4 -
 sc/source/core/data/cellvalue.cxx  |   48 -
 sc/source/core/data/clipcontext.cxx|   18 +++---
 sc/source/core/data/column2.cxx|4 -
 sc/source/core/data/column3.cxx|6 +-
 sc/source/core/data/column4.cxx|2 
 sc/source/core/data/conditio.cxx   |8 +-
 sc/source/core/data/dociter.cxx|   18 +++---
 sc/source/core/data/document.cxx   |2 
 sc/source/core/data/documentimport.cxx |5 -
 sc/source/core/data/queryevaluator.cxx |   18 +++---
 sc/source/core/data/queryiter.cxx  |2 
 sc/source/core/data/table2.cxx |6 +-
 sc/source/core/data/table3.cxx |   20 +++
 sc/source/core/data/table4.cxx |   14 ++--
 sc/source/core/data/table5.cxx |4 -
 sc/source/core/data/table6.cxx |6 +-
 sc/source/core/data/validat.cxx|2 
 sc/source/core/tool/cellform.cxx   |4 -
 sc/source/core/tool/chartarr.cxx   |2 
 sc/source/core/tool/chgtrack.cxx   |   44 +++
 sc/source/core/tool/detfunc.cxx|6 +-
 sc/source/core/tool/interpr1.cxx   |   20 +++
 sc/source/core/tool/interpr4.cxx   |   48 -
 sc/source/core/tool/interpr5.cxx   |   18 +++---
 sc/source/core/tool/rangeseq.cxx   |2 
 sc/source/filter/dif/difexp.cxx|6 +-
 sc/source/filter/excel/xetable.cxx |2 
 sc/source/filter/html/htmlexp.cxx  |4 -
 sc/source/filter/xcl97/XclExpChangeTrack.cxx   |2 
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx |2 
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx |   12 ++--
 sc/source/filter/xml/xmlcelli.cxx  |4 -
 sc/source/filter/xml/xmlexprt.cxx  |6 +-
 sc/source/ui/Accessibility/AccessibleCell.cxx  |2 
 sc/source/ui/docshell/docsh.cxx|8 +-
 sc/source/ui/docshell/docsh3.cxx   |4 -
 sc/source/ui/docshell/externalrefmgr.cxx   |4 -
 sc/source/ui/docshell/impex.cxx|4 -
 sc/source/ui/undo/undocell.cxx |2 
 sc/source/ui/unoobj/cellsuno.cxx   |   18 +++---
 sc/source/ui/unoobj/chart2uno.cxx  |2 
 sc/source/ui/view/cellsh1.cxx  |2 
 sc/source/ui/view/gridwin.cxx  |8 +-
 sc/source/ui/view/output.cxx   |4 -
 sc/source/ui/view/output2.cxx  |   16 ++---
 sc/source/ui/view/tabvwsh.cxx  |2 
 sc/source/ui/view/tabvwsh5.cxx |4 -
 sc/source/ui/view/tabvwsha.cxx |2 
 sc/source/ui/view/viewfun2.cxx |2 
 51 files changed, 238 insertions(+), 228 deletions(-)

New commits:
commit 20b8c7f38ae1c03dc0405a2da006ab6b2dbf3627
Author: Noel Grandin 
AuthorDate: Fri Jun 17 19:55:58 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Jun 18 08:23:06 2022 +0200

create getter for ScCellValue::mpFormula

so we can assert that it has the correct tag type

Change-Id: Iab13a6d6ea1783c69395f06f28732769e5fe8b18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136059
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 192e499bbb25..1095d32a3d39 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -41,7 +41,7 @@ public:
 double mfValue1;
 svl::SharedString* mpString;
 EditTextObject* mpEditText1;
-ScFormulaCell* mpFormula;
+ScFormulaCell* mpFormula1;
 };
 
 ScCellValue();
@@ -72,6 +72,14 @@ public:
 mpEditText1 = nullptr;
 return p;
 }
+ScFormulaCell* getFormula() const { assert(meType == CELLTYPE_FORMULA); 
return mpFormula1; }
+ScFormulaCell* releaseFormula()
+{
+assert(meType == CELLTYPE_FORMULA);
+auto p = mpFormula1;
+mpFormula1 = nullptr;
+return p;
+}
 
 /**
  * Take cell value from specified position in specified document.
@@ -124,7 +132,7 @@ public:
 double mfValue1;
 const svl::SharedString* mpString;
 const EditTextObject* mpEditText1;
-ScFormulaCell* mpFormula;
+ScFormulaCell* mpFormula1;
 };
 
 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-17 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx   |   13 +++
 sc/inc/dociter.hxx |2 
 sc/source/core/data/attarray.cxx   |8 +-
 sc/source/core/data/cellvalue.cxx  |   56 -
 sc/source/core/data/column2.cxx|2 
 sc/source/core/data/column4.cxx|2 
 sc/source/core/data/conditio.cxx   |4 -
 sc/source/core/data/dociter.cxx|2 
 sc/source/core/data/documen8.cxx   |4 -
 sc/source/core/data/documentimport.cxx |3 
 sc/source/core/data/table3.cxx |2 
 sc/source/core/data/table4.cxx |4 -
 sc/source/core/data/table6.cxx |4 -
 sc/source/core/data/validat.cxx|4 -
 sc/source/core/tool/cellform.cxx   |2 
 sc/source/core/tool/chgtrack.cxx   |8 +-
 sc/source/filter/excel/xetable.cxx |2 
 sc/source/filter/excel/xicontent.cxx   |2 
 sc/source/filter/html/htmlexp.cxx  |2 
 sc/source/filter/rtf/rtfexp.cxx|2 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx   |6 -
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx |   10 +--
 sc/source/filter/xml/xmlcelli.cxx  |2 
 sc/source/filter/xml/xmlexprt.cxx  |4 -
 sc/source/ui/app/transobj.cxx  |2 
 sc/source/ui/docshell/docsh.cxx|2 
 sc/source/ui/docshell/docsh8.cxx   |4 -
 sc/source/ui/undo/undocell.cxx |2 
 sc/source/ui/unoobj/cellsuno.cxx   |2 
 sc/source/ui/unoobj/textuno.cxx|2 
 sc/source/ui/view/gridwin.cxx  |4 -
 sc/source/ui/view/output2.cxx  |8 +-
 sc/source/ui/view/spellcheckcontext.cxx|2 
 sc/source/ui/view/spelleng.cxx |2 
 sc/source/ui/view/tabvwsha.cxx |2 
 sc/source/ui/view/viewfun4.cxx |2 
 sc/source/ui/view/viewfunc.cxx |2 
 37 files changed, 97 insertions(+), 89 deletions(-)

New commits:
commit c78193b32152122e9b71151b1b463b2dff99f42f
Author: Noel Grandin 
AuthorDate: Fri Jun 17 16:00:06 2022 +0200
Commit: Noel Grandin 
CommitDate: Fri Jun 17 17:00:11 2022 +0200

create getter for ScCellValue::mpEditText

so we can assert that it has the correct tag type

Change-Id: I984c22ae2527d652f2d4194227dc1173793300c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136054
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 643889e2c154..192e499bbb25 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -40,7 +40,7 @@ public:
 union {
 double mfValue1;
 svl::SharedString* mpString;
-EditTextObject* mpEditText;
+EditTextObject* mpEditText1;
 ScFormulaCell* mpFormula;
 };
 
@@ -64,6 +64,14 @@ public:
 CellType getType() const { return meType; }
 double getDouble() const { assert(meType == CELLTYPE_VALUE); return 
mfValue1; }
 svl::SharedString* getSharedString() const { assert(meType == 
CELLTYPE_STRING); return mpString; }
+EditTextObject* getEditText() const { assert(meType == CELLTYPE_EDIT); 
return mpEditText1; }
+EditTextObject* releaseEditText()
+{
+assert(meType == CELLTYPE_EDIT);
+auto p = mpEditText1;
+mpEditText1 = nullptr;
+return p;
+}
 
 /**
  * Take cell value from specified position in specified document.
@@ -115,7 +123,7 @@ public:
 union {
 double mfValue1;
 const svl::SharedString* mpString;
-const EditTextObject* mpEditText;
+const EditTextObject* mpEditText1;
 ScFormulaCell* mpFormula;
 };
 
@@ -136,6 +144,7 @@ public:
 CellType getType() const { return meType; }
 double getDouble() const { assert(meType == CELLTYPE_VALUE); return 
mfValue1; }
 const svl::SharedString* getSharedString() const { assert(meType == 
CELLTYPE_STRING); return mpString; }
+const EditTextObject* getEditText() const { assert(meType == 
CELLTYPE_EDIT); return mpEditText1; }
 
 /**
  * Take cell value from specified position in specified document.
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 622d36332d97..fc1609d6daab 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -234,7 +234,7 @@ public:
 
 CellType getType() const { return maCurCell.getType();}
 OUString getString() const;
-const EditTextObject* getEditText() const { return maCurCell.mpEditText;}
+   

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-16 Thread Eike Rathke (via logerrit)
 sc/inc/listenercalls.hxx  |6 --
 sc/source/ui/unoobj/listenercalls.cxx |2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 7a0a0e23b7e81c1ee0601824a4ee990a2178f98b
Author: Eike Rathke 
AuthorDate: Thu Jun 16 21:44:40 2022 +0200
Commit: Eike Rathke 
CommitDate: Thu Jun 16 22:39:38 2022 +0200

Resolves: tdf#147822 ScUnoListenerEntry container must be std::list

... instead of std::vector to not get invalidated iterators when
the container is resized.

Regression from

commit f8defe59ff75df2b516ee407f1dac22b0ac72a19
CommitDate: Wed Sep 6 22:45:10 2017 +0200

Replace some lists by vectors in unoobj (sc)

which was bad for this case.

Change-Id: I8d3a001242865cadc82b359a3198906d26373a41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136007
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/listenercalls.hxx b/sc/inc/listenercalls.hxx
index ff835a048b1a..acb009937fa1 100644
--- a/sc/inc/listenercalls.hxx
+++ b/sc/inc/listenercalls.hxx
@@ -19,7 +19,7 @@
 
 #pragma once
 
-#include 
+#include 
 #include 
 #include 
 
@@ -48,7 +48,9 @@ struct ScUnoListenerEntry
 class ScUnoListenerCalls
 {
 private:
-::std::vector aEntries;
+// Must be list, not vector, to not invalidate iterators, see
+// ExecuteAndClear() implementation.
+::std::list aEntries;
 
 public:
 ScUnoListenerCalls();
diff --git a/sc/source/ui/unoobj/listenercalls.cxx 
b/sc/source/ui/unoobj/listenercalls.cxx
index 2d9a23083ca8..7ff7c7df0956 100644
--- a/sc/source/ui/unoobj/listenercalls.cxx
+++ b/sc/source/ui/unoobj/listenercalls.cxx
@@ -44,7 +44,7 @@ void ScUnoListenerCalls::ExecuteAndClear()
 //  During each modified() call, Add may be called again.
 //  These new calls are executed here, too.
 
-std::vector::iterator aItr(aEntries.begin());
+std::list::iterator aItr(aEntries.begin());
 while (aItr != aEntries.end())
 {
 ScUnoListenerEntry aEntry = *aItr;


[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-16 Thread Noel Grandin (via logerrit)
 sc/inc/cellvalue.hxx  |2 +-
 sc/source/core/data/cellvalue.cxx |4 ++--
 sc/source/filter/oox/revisionfragment.cxx |2 +-
 sc/source/filter/xml/XMLTrackedChangesContext.cxx |2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 7eae7e54e0c55d5896cf807c339fd0789f54d380
Author: Noel Grandin 
AuthorDate: Thu Jun 16 14:24:56 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Jun 16 20:39:05 2022 +0200

pass EditTextObject by unique_ptr

to make the ownership passing obvious

Change-Id: Icf4b94a422b91da3082fe1ce56eff149d390a649
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136000
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 5876f9584a4f..942cf006cab5 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -58,7 +58,7 @@ public:
 void set( double fValue );
 void set( const svl::SharedString& rStr );
 void set( const EditTextObject& rEditText );
-void set( EditTextObject* pEditText );
+void set( std::unique_ptr );
 void set( ScFormulaCell* pFormula );
 
 CellType getType() const { return meType; }
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index ca8c8e78c954..c565e0a488d6 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -315,11 +315,11 @@ void ScCellValue::set( const EditTextObject& rEditText )
 mpEditText = rEditText.Clone().release();
 }
 
-void ScCellValue::set( EditTextObject* pEditText )
+void ScCellValue::set( std::unique_ptr xEditText )
 {
 clear();
 meType = CELLTYPE_EDIT;
-mpEditText = pEditText;
+mpEditText = xEditText.release();
 }
 
 void ScCellValue::set( ScFormulaCell* pFormula )
diff --git a/sc/source/filter/oox/revisionfragment.cxx 
b/sc/source/filter/oox/revisionfragment.cxx
index f6fee91c4051..4a0fa785e6df 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -147,7 +147,7 @@ protected:
 {
 svl::SharedStringPool& rPool = 
rDoc.GetSharedStringPool();
 pTextObj->NormalizeString(rPool);
-mrCellValue.set(pTextObj.release());
+mrCellValue.set(std::move(pTextObj));
 }
 }
 }
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx 
b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index d478a8af0ba9..8294eb979a92 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -860,7 +860,7 @@ void SAL_CALL ScXMLChangeCellContext::endFastElement( 
sal_Int32 /*nElement*/ )
 }
 
 // The cell will own the text object instance.
-mrOldCell.set(mpEditTextObj->CreateTextObject().release());
+mrOldCell.set(mpEditTextObj->CreateTextObject());
 GetScImport().GetTextImport()->ResetCursor();
 mpEditTextObj.clear();
 }


[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-16 Thread Luboš Luňák (via logerrit)
 sc/inc/document.hxx|5 +-
 sc/inc/interpretercontext.hxx  |4 --
 sc/inc/rangecache.hxx  |5 --
 sc/source/core/data/documen2.cxx   |   49 +++--
 sc/source/core/tool/interpretercontext.cxx |   12 ---
 sc/source/core/tool/rangecache.cxx |4 --
 6 files changed, 33 insertions(+), 46 deletions(-)

New commits:
commit 1ac3b4ae83856eebe6bc329b7a92575b6b1d84be
Author: Luboš Luňák 
AuthorDate: Mon Jun 13 20:46:08 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Jun 16 15:12:42 2022 +0200

share ScSortedRangeCache between threads

It's the same data for all threads, they access it as read-only,
so it doesn't make sense for each thread to build its own copy.

Change-Id: Ia1559c61d976bcce78661cae7e030bb8430aed7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135794
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7bd27c6b95fa..294d7deadecc 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -48,7 +48,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -471,7 +471,8 @@ private:
 
 mutable ScInterpreterContext maInterpreterContext;
 
-std::mutex mScLookupMutex; // protection for thread-unsafe parts of 
handling ScLookup
+std::shared_mutex mScLookupMutex; // protection for thread-unsafe parts of 
handling ScLookup
+std::unique_ptr mxScSortedRangeCache; // cache for 
unsorted lookups
 
 static const sal_uInt16 nSrcVer;// file version 
(load/save)
 sal_uInt16  nFormulaTrackCount;
diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 9f424b1a4f42..4ecb1ed9de1a 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -23,7 +23,6 @@ class FormulaToken;
 class ScDocument;
 class SvNumberFormatter;
 struct ScLookupCacheMap;
-struct ScSortedRangeCacheMap;
 class ScInterpreter;
 enum class SvNumFormatType : sal_Int16;
 
@@ -58,7 +57,6 @@ struct ScInterpreterContext
 std::vector maTokens;
 std::vector maDelayedSetNumberFormat;
 std::unique_ptr mxScLookupCache; // cache for lookups 
like VLOOKUP and MATCH
-std::unique_ptr mxScSortedRangeCache; // cache for 
unsorted lookups
 // Allocation cache for "aConditions" array in 
ScInterpreter::IterateParameterIfs()
 // This is populated/used only when formula-group threading is enabled.
 std::vector maConditions;
@@ -85,7 +83,6 @@ private:
 void SetDocAndFormatter(const ScDocument& rDoc, SvNumberFormatter* 
pFormatter);
 void Cleanup();
 void ClearLookupCache();
-void ClearSortedRangeCache();
 void initFormatTable();
 SvNumberFormatter* mpFormatter;
 mutable NFIndexAndFmtType maNFTypeCache;
@@ -139,7 +136,6 @@ class ScInterpreterContextPool
 public:
 // Only to be used to clear lookup cache in all pool elements
 static void ClearLookupCaches();
-static void ClearSortedRangeCaches();
 };
 
 class ScThreadedInterpreterContextGetterGuard
diff --git a/sc/inc/rangecache.hxx b/sc/inc/rangecache.hxx
index fd5b12cbd8de..048d9b9ba046 100644
--- a/sc/inc/rangecache.hxx
+++ b/sc/inc/rangecache.hxx
@@ -45,7 +45,7 @@ class ScSortedRangeCache final : public SvtListener
 public:
 /// MUST be new'd because Notify() deletes.
 ScSortedRangeCache(ScDocument* pDoc, const ScRange& rRange, const 
ScQueryParam& param,
-   ScSortedRangeCacheMap& cacheMap, ScInterpreterContext* 
context);
+   ScInterpreterContext* context);
 
 /// Remove from document structure and delete (!) cache on modify hint.
 virtual void Notify(const SfxHint& rHint) override;
@@ -53,8 +53,6 @@ public:
 const ScRange& getRange() const { return maRange; }
 bool isDescending() const { return mDescending; }
 
-ScSortedRangeCacheMap& getCacheMap() const { return mCacheMap; }
-
 enum class ValueType
 {
 Values,
@@ -102,7 +100,6 @@ private:
 std::vector mRowToIndex; // indexed by 'SCROW - 
maRange.aStart.Row()'
 ScRange maRange;
 ScDocument* mpDoc;
-ScSortedRangeCacheMap& mCacheMap;
 bool mDescending;
 ValueType mValues;
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index bcdbd9b586e9..ed090885ed3b 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -137,6 +137,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, 
SfxObjectShell* pDocShell ) :
 nMacroInterpretLevel(0),
 nInterpreterTableOpLevel(0),
 maInterpreterContext( *this, nullptr ),
+mxScSortedRangeCache(new ScSortedRangeCacheMap),
 nFormulaTrackCount(0),
 eHardRecalcState(HardRecalcState::OFF),
 nVisibleTab( 0 ),
@@ -1198,25 +1199,31 @@ ScLookupCache & ScDocument::GetLookupCache( const 
ScRange & rRange, 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-06-06 Thread Eike Rathke (via logerrit)
 sc/inc/refdata.hxx  |2 +-
 sc/source/core/tool/refdata.cxx |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 1e022eb12e1222d6d9c6d127a18b0ed8fd49b6c0
Author: Eike Rathke 
AuthorDate: Mon Jun 6 17:00:31 2022 +0200
Commit: Eike Rathke 
CommitDate: Mon Jun 6 17:55:58 2022 +0200

ScSingleRefData::TabValid: for absolute reference take sheets into account

Change-Id: I56e7e34f127345e2633b5bef07c2783ed8ffbbfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135456
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 4cc296a0a394..d893248ba0bc 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -94,7 +94,7 @@ public:
 bool Valid(const ScDocument& rDoc) const;
 bool ColValid(const ScDocument& rDoc) const;
 bool RowValid(const ScDocument& rDoc) const;
-bool TabValid() const;
+bool TabValid(const ScDocument& rDoc) const;
 /** In external references nTab is -1 if the external document was not
 loaded but the sheet was cached, or >=0 if the external document was
 loaded. */
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 8bd55dfc92ec..3e1b9b1af8be 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -129,7 +129,7 @@ bool ScSingleRefData::IsDeleted() const
 
 bool ScSingleRefData::Valid(const ScDocument& rDoc) const
 {
-return !IsDeleted() && ColValid(rDoc) && RowValid(rDoc) && TabValid();
+return !IsDeleted() && ColValid(rDoc) && RowValid(rDoc) && TabValid(rDoc);
 }
 
 bool ScSingleRefData::ColValid(const ScDocument& rDoc) const
@@ -164,7 +164,7 @@ bool ScSingleRefData::RowValid(const ScDocument& rDoc) const
 return true;
 }
 
-bool ScSingleRefData::TabValid() const
+bool ScSingleRefData::TabValid(const ScDocument& rDoc) const
 {
 if (Flags.bTabRel)
 {
@@ -173,7 +173,7 @@ bool ScSingleRefData::TabValid() const
 }
 else
 {
-if (mnTab < 0 || MAXTAB < mnTab)
+if (mnTab < 0 || rDoc.GetTableCount() <= mnTab)
 return false;
 }
 


[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-30 Thread Noel Grandin (via logerrit)
 sc/inc/chartlis.hxx   |4 +--
 sc/source/core/tool/chartlis.cxx  |   27 --
 sc/source/filter/excel/xichart.cxx|8 +++
 sc/source/filter/xml/XMLTableShapeResizer.cxx |8 +++
 4 files changed, 23 insertions(+), 24 deletions(-)

New commits:
commit a57209bf4b7aa442757c57b542512fb7ecc9b23d
Author: Noel Grandin 
AuthorDate: Mon May 30 16:17:12 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 30 19:17:42 2022 +0200

no need to use unique_ptr for tokens in ScChartListener

since vector is a moveable type, and we always initialise this field

Change-Id: Icd598ad942dcfbdf77c7c8eef9fa0b6b7c6fe1be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135134
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 7e351082f4f7..d140531a9451 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -62,7 +62,7 @@ public:
 private:
 
 std::unique_ptr mpExtRefListener;
-std::unique_ptr > mpTokens;
+std::vector maTokens;
 
 OUString maName;
 std::unique_ptr pUnoData;
@@ -76,7 +76,7 @@ public:
 ScChartListener( const OUString& rName, ScDocument& rDoc,
  const ScRangeListRef& rRangeListRef );
 ScChartListener( const OUString& rName, ScDocument& rDoc,
- std::unique_ptr<::std::vector> pTokens );
+ ::std::vector aTokens );
 ScChartListener( const ScChartListener& ) = delete;
 virtual ~ScChartListener() override;
 
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 3566e357f67b..2fe7f97ee7ac 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -97,17 +97,16 @@ void 
ScChartListener::ExternalRefListener::removeFileId(sal_uInt16 nFileId)
 
 ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP,
 const ScRangeListRef& rRangeList ) :
-mpTokens(new vector),
 maName(rName),
 mrDoc( rDocP ),
 bUsed( false ),
 bDirty( false )
 {
-ScRefTokenHelper::getTokensFromRangeList(, *mpTokens, *rRangeList);
+ScRefTokenHelper::getTokensFromRangeList(, maTokens, *rRangeList);
 }
 
-ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP, 
std::unique_ptr> pTokens ) :
-mpTokens(std::move(pTokens)),
+ScChartListener::ScChartListener( const OUString& rName, ScDocument& rDocP, 
vector aTokens ) :
+maTokens(std::move(aTokens)),
 maName(rName),
 mrDoc( rDocP ),
 bUsed( false ),
@@ -187,7 +186,7 @@ void ScChartListener::Update()
 ScRangeListRef ScChartListener::GetRangeList() const
 {
 ScRangeListRef aRLRef(new ScRangeList);
-ScRefTokenHelper::getRangeListFromTokens(, *aRLRef, *mpTokens, 
ScAddress());
+ScRefTokenHelper::getRangeListFromTokens(, *aRLRef, maTokens, 
ScAddress());
 return aRLRef;
 }
 
@@ -195,7 +194,7 @@ void ScChartListener::SetRangeList( const ScRangeListRef& 
rNew )
 {
 vector aTokens;
 ScRefTokenHelper::getTokensFromRangeList(, aTokens, *rNew);
-mpTokens->swap(aTokens);
+maTokens.swap(aTokens);
 }
 
 namespace {
@@ -264,20 +263,20 @@ private:
 
 void ScChartListener::StartListeningTo()
 {
-if (!mpTokens || mpTokens->empty())
+if (maTokens.empty())
 // no references to listen to.
 return;
 
-for_each(mpTokens->begin(), mpTokens->end(), StartEndListening(mrDoc, 
*this, true));
+for_each(maTokens.begin(), maTokens.end(), StartEndListening(mrDoc, *this, 
true));
 }
 
 void ScChartListener::EndListeningTo()
 {
-if (!mpTokens || mpTokens->empty())
+if (maTokens.empty())
 // no references to listen to.
 return;
 
-for_each(mpTokens->begin(), mpTokens->end(), StartEndListening(mrDoc, 
*this, false));
+for_each(maTokens.begin(), maTokens.end(), StartEndListening(mrDoc, *this, 
false));
 }
 
 void ScChartListener::ChangeListening( const ScRangeListRef& rRangeListRef,
@@ -295,7 +294,7 @@ void ScChartListener::UpdateChartIntersecting( const 
ScRange& rRange )
 ScTokenRef pToken;
 ScRefTokenHelper::getTokenFromRange(, pToken, rRange);
 
-if (ScRefTokenHelper::intersects(, *mpTokens, pToken, ScAddress()))
+if (ScRefTokenHelper::intersects(, maTokens, pToken, ScAddress()))
 {
 // force update (chart has to be loaded), don't use 
ScChartListener::Update
 mrDoc.UpdateChart(GetName());
@@ -318,8 +317,8 @@ void ScChartListener::SetUpdateQueue()
 
 bool ScChartListener::operator==( const ScChartListener& r ) const
 {
-bool b1 = (mpTokens && !mpTokens->empty());
-bool b2 = (r.mpTokens && !r.mpTokens->empty());
+bool b1 = !maTokens.empty();
+bool b2 = !r.maTokens.empty();
 
 if ( !=  || bUsed != r.bUsed || bDirty != r.bDirty ||
 GetName() != r.GetName() || b1 != b2)
@@ -329,7 +328,7 @@ bool ScChartListener::operator==( const ScChartListener& r 
) const
  

[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-22 Thread Caolán McNamara (via logerrit)
 sc/inc/dapiuno.hxx   |8 
 sc/source/ui/unoobj/cellsuno.cxx |2 +-
 sc/source/ui/unoobj/dapiuno.cxx  |   26 +-
 3 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit a5d2e06d444b486bb2695c9268681f044f27d599
Author: Caolán McNamara 
AuthorDate: Sun May 22 12:16:41 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 22 15:16:27 2022 +0200

pass ScDocShell by reference in ctor to indicate never initially null

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

diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index 86d2d56893b5..07d2740efa98 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -90,7 +90,7 @@ private:
 rtl::Reference GetObjectByName_Impl(const OUString& 
aName);
 
 public:
-ScDataPilotTablesObj(ScDocShell* pDocSh, SCTAB nT);
+ScDataPilotTablesObj(ScDocShell& rDocSh, SCTAB nT);
 virtual ~ScDataPilotTablesObj() override;
 
 virtual voidNotify( SfxBroadcaster& rBC, const SfxHint& rHint 
) override;
@@ -141,7 +141,7 @@ private:
 ScDocShell* pDocShell;
 
 public:
-ScDataPilotDescriptorBase(ScDocShell* pDocSh);
+ScDataPilotDescriptorBase(ScDocShell& rDocSh);
 virtual ~ScDataPilotDescriptorBase() override;
 
 virtual voidNotify( SfxBroadcaster& rBC, const SfxHint& rHint 
) override;
@@ -207,7 +207,7 @@ private:
 std::unique_ptr  mpDPObject;
 
 public:
-ScDataPilotDescriptor(ScDocShell* pDocSh);
+ScDataPilotDescriptor(ScDocShell& rDocSh);
 virtual ~ScDataPilotDescriptor() override;
 
 virtual ScDPObject* GetDPObject() const override;
@@ -237,7 +237,7 @@ private:
 voidRefreshed_Impl();
 
 public:
-ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, 
const OUString& rN);
+ScDataPilotTableObj(ScDocShell& rDocSh, SCTAB nT, 
const OUString& rN);
 virtual ~ScDataPilotTableObj() override;
 
 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & 
rType ) override;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 763ee12f7b24..c2ef70015d1f 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6652,7 +6652,7 @@ uno::Reference SAL_CALL 
ScTableSheetObj::getDataPilotTa
 SolarMutexGuard aGuard;
 ScDocShell* pDocSh = GetDocShell();
 if ( pDocSh )
-return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
+return new ScDataPilotTablesObj(*pDocSh, GetTab_Impl());
 
 OSL_FAIL("no document");
 return nullptr;
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index dfd11971e88f..4bf5018e2cd4 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -295,8 +295,8 @@ static sal_Int32 lcl_GetObjectIndex( ScDPObject* pDPObj, 
const ScFieldIdentifier
 return -1;  // none
 }
 
-ScDataPilotTablesObj::ScDataPilotTablesObj(ScDocShell* pDocSh, SCTAB nT) :
-pDocShell( pDocSh ),
+ScDataPilotTablesObj::ScDataPilotTablesObj(ScDocShell& rDocSh, SCTAB nT) :
+pDocShell(  ),
 nTab( nT )
 {
 pDocShell->GetDocument().AddUnoObject(*this);
@@ -340,7 +340,7 @@ rtl::Reference 
ScDataPilotTablesObj::GetObjectByIndex_Impl(
 {
 if ( nFound == nIndex )
 {
-return new ScDataPilotTableObj( pDocShell, nTab, 
rDPObj.GetName() );
+return new ScDataPilotTableObj(*pDocShell, nTab, 
rDPObj.GetName());
 }
 ++nFound;
 }
@@ -353,7 +353,7 @@ rtl::Reference 
ScDataPilotTablesObj::GetObjectByIndex_Impl(
 rtl::Reference 
ScDataPilotTablesObj::GetObjectByName_Impl(const OUString& rName)
 {
 if (hasByName(rName))
-return new ScDataPilotTableObj( pDocShell, nTab, rName );
+return new ScDataPilotTableObj(*pDocShell, nTab, rName);
 return nullptr;
 }
 
@@ -361,7 +361,7 @@ Reference SAL_CALL 
ScDataPilotTablesObj::createDataPilotDe
 {
 SolarMutexGuard aGuard;
 if (pDocShell)
-return new ScDataPilotDescriptor(pDocShell);
+return new ScDataPilotDescriptor(*pDocShell);
 return nullptr;
 }
 
@@ -578,9 +578,9 @@ sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const 
OUString& aName )
 return false;
 }
 
-ScDataPilotDescriptorBase::ScDataPilotDescriptorBase(ScDocShell* pDocSh) :
+ScDataPilotDescriptorBase::ScDataPilotDescriptorBase(ScDocShell& rDocSh) :
 maPropSet( lcl_GetDataPilotDescriptorBaseMap() ),
-pDocShell( pDocSh )
+pDocShell(  )
 {
 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-18 Thread Luboš Luňák (via logerrit)
 sc/inc/column.hxx  |6 ++
 sc/source/core/data/column.cxx |6 +++---
 sc/source/core/data/table1.cxx |   25 ++---
 sc/source/core/data/table2.cxx |3 ++-
 4 files changed, 21 insertions(+), 19 deletions(-)

New commits:
commit 2e86718626a07e1656661df3ad69a64848bf4614
Author: Luboš Luňák 
AuthorDate: Wed May 18 18:48:23 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu May 19 00:18:26 2022 +0200

don't allocate unnecessary columns when inserting a row

Change-Id: I616ef20dc1295ce17c4877ff367815bb6a90b7a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134547
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 290334f7f3fd..e4b7eb148d9a 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -171,6 +171,7 @@ public:
 voidChangeSelectionIndent( bool bIncrement, const ScMarkData& 
rMark, SCCOL nCol );
 
 boolTestInsertRow( SCSIZE nSize ) const;
+voidInsertRow( SCROW nStartRow, SCSIZE nSize );
 };
 
 // Use protected inheritance to prevent publishing some internal ScColumnData
@@ -1041,4 +1042,9 @@ inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) 
const
 return pAttrArray->TestInsertRow( nSize );
 }
 
+inline void ScColumnData::InsertRow( SCROW nStartRow, SCSIZE nSize )
+{
+pAttrArray->InsertRow( nStartRow, nSize );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 2353a476fe8a..57451b19f305 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2391,13 +2391,13 @@ bool ScColumn::UpdateReferenceOnCopy( 
sc::RefUpdateContext& rCxt, ScDocument* pU
 
 bool ScColumn::UpdateReference( sc::RefUpdateContext& rCxt, ScDocument* 
pUndoDoc )
 {
-if (rCxt.meMode == URM_COPY)
-return UpdateReferenceOnCopy(rCxt, pUndoDoc);
-
 if (IsEmptyData() || GetDoc().IsClipOrUndo())
 // Cells in this column are all empty, or clip or undo doc. No update 
needed.
 return false;
 
+if (rCxt.meMode == URM_COPY)
+return UpdateReferenceOnCopy(rCxt, pUndoDoc);
+
 std::vector aBounds;
 
 bool bThisColShifted = (rCxt.maRange.aStart.Tab() <= nTab && nTab <= 
rCxt.maRange.aEnd.Tab() &&
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 619947b15f2a..0b75dcefca2e 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1819,19 +1819,6 @@ void ScTable::UpdateReference(
 sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc, bool bIncludeDraw, bool 
bUpdateNoteCaptionPos )
 {
 bool bUpdated = false;
-SCCOL i;
-SCCOL iMax;
-if (rCxt.meMode == URM_COPY )
-{
-i = rCxt.maRange.aStart.Col();
-iMax = rCxt.maRange.aEnd.Col();
-}
-else
-{
-i = 0;
-iMax = rDocument.MaxCol();
-}
-
 UpdateRefMode eUpdateRefMode = rCxt.meMode;
 SCCOL nDx = rCxt.mnColDelta;
 SCROW nDy = rCxt.mnRowDelta;
@@ -1844,8 +1831,16 @@ void ScTable::UpdateReference(
 if (mpRangeName)
 mpRangeName->UpdateReference(rCxt, nTab);
 
-for ( ; i<=iMax; i++)
-bUpdated |= CreateColumnIfNotExists(i).UpdateReference(rCxt, pUndoDoc);
+if (rCxt.meMode == URM_COPY )
+{
+for( SCCOL col : GetAllocatedColumnsRange( rCxt.maRange.aStart.Col(), 
rCxt.maRange.aEnd.Col()))
+bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc);
+}
+else
+{
+for( SCCOL col : GetAllocatedColumnsRange( 0, rDocument.MaxCol()))
+bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc);
+}
 
 if ( bIncludeDraw )
 UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, 
nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos );
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2b6706790bdc..4e1d1f4da99d 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -186,8 +186,9 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, 
SCROW nStartRow, SCSIZE
 }
 }
 
-for (SCCOL j=nStartCol; j<=nEndCol; j++)
+for (SCCOL j : GetAllocatedColumnsRange(nStartCol, nEndCol))
 aCol[j].InsertRow( nStartRow, nSize );
+aDefaultColData.InsertRow( nStartRow, nSize );
 
 mpCondFormatList->InsertRow(nTab, nStartCol, nEndCol, nStartRow, nSize);
 


[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-18 Thread Luboš Luňák (via logerrit)
 sc/inc/column.hxx  |7 +++
 sc/source/core/data/table2.cxx |   17 +++--
 2 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit f3e1ebd309a967d3bb06a7e0fe9b501d1faa124b
Author: Luboš Luňák 
AuthorDate: Wed May 18 18:05:31 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu May 19 00:17:52 2022 +0200

ScTable::TestInsertRow() does not need to allocate all columns

Change-Id: Ic213997edf6838282a38e444a638713a72397fb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134545
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4d6f2c8e01ac..290334f7f3fd 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -169,6 +169,8 @@ public:
 
 voidClearSelectionItems( const sal_uInt16* pWhich, const 
ScMarkData& rMark, SCCOL nCol );
 voidChangeSelectionIndent( bool bIncrement, const ScMarkData& 
rMark, SCCOL nCol );
+
+boolTestInsertRow( SCSIZE nSize ) const;
 };
 
 // Use protected inheritance to prevent publishing some internal ScColumnData
@@ -1034,4 +1036,9 @@ inline void 
ScColumnData::SetAttrEntries(std::vector && vNewData)
 pAttrArray->SetAttrEntries( std::move( vNewData ));
 }
 
+inline bool ScColumnData::TestInsertRow( SCSIZE nSize ) const
+{
+return pAttrArray->TestInsertRow( nSize );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a290d07f4769..ef49854b5c01 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -134,15 +134,20 @@ void ScTable::SetCalcNotification( bool bSet )
 
 bool ScTable::TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, 
SCSIZE nSize ) const
 {
-bool bTest = true;
-
 if ( nStartCol==0 && nEndCol==rDocument.MaxCol() && pOutlineTable )
-bTest = pOutlineTable->TestInsertRow(nSize);
+if (!pOutlineTable->TestInsertRow(nSize))
+return false;
+
+SCCOL maxCol = ClampToAllocatedColumns(nEndCol);
+for (SCCOL i=nStartCol; i<=maxCol; i++)
+if (!aCol[i].TestInsertRow(nStartRow, nSize))
+return false;
 
-for (SCCOL i=nStartCol; (i<=nEndCol) && bTest; i++)
-bTest = 
const_cast(this)->CreateColumnIfNotExists(i).TestInsertRow(nStartRow, 
nSize);
+if( maxCol != nEndCol )
+if (!aDefaultColData.TestInsertRow(nSize))
+return false;
 
-return bTest;
+return true;
 }
 
 void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, 
SCSIZE nSize )


[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-17 Thread Luboš Luňák (via logerrit)
 sc/inc/column.hxx  |2 +-
 sc/inc/table.hxx   |8 
 sc/source/core/data/column.cxx |7 ---
 sc/source/core/data/document10.cxx |2 +-
 sc/source/core/data/table1.cxx |5 +++--
 sc/source/core/data/table2.cxx |   12 ++--
 sc/source/core/data/table3.cxx |   20 +---
 sc/source/core/data/table7.cxx |2 +-
 8 files changed, 33 insertions(+), 25 deletions(-)

New commits:
commit 9b06af2adddc49414adc135f3d08dcc88c896058
Author: Luboš Luňák 
AuthorDate: Tue May 17 19:59:09 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed May 18 06:36:18 2022 +0200

make CreateColumnIfNotExists() non-const

Generally const functions should not modify the data, so this
generally should not be needed. Those functions that need to allocate
a column because they can't/don't handle default values for
non-existent columns well should go with const_cast, being
an exception to the rule.

Change-Id: I62706da5b447019542d6775f14064fa15b71f3c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134488
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 01dc4e8611fa..4d6f2c8e01ac 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -379,7 +379,7 @@ public:
 bool   TestCopyScenarioTo( const ScColumn& rDestCol ) const;
 voidMarkScenarioIn( ScMarkData& rDestMark ) const;
 
-voidCopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) 
const;
+voidCopyUpdated( const ScColumn* pPosCol, ScColumn& rDestCol ) 
const;
 
 voidSwapCol(ScColumn& rCol);
 voidMoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol);
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e89dbd34dbc8..6c083e064add 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -157,7 +157,7 @@ class ScTable
 private:
 typedef ::std::vector< ScRange > ScRangeVec;
 
-mutable ScColContainer aCol;
+ScColContainer aCol;
 
 OUString aName;
 OUString aCodeName;
@@ -286,14 +286,14 @@ public:
 
 ScOutlineTable* GetOutlineTable()   { return 
pOutlineTable.get(); }
 
-ScColumn& CreateColumnIfNotExists( const SCCOL nScCol ) const
+ScColumn& CreateColumnIfNotExists( const SCCOL nScCol )
 {
 if ( nScCol >= aCol.size() )
 CreateColumnIfNotExistsImpl(nScCol);
 return aCol[nScCol];
 }
 // out-of-line the cold part of the function
-void CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const;
+void CreateColumnIfNotExistsImpl( const SCCOL nScCol );
 sal_uInt64  GetCellCount() const;
 sal_uInt64  GetWeightedCount() const;
 sal_uInt64  GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const;
@@ -584,7 +584,7 @@ public:
 SCCOL nDestCol, SCROW nDestRow, SCTAB nDestTab );
 
 voidCopyScenarioFrom( const ScTable* pSrcTab );
-voidCopyScenarioTo( const ScTable* pDestTab ) const;
+voidCopyScenarioTo( ScTable* pDestTab ) const;
 boolTestCopyScenarioTo( const ScTable* pDestTab ) const;
 voidMarkScenarioIn(ScMarkData& rMark, ScScenarioFlags nNeededBits) 
const;
 boolHasScenarioRange( const ScRange& rRange ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d9133e3ad55c..2353a476fe8a 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1680,14 +1680,15 @@ void ScColumn::UndoToColumn(
 CopyToColumn(rCxt, nRow2+1, GetDoc().MaxRow(), 
InsertDeleteFlags::FORMULA, false, rColumn);
 }
 
-void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const
+void ScColumn::CopyUpdated( const ScColumn* pPosCol, ScColumn& rDestCol ) const
 {
 // Copy cells from this column to the destination column only for those
-// rows that are present in the position column (rPosCol).
+// rows that are present in the position column (pPosCol).
 
 // First, mark all the non-empty cell ranges from the position column.
 sc::SingleColumnSpanSet aRangeSet(GetDoc().GetSheetLimits());
-aRangeSet.scan(rPosCol);
+if(pPosCol)
+aRangeSet.scan(*pPosCol);
 
 // Now, copy cells from this column to the destination column for those
 // marked row ranges.
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 4a9efa170285..ec61fa530952 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -991,7 +991,7 @@ std::optional 
ScDocument::GetColumnIterator( SCTAB nTab, SCC
 
 void ScDocument::CreateColumnIfNotExists( SCTAB nTab, SCCOL nCol )
 {
-const ScTable* pTab = FetchTable(nTab);
+ScTable* pTab = FetchTable(nTab);
 if (!pTab)
 return;
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 

[Libreoffice-commits] core.git: sc/inc sc/source

2022-05-11 Thread Luboš Luňák (via logerrit)
 sc/inc/interpretercontext.hxx|2 +-
 sc/source/core/tool/interpr1.cxx |   16 
 2 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit a49afabb0cf1eac8f1214bfada0d7c9bc662878e
Author: Luboš Luňák 
AuthorDate: Tue May 10 21:30:31 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed May 11 11:52:04 2022 +0200

reduce size of *IFS conditions array (tdf#144777)

The array is used to count the number of matching conditions
e.g. in COUNTIFS, which can be only up to nQueryCount, which
is sal_uInt8. So there's no need to count it as sal_uInt32,
and doing so may cause 4MiB array per thread for full-column
references, which causes easily causes 60% of time spent
just clearing and checking the complete array.

Change-Id: Id4bebf90619f7f2a721edb9cd31e6a11469579aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134138
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/inc/interpretercontext.hxx b/sc/inc/interpretercontext.hxx
index 07e20f3a887e..9f424b1a4f42 100644
--- a/sc/inc/interpretercontext.hxx
+++ b/sc/inc/interpretercontext.hxx
@@ -61,7 +61,7 @@ struct ScInterpreterContext
 std::unique_ptr mxScSortedRangeCache; // cache for 
unsorted lookups
 // Allocation cache for "aConditions" array in 
ScInterpreter::IterateParameterIfs()
 // This is populated/used only when formula-group threading is enabled.
-std::vector maConditions;
+std::vector maConditions;
 ScInterpreter* pInterpreter;
 
 ScInterpreterContext(const ScDocument& rDoc, SvNumberFormatter* 
pFormatter);
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index afd9079de498..ce05f771bd6d 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5827,7 +5827,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 sal_uInt8 nParamCount = GetByte();
 sal_uInt8 nQueryCount = nParamCount / 2;
 
-std::vector& vConditions = mrContext.maConditions;
+std::vector& vConditions = mrContext.maConditions;
 // vConditions is cached, although it is clear'ed after every cell is 
interpreted,
 // if the SUMIFS/COUNTIFS are part of a matrix formula, then that is not 
enough because
 // with a single InterpretTail() call it results in evaluation of all the 
cells in the
@@ -5886,7 +5886,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 SCCOL nDimensionCols = 0;
 SCROW nDimensionRows = 0;
 const SCSIZE nRefArrayRows = GetRefListArrayMaxSize( nParamCount);
-std::vector> vRefArrayConditions;
+std::vector> vRefArrayConditions;
 
 while (nParamCount > 1 && nGlobalError == FormulaError::NONE)
 {
@@ -6016,7 +6016,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 }
 // Reset condition results.
 std::for_each( vConditions.begin(), 
vConditions.end(),
-[](sal_uInt32 & r){ r = 0.0; } );
+[](sal_uInt8 & r){ r = 0.0; } );
 }
 }
 nRefArrayPos = nRefInList;
@@ -6192,7 +6192,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 if (nRefArrayPos != std::numeric_limits::max())
 {
 // Apply condition result to reference list array result 
position.
-std::vector& rVec = 
vRefArrayConditions[nRefArrayPos];
+std::vector& rVec = 
vRefArrayConditions[nRefArrayPos];
 if (rVec.empty())
 rVec = vConditions;
 else
@@ -6207,9 +6207,9 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 // When leaving an svRefList this has to be emptied not set to
 // 0.0 because it's checked when entering an svRefList.
 if (nRefInList == 0)
-std::vector().swap( vConditions);
+std::vector().swap( vConditions);
 else
-std::for_each( vConditions.begin(), vConditions.end(), 
[](sal_uInt32 & r){ r = 0.0; } );
+std::for_each( vConditions.begin(), vConditions.end(), 
[](sal_uInt8 & r){ r = 0; } );
 }
 }
 nParamCount -= 2;
@@ -6392,7 +6392,7 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 return;
 }
 
-std::vector::const_iterator itRes = 
vConditions.begin(), itResEnd = vConditions.end();
+std::vector::const_iterator itRes = 
vConditions.begin(), itResEnd = vConditions.end();
 

  1   2   3   4   5   6   7   8   9   10   >