[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-10-06 Thread Caolán McNamara (via logerrit)
 sc/source/filter/xml/XMLExportIterator.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2819bdf9a9abfd31ca33b504183cf141cc52a8c9
Author: Caolán McNamara 
AuthorDate: Thu Oct 5 14:27:45 2023 +0100
Commit: Xisco Fauli 
CommitDate: Fri Oct 6 09:26:08 2023 +0200

ubsan error seen export to ods

sc/source/filter/xml/XMLExportIterator.cxx:722:30: runtime error: load of 
value 5, which is not a valid value for type 'bool'

Change-Id: I3cf4b6f0a4036a764e976cac6e1b91e298948e13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157612
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit 77de4babe762e831f818cfc53ba4223575a981bf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157616

diff --git a/sc/source/filter/xml/XMLExportIterator.cxx 
b/sc/source/filter/xml/XMLExportIterator.cxx
index 6d8c408f19ec..bff7e8498642 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -712,7 +712,7 @@ bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, 
ScFormatRangeStyles* pC
 pDetectiveOp->SetCellData( aCell );
 
 HasAnnotation( aCell );
-bool bIsAutoStyle;
+bool bIsAutoStyle(false);
 // Ranges before the previous cell are not needed by 
ExportFormatRanges anymore and can be removed
 SCROW nRemoveBeforeRow = aLastAddress.Row();
 aCell.nStyleIndex = 
pCellStyles->GetStyleNameIndex(aCell.maCellAddress.Tab(),


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-10-05 Thread Justin Luth (via logerrit)
 sc/source/ui/view/gridwin.cxx |   15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 0e87e8a810b93a740beff63ceb1e40d2e5271acf
Author: Justin Luth 
AuthorDate: Sat Sep 30 07:02:08 2023 -0400
Commit: Xisco Fauli 
CommitDate: Thu Oct 5 11:35:10 2023 +0200

tdf#157038 sc: avoid spell-check dialog from outside selection

Fixes 7.4 regression from cf18038c66075f7a18d89e47f3a2ab1a5bf7c4fd

To avoid the HIGHLY LIKELY risk of losing the selection
because of the LOW POTENTIAL of the right click
being over a misspelling (that overflowed from outside the selection),
simply don't even attempt to spell-check in that case.

The opposite was already true (and is even worse).
If the misspelling originates in the selected cells,
but has overflowed into an unselected area,
right clicking on the misspelling is deliberately ignored
by SelectForContextMenu().

Change-Id: I7dfc5b190036f1705d848cb621e527cbff37e425
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157430
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 4cf4516bac88fb8f58743e6ae68eab0393059d7f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157328
Reviewed-by: Dennis Francis 
(cherry picked from commit d23b589a9c4fd38e714e23ff91e623a33909a739)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157469

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d1f8dead3a7c..e86f97f33ed4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3153,9 +3153,22 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
 if (aPos.Col() >= 0 && (aSpellCheckCell.getType() == 
CELLTYPE_STRING || aSpellCheckCell.getType() == CELLTYPE_EDIT))
 nColSpellError = aPos.Col();
 
-// Is there a misspelled word somewhere in the cell?
+// Is there possibly a misspelled word somewhere in the cell?
 // A "yes" does not mean that the word under the mouse pointer is 
wrong though.
 bSpellError = (mpSpellCheckCxt->isMisspelled(nColSpellError, 
nCellY));
+// Avoid situations where selecting the cell-with-wrong-spelling 
would be bad
+if (bSpellError)
+{
+// When the mouse is over an empty cell, text with spelling 
errors
+// potentially could have overflowed underneath the mouse 
pointer
+if (nColSpellError != nCellX)
+{
+// If the mouse is over a selected cell, only consider 
spell-checking
+// if the cell with the misspelling is also selected. 
tdf#157038
+if (mrViewData.GetMarkData().IsCellMarked(nCellX, nCellY))
+bSpellError = 
mrViewData.GetMarkData().IsCellMarked(nColSpellError, nCellY);
+}
+}
 }
 
 //  #i18735# First select the item under the mouse pointer.


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-08-30 Thread Xisco Fauli (via logerrit)
 sc/source/ui/app/transobj.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b00ebfb4f0803ef276f452e17d9e99f2229ef32f
Author: Xisco Fauli 
AuthorDate: Fri Aug 25 12:42:02 2023 +0200
Commit: Christian Lohmaier 
CommitDate: Wed Aug 30 15:50:10 2023 +0200

sc: fix crash in ScTransferObj::DragFinished

See 
https://crashreport.libreoffice.org/stats/signature/ScModule::GetDragData()

Change-Id: Ic5cdc3e1796fa20ac84150a04bed539bc9ca7321
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156094
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 8b022db4cd397fd88f8078fc7f5ff85f21635155)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156006
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index a81e4149956e..9f6729d46a43 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -566,7 +566,7 @@ void ScTransferObj::DragFinished( sal_Int8 nDropAction )
 }
 
 ScModule* pScMod = SC_MOD();
-if ( pScMod->GetDragData().pCellTransfer == this )
+if ( pScMod && pScMod->GetDragData().pCellTransfer == this )
 pScMod->ResetDragObject();
 
 m_xDragSourceRanges = nullptr;   // don't keep source after dropping


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-08-30 Thread Xisco Fauli (via logerrit)
 sc/source/ui/attrdlg/attrdlg.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit f0f51d05f27d7a1ed31b3b9d304170f7c951f5ac
Author: Xisco Fauli 
AuthorDate: Fri Aug 25 12:39:37 2023 +0200
Commit: Christian Lohmaier 
CommitDate: Wed Aug 30 15:49:40 2023 +0200

sc: fix crash in ScAttrDlg::PageCreated

See 
https://crashreport.libreoffice.org/stats/signature/ScAttrDlg::PageCreated(rtl::OString%20const%20&,SfxTabPage%20&)

Change-Id: I3f89cc917648462f819eb35461055096a6eb3853
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156093
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 
(cherry picked from commit c46f00166027fa3eefc75f9cb13bf4afc887bf1d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156004
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/attrdlg/attrdlg.cxx b/sc/source/ui/attrdlg/attrdlg.cxx
index 734ae94d606f..3f307adddeb4 100644
--- a/sc/source/ui/attrdlg/attrdlg.cxx
+++ b/sc/source/ui/attrdlg/attrdlg.cxx
@@ -76,8 +76,11 @@ void ScAttrDlg::PageCreated(const OString& rPageId, 
SfxTabPage& rTabPage)
 {
 const SfxPoolItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST 
);
 assert(pInfoItem && "FontListItem  not found :-(");
-aSet.Put (SvxFontListItem(static_cast(pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
-rTabPage.PageCreated(aSet);
+if (pInfoItem)
+{
+aSet.Put (SvxFontListItem(static_cast(pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
+rTabPage.PageCreated(aSet);
+}
 }
 else if (rPageId == "background")
 {


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-08-04 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |8 +++-
 sc/source/ui/inc/inputwin.hxx |2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

New commits:
commit a0b0215f5adc68b02c86a7dac2c0f49a0f53f28c
Author: Caolán McNamara 
AuthorDate: Wed Jul 26 09:29:18 2023 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Fri Aug 4 09:17:31 2023 +0200

Resolves: tdf#155716 grab focus when context menu is activated

Change-Id: I194aba413d5adf07c8d78823f2f9a086f95cf248
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154924
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7f33e397fc95..5ac3944df08e 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1648,7 +1648,7 @@ bool ScTextWnd::CanFocus() const
 return SC_MOD()->IsEditMode();
 }
 
-bool ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
+void ScTextWnd::UpdateFocus()
 {
 if (!HasFocus())
 {
@@ -1656,6 +1656,11 @@ bool ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt 
)
 if (CanFocus())
 TextGrabFocus();
 }
+}
+
+bool ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
+{
+UpdateFocus();
 
 bool bClickOnSelection = false;
 if (m_xEditView)
@@ -1771,6 +1776,7 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt )
 }
 if (IsMouseCaptured())
 ReleaseMouse();
+UpdateFocus();
 pViewFrm->GetDispatcher()->ExecutePopup("formulabar", 
(), );
 }
 }
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index f0f69e948843..823c9e177ed8 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -135,6 +135,8 @@ private:
 
 void InitEditEngine();
 
+void UpdateFocus();
+
 rtl::Reference m_xHelper;
 
 typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-08-01 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/table1.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit ce8c23e885404f971bc41b48cea8f9b56e345f80
Author: Caolán McNamara 
AuthorDate: Tue Jul 25 10:08:38 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Aug 1 16:04:20 2023 +0200

Resolves: tdf#156462 ctrl+left in calc doesn't always jump to the correct 
cell

since:

commit 9e2d48b9e04f7ea895fb095699c32ed8a44eb129
Date:   Wed Mar 30 11:58:04 2022 +0200

reduce Calc's INITIALCOLCOUNT to 1

but:

commit a680f6988482f13489d6c802b6078d43564ae934
Date:   Wed Jun 7 22:48:01 2017 +0530

tdf#50916 : More refactoring in table1.cxx

is likely also relevant wrt: "If nCol is in the unallocated range
[nLastCol+1, MAXCOL], then move it directly to nLastCol"

If the cursor is outside the allocated column range then the search
started 1 cell to the left of the last allocated column

Change-Id: I854173ad13d50e50d85e9902b31585e8ae3e2c0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154910
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 308025656319..9064c5241acf 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1344,14 +1344,14 @@ SCCOL ScTable::FindNextVisibleColWithContent( SCCOL 
nCol, bool bRight, SCROW nRo
 }
 else
 {
-// If nCol is in the unallocated range [nLastCol+1, 
rDocument.MaxCol()], then move it directly to nLastCol
+if(nCol == 0)
+return 0;
+
+// If nCol is in the unallocated range [nLastCol+1, 
rDocument.MaxCol()], then move it directly after nLastCol
 // as there is no data in the unallocated range. This also makes the 
search faster and avoids
 // the need for more range checks in the loop below.
 if ( nCol > nLastCol )
-nCol = nLastCol;
-
-if(nCol == 0)
-return 0;
+nCol = nLastCol + 1;
 
 do
 {


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-29 Thread Andreas Heinisch (via logerrit)
 sc/source/ui/miscdlgs/linkarea.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 0290a06c016186588720d73d6786acdc9f3880e6
Author: Andreas Heinisch 
AuthorDate: Fri Jul 28 09:37:47 2023 +0200
Commit: Eike Rathke 
CommitDate: Sat Jul 29 20:42:15 2023 +0200

tdf#142600 - External links dialog: list database ranges

Regression from commit 462f9d1f589a7afd66d3fc61925467d3b68e5b31 where
the database ranges were dropped.

Change-Id: Ic0e453fc6fe62849d72b6acf88ed7ebd3c47775b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155009
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 2f2cd7558e1d01f9670436412d62d03f28bab2c1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155031

diff --git a/sc/source/ui/miscdlgs/linkarea.cxx 
b/sc/source/ui/miscdlgs/linkarea.cxx
index 09cfe6c3c285..6b1716407561 100644
--- a/sc/source/ui/miscdlgs/linkarea.cxx
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -259,6 +260,13 @@ void ScLinkedAreaDlg::UpdateSourceRanges()
 m_xLbRanges->append_text(pRangeData->GetName());
 }
 }
+// tdf#142600 - list database ranges
+if (const auto pDBs = m_pSourceShell->GetDocument().GetDBCollection())
+{
+const auto& rNamedDBs = pDBs->getNamedDBs();
+for (const auto& rNamedDB : rNamedDBs)
+m_xLbRanges->append_text(rNamedDB->GetName());
+}
 }
 
 m_xLbRanges->thaw();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-18 Thread László Németh (via logerrit)
 sc/source/core/data/table2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0985431e0c5e0baab80df0450c6b7a3699430c87
Author: László Németh 
AuthorDate: Fri Jul 14 18:41:31 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 18 12:16:09 2023 +0200

tdf#156286 sc: fix crash with column deletion

Skip negative indices, which caused the crash, when
more columns were deleted, than the remaining columns
before them.

Regression from commit dd8e061406fac581d399da088c7f0187278035dc
"tdf#153437 sc: fix broken formatting without performance regression".

Change-Id: I223e2fbb321fc4bd2ddb7a67a16a64c69e1e7872
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154445
Reviewed-by: Czeber László 
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit e4ae409b8e57f5efe53af7bacd08b0d226a0d96f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154456

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index dbcd594fd62a..18fac8ddd176 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -401,7 +401,7 @@ void ScTable::DeleteCol(
 for (SCCOL nCol = nStartCol + nSize; nCol < aCol.size(); ++nCol)
 aCol[nCol].SwapCol(aCol[nCol - nSize]);
 // When delete column(s), initialize the last columns from the default 
attributes
-for (SCCOL nCol = aCol.size() - nSize; nCol < aCol.size(); ++nCol)
+for (SCCOL nCol = aCol.size() < static_cast(nSize) ? 0 : 
aCol.size() - nSize; nCol < aCol.size(); ++nCol)
 aCol[nCol].Init(nCol, aCol[nCol].GetTab(), rDocument, false);
 }
 else


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-14 Thread Andrea Gelmini (via logerrit)
 sc/source/core/data/table2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 724e101bb56aabe0d3dfedeef6ba05b4e31ae5dd
Author: Andrea Gelmini 
AuthorDate: Fri Jun 9 21:13:56 2023 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Sat Jul 15 01:41:23 2023 +0200

Fix typo

Change-Id: I93f8dc6746a9173847e96f1ba16e5fdc4a817ced
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152804
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 
(cherry picked from commit 97a4e4582698c74fa4fa5c2fed3cd48d4c66da8b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154453
Reviewed-by: László Németh 
Tested-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 910568d35720..dbcd594fd62a 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -400,7 +400,7 @@ 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
+// When delete column(s), initialize 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);
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-07 Thread Luigi Iucci (via logerrit)
 sc/source/ui/view/viewfun3.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 3e4625f35712ab2af97b9c159ed65619997ff2ea
Author: Luigi Iucci 
AuthorDate: Wed Jun 21 10:16:16 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri Jul 7 11:15:55 2023 +0200

tdf#155452 problem pasting to calc an image copied from firefox (windows)

Calc tries to paste the image as html.
In case both HTML_SIMPLE and BITMAP flavors are present in
the clipboard, we paste as BITMAP

Change-Id: I2527bedf11eb6986b58329acaf360a397af03101
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153614
Tested-by: Jenkins
Reviewed-by: Henry Castro 
(cherry picked from commit 46fa17b70db0d543518dde52908f46c85838ac12)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153668
Reviewed-by: Xisco Fauli 
(cherry picked from commit adaae622b67f525e0fb58af848a7cece8ac65f45)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153844
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 9dd9b810273a..64df4aed5f29 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -599,6 +599,8 @@ void ScViewFunc::PasteFromSystem()
 PasteFromSystem(SotClipboardFormatId::RICHTEXT);
 else if (aDataHelper.HasFormat(SotClipboardFormatId::HTML))
 PasteFromSystem(SotClipboardFormatId::HTML);
+else if (aDataHelper.HasFormat(SotClipboardFormatId::BITMAP))
+PasteFromSystem(SotClipboardFormatId::BITMAP);
 else if 
(aDataHelper.HasFormat(SotClipboardFormatId::HTML_SIMPLE))
 PasteFromSystem(SotClipboardFormatId::HTML_SIMPLE);
 else if (aDataHelper.HasFormat(SotClipboardFormatId::SYLK))


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-05 Thread Xisco Fauli (via logerrit)
 sc/source/ui/vba/vbaworksheet.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit a2427519315f07b6c79d8456b9b7c128371b7e74
Author: Xisco Fauli 
AuthorDate: Tue Jul 4 14:06:26 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Jul 5 11:24:37 2023 +0200

sc: fix crash in ScVbaWorksheet::Cells

See 
https://crashreport.libreoffice.org/stats/signature/ScDocShell::GetDocument()

Similar to 286a1c03fa10acf60f076a0af987112d24cb2ff5
"sc: check excel::getDocShell"

Change-Id: I102e575b4992e175d4e780ef2b43f887d94bbd24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153964
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit c7a8889302fd7e9e0665c3d21510e374cff3891e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153992
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/vba/vbaworksheet.cxx 
b/sc/source/ui/vba/vbaworksheet.cxx
index abd76c6023c6..53bdc893281a 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -681,8 +681,9 @@ ScVbaWorksheet::Cells( const ::uno::Any , const 
::uno::Any  )
 // Use a common helper method instead of creating a new ScVbaRange object
 uno::Reference< table::XCellRange > xRange( getSheet(), 
uno::UNO_QUERY_THROW );
 uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
-ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
-return ScVbaRange::CellsHelper( rDoc, this, mxContext, xRange, nRow, nCol 
);
+if(ScDocShell* pShell = excel::getDocShell( xModel ))
+return ScVbaRange::CellsHelper(pShell->GetDocument(), this, mxContext, 
xRange, nRow, nCol );
+throw uno::RuntimeException();
 }
 
 uno::Reference< excel::XRange >


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-07-05 Thread Xisco Fauli (via logerrit)
 sc/source/ui/app/inputhdl.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 2bcfff3f43292b8c81dea32796a3e8c78ec16bc1
Author: Xisco Fauli 
AuthorDate: Tue Jul 4 17:46:26 2023 +0200
Commit: Michael Stahl 
CommitDate: Wed Jul 5 11:13:52 2023 +0200

sc: fix crash in ScInputHandler::ShowArgumentsTip

See 
https://crashreport.libreoffice.org/stats/signature/ScInputHandler::ShowArgumentsTip(rtl::OUString%20&)

Change-Id: I0fd61d5cca58121e77e102edd3c8e77c75baf800
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153976
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit c38c8e6574ccb4502fc6a6ffbc4d2f700b582366)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153999
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 1f9ae0c29eeb..e56d94f4c367 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1137,6 +1137,9 @@ void ScInputHandler::ShowArgumentsTip( OUString& rSelText 
)
 return;
 }
 
+if ( !pActiveViewSh )
+return;
+
 ScDocShell* pDocSh = pActiveViewSh->GetViewData().GetDocShell();
 const sal_Unicode cSep = ScCompiler::GetNativeSymbolChar(ocSep);
 const sal_Unicode cSheetSep = pDocSh->GetDocument().GetSheetSeparator();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-06-29 Thread Henry Castro (via logerrit)
 sc/source/filter/html/htmlexp.cxx |   23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 87d1e49f0cdbff6023bc6083a561c96192eb1eed
Author: Henry Castro 
AuthorDate: Thu May 11 16:29:55 2023 -0400
Commit: Henry Castro 
CommitDate: Thu Jun 29 19:30:40 2023 +0200

tdf#154477: sc: filter: html: fix missing color scale conditional format

When copying a range cell to an external application that request
html data, the color scale conditional format does not have an
associate a set attribute.

Signed-off-by: Henry Castro 
Change-Id: I82b466a2100abc5070e92f844dc706d9b015c2e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151837
Tested-by: Jenkins
(cherry picked from commit 604c27f7c382bdd6baea73e60eed6525b9bfbd3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152522

diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index 16db15316121..98b2c980f304 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -65,6 +65,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -881,10 +883,27 @@ void ScHTMLExport::WriteTables()
 
 void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, 
SCROW nRow, SCTAB nTab )
 {
+std::optional aColorScale;
 ScAddress aPos( nCol, nRow, nTab );
 ScRefCellValue aCell(*pDoc, aPos, rBlockPos);
 const ScPatternAttr* pAttr = pDoc->GetPattern( nCol, nRow, nTab );
 const SfxItemSet* pCondItemSet = pDoc->GetCondResult( nCol, nRow, nTab, 
 );
+if (!pCondItemSet)
+{
+ScConditionalFormatList* pCondList = pDoc->GetCondFormList(nTab);
+const ScCondFormatItem& rCondItem = pAttr->GetItem(ATTR_CONDITIONAL);
+const ScCondFormatIndexes& rCondIndex = rCondItem.GetCondFormatData();
+if (rCondIndex.size() > 0)
+{
+ScConditionalFormat* pCondFmt = 
pCondList->GetFormat(rCondIndex[0]);
+if (pCondFmt)
+{
+const ScColorScaleFormat* pEntry = dynamic_cast(pCondFmt->GetEntry(0));
+if (pEntry)
+aColorScale = pEntry->GetColor(aPos);
+}
+}
+}
 
 const ScMergeFlagAttr& rMergeFlagAttr = pAttr->GetItem( ATTR_MERGE_FLAG, 
pCondItemSet );
 if ( rMergeFlagAttr.IsOverlapped() )
@@ -1023,7 +1042,9 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 ATTR_BACKGROUND, pCondItemSet );
 
 Color aBgColor;
-if ( rBrushItem.GetColor().GetAlpha() == 0 )
+if ( aColorScale )
+aBgColor = *aColorScale;
+else if ( rBrushItem.GetColor().GetAlpha() == 0 )
 aBgColor = aHTMLStyle.aBackgroundColor; // No unwanted background color
 else
 aBgColor = rBrushItem.GetColor();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-06-29 Thread Czeber László Ádám (via logerrit)
 sc/source/ui/view/output2.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 56c965372e2de4ea53b1ab09056906c85fbff06b
Author: Czeber László Ádám 
AuthorDate: Mon Jun 12 16:12:05 2023 +0200
Commit: László Németh 
CommitDate: Thu Jun 29 10:54:19 2023 +0200

tdf#122676 sc: fix format with * (filling) and NBSP thousand separator

Numbers containing no-break space (NBSP) thousand separator enabled
the EditEngine layout, losing filling e.g. for stretching spaces.
Enable EditEngine for NBSP characters only if there is no filling
in the number format code, fixing MSO interoperability, too.

In number format codes, asterisk (*) followed by a character is used
to fill the available space in the column with that character, e.g.
format code

[>0]" "* # ##0" € ";[<0]-* # ##0" € ";" "* -#" € ";" "@" "

put the minus sign at the left side of the column, while
the number at the right side of the column. Because of the NBSP
thousand separator, bigger numbers got different layout previously,
i.e. minus signs right next to the numbers.

Note: there is a better solution for the layout problem: using narrow
no-break space (U-202F), which is the proposed thousand separator in
typography, and it's back-compatible, because it doesn't enable the 
different layout.

Change-Id: Ia35f01733687ee6005f06ff3ab999b7a4b712ad4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152901
Reviewed-by: László Németh 
Tested-by: László Németh 
(cherry picked from commit 72e70088dc45fbe15f809abf5263247b13d937ac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153337
Tested-by: Jenkins

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 649ccdd7349e..fe8d06684517 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -815,6 +815,11 @@ bool ScDrawStringsVars::HasEditCharacters() const
 switch(aString[nIdx])
 {
 case CHAR_NBSP:
+// tdf#122676: Ignore CHAR_NBSP (this is thousand separator in 
any number)
+// if repeat character is set
+if (nRepeatPos < 0)
+return true;
+break;
 case CHAR_SHY:
 case CHAR_ZWSP:
 case CHAR_LRM:


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-06-27 Thread Caolán McNamara (via logerrit)
 sc/source/filter/excel/xiname.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 1b3963b93866680621016860276f53ae428ec6ad
Author: Caolán McNamara 
AuthorDate: Sun Jan 29 20:59:44 2023 +
Commit: Xisco Fauli 
CommitDate: Tue Jun 27 22:37:57 2023 +0200

crashtesting: crash in ReadQsiforum-mso-en4-30276.xls

on duplicate names where during import an existing ScRangeData using the
name is deleted on inserting a new one, leaving a XclImpName behind that
still references the deleted ScRangeData. Reverse the order of lookup
of XclImpName so we find the duplicate that references the valid
ScRangeData first.

likely also

forums/xls/forum-mso-en4-69844.xls
forums/xls/forum-mso-en4-69589.xls
forums/xls/forum-mso-en4-69308.xls

see also:

commit 657b3c889ae107d9ccaaab569929a3a1abde3200
Date:   Sat Jan 21 00:08:29 2012 -0500

fdo#44831: Named range should overwrite existing name.

When inserting a new named range, it should overwrite any existing
name if one exists.

Change-Id: I275663cacc34a2b85080c038dc5a199563f3547c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146310
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit ea093514e4fc3a66f57e07486863c22e32db4245)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153380
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/excel/xiname.cxx 
b/sc/source/filter/excel/xiname.cxx
index d498dfba492c..cd9e92dfaa93 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -291,8 +291,15 @@ const XclImpName* XclImpNameManager::FindName( 
std::u16string_view rXclName, SCT
 {
 const XclImpName* pGlobalName = nullptr;   // a found global name
 const XclImpName* pLocalName = nullptr;// a found local name
-for( const auto& rxName : maNameList )
+// If a duplicate name is seen by ScRangeName::insert then the existing
+// name is erased and the new one inserted, so in the case of duplicates
+// the last one seen is valid and the others invalid. So do this lookup in
+// reverse in order to return the XclImpName* that references the valid
+// entry (see tdf#44831 for the insert behavior and 
'forum-mso-en4-30276.xls'
+// for an example of this problem)
+for (auto itName = maNameList.rbegin(); itName != maNameList.rend(); 
++itName)
 {
+const auto& rxName = *itName;
 if( rxName->GetXclName() == rXclName )
 {
 if( rxName->GetScTab() == nScTab )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-06-05 Thread Mike Kaganski (via logerrit)
 sc/source/core/tool/appoptio.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 9f7e3560ba3ecdf52bc5b9637485fea57ae1b132
Author: Mike Kaganski 
AuthorDate: Sat Jun 3 22:41:45 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Jun 5 13:25:03 2023 +0200

tdf#151987: clean default list before using non-default one

This restores the code that I had dropped inexplicably in commit
8810812e58f1b014d3156235c1ab5a2d6c73c828 (tdf#132145: Synchronize
ScAppCfg with configuration, 2021-11-29).

Change-Id: Ie0215c9296d9cf9fcd75ed5b08218af9900eadb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152579
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit e0c7d7bc511c90e820adaaebb14ca8175364371d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152545
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 244f4ffc777e..3b19fbed2204 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -415,6 +415,8 @@ void ScAppCfg::ReadSortListCfg()
 
 if (!bDefault)
 {
+aList.clear();
+
 for (const OUString& rStr : std::as_const(aSeq))
 {
 ScUserListData* pNew = new ScUserListData(rStr);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-06-02 Thread Samuel Mehrbrodt (via logerrit)
 sc/source/core/data/column3.cxx |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 1aa089472457f0d6b67abb4637a5803b73682028
Author: Samuel Mehrbrodt 
AuthorDate: Thu Apr 27 13:58:26 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jun 2 12:36:58 2023 +0200

tdf#153972 Fix color filter when cells have no content

Change-Id: I9742fc0627c2311bfe4c067961e0feea476f1899
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151096
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152493

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 900ed04fa795..ca16c49d8de8 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2564,7 +2564,7 @@ class FilterEntriesHandler
 bool mbFiltering;
 bool mbFilteredRow;
 
-void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell)
+void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell, bool bIsEmptyCell=false)
 {
 SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
 sal_uLong nFormat = 
mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
@@ -2632,6 +2632,16 @@ class FilterEntriesHandler
 }
 mrFilterEntries.addBackgroundColor(backgroundColor);
 
+if (bIsEmptyCell)
+{
+if (!mrFilterEntries.mbHasEmpties)
+{
+mrFilterEntries.push_back(ScTypedStrData(OUString()));
+mrFilterEntries.mbHasEmpties = true;
+}
+return;
+}
+
 if (rCell.hasString())
 {
 mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), 0.0, 
0.0, ScTypedStrData::Standard, false, mbFilteredRow));
@@ -2727,17 +2737,8 @@ public:
 
 void operator() (const int nElemType, size_t nRow, size_t /* nDataSize */)
 {
-if ( nElemType == sc::element_type_empty )
-{
-if (!mrFilterEntries.mbHasEmpties)
-{
-mrFilterEntries.push_back(ScTypedStrData(OUString()));
-mrFilterEntries.mbHasEmpties = true;
-}
-return;
-}
 ScRefCellValue aCell = mrColumn.GetCellValue(nRow);
-processCell(mrColumn, nRow, aCell);
+processCell(mrColumn, nRow, aCell, nElemType == 
sc::element_type_empty);
 }
 };
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-31 Thread Xisco Fauli (via logerrit)
 sc/source/core/data/dociter.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 5716bb7165e8b095c202ea7a8717f2633c0d006f
Author: Xisco Fauli 
AuthorDate: Fri May 19 12:17:13 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed May 31 08:56:07 2023 +0200

sc: avoid crash in ScHorizontalCellIterator

At least do not crash with release builds as seen in

https://crashreport.libreoffice.org/stats/signature/ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument%20&,short,short,long,short,long)

Change-Id: If253e950bbb709b585dc9398beddd1303dcb1b57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152000
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 5655cc201e5a80997fe21bc2a0c7abcbe4fb488f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152325
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 123d96d91b8c..fd4fa7afe42f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1039,7 +1039,11 @@ 
ScHorizontalCellIterator::ScHorizontalCellIterator(ScDocument& rDocument, SCTAB
 {
 assert(mnTab < rDoc.GetTableCount() && "index out of bounds, FIX IT");
 
-nEndCol = rDoc.maTabs[mnTab]->ClampToAllocatedColumns(nEndCol);
+const ScTable* pTab = rDoc.FetchTable(mnTab);
+if (!pTab)
+return;
+
+nEndCol = pTab->ClampToAllocatedColumns(nEndCol);
 if (nEndCol < nStartCol) // E.g., somewhere completely outside allocated 
area
 nEndCol = nStartCol - 1; // Empty
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-22 Thread Noel Grandin (via logerrit)
 sc/source/ui/view/viewfunc.cxx |   29 -
 1 file changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 9494b7d3602aeccec0e434219c71a8b0223dfe82
Author: Noel Grandin 
AuthorDate: Sun May 21 21:18:58 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon May 22 14:08:39 2023 +0200

tdf#155368 Can't toggle Wrap Text on all cells if cell already has

The problem is not so much that we cannot toggle, it is that we
cannot unset a toggle property.
And the reason for that, is that the state of the toggle never
goes off because the view state as computed by
ScViewFunc::GetSelectionPattern is different
from the state that is seen in ScViewFunc::ApplySelectionPattern
where we apply the pattern.

So make the same shrink-data-area adjustment in GetSelectionPattern.

Change-Id: Ic56145ee98ead931278767851f74e0ce7422a150
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152074
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 8cc51cf9886a1e2f185c3824b71c960c08a9bf2e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152092
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 6e15f9b3e0f8..b5953bbf26f0 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -904,17 +904,25 @@ SvtScriptType ScViewFunc::GetSelectionScriptType()
 return nScript;
 }
 
+static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc);
+
 const ScPatternAttr* ScViewFunc::GetSelectionPattern()
 {
 // Don't use UnmarkFiltered in slot state functions, for performance 
reasons.
 // The displayed state is always that of the whole selection including 
filtered rows.
 
-const ScMarkData& rMark = GetViewData().GetMarkData();
+ScMarkData aMark = GetViewData().GetMarkData();
 ScDocument& rDoc = GetViewData().GetDocument();
-if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+
+// tdf#155368 if the selection is the whole sheet, we need to shrink the 
mark area, otherwise
+// we will not return a consistent result
+// (consistent compared to what happens in 
ScViewFunc::ApplySelectionPattern)
+ShrinkToDataArea( aMark, rDoc );
+
+if ( aMark.IsMarked() || aMark.IsMultiMarked() )
 {
 //  MarkToMulti is no longer necessary for rDoc.GetSelectionPattern
-const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( rMark );
+const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
 return pAttr;
 }
 else
@@ -923,9 +931,9 @@ const ScPatternAttr* ScViewFunc::GetSelectionPattern()
 SCROW  nRow = GetViewData().GetCurY();
 SCTAB  nTab = GetViewData().GetTabNo();
 
-ScMarkData aTempMark( rMark );  // copy sheet selection
-aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
-const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aTempMark );
+// copy sheet selection
+aMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
+const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
 return pAttr;
 }
 }
@@ -1181,11 +1189,14 @@ void ScViewFunc::ApplyPatternLines( const 
ScPatternAttr& rAttr, const SvxBoxItem
 StartFormatArea();
 }
 
+// tdf#147842 if the marked area is the entire sheet, then shrink it to the 
data area.
+// Otherwise ctrl-A, perform-action, will take a very long time as it tries to 
modify
+// cells that we are not using.
 static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc)
 {
-// tdf#147842 if the marked area is the entire sheet, then shrink it to 
the data area.
-// Otherwise ctrl-A, perform-action, will take a very long time as it 
tries to modify
-// cells then we are not using.
+// do not make it marked if it is not already marked
+if (!rFuncMark.IsMarked())
+return;
 if (rFuncMark.IsMultiMarked())
 return;
 ScRange aMarkArea = rFuncMark.GetMarkArea();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-19 Thread Xisco Fauli (via logerrit)
 sc/source/ui/vba/vbaapplication.cxx |   13 +++-
 sc/source/ui/vba/vbapagesetup.cxx   |7 +-
 sc/source/ui/vba/vbaworkbook.cxx|   26 +
 sc/source/ui/vba/vbaworksheet.cxx   |  102 +++-
 4 files changed, 85 insertions(+), 63 deletions(-)

New commits:
commit c0e96f302c04597bc49d55e262b069f1eb170e45
Author: Xisco Fauli 
AuthorDate: Thu May 18 13:31:14 2023 +0200
Commit: Caolán McNamara 
CommitDate: Fri May 19 10:06:30 2023 +0200

sc: check excel::getDocShell

There seems to be some crashes related. See

https://crashreport.libreoffice.org/stats/signature/ScDocShell::GetDocument()
or

https://crashreport.libreoffice.org/stats/signature/ScDocShell::RegisterAutomationWorkbookObject(com::sun::star::uno::Reference%3Cooo::vba::excel::XWorkbook%3E%20const%20&)

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

diff --git a/sc/source/ui/vba/vbaapplication.cxx 
b/sc/source/ui/vba/vbaapplication.cxx
index 98c7cf7708a5..6676b4bb5eaa 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1203,7 +1203,8 @@ uno::Reference< excel::XRange > lclCreateVbaRange(
 const ListOfScRange& rList )
 {
 ScDocShell* pDocShell = excel::getDocShell( rxModel );
-if( !pDocShell ) throw uno::RuntimeException();
+if( !pDocShell )
+throw uno::RuntimeException();
 
 ScRangeList aCellRanges;
 for( const auto& rItem : rList )
@@ -1345,8 +1346,11 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile )
 if ( pMeth )
 {
 uno::Reference< frame::XModel > xModel( getCurrentDocument() );
-ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
-rDoc.GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), 
bVolatile);
+if ( ScDocShell* pShell = excel::getDocShell( xModel ))
+{
+ScDocument& rDoc = pShell->GetDocument();
+rDoc.GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), 
bVolatile);
+}
 }
 
 // this is bound to break when loading the document
@@ -1446,7 +1450,10 @@ void SAL_CALL 
ScVbaApplication::setScreenUpdating(sal_Bool bUpdate)
 VbaApplicationBase::setScreenUpdating( bUpdate );
 
 uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), 
uno::UNO_SET_THROW );
+
 ScDocShell* pDocShell = excel::getDocShell( xModel );
+if (!pDocShell)
+return;
 ScDocument& rDoc = pDocShell->GetDocument();
 
 if( bUpdate )
diff --git a/sc/source/ui/vba/vbapagesetup.cxx 
b/sc/source/ui/vba/vbapagesetup.cxx
index f487b74e0c7b..f945802e1082 100644
--- a/sc/source/ui/vba/vbapagesetup.cxx
+++ b/sc/source/ui/vba/vbapagesetup.cxx
@@ -77,8 +77,11 @@ OUString SAL_CALL ScVbaPageSetup::getPrintArea()
 ScUnoConversion::FillScRange( aRange, rRange );
 aRangeList.push_back( aRange );
 }
-ScDocument& rDoc = excel::getDocShell( mxModel )->GetDocument();
-aRangeList.Format( aPrintArea, ScRefFlags::RANGE_ABS, rDoc, 
formula::FormulaGrammar::CONV_XL_A1, ','  );
+if ( ScDocShell* pShell = excel::getDocShell( mxModel ))
+{
+ScDocument& rDoc = pShell->GetDocument();
+aRangeList.Format( aPrintArea, ScRefFlags::RANGE_ABS, rDoc, 
formula::FormulaGrammar::CONV_XL_A1, ','  );
+}
 }
 
 return aPrintArea;
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 23cc523a1aa8..0604d9686b61 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -184,9 +184,8 @@ ScVbaWorkbook::init()
 {
 if ( !ColorData.hasElements() )
 ResetColors();
-uno::Reference< frame::XModel > xModel = getModel();
-if ( xModel.is() )
-excel::getDocShell( xModel )->RegisterAutomationWorkbookObject( this );
+if ( ScDocShell* pShell = excel::getDocShell( getModel() ))
+pShell->RegisterAutomationWorkbookObject( this );
 }
 
 ScVbaWorkbook::ScVbaWorkbook(   const css::uno::Reference< 
ov::XHelperInterface >& xParent, const css::uno::Reference< 
css::uno::XComponentContext >& xContext, css::uno::Reference< 
css::frame::XModel > const & xModel ) : ScVbaWorkbook_BASE( xParent, xContext, 
xModel )
@@ -264,18 +263,23 @@ ScVbaWorkbook::getProtectStructure()
 
 sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed()
 {
-uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
-ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
-return rDoc.GetDocOptions().IsCalcAsShown();
+if ( ScDocShell* pShell = excel::getDocShell( getModel() ))
+{
+ScDocument& rDoc = pShell->GetDocument();
+return rDoc.GetDocOptions().IsCalcAsShown();
+}
+return false;
 }
 
 void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-17 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/token.cxx |   35 ---
 1 file changed, 28 insertions(+), 7 deletions(-)

New commits:
commit 41fb05d4b21ab8fd5a522ff8eba6844333fbf4cf
Author: Eike Rathke 
AuthorDate: Tue May 16 17:33:36 2023 +0200
Commit: Christian Lohmaier 
CommitDate: Wed May 17 14:02:49 2023 +0200

Resolves: tdf#153790 Suppress duplicated end part sheet reference, 
tdf#103890

Also keep explicitly given sheet reference relative to the same
sheet as user wished.

Affected only when moving formula cell position like with
cut and drag

Change-Id: I6b1da6aea58b88a24567189ef6aa212dab01de49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151845
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit fcb66a74ae3af322b2829040bb84669d5c63e568)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151782
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4315f017e67c..337a2fb86d21 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3416,7 +3416,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetAddress(*mxSheetLimits, aAbs, rNewPos);
-rRef.SetFlag3D(aAbs.Tab() != rNewPos.Tab() || 
!rRef.IsTabRel());
+rRef.SetFlag3D(rRef.IsFlag3D() || !rRef.IsTabRel() || 
aAbs.Tab() != rNewPos.Tab());
 }
 break;
 case svDoubleRef:
@@ -3446,12 +3446,33 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetRange(*mxSheetLimits, aAbs, rNewPos);
-// Absolute sheet reference => set 3D flag.
-// More than one sheet referenced => has to have both 
3D flags.
-// If end part has 3D flag => start part must have it 
too.
-rRef.Ref2.SetFlag3D(aAbs.aStart.Tab() != 
aAbs.aEnd.Tab() || !rRef.Ref2.IsTabRel());
-rRef.Ref1.SetFlag3D(aAbs.aStart.Tab() != rNewPos.Tab() 
|| !rRef.Ref1.IsTabRel() ||
-rRef.Ref2.IsFlag3D());
+bool b1, b2;
+if (aAbs.aStart.Tab() != aAbs.aEnd.Tab())
+{
+// More than one sheet referenced => has to have
+// both 3D flags.
+b1 = b2 = true;
+}
+else
+{
+// Keep given 3D flag even for relative sheet
+// reference to same sheet.
+// Absolute sheet reference => set 3D flag.
+// Reference to another sheet => set 3D flag.
+b1 = rRef.Ref1.IsFlag3D() || !rRef.Ref1.IsTabRel() 
|| rNewPos.Tab() != aAbs.aStart.Tab();
+b2 = rRef.Ref2.IsFlag3D() || !rRef.Ref2.IsTabRel() 
|| rNewPos.Tab() != aAbs.aEnd.Tab();
+// End part has 3D flag => start part must have it 
too.
+if (b2)
+b1 = true;
+// End part sheet reference is identical to start
+// part sheet reference and end part sheet
+// reference was not explicitly given => clear end
+// part 3D flag.
+if (b1 && b2 && rRef.Ref1.IsTabRel() == 
rRef.Ref2.IsTabRel() && !rRef.Ref2.IsFlag3D())
+b2 = false;
+}
+rRef.Ref1.SetFlag3D(b1);
+rRef.Ref2.SetFlag3D(b2);
 }
 break;
 case svExternalSingleRef:


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-08 Thread Eike Rathke (via logerrit)
 sc/source/ui/app/inputhdl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c3135bd43e216ef33bc554597c120388cf2babe1
Author: Eike Rathke 
AuthorDate: Tue Apr 25 19:46:45 2023 +0200
Commit: Xisco Fauli 
CommitDate: Mon May 8 15:24:46 2023 +0200

Resolves: tdf#41304 Add percent operator % to reference delimiters

Change-Id: I094fcb800a29de424db28e1b58f1239381a3b4a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151001
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151012
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 422a9a128508..1f9ae0c29eeb 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -364,7 +364,7 @@ void ScInputHandler::InitRangeFinder( const OUString& 
rFormula )
 ScDocument& rDoc = pDocSh->GetDocument();
 const sal_Unicode cSheetSep = rDoc.GetSheetSeparator();
 
-OUString aDelimiters = ScEditUtil::ModifyDelimiters(" !~\"\t\n");
+OUString aDelimiters = ScEditUtil::ModifyDelimiters(" !~%\"\t\n");
 // delimiters (in addition to ScEditUtil): only characters that are
 // allowed in formulas next to references and the quotation mark (so
 // string constants can be skipped)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-07 Thread Eike Rathke (via logerrit)
 sc/source/ui/app/inputhdl.cxx |   72 +++---
 sc/source/ui/inc/rfindlst.hxx |   12 +++
 2 files changed, 53 insertions(+), 31 deletions(-)

New commits:
commit f6a783af88b571ff1f3df9bda31eb0aac66a2c5f
Author: Eike Rathke 
AuthorDate: Tue Apr 25 16:44:25 2023 +0200
Commit: Caolán McNamara 
CommitDate: Sun May 7 20:50:47 2023 +0200

Resolves: tdf#144547 ScRangeFindList: handle references in multi-line 
formula

Also fix a color attribution error if when dragging the reference
the new reference string is longer (colored too short) or shorter
(colored too much including the next characters/operator/...) than
the old reference string.

Change-Id: I1b39fd5778d75290a0233f51a4198753fa858f48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150979
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 82b887c026cb6b0506ebecdcbc8e4b30362ec55b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151010
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 75655d807b73..422a9a128508 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -341,6 +341,20 @@ void ScInputHandler::SendReferenceMarks( const 
SfxViewShell* pViewShell,
 LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
 }
 
+static inline void incPos( const sal_Unicode c, sal_Int32& rPos, ESelection& 
rSel )
+{
+++rPos;
+if (c == '\n')
+{
+++rSel.nEndPara;
+rSel.nEndPos = 0;
+}
+else
+{
+++rSel.nEndPos;
+}
+}
+
 void ScInputHandler::InitRangeFinder( const OUString& rFormula )
 {
 DeleteRangeFinder();
@@ -350,7 +364,7 @@ void ScInputHandler::InitRangeFinder( const OUString& 
rFormula )
 ScDocument& rDoc = pDocSh->GetDocument();
 const sal_Unicode cSheetSep = rDoc.GetSheetSeparator();
 
-OUString aDelimiters = ScEditUtil::ModifyDelimiters(" !~\"");
+OUString aDelimiters = ScEditUtil::ModifyDelimiters(" !~\"\t\n");
 // delimiters (in addition to ScEditUtil): only characters that are
 // allowed in formulas next to references and the quotation mark (so
 // string constants can be skipped)
@@ -366,6 +380,7 @@ void ScInputHandler::InitRangeFinder( const OUString& 
rFormula )
 sal_Int32 nLen = rFormula.getLength();
 sal_Int32 nPos = 0;
 sal_Int32 nStart = 0;
+ESelection aSel;
 sal_uInt16 nCount = 0;
 ScRange aRange;
 while ( nPos < nLen && nCount < RANGEFIND_MAX )
@@ -375,14 +390,16 @@ void ScInputHandler::InitRangeFinder( const OUString& 
rFormula )
 {
 if ( pChar[nPos] == '"' )   // String
 {
-++nPos;
+incPos( pChar[nPos], nPos, aSel);
 while (nPosGetTitle() ));
 }
 
-Color nColor = pRangeFindList->Insert( ScRangeFindData( 
aRange, nFlags, nStart, nPos ) );
+Color nColor = pRangeFindList->Insert( ScRangeFindData( 
aRange, nFlags, aSel));
 
-ESelection aSel( 0, nStart, 0, nPos );
 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
 aSet.Put( SvxColorItem( nColor, EE_CHAR_COLOR ) );
 mpEditEngine->QuickSetAttribs( aSet, aSel );
@@ -620,8 +636,9 @@ static void lcl_Replace( EditView* pView, const OUString& 
rNewStr, const ESelect
 // To do that we need to cancel the selection from above (before 
QuickInsertText)
 pView->InsertText( OUString() );
 
-sal_Int32 nLen = pEngine->GetTextLen(0);
-ESelection aSel( 0, nLen, 0, nLen );
+const sal_Int32 nPara = pEngine->GetParagraphCount() - 1;
+const sal_Int32 nLen = pEngine->GetTextLen(nPara);
+ESelection aSel( nPara, nLen, nPara, nLen );
 pView->SetSelection( aSel ); // Set cursor to the end
 }
 
@@ -631,8 +648,6 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const 
ScRange& rNew )
 if ( pDocView && pRangeFindList && nIndex < pRangeFindList->Count() )
 {
 ScRangeFindData& rData = pRangeFindList->GetObject( nIndex );
-sal_Int32 nOldStart = rData.nSelStart;
-sal_Int32 nOldEnd = rData.nSelEnd;
 Color nNewColor = pRangeFindList->FindColor( rNew, nIndex );
 
 ScRange aJustified = rNew;
@@ -640,32 +655,39 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, 
const ScRange& rNew )
 ScDocument& rDoc = pDocView->GetViewData().GetDocument();
 const ScAddress::Details aAddrDetails( rDoc, aCursorPos );
 OUString aNewStr(aJustified.Format(rDoc, rData.nFlags, aAddrDetails));
-ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
 
 DataChanging();
 
-lcl_Replace( pTopView, aNewStr, aOldSel );
-lcl_Replace( pTableView, aNewStr, aOldSel );
+lcl_Replace( pTopView, aNewStr, 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-05 Thread Xisco Fauli (via logerrit)
 sc/source/core/data/documen2.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 0e4b219337fc4df1ae58f3f257ea3990b615f983
Author: Xisco Fauli 
AuthorDate: Wed May 3 19:10:31 2023 +0200
Commit: Michael Stahl 
CommitDate: Fri May 5 10:49:42 2023 +0200

tdf#155037: check source code name exists

Otherwise, it crashes with
terminate called after throwing an instance of 
'com::sun::star::container::NoSuchElementException'

Change-Id: Ic53bedcc19690d43aef20d4193e840e340e349d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151336
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Reviewed-by: Xisco Fauli 
(cherry picked from commit 5f914d5f4b48a092736650db1e1e431787e50096)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151371
Reviewed-by: Michael Stahl 

diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a7ea162177a9..2faa9cd1c7d0 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1117,7 +1117,8 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, 
SCTAB nSrcPos,
 OUString sSrcCodeName;
 rSrcDoc.GetCodeName( nSrcPos, sSrcCodeName );
 OUString sRTLSource;
-xLib->getByName( sSrcCodeName ) >>= sRTLSource;
+if (xLib->hasByName( sSrcCodeName ))
+xLib->getByName( sSrcCodeName ) >>= sRTLSource;
 sSource = sRTLSource;
 }
 VBA_InsertModule( *this, nDestPos, sSource );


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-05-02 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr1.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 700e918ba7c481034a4629fbbf95e829e2a2786a
Author: Eike Rathke 
AuthorDate: Sat Apr 29 18:59:30 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue May 2 11:09:40 2023 +0200

Resolves: tdf#119659 Check found position for result vector

Change-Id: Idc454462c47b6c7b7b7cb6c86b08650d059221c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151186
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 89e725dc3236f6f8ad226adf6508f7fc753b5572)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151190
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ac0fb22b6231..b833e3f48f24 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7072,7 +7072,8 @@ void ScInterpreter::ScLookup()
 if (pResMat)
 {
 VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
-// result array is matrix.
+// Result array is matrix.
+// Note this does not replicate the other dimension.
 if (o3tl::make_unsigned(nDelta) >= aResMatAcc.GetElementCount())
 {
 PushNA();
@@ -7206,6 +7207,12 @@ void ScInterpreter::ScLookup()
 {
 VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
 // Use the matrix result array.
+// Note this does not replicate the other dimension.
+if (o3tl::make_unsigned(nDelta) >= aResMatAcc.GetElementCount())
+{
+PushNA();
+return;
+}
 if (aResMatAcc.IsValue(nDelta))
 PushDouble(aResMatAcc.GetDouble(nDelta));
 else


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-28 Thread Eike Rathke (via logerrit)
 sc/source/filter/oox/sheetdatacontext.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 3e7702774b7309e8fa07930d2960e4e619bfb291
Author: Eike Rathke 
AuthorDate: Thu Apr 27 14:56:36 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Apr 28 10:53:55 2023 +0200

Resolves: tdf#155046 Accept true and false as 1 and 0 for OOXML boolean 
cells

Encountered in the wild written by
https://www.npmjs.com/package/excel4node

https://github.com/advisr-io/excel4node/blob/c14213abb9a511ff786c574e473f53006a85e4f9/source/lib/cell/cell.js#L74

Change-Id: Ib21242a55f0d8530fd9120b07a096a9908f451bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151101
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit e45d77a41139aad38151f4d8e48fd894fd9811a6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151119
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/oox/sheetdatacontext.cxx 
b/sc/source/filter/oox/sheetdatacontext.cxx
index c1a270afb41a..bc5855e9f4b7 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -185,7 +185,16 @@ void SheetDataContext::onEndElement()
 mrSheetData.setValueCell( maCellData, maCellValue.toDouble() );
 break;
 case XML_b:
-mrSheetData.setBooleanCell( maCellData, maCellValue.toDouble() != 
0.0 );
+{
+// Some generators may write true or false instead of 1 or 0.
+/* XXX NOTE: PivotCacheItem::readBool() may suffer from this as
+ * well, but for now let's assume that software writing this
+ * here wrong won't write pivot caches at all.. */
+bool bValue = (maCellValue.toDouble() != 0.0);
+if (!bValue && maCellValue.equalsIgnoreAsciiCase(u"true"))
+bValue = true;
+mrSheetData.setBooleanCell( maCellData, bValue );
+}
 break;
 case XML_e:
 mrSheetData.setErrorCell( maCellData, maCellValue );


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-27 Thread Eike Rathke (via logerrit)
 sc/source/core/data/queryiter.cxx |   18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 054455d259037c97b2b67e738b6655e33ddfe126
Author: Eike Rathke 
AuthorDate: Wed Apr 26 21:11:44 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 27 09:23:29 2023 +0200

Resolves: tdf#151958 Disable binary search on sorted cache for current 
releases

Temporary measure until the actual cause is fixed.
The by string query of binary search on sorted cache is broken for
mixed types like here the numeric date cells and text cells.

Change-Id: Icfe0b0c30987fcefdd6ed11066ea9113f3b4dabe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151074
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit cf3fcb875ecfe47940347286e869b3909ed42274)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151023
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index 5d8a3695f7d1..1fbdb526bc0f 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -1219,10 +1219,21 @@ ScQueryCellIteratorAccessSpecific< 
ScQueryCellIteratorAccess::SortedCache >::Mak
 return SortedCacheIndexer(rCells, nStartRow, nEndRow, sortedCache);
 }
 
-static bool CanBeUsedForSorterCache(ScDocument& rDoc, const ScQueryParam& 
rParam,
-SCTAB nTab, const ScFormulaCell* cell, const ScComplexRefData* refData,
-ScInterpreterContext& context)
+static bool CanBeUsedForSorterCache(ScDocument& /*rDoc*/, const ScQueryParam& 
/*rParam*/,
+SCTAB /*nTab*/, const ScFormulaCell* /*cell*/, const ScComplexRefData* 
/*refData*/,
+ScInterpreterContext& /*context*/)
 {
+#if 1
+/* TODO: tdf#151958 broken by string query of binary search on sorted
+ * cache, use the direct query instead for releases and fix SortedCache
+ * implementation after. Not only COUNTIF() is broken, but also COUNTIFS(),
+ * and maybe lcl_LookupQuery() for VLOOKUP() etc. as well. Just disable
+ * this for now.
+ * Can't just return false because below would be unreachable code. Can't
+ * just #if/#else/#endif either because parameters would be unused. Crap
+ * this and comment out parameter names. */
+return false;
+#else
 if(!rParam.GetEntry(0).bDoQuery || rParam.GetEntry(1).bDoQuery
 || rParam.GetEntry(0).GetQueryItems().size() != 1 )
 return false;
@@ -1278,6 +1289,7 @@ static bool CanBeUsedForSorterCache(ScDocument& rDoc, 
const ScQueryParam& rParam
 return false;
 }
 return true;
+#endif
 }
 
 // Generic query implementation.


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-20 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr2.cxx |   17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 81458d155a442a98dac0e30ce36725c15901f7a9
Author: Eike Rathke 
AuthorDate: Sat Apr 15 01:01:58 2023 +0200
Commit: Mike Kaganski 
CommitDate: Thu Apr 20 17:54:23 2023 +0200

ROUNDSIG() Avoid inaccuracy of pow(10,negative) tdf#138220, tdf#105931 
follow

https://bugs.documentfoundation.org/show_bug.cgi?id=138220#c6
(otherwise unrelated) has an example of
=RAWSUBTRACT(ROUNDSIG(-999.13;12);-999.13)
resulting in -0,11368684 instead of 0, due to these
0.1 ... inexact negative power of 10 values.

Change-Id: I82429f0871f1de35a7f2092708fc6b9c2e902999
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150438
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 397d12997a604730ad11316faa34cefd470ee0ff)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150618
Reviewed-by: Mike Kaganski 

diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index a0b857defc76..6259d20ce5f7 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1036,8 +1036,21 @@ void ScInterpreter::ScRoundUp()
 
 void ScInterpreter::RoundSignificant( double fX, double fDigits, double  )
 {
-double fTemp = ::rtl::math::approxFloor( log10( std::abs(fX) ) ) + 1.0 - 
fDigits;
-fRes = ::rtl::math::round( pow(10.0, -fTemp ) * fX ) * pow( 10.0, fTemp );
+double fTemp = floor( log10( std::abs(fX) ) ) + 1.0 - fDigits;
+double fIn = fX;
+// Avoid inaccuracy of negative powers of 10.
+if (fTemp < 0.0)
+fIn *= pow(10.0, -fTemp);
+else
+fIn /= pow(10.0, fTemp);
+// For very large fX there might be an overflow in fIn resulting in
+// non-finite. rtl::math::round() handles that and it will be propagated as
+// usual.
+fRes = ::rtl::math::round(fIn);
+if (fTemp < 0.0)
+fRes /= pow(10.0, -fTemp);
+else
+fRes *= pow(10.0, fTemp);
 }
 
 // tdf#105931


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-20 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr2.cxx |   49 +--
 1 file changed, 42 insertions(+), 7 deletions(-)

New commits:
commit f0f2ceaf978a0eee8e3c1fcfe6dec546ab8f07d6
Author: Eike Rathke 
AuthorDate: Sat Apr 15 01:38:39 2023 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Apr 20 09:51:17 2023 +0200

Resolves: tdf#138220 tdf#154792 Avoid double rounding; tdf#124286 follow-up

Change-Id: Ie4028b20f2d3087a54bbfafd35d59fa06ec7a061
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150439
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 8186a01f2a26f05645a2a3c9c93b453bd35b796f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150505
Reviewed-by: Mike Kaganski 
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 7826522a89bf..a0b857defc76 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -962,20 +962,55 @@ void ScInterpreter::RoundNumber( rtl_math_RoundingMode 
eMode )
 fVal = ::rtl::math::round( GetDouble(), 0, eMode );
 else
 {
-sal_Int16 nDec = GetInt16();
-double fX = GetDouble();
+const sal_Int16 nDec = GetInt16();
+const double fX = GetDouble();
 if (nGlobalError == FormulaError::NONE)
 {
+// A quite aggressive approach with 12 significant digits.
+// However, using 14 or some other doesn't work because other
+// values may fail, like =ROUNDDOWN(2-5E-015;13) would produce
+// 2 (another example in tdf#124286).
+constexpr sal_Int16 kSigDig = 12;
+
 if ( ( eMode == rtl_math_RoundingMode_Down ||
eMode == rtl_math_RoundingMode_Up ) &&
- nDec < 12 && fmod( fX, 1.0 ) != 0.0 )
+ nDec < kSigDig && fmod( fX, 1.0 ) != 0.0 )
+
 {
-// tdf124286 : round to 12 significant digits before rounding
+// tdf124286 : round to significant digits before rounding
 // down or up to avoid unexpected rounding errors
 // caused by decimal -> binary -> decimal 
conversion
-double fRes;
-RoundSignificant( fX, 12, fRes );
-fVal = ::rtl::math::round( fRes, nDec, eMode );
+
+double fRes = fX;
+// Similar to RoundSignificant() but omitting the back-scaling
+// and interim integer rounding before the final rounding,
+// which would result in double rounding. Instead, adjust the
+// decimals and round into integer part before scaling back.
+const double fTemp = floor( log10( std::abs(fRes))) + 1.0 - 
kSigDig;
+// Avoid inaccuracy of negative powers of 10.
+if (fTemp < 0.0)
+fRes *= pow(10.0, -fTemp);
+else
+fRes /= pow(10.0, fTemp);
+if (std::isfinite(fRes))
+{
+// fRes is now at a decimal normalized scale.
+// Truncate up-rounding to opposite direction for values
+// like 0.0605 =ROUNDUP(8.06-8;2) that here now
+// is 6000.005 and otherwise would yield 0.07
+if (eMode == rtl_math_RoundingMode_Up)
+fRes = ::rtl::math::approxFloor(fRes);
+fVal = ::rtl::math::round( fRes, nDec + fTemp, eMode );
+if (fTemp < 0.0)
+fVal /= pow(10.0, -fTemp);
+else
+fVal *= pow(10.0, fTemp);
+}
+else
+{
+// Overflow. Let our round() decide if and how to round.
+fVal = ::rtl::math::round( fX, nDec, eMode );
+}
 }
 else
 fVal = ::rtl::math::round( fX, nDec, eMode );


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-17 Thread Caolán McNamara (via logerrit)
 sc/source/filter/xml/xmlcelli.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 4ad3605166c91193b3dbf41ed33515e267133f90
Author: Caolán McNamara 
AuthorDate: Mon Apr 17 09:17:43 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 17 14:53:05 2023 +0200

tdf#151560 don't crash on loading dubious fods

Change-Id: Ib41b3a95dd3829e8d3eca61621257fdd416bd8dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150498
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 7ae36e35..7288c631f68c 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1483,7 +1483,7 @@ bool ScXMLTableRowCellContext::IsPossibleErrorString() 
const
 return false;
 else if(mbNewValueType && mbErrorValue)
 return true;
-return mbPossibleErrorCell || (mbCheckWithCompilerForError &&
+return mbPossibleErrorCell || (mbCheckWithCompilerForError && 
maStringValue &&
 GetScImport().GetFormulaErrorConstant(*maStringValue) != 
FormulaError::NONE);
 }
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-11 Thread Stephan Bergmann (via logerrit)
 sc/source/core/tool/reffind.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c7c7f1c39630890f0c6eadbf9cd44b3ba88f9d81
Author: Stephan Bergmann 
AuthorDate: Tue Apr 11 10:35:36 2023 +0200
Commit: Caolán McNamara 
CommitDate: Tue Apr 11 20:39:03 2023 +0200

Fix heap-buffer-overflow

...during CppunitTest_sc_ucalc, after 
40e3e9fd1c501cc1978d4370b6392701ccd42a71
"tdf#113027 - Allow cycling cell reference types including whitespaces",

> ==5140==ERROR: AddressSanitizer: heap-buffer-overflow on address 
0x604000cfba74 at pc 0x7f36cb07ef6e bp 0x7ffd061d34d0 sp 0x7ffd061d34c8
> READ of size 2 at 0x604000cfba74 thread T0
> #0 0x7f36cb07ef6d in (anonymous namespace)::FindEndPosR1C1(char16_t 
const*, int, int) /sc/source/core/tool/reffind.cxx:91:13
> #1 0x7f36cb07cf0f in (anonymous namespace)::FindEndPos(char16_t 
const*, int, int, formula::FormulaGrammar::AddressConvention) 
/sc/source/core/tool/reffind.cxx:126:20
> #2 0x7f36cb07b029 in ScRefFinder::ToggleRel(int, int) 
/sc/source/core/tool/reffind.cxx:262:28
> #3 0x7f36c7b8482b in testTdf113027::TestBody() 
/sc/qa/unit/ucalc.cxx:467:13
>
> 0x604000cfba74 is located 0 bytes to the right of 36-byte region 
[0x604000cfba50,0x604000cfba74)
> allocated by thread T0 here:
> #0 0x4b7c20 in malloc 
/home/tdf/lode/packages/llvm-llvmorg-12.0.1.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:145
> #1 0x7f371b927c59 in _rtl_uString* rtl::str::Alloc<_rtl_uString>(int) 
/sal/rtl/strtmpl.hxx:833:46
> #2 0x7f371b92640f in void 
rtl::str::newFromStr_WithLength<_rtl_uString, char>(_rtl_uString**, char 
const*, int, int) /sal/rtl/strtmpl.hxx:947:15
> #3 0x7f371b9797f0 in rtl_uString_newFromLiteral 
/sal/rtl/ustring.cxx:1252:5
> #4 0x7f36c7dab771 in rtl::OUString::OUString(char 
const (&) [14], rtl::libreoffice_internal::ConstCharArrayDetector::Type) /include/rtl/ustring.hxx:365:13
> #5 0x7f36c7b843e8 in testTdf113027::TestBody() 
/sc/qa/unit/ucalc.cxx:462:31

()

Change-Id: Ie8d053cdb56bdf00bf21663b05521eca632ddfbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150219
Reviewed-by: Andreas Heinisch 
Tested-by: Jenkins
(cherry picked from commit dc80c92a1e63fd88560fd77261b96f6c5be97273)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150199
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/reffind.cxx b/sc/source/core/tool/reffind.cxx
index c2851c7ff247..63c53a4f5e57 100644
--- a/sc/source/core/tool/reffind.cxx
+++ b/sc/source/core/tool/reffind.cxx
@@ -91,7 +91,7 @@ sal_Int32 FindEndPosR1C1(const sal_Unicode* p, sal_Int32 
nStartPos, sal_Int32 nE
 if (*p == '\'')
 {
 // Skip until the closing quote.
-for (++p; nNewEnd <= nEndPos; ++p, ++nNewEnd)
+for (++p, ++nNewEnd; nNewEnd <= nEndPos; ++p, ++nNewEnd)
 if (*p == '\'')
 break;
 if (nNewEnd > nEndPos)
@@ -100,7 +100,7 @@ sal_Int32 FindEndPosR1C1(const sal_Unicode* p, sal_Int32 
nStartPos, sal_Int32 nE
 else if (*p == '[')
 {
 // Skip until the closing bracket.
-for (++p; nNewEnd <= nEndPos; ++p, ++nNewEnd)
+for (++p, ++nNewEnd; nNewEnd <= nEndPos; ++p, ++nNewEnd)
 if (*p == ']')
 break;
 if (nNewEnd > nEndPos)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-07 Thread Andreas Heinisch (via logerrit)
 sc/source/core/data/table6.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f2fb7d930b10626d9987b0ed52cc8e6a281c0f0d
Author: Andreas Heinisch 
AuthorDate: Mon Apr 3 12:58:27 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Apr 7 21:49:24 2023 +0200

tdf#89920 - Handle embedded newline in Calc's search cell

Update short-circuited boolean expression so the least expensive 
subexpressions will be executed first

Change-Id: I8c924e00e8de809f3e6df2828f8537185e71c18c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149891
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 
(cherry picked from commit 8fc316fb65e0d4b78ec881aa79f4184602b96f54)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150140
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 1ea4a5ace99d..a6b03f6b3d8d 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -257,7 +257,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 pFCell->SetMatColsRows( nMatCols, nMatRows );
 aCol[nCol].SetFormulaCell(nRow, pFCell);
 }
-else if (aString.indexOf('\n') != -1 && eCellType != CELLTYPE_FORMULA)
+else if (eCellType != CELLTYPE_FORMULA && aString.indexOf('\n') != -1)
 {
 ScFieldEditEngine& rEngine = rDocument.GetEditEngine();
 rEngine.SetTextCurrentDefaults(aString);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-07 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/addincol.cxx |   54 ---
 1 file changed, 45 insertions(+), 9 deletions(-)

New commits:
commit c3ab1cb764a368a8b2642e73c744dee9282cfd4b
Author: Eike Rathke 
AuthorDate: Mon Apr 3 19:28:59 2023 +0200
Commit: Xisco Fauli 
CommitDate: Fri Apr 7 18:46:44 2023 +0200

Resolves: tdf#154582 Obtain English DisplayName before CompatibilityName

... for Add-Ins from configuration.

Change-Id: If13d692ca7550e69d2f6e3ff72747d17aee3e7f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149995
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit dcb50fe7444dd746ba4d3f8476026bb997a595b5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149976
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 99f8061df3d2..9ddc97f0cb5b 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -360,7 +360,8 @@ void ScUnoAddInCollection::ReadConfiguration()
 
 ScAddInCfg& rAddInConfig = SC_MOD()->GetAddInCfg();
 
-// additional, temporary config item for the compatibility names
+// Additional, temporary config item for the display names and
+// compatibility names.
 ScLinkConfigItem aAllLocalesConfig( CFGPATH_ADDINS, 
ConfigItemMode::AllLocales );
 // CommitLink is not used (only reading values)
 
@@ -441,6 +442,35 @@ void ScUnoAddInCollection::ReadConfiguration()
 nCategory = lcl_GetCategory( aCategoryName );
 }
 
+// get English display name
+
+OUString aDisplayNamePath(aFuncPropPath + CFGSTR_DISPLAYNAME);
+uno::Sequence aDisplayNamePropNames( 
, 1 );
+
+uno::Sequence aDisplayNameProperties = 
aAllLocalesConfig.GetProperties( aDisplayNamePropNames );
+if ( aDisplayNameProperties.getLength() == 1 )
+{
+uno::Sequence aLocalEntries;
+if ( aDisplayNameProperties[0] >>= aLocalEntries )
+{
+for ( const beans::PropertyValue& rConfig : 
std::as_const(aLocalEntries) )
+{
+// PropertyValue name is the locale ("convert" from
+// string to canonicalize).
+OUString aLocale( LanguageTag( rConfig.Name, 
true).getBcp47( false));
+// PropertyValue value is the localized value 
(string in this case).
+OUString aName;
+rConfig.Value >>= aName;
+// Accept 'en' and 'en-...' but prefer 'en-US'.
+if (aLocale == "en-US" && !aName.isEmpty())
+aEnglishName = aName;
+else if (aEnglishName.isEmpty() && (aLocale == 
"en" || aLocale.startsWith("en-")))
+aEnglishName = aName;
+}
+}
+}
+bool bNeedEnglish = aEnglishName.isEmpty();
+
 // get compatibility names
 
 ::std::vector aCompNames;
@@ -457,17 +487,23 @@ void ScUnoAddInCollection::ReadConfiguration()
 for ( const beans::PropertyValue& rConfig : 
std::as_const(aLocalEntries) )
 {
 // PropertyValue name is the locale ("convert" from
-// string to canonicalize)
+// string to canonicalize).
 OUString aLocale( LanguageTag( rConfig.Name, 
true).getBcp47( false));
-// PropertyValue value is the localized value 
(string in this case)
+// PropertyValue value is the localized value 
(string in this case).
 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;
+if (!aName.isEmpty())
+{
+aCompNames.emplace_back( aLocale, aName);
+if (bNeedEnglish)
+{
+// Accept 'en' and 'en-...' but prefer 
'en-US'.
+if (aLocale == "en-US")
+aEnglishName = aName;
+else if 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-04-06 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/column2.cxx |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

New commits:
commit f4e670e2543411ee15f8e3a2fff9b740168e1677
Author: Mike Kaganski 
AuthorDate: Fri Mar 17 09:30:44 2023 +
Commit: Caolán McNamara 
CommitDate: Thu Apr 6 16:50:54 2023 +0200

tdf#148008: do not proceed after the marked range

Implementation error in commit c008dc483f8c6840803983e7e351cec6fdd32070
("Switch to using multi_type_vector for cell storage.", 2013-06-24).

Change-Id: I1e946b3b816db3d24f79a10fe8aa0dfc673b2e4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149026
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 32b2d00853d049bacb60cfb40e732602da048c89)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149031
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4f5c717cec4e..d20dd4bdb207 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -808,22 +808,21 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
 
 // Go though all non-empty cells within selection.
 sc::CellStoreType::const_iterator itPos = maCells.begin();
-for (const auto& rMarkedSpan : aMarkedSpans)
+for (const auto& [ nRow1, nRow2 ] : aMarkedSpans)
 {
-SCROW nRow1 = rMarkedSpan.mnRow1, nRow2 = rMarkedSpan.mnRow2;
 SCROW nRow = nRow1;
 while (nRow <= nRow2)
 {
-std::pair aPos = 
maCells.position(itPos, nRow);
-itPos = aPos.first;
+size_t nOffset;
+std::tie(itPos, nOffset) = maCells.position(itPos, nRow);
 if (itPos->type == sc::element_type_empty)
 {
 // Skip empty cells.
-nRow += itPos->size - aPos.second;
+nRow += itPos->size - nOffset;
 continue;
 }
 
-for (size_t nOffset = aPos.second; nOffset < itPos->size; 
++nOffset, ++nRow)
+for (; nOffset < itPos->size && nRow <= nRow2; ++nOffset, 
++nRow)
 {
 SvtScriptType nScript = rDocument.GetScriptType(nCol, 
nRow, nTab);
 if (nScript == SvtScriptType::NONE)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-21 Thread Patrick Luby (via logerrit)
 sc/source/ui/view/tabview.cxx |   28 
 1 file changed, 20 insertions(+), 8 deletions(-)

New commits:
commit 12fdd2792c392a5b355110836faa40db5866e57e
Author: Patrick Luby 
AuthorDate: Mon Mar 20 16:48:30 2023 -0400
Commit: Caolán McNamara 
CommitDate: Tue Mar 21 20:21:47 2023 +

tdf#152406 Disable anti-jitter code for scroll wheel events

After moving thousands of columns to the right via horizontal
scroll wheel or trackpad swipe events, most vertical scroll
wheel or trackpad swipe events will trigger the anti-jitter code
because nScrollPos and nPrevDragPos will be equal and nDelta
will be overriden and set to zero. So, only use the anti-jitter
code for mouse drag events.

Change-Id: I9a22b31e1e012a97a058ab36e040629a71f5d24f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149183
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit d82a734c07b85cbd7861699b7fa6d3ebbb3122f2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149238

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 17a414a5f5e4..aad41a9c1236 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1182,16 +1182,28 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
 
 tools::Long nScrollPos = GetScrollBarPos( *pScroll ) + 
nScrollMin;
 nDelta = nScrollPos - nViewPos;
-if ( nScrollPos > nPrevDragPos )
-{
-if (nDelta<0) nDelta=0;
-}
-else if ( nScrollPos < nPrevDragPos )
+
+// tdf#152406 Disable anti-jitter code for scroll wheel events
+// After moving thousands of columns to the right via
+// horizontal scroll wheel or trackpad swipe events, most
+// vertical scroll wheel or trackpad swipe events will trigger
+// the anti-jitter code because nScrollPos and nPrevDragPos
+// will be equal and nDelta will be overriden and set to zero.
+// So, only use the anti-jitter code for mouse drag events.
+if ( eType == ScrollType::Drag )
 {
-if (nDelta>0) nDelta=0;
+if ( nScrollPos > nPrevDragPos )
+{
+if (nDelta<0) nDelta=0;
+}
+else if ( nScrollPos < nPrevDragPos )
+{
+if (nDelta>0) nDelta=0;
+}
+else
+nDelta = 0;
 }
-else
-nDelta = 0;
+
 nPrevDragPos = nScrollPos;
 }
 break;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-21 Thread Caolán McNamara (via logerrit)
 sc/source/filter/excel/xiescher.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit fa1760d0c7ac8b9fb2e88f7d6d7f9de14479cbf6
Author: Caolán McNamara 
AuthorDate: Tue Mar 21 13:29:23 2023 +
Commit: Xisco Fauli 
CommitDate: Tue Mar 21 15:55:23 2023 +

crashreporting: CreateEmbeddedObject might fail

Change-Id: I0e1ccbea92343d18e5ff3a9af1f54ed5e0dd796b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149113
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index 7940758bffc5..2838347b3f14 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1763,6 +1763,9 @@ rtl::Reference XclImpChartObj::DoCreateSdrObj( 
XclImpDffConverter& rD
 Reference< XEmbeddedObject > xEmbObj = 
pDocShell->GetEmbeddedObjectContainer().
 CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID 
).GetByteSequence(), aEmbObjName,  );
 
+if (!xEmbObj)
+return xSdrObj;
+
 /*  Set the size to the embedded object, this prevents that font sizes
 of text objects are changed in the chart when the object is
 inserted into the draw page. */


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-13 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr1.cxx |   63 +++
 1 file changed, 51 insertions(+), 12 deletions(-)

New commits:
commit 9820f754f1a8a26568d4d848072fe8bb5f6c04b1
Author: Eike Rathke 
AuthorDate: Sun Mar 12 15:20:45 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Mar 13 09:17:12 2023 +

Resolves: tdf#154125 Fix INDEX() one-dimensional vector access

For i62850 a (not documented by Excel in

https://support.microsoft.com/en-us/office/index-function-a5dcf0dd-996d-40a4-a822-b56b061328bd?ui=en-us=en-us=us)
one-dimensional vector's element access was implemented with
non-sufficient conditions that prevented returning an entire
vector. Later ODFF defined proper conditions for that, see

https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#INDEX

Also, that vector element case assumed vector replication to the
other dimension as usual, which is not the case here, access to
the other dimension's index >1 must return error.

Change-Id: I604c2355f0aca2988cb13f0d4f54ccd2d74c3b0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148736
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit df706f47a2b62248d222911db12c674e6507e5c6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148755
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 5673bb7ecda2..ac0fb22b6231 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8674,10 +8674,17 @@ void ScInterpreter::ScIndex()
 nArea = GetUInt32();
 else
 nArea = 1;
+bool bColMissing;
 if (nParamCount >= 3)
+{
+bColMissing = IsMissing();
 nCol = static_cast(GetInt16());
+}
 else
+{
+bColMissing = false;
 nCol = 0;
+}
 if (nParamCount >= 2)
 nRow = static_cast(GetInt32());
 else
@@ -8710,25 +8717,57 @@ void ScInterpreter::ScIndex()
 {
 SCSIZE nC, nR;
 pMat->GetDimensions(nC, nR);
+
 // Access one element of a vector independent of col/row
-// orientation?
-bool bVector = ((nCol == 0 || nRow == 0) && (nC == 1 || nR 
== 1));
-SCSIZE nElement = ::std::max( static_cast(nCol),
-static_cast(nRow));
+// orientation. Excel documentation does not mention, but
+// i62850 had a .xls example of a row vector accessed by
+// row number returning one element. This
+// INDEX(row_vector;element) behaves the same as
+// INDEX(row_vector;0;element) and thus contradicts Excel
+// documentation where the second parameter is always
+// row_num.
+//
+// ODFF v1.3 in 6.14.6 INDEX states "If DataSource is a
+// one-dimensional row vector, Row is optional, which
+// effectively makes Row act as the column offset into the
+// vector". Guess the first Row is a typo and should read
+// Column instead.
+
+const bool bRowVectorSpecial = (nParamCount == 2 || 
bColMissing);
+const bool bRowVectorElement = (nR == 1 && (nCol != 0 || 
(bRowVectorSpecial && nRow != 0)));
+const bool bVectorElement = (bRowVectorElement || (nC == 1 
&& nRow != 0));
+
 if (nC == 0 || nR == 0 ||
-(!bVector && (o3tl::make_unsigned(nCol) > nC ||
-  o3tl::make_unsigned(nRow) > nR)) ||
-(bVector && nElement > nC * nR))
+(!bVectorElement && (o3tl::make_unsigned(nCol) > 
nC ||
+ o3tl::make_unsigned(nRow) > 
nR)))
 PushIllegalArgument();
 else if (nCol == 0 && nRow == 0)
 sp = nOldSp;
-else if (bVector)
+else if (bVectorElement)
 {
---nElement;
-if (pMat->IsStringOrEmpty( nElement))
-PushString( pMat->GetString(nElement).getString());
+// Vectors here don't replicate to the other dimension.
+SCSIZE nElement, nOtherDimension;
+if (bRowVectorElement && !bRowVectorSpecial)
+{
+nElement = o3tl::make_unsigned(nCol);
+nOtherDimension = o3tl::make_unsigned(nRow);
+}
 else
-  

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-09 Thread Maxim Monastirsky (via logerrit)
 sc/source/ui/drawfunc/futext3.cxx |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 25dd1b089fedec1a7ba45f3a3be7d10217165106
Author: Maxim Monastirsky 
AuthorDate: Thu Mar 9 02:37:19 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Mar 9 10:01:57 2023 +

tdf#154050 Unset external pointer before destroying

Regression of 48ca2336251d62ac2e90300cd9945fb84b1cddd8
("tdf#125040 Avoid flickering on context change").
Before that commit the state of toolbar commands was
updating async, which is how it managed to not crash.

Change-Id: I07e2ce25faf848c7db33dd029b54a98bafcf8fa9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148518
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 
(cherry picked from commit 37b2bb1f6c18b915286264682bf0b3c25f0d552a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148501
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/drawfunc/futext3.cxx 
b/sc/source/ui/drawfunc/futext3.cxx
index 1c13beea9388..a0db57860945 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -92,6 +92,11 @@ void FuText::StopEditMode()
 if( pNote )
 rDoc.LockStreamValid(true); // only the affected sheet is 
invalidated below
 
+/*  Unset the outliner undo manager before the call to SdrEndTextEdit.
+SdrObjEditView::SdrEndTextEdit destroys it, but then 
ScDrawView::SdrEndTextEdit
+initiates some UI update which might try to access the now invalid 
pointer. */
+rViewShell.SetDrawTextUndo( nullptr );
+
 /*  SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing
 object, if it does not contain text and has invisible border and fill.
 This must not happen for note caption objects. They will be removed
@@ -102,9 +107,6 @@ void FuText::StopEditMode()
 case. */
 /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != nullptr );
 
-// or ScEndTextEdit (with drawview.hxx)
-rViewShell.SetDrawTextUndo( nullptr );
-
 vcl::Cursor* pCur = pWindow->GetCursor();
 if( pCur && pCur->IsVisible() )
 pCur->Hide();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-07 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit d5a97bbafe02b7d51bb5a6f609acc25f03c8469d
Author: Caolán McNamara 
AuthorDate: Tue Mar 7 16:43:42 2023 +
Commit: Adolfo Jayme Barrientos 
CommitDate: Tue Mar 7 20:43:29 2023 +

tdf#154042 Use an initial height of one row for toolbar layout

so the Toolbar positions this in the same place regardless of how many
rows it eventually shows

Change-Id: I7ec31e50557a099962fb051a1948781ef9abdfb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148402
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index e19de72e928e..7f33e397fc95 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -879,6 +879,11 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, 
ScTabViewShell* pViewSh)
 const SfxViewShell* pViewShell = SfxViewShell::Current();
 if (!comphelper::LibreOfficeKit::isActive() || !(pViewShell && 
pViewShell->isLOKMobilePhone()))
 mxButtonDown->show();
+
+// tdf#154042 Use an initial height of one row so the Toolbar positions
+// this in the same place regardless of how many rows it eventually shows
+Size aSize(GetSizePixel().Width(), nHeight);
+SetSizePixel(aSize);
 }
 
 void ScInputBarGroup::SetBackgrounds()


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source sfx2/source

2023-03-07 Thread Xisco Fauli (via logerrit)
 sc/source/ui/view/tabvwshb.cxx   |6 ++
 sfx2/source/control/ctrlitem.cxx |   16 +---
 sfx2/source/control/dispatch.cxx |   21 +++--
 sfx2/source/control/unoctitm.cxx |4 +---
 sfx2/source/view/viewfrm.cxx |3 +++
 5 files changed, 34 insertions(+), 16 deletions(-)

New commits:
commit bd323bb9554265ec093fed3274cb232fbf0cd2ec
Author: Xisco Fauli 
AuthorDate: Fri Mar 3 16:29:17 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue Mar 7 16:48:44 2023 +

check GetShell

it might return nullptr

Change-Id: I65b43d69f4757b6c331582ca2e256cdea01377af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148194
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 9eb083ab732512c3ab64007c3be1c54be97172f6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148231

diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index d718a2e2cd00..6d7d89421d09 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -712,6 +712,9 @@ bool ScTabViewShell::IsSignatureLineSigned()
 void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
 {
 SfxShell* pSh = GetViewData().GetDispatcher().GetShell(0);
+if (!pSh)
+return;
+
 ScUndoManager* pUndoManager = 
static_cast(pSh->GetUndoManager());
 
 const SfxItemSet* pReqArgs = rReq.GetArgs();
@@ -812,6 +815,9 @@ void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
 void ScTabViewShell::GetUndoState(SfxItemSet )
 {
 SfxShell* pSh = GetViewData().GetDispatcher().GetShell(0);
+if (!pSh)
+return;
+
 SfxUndoManager* pUndoManager = pSh->GetUndoManager();
 ScUndoManager* pScUndoManager = dynamic_cast(pUndoManager);
 
diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx
index 28edfec666de..df7ba128659d 100644
--- a/sfx2/source/control/ctrlitem.cxx
+++ b/sfx2/source/control/ctrlitem.cxx
@@ -325,15 +325,17 @@ MapUnit SfxControllerItem::GetCoreMetric() const
 const SfxSlotServer *pServer = pCache->GetSlotServer( *pDispat );
 if ( pServer )
 {
-SfxShell *pSh = pDispat->GetShell( pServer->GetShellLevel() );
-SfxItemPool  = pSh->GetPool();
-sal_uInt16 nWhich = rPool.GetWhich( nId );
+if (SfxShell *pSh = pDispat->GetShell( pServer->GetShellLevel() ))
+{
+SfxItemPool  = pSh->GetPool();
+sal_uInt16 nWhich = rPool.GetWhich( nId );
 
-// invalidate slot and its message|slot server as 'global' 
information
-// about the validated message|slot server is not made available
-pCache->Invalidate( true );
+// invalidate slot and its message|slot server as 'global' 
information
+// about the validated message|slot server is not made 
available
+pCache->Invalidate( true );
 
-return rPool.GetMetric( nWhich );
+return rPool.GetMetric( nWhich );
+}
 }
 }
 
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 17edf97cc16d..9d85075de433 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -774,11 +774,13 @@ const SfxSlot* SfxDispatcher::GetSlot( const OUString& 
rCommand )
 
 for ( sal_uInt16 i = 0; i < nTotCount; ++i )
 {
-SfxShell *pObjShell = GetShell(i);
-SfxInterface *pIFace = pObjShell->GetInterface();
-const SfxSlot *pSlot = pIFace->GetSlot( rCommand );
-if ( pSlot )
-return pSlot;
+if (SfxShell *pObjShell = GetShell(i))
+{
+SfxInterface *pIFace = pObjShell->GetInterface();
+const SfxSlot *pSlot = pIFace->GetSlot( rCommand );
+if ( pSlot )
+return pSlot;
+}
 }
 
 return nullptr;
@@ -1152,6 +1154,9 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool 
bIsMDIApp, bool bIsIPOwne
 for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell )
 {
 SfxShell *pShell = GetShell( nShell-1 );
+if (!pShell)
+continue;
+
 SfxInterface *pIFace = pShell->GetInterface();
 
 // don't consider shells if "Hidden" or "Quiet"
@@ -1567,6 +1572,9 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, 
SfxSlotServer& rServer)
 for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
 {
 SfxShell *pObjShell = GetShell(i);
+if (!pObjShell)
+continue;
+
 SfxInterface *pIFace = pObjShell->GetInterface();
 const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
 
@@ -1646,7 +1654,8 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, 
SfxItemSet& rState,
 
 // Determine the object and call the Message of this object
 SfxShell *pSh = GetShell(rSvr.GetShellLevel());
-DBG_ASSERT(pSh, "ObjectShell not 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-07 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |   41 +++--
 sc/source/ui/inc/inputwin.hxx |9 +
 2 files changed, 28 insertions(+), 22 deletions(-)

New commits:
commit 8fd61209c9aede44b30f74d8d630236f79504a5e
Author: Caolán McNamara 
AuthorDate: Wed Mar 1 11:06:28 2023 +
Commit: Eike Rathke 
CommitDate: Tue Mar 7 11:49:42 2023 +

tdf#153784 account for initial vertical offset when toggled into multiline

Initially there is 1 line and the edit is vertically centered in the
toolbar

Later, if expanded then the vertical position of the edit will remain at
that initial position, so when calculating the overall size of the
expanded toolbar we have to include that initial offset in order to not
make the edit overlap the RESIZE_HOTSPOT_HEIGHT area so that dragging to
resize is still possible.

Change-Id: Ic99e1cf4f3b1ca53c5d6feaa50d8bfac030f8124
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148069
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148074
Reviewed-by: Eike Rathke 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 6f567e440515..e19de72e928e 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -82,6 +82,7 @@ const tools::Long LEFT_OFFSET = 5;  // Left 
offset of input line
 const tools::Long INPUTWIN_MULTILINES = 6;  // Initial number of lines 
within multiline dropdown
 const tools::Long TOOLBOX_WINDOW_HEIGHT = 22;   // Height of toolbox window in 
pixels - TODO: The same on all systems?
 const tools::Long POSITION_COMBOBOX_WIDTH = 18; // Width of position combobox 
in characters
+const int RESIZE_HOTSPOT_HEIGHT = 4;
 
 using com::sun::star::uno::Reference;
 using com::sun::star::uno::UNO_QUERY;
@@ -165,6 +166,7 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, const 
SfxBindings* pBind ) :
 pInputHdl   ( nullptr ),
 mpViewShell ( nullptr ),
 mnMaxY  (0),
+mnStandardItemHeight(0),
 bIsOkCancelMode ( false ),
 bInResize   ( false )
 {
@@ -238,6 +240,8 @@ ScInputWindow::ScInputWindow( vcl::Window* pParent, const 
SfxBindings* pBind ) :
 
 HideItem( SID_INPUT_CANCEL );
 HideItem( SID_INPUT_OK );
+
+mnStandardItemHeight = GetItemRect(SID_INPUT_SUM).GetHeight();
 }
 
 SetHelpId( HID_SC_INPUTWIN ); // For the whole input row
@@ -477,29 +481,31 @@ void ScInputWindow::Resize()
 Size aStartSize = GetSizePixel();
 Size aSize = aStartSize;
 
+auto nLines = mxTextWindow->GetNumLines();
 //(-10) to allow margin between sidebar and formulabar
 tools::Long margin = (comphelper::LibreOfficeKit::isActive()) ? 10 : 0;
 Size aTextWindowSize(aSize.Width() - mxTextWindow->GetPosPixel().X() - 
LEFT_OFFSET - margin,
- mxTextWindow->GetPixelHeightForLines());
+ mxTextWindow->GetPixelHeightForLines(nLines));
 mxTextWindow->SetSizePixel(aTextWindowSize);
 
-aSize.setHeight(CalcWindowSizePixel().Height() + 1);
-ScInputBarGroup* pGroupBar = mxTextWindow.get();
-if (pGroupBar)
-{
-// To ensure smooth display and prevent the items in the toolbar being
-// repositioned (vertically) we lock the vertical positioning of the 
toolbox
-// items when we are displaying > 1 line.
-// So, we need to adjust the height of the toolbox accordingly. If we 
don't
-// then the largest item (e.g. the GroupBar window) will actually be
-// positioned such that the toolbar will cut off the bottom of that 
item
-if (pGroupBar->GetNumLines() > 1)
-{
-Size aGroupBarSize = pGroupBar->GetSizePixel();
-aSize.setHeight(aGroupBarSize.Height());
-}
+int nTopOffset = 0;
+if (nLines > 1)
+{
+// Initially there is 1 line and the edit is vertically centered in 
the toolbar
+// Later, if expanded then the vertical position of the edit will 
remain at
+// that initial position, so when calculating the overall size of the 
expanded
+// toolbar we have to include that initial offset in order to not make
+// the edit overlap the RESIZE_HOTSPOT_HEIGHT area so that dragging to 
resize
+// is still possible.
+int nNormalHeight = mxTextWindow->GetPixelHeightForLines(1);
+int nInitialTopMargin = (mnStandardItemHeight - nNormalHeight) / 2;
+if (nInitialTopMargin > 0)
+nTopOffset = nInitialTopMargin;
 }
 
+// add empty space of RESIZE_HOTSPOT_HEIGHT so resize is possible when 
hovering there
+aSize.setHeight(CalcWindowSizePixel().Height() + RESIZE_HOTSPOT_HEIGHT + 
nTopOffset);
+
 if (aStartSize != aSize)
 SetSizePixel(aSize);
 
@@ -724,7 +730,7 @@ void ScInputWindow::DataChanged( const DataChangedEvent& 
rDCEvt )
 
 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-07 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 5e9df4ffa753ac038bc6b94c48f393f81545a322
Author: Caolán McNamara 
AuthorDate: Fri Jan 20 12:47:42 2023 +
Commit: Eike Rathke 
CommitDate: Tue Mar 7 11:45:56 2023 +

rhbz#2162658 backtrace showing endlessly recursive ScInputWindow::Resize

Change-Id: I2d10fd1ebfb1c25cf213ebb68e7d34e39fadde13
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145894
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 13b2bd1006182637b189bcfa77acfaf03ae028f0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145811
Reviewed-by: Eike Rathke 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 4e8e544d2103..6f567e440515 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -474,7 +474,8 @@ void ScInputWindow::Resize()
 {
 ToolBox::Resize();
 
-Size aSize = GetSizePixel();
+Size aStartSize = GetSizePixel();
+Size aSize = aStartSize;
 
 //(-10) to allow margin between sidebar and formulabar
 tools::Long margin = (comphelper::LibreOfficeKit::isActive()) ? 10 : 0;
@@ -498,7 +499,9 @@ void ScInputWindow::Resize()
 aSize.setHeight(aGroupBarSize.Height());
 }
 }
-SetSizePixel(aSize);
+
+if (aStartSize != aSize)
+SetSizePixel(aSize);
 
 Invalidate();
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-03-04 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr3.cxx |   44 ---
 1 file changed, 32 insertions(+), 12 deletions(-)

New commits:
commit c8a033f0bbcc61feef3b42ea6a8833bcbc6ac552
Author: Eike Rathke 
AuthorDate: Fri Mar 3 13:39:03 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sat Mar 4 20:53:33 2023 +

Resolves: tdf#153924 handle non-numeric and error values in rank array

... of LARGE()/SMALL() instead of yielding error value for all result
elements.

Fallout from

commit e4c2d0bb57ab8ea8f5c400d103d01376b8140f22
CommitDate: Fri Nov 30 22:14:17 2018 +0100

i#32345 Support a matrix of rank argument for LARGE()/SMALL()

that in ScInterpreter::GetTopNumberArray() required the entire
rank array would have to be numeric, which with an empty cell or
string it isn't.

Change-Id: Ieaa1a68bb8f98614119550b1442665b6fbb4817a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148178
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 019e751c71dcb2d34c6fd8bb9dda267c6ba2b48e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148217
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index d95510acd51c..c20d7e0327e1 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3638,8 +3638,8 @@ void ScInterpreter::CalculateSmallLarge(bool bSmall)
 return;
 
 SCSIZE nCol = 0, nRow = 0;
-auto aArray = GetTopNumberArray(nCol, nRow);
-const auto nRankArraySize = aArray.size();
+const auto aArray = GetTopNumberArray(nCol, nRow);
+const size_t nRankArraySize = aArray.size();
 if (nRankArraySize == 0 || nGlobalError != FormulaError::NONE)
 {
 PushNoValue();
@@ -3667,7 +3667,12 @@ void ScInterpreter::CalculateSmallLarge(bool bSmall)
 {
 const SCSIZE k = aRankArray[0];
 if (k < 1 || nSize < k)
-PushNoValue();
+{
+if (!std::isfinite(aArray[0]))
+PushDouble(aArray[0]);  // propagates error
+else
+PushNoValue();
+}
 else
 {
 vector::iterator iPos = aSortArray.begin() + (bSmall ? k-1 
: nSize-k);
@@ -3699,15 +3704,19 @@ void ScInterpreter::CalculateSmallLarge(bool bSmall)
 else
 std::sort(aSortArray.begin(), aSortArray.end());
 
-aArray.clear();
-for (SCSIZE n : aRankArray)
+std::vector aResultArray;
+aResultArray.reserve(nRankArraySize);
+for (size_t i = 0; i < nRankArraySize; ++i)
 {
+const SCSIZE n = aRankArray[i];
 if (1 <= n && n <= nSize)
-aArray.push_back( aSortArray[bSmall ? n-1 : nSize-n]);
+aResultArray.push_back( aSortArray[bSmall ? n-1 : nSize-n]);
+else if (!std::isfinite( aArray[i]))
+aResultArray.push_back( aArray[i]);  // propagate error
 else
-aArray.push_back( CreateDoubleError( FormulaError::NoValue));
+aResultArray.push_back( CreateDoubleError( 
FormulaError::IllegalArgument));
 }
-ScMatrixRef pResult = GetNewMat(nCol, nRow, aArray);
+ScMatrixRef pResult = GetNewMat(nCol, nRow, aResultArray);
 PushMatrix(pResult);
 }
 }
@@ -3912,19 +3921,30 @@ std::vector ScInterpreter::GetTopNumberArray( 
SCSIZE& rCol, SCSIZE& rRow
 if (!pMat)
 break;
 
+const SCSIZE nCount = pMat->GetElementCount();
+aArray.reserve(nCount);
+// Do not propagate errors from matrix elements as global error.
+pMat->SetErrorInterpreter(nullptr);
 if (pMat->IsNumeric())
 {
-SCSIZE nCount = pMat->GetElementCount();
-aArray.reserve(nCount);
 for (SCSIZE i = 0; i < nCount; ++i)
 aArray.push_back(pMat->GetDouble(i));
-pMat->GetDimensions(rCol, rRow);
 }
 else
-SetError(FormulaError::IllegalParameter);
+{
+for (SCSIZE i = 0; i < nCount; ++i)
+{
+if (pMat->IsValue(i))
+aArray.push_back( pMat->GetDouble(i));
+else
+aArray.push_back( CreateDoubleError( 
FormulaError::NoValue));
+}
+}
+pMat->GetDimensions(rCol, rRow);
 }
 break;
 default:
+PopError();
 SetError(FormulaError::IllegalParameter);
 break;
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-27 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr3.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 69f04e96ff22f7cd18453a784ed5b3f23b0d7b11
Author: Eike Rathke 
AuthorDate: Mon Feb 27 16:10:06 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Feb 27 20:30:43 2023 +

Always push a result, even if it's only an error

PERCENTILE() and QUARTILE() if an error was passed as argument (or
an error encountered during obtaining arguments) omitted to push
an error result, only setting the error.

Fallout from

commit f336f63da900d76c2bf6e5690f1c8a7bd15a0aa2
CommitDate: Thu Mar 3 16:28:59 2016 +

tdf#94635 Add FORECAST.ETS functions to Calc

Change-Id: I23e276fb0ce735cfd6383cc963446499dcf819f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147922
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 64914560e279c71ff1233f4bab851e2a292797e6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147899
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 12e49de73972..d95510acd51c 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3470,7 +3470,7 @@ void ScInterpreter::ScPercentile( bool bInclusive )
 GetNumberSequenceArray( 1, aArray, false );
 if ( aArray.empty() || nGlobalError != FormulaError::NONE )
 {
-SetError( FormulaError::NoValue );
+PushNoValue();
 return;
 }
 if ( bInclusive )
@@ -3493,7 +3493,7 @@ void ScInterpreter::ScQuartile( bool bInclusive )
 GetNumberSequenceArray( 1, aArray, false );
 if ( aArray.empty() || nGlobalError != FormulaError::NONE )
 {
-SetError( FormulaError::NoValue );
+PushNoValue();
 return;
 }
 if ( bInclusive )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-24 Thread Caolán McNamara (via logerrit)
 sc/source/filter/oox/condformatbuffer.cxx |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 09d6e6c81633eef6eaecf011dc766cdc68e52fd7
Author: Caolán McNamara 
AuthorDate: Thu Feb 23 21:12:41 2023 +
Commit: Michael Stahl 
CommitDate: Fri Feb 24 08:57:11 2023 +

crashtesting: null-deref seen on loading forum-mso-en4-399427.xlsx

and others. A problem since:

commit 8c9a6abf30e9ff1ebd5647f7c271e0d64643860a
Date:   Thu Feb 2 20:16:04 2023 +0100

tdf#138601 XLSX import: fix priority of conditional formatting rules

Change-Id: I663b193c5bd7c5c92d3c423e70b0f7a24e3e5d76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147552
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 1abb3bf91938..ac5c2738aa47 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1172,11 +1172,12 @@ void CondFormatBuffer::finalizeImport()
 minIndex = i;
 for (size_t j = i + 1; j < maCondFormats.size(); ++j)
 {
-if (maCondFormats[j]->maRules.begin()->first
-< maCondFormats[minIndex]->maRules.begin()->first)
-{
+const CondFormat::CondFormatRuleMap& rNextRules = 
maCondFormats[j]->maRules;
+const CondFormat::CondFormatRuleMap& rMinRules = 
maCondFormats[minIndex]->maRules;
+if (rNextRules.empty() || rMinRules.empty())
+continue;
+if (rNextRules.begin()->first < rMinRules.begin()->first)
 minIndex = j;
-}
 }
 if (i != minIndex)
 std::swap(maCondFormats[i], maCondFormats[minIndex]);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-23 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/interpr1.cxx |   34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

New commits:
commit 0f305c976c4a619f53154d13be134d3bbe6f3302
Author: Caolán McNamara 
AuthorDate: Sun Feb 19 17:33:20 2023 +
Commit: Eike Rathke 
CommitDate: Thu Feb 23 19:29:11 2023 +

crashtesting: crash on import of forum-mso-en4-702161.xlsx

vConditions is empty at this point for row 5

git show -w

Change-Id: I05d984d73d4dd5a0ece894f854263528c9c00be9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147303
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 35e3c499cb64ed647fc8cc0a42a2d83948abcbdf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147287
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 405d9fe00023..5673bb7ecda2 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6491,25 +6491,29 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 if (nRefArrayMainPos < vRefArrayConditions.size())
 vConditions = vRefArrayConditions[nRefArrayMainPos];
 
-std::vector::const_iterator itRes = 
vConditions.begin();
-for (SCCOL nCol = 0; nCol < nDimensionCols; ++nCol)
+SAL_WARN_IF(nDimensionCols && nDimensionRows && 
vConditions.empty(), "sc",  "ScInterpreter::IterateParametersIfs vConditions is 
empty");
+if (!vConditions.empty())
 {
-for (SCROW nRow = 0; nRow < nDimensionRows; ++nRow, 
++itRes)
+std::vector::const_iterator itRes = 
vConditions.begin();
+for (SCCOL nCol = 0; nCol < nDimensionCols; ++nCol)
 {
-if (*itRes == nQueryCount)
+for (SCROW nRow = 0; nRow < nDimensionRows; 
++nRow, ++itRes)
 {
-aAdr.SetCol( nCol + nMainCol1);
-aAdr.SetRow( nRow + nMainRow1);
-ScRefCellValue aCell(mrDoc, aAdr);
-if (aCell.hasNumeric())
+if (*itRes == nQueryCount)
 {
-fVal = GetCellValue(aAdr, aCell);
-++aRes.mfCount;
-aRes.mfSum += fVal;
-if ( aRes.mfMin > fVal )
-aRes.mfMin = fVal;
-if ( aRes.mfMax < fVal )
-aRes.mfMax = fVal;
+aAdr.SetCol( nCol + nMainCol1);
+aAdr.SetRow( nRow + nMainRow1);
+ScRefCellValue aCell(mrDoc, aAdr);
+if (aCell.hasNumeric())
+{
+fVal = GetCellValue(aAdr, aCell);
+++aRes.mfCount;
+aRes.mfSum += fVal;
+if ( aRes.mfMin > fVal )
+aRes.mfMin = fVal;
+if ( aRes.mfMax < fVal )
+aRes.mfMax = fVal;
+}
 }
 }
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-23 Thread Samuel Mehrbrodt (via logerrit)
 sc/source/ui/app/inputwin.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 505bb358c0cda60577ceb47daa0347b219b6c147
Author: Samuel Mehrbrodt 
AuthorDate: Mon Feb 20 23:58:55 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Feb 23 10:04:35 2023 +

tdf#151745 Fix input line redraw issue after resizing calc window

Change-Id: Ia8a7e1ab6b68f10f19733d8ce7f36d9ea02d4785
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147352
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit 228caa2bafe214a0b502db4ac288dd70169ac2b8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147447
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index f035eb0b7314..4e8e544d2103 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -934,7 +934,6 @@ void ScInputBarGroup::Resize()
 {
 mxTextWndGroup->SetScrollPolicy();
 InterimItemWindow::Resize();
-TriggerToolboxLayout();
 }
 
 void ScInputBarGroup::StopEditEngine(bool bAll)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-17 Thread Eike Rathke (via logerrit)
 sc/source/core/inc/interpre.hxx  |   12 
 sc/source/core/tool/interpr1.cxx |4 ++--
 2 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit cf43a5ca4c00648a29bc70ef4d3a8039466f3a8f
Author: Eike Rathke 
AuthorDate: Fri Feb 17 12:03:54 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Feb 17 19:39:35 2023 +

Stack check safety belt before fishing in muddy waters

Have it hit hard in debug builds.

Change-Id: I9ea54844a0661fd7a75616a2876983a74b2d5bad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147205
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 9d91fbba6f374fa1c10b38eae003da89bd4e6d4b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147244
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 85d2955003af..a6bd98320f71 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -221,6 +221,7 @@ private:
 inline bool MustHaveParamCount( short nAct, short nMust );
 inline bool MustHaveParamCount( short nAct, short nMust, short nMax );
 inline bool MustHaveParamCountMin( short nAct, short nMin );
+inline bool MustHaveParamCountMinWithStackCheck( short nAct, short nMin );
 void PushParameterExpected();
 void PushIllegalParameter();
 void PushIllegalArgument();
@@ -1074,6 +1075,17 @@ inline bool ScInterpreter::MustHaveParamCountMin( short 
nAct, short nMin )
 return false;
 }
 
+inline bool ScInterpreter::MustHaveParamCountMinWithStackCheck( short nAct, 
short nMin )
+{
+assert(sp >= nAct);
+if (sp < nAct)
+{
+PushParameterExpected();
+return false;
+}
+return MustHaveParamCountMin( nAct, nMin);
+}
+
 inline bool ScInterpreter::CheckStringPositionArgument( double & fVal )
 {
 if (!std::isfinite( fVal))
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index d82acb37494c..405d9fe00023 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7643,7 +7643,7 @@ void ScInterpreter::ScVLookup()
 void ScInterpreter::ScSubTotal()
 {
 sal_uInt8 nParamCount = GetByte();
-if ( !MustHaveParamCountMin( nParamCount, 2 ) )
+if ( !MustHaveParamCountMinWithStackCheck( nParamCount, 2 ) )
 return;
 
 // We must fish the 1st parameter deep from the stack! And push it on top.
@@ -7690,7 +7690,7 @@ void ScInterpreter::ScSubTotal()
 void ScInterpreter::ScAggregate()
 {
 sal_uInt8 nParamCount = GetByte();
-if ( !MustHaveParamCountMin( nParamCount, 3 ) )
+if ( !MustHaveParamCountMinWithStackCheck( nParamCount, 3 ) )
 return;
 
 const FormulaError nErr = nGlobalError;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-17 Thread Xisco Fauli (via logerrit)
 sc/source/ui/view/gridwin4.cxx |   15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit 8afc7788b83152528ff2a72b16ae829bde9ace54
Author: Xisco Fauli 
AuthorDate: Fri Feb 17 12:44:03 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Feb 17 16:31:31 2023 +

sc: fix divide by zero in ScGridWindow::DrawPagePreview

Seen in 
https://crashreport.libreoffice.org/stats/signature/ScGridWindow::DrawPagePreview(short,long,short,long,OutputDevice%20&)

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

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 07265d4cf23e..8af86b8601a0 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -2041,13 +2041,16 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW 
nY1, SCCOL nX2, SCROW nY2,
 //  find right font size for DrawText
 aFont.SetFontSize( Size( 0,100 ) );
 rRenderContext.SetFont( aFont );
-Size aSize100(rRenderContext.GetTextWidth( 
aThisPageStr ), rRenderContext.GetTextHeight() );
 
-//  40% of width or 60% of height
-tools::Long nSizeX = 40 * ( aPageEnd.X() - 
aPageStart.X() ) / aSize100.Width();
-tools::Long nSizeY = 60 * ( aPageEnd.Y() - 
aPageStart.Y() ) / aSize100.Height();
-aFont.SetFontSize( Size( 
0,std::min(nSizeX,nSizeY) ) );
-rRenderContext.SetFont( aFont );
+Size aSize100(rRenderContext.GetTextWidth( 
aThisPageStr ), rRenderContext.GetTextHeight() );
+if (aSize100.Width() && aSize100.Height())
+{
+//  40% of width or 60% of height
+tools::Long nSizeX = 40 * ( aPageEnd.X() - 
aPageStart.X() ) / aSize100.Width();
+tools::Long nSizeY = 60 * ( aPageEnd.Y() - 
aPageStart.Y() ) / aSize100.Height();
+aFont.SetFontSize( Size( 
0,std::min(nSizeX,nSizeY) ) );
+rRenderContext.SetFont( aFont );
+}
 
 //  centered output with DrawText
 Size aTextSize(rRenderContext.GetTextWidth( 
aThisPageStr ), rRenderContext.GetTextHeight() );


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-15 Thread Caolán McNamara (via logerrit)
 sc/source/ui/view/gridwin.cxx |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 80cb24c37bba6ebbcd711d03e57a39b4827f3904
Author: Caolán McNamara 
AuthorDate: Tue Feb 14 21:25:45 2023 +
Commit: Xisco Fauli 
CommitDate: Wed Feb 15 12:59:03 2023 +

Resolves: tdf#153622 crash in SvListView::SelectListEntry

probably since:

commit 4c8b1fa44d4f49510d3910981e649dcb08bceb36
Date:   Fri Oct 28 13:15:00 2022 -0400

tdf#151794 sc validate: honor NO_BLANK in Cell range dropdown

Change-Id: Id6752126c0c8df8d813bc862e5533d05bba1b622
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146992
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 547338589298..d1f8dead3a7c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1432,6 +1432,14 @@ void ScGridWindow::LaunchDataSelectMenu(const SCCOL 
nCol, const SCROW nRow)
 std::vector aStrings; // case sensitive
 // Fill List
 rDoc.GetDataEntries(nCol, nRow, nTab, aStrings, true /* bValidation */);
+
+// IsIgnoreBlank allows blank values. Don't add empty string unless "Allow 
Empty Cells"
+if (pData && !pData->IsIgnoreBlank())
+{
+auto lambda = [](const ScTypedStrData& rStr) { return 
rStr.GetString().isEmpty(); };
+aStrings.erase(std::remove_if(aStrings.begin(), aStrings.end(), 
lambda), aStrings.end());
+}
+
 if (aStrings.empty())
 bEmpty = true;
 
@@ -1447,10 +1455,8 @@ void ScGridWindow::LaunchDataSelectMenu(const SCCOL 
nCol, const SCROW nRow)
 
 for (const auto& rString : aStrings)
 {
-// IsIgnoreBlank allows blank values. Don't add empty string 
unless "Allow Empty Cells"
 const OUString& rFilterString = rString.GetString();
-if (!rFilterString.isEmpty() || !pData || pData->IsIgnoreBlank())
-rFilterBox.append_text(rFilterString);
+rFilterBox.append_text(rFilterString);
 }
 
 if (bWait)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-14 Thread Kohei Yoshida (via logerrit)
 sc/source/ui/xmlsource/xmlsourcedlg.cxx |   34 
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit bad4f41a69fe3fb08191b839f0c9389683685855
Author: Kohei Yoshida 
AuthorDate: Mon Feb 13 22:12:59 2023 -0500
Commit: Xisco Fauli 
CommitDate: Tue Feb 14 20:14:49 2023 +

tdf#153604: include the root element when traversing the tree

Change-Id: I35098e687eea832c075f68861e04be7b492ed25e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146966
Tested-by: Jenkins
Reviewed-by: Kohei Yoshida 
(cherry picked from commit 4d9a8f07b77917b0756dc2d8d8082c6e63e560a2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146982

diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx 
b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 902c8c0a0bec..663db63475d8 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -448,31 +448,33 @@ void getFieldLinks(
 ScOrcusImportXMLParam::RangeLink& rRangeLink, std::vector& 
rNamespaces,
 const weld::TreeView& rTree, const weld::TreeIter& rEntry)
 {
+OUString aPath = getXPath(rTree, rEntry, rNamespaces);
+const ScOrcusXMLTreeParam::EntryData* pUserData = 
ScOrcusXMLTreeParam::getUserData(rTree, rEntry);
+
+if (pUserData)
+{
+if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat)
+// nested repeat element automatically becomes a row-group node.
+rRangeLink.maRowGroups.push_back(
+OUStringToOString(aPath, RTL_TEXTENCODING_UTF8));
+
+if (pUserData->mbLeafNode && !aPath.isEmpty())
+// XPath should never be empty anyway, but it won't hurt to 
check...
+rRangeLink.maFieldPaths.push_back(OUStringToOString(aPath, 
RTL_TEXTENCODING_UTF8));
+}
+
 std::unique_ptr xChild(rTree.make_iterator());
+
 if (!rTree.iter_children(*xChild))
 // No more children.  We're done.
 return;
 
 do
 {
-OUString aPath = getXPath(rTree, *xChild, rNamespaces);
-const ScOrcusXMLTreeParam::EntryData* pUserData = 
ScOrcusXMLTreeParam::getUserData(rTree, *xChild);
-
-if (pUserData)
-{
-if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat)
-// nested repeat element automatically becomes a row-group 
node.
-rRangeLink.maRowGroups.push_back(
-OUStringToOString(aPath, RTL_TEXTENCODING_UTF8));
-
-if (pUserData->mbLeafNode && !aPath.isEmpty())
-// XPath should never be empty anyway, but it won't hurt to 
check...
-rRangeLink.maFieldPaths.push_back(OUStringToOString(aPath, 
RTL_TEXTENCODING_UTF8));
-}
-
 // Walk recursively.
 getFieldLinks(rRangeLink, rNamespaces, rTree, *xChild);
-} while (rTree.iter_next_sibling(*xChild));
+}
+while (rTree.iter_next_sibling(*xChild));
 }
 
 void removeDuplicates(std::vector& rArray)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-13 Thread Xisco Fauli (via logerrit)
 sc/source/filter/rtf/eeimpars.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 1e7ee035992a0b29f42eac56ad82e2a1b0fe8ccd
Author: Xisco Fauli 
AuthorDate: Fri Feb 10 10:50:24 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 12:44:38 2023 +

sc: avoid divide by zero in ScEEImport::GraphicSize

See 
https://crashreport.libreoffice.org/stats/signature/ScEEImport::GraphicSize(short,long,ScEEParseEntry%20*)

Change-Id: Ia5acccb1118aff2486d23eabd536053e67f346ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146915
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/rtf/eeimpars.cxx 
b/sc/source/filter/rtf/eeimpars.cxx
index b9678e2fdd5f..e9ab9175ab8f 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -528,7 +528,13 @@ bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, 
ScEEParseEntry* pE )
 }
 // Distribute line height difference between all affected lines
 SCROW nRowSpan = pE->nRowOverlap;
+
+assert(nRowSpan != 0);
+if ( nRowSpan == 0 )
+return bHasGraphics;
+
 nHeight /= nRowSpan;
+
 if ( nHeight == 0 )
 nHeight = 1; // For definite comparison
 for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-13 Thread Eike Rathke (via logerrit)
 sc/source/filter/oox/stylesbuffer.cxx |   46 ++
 1 file changed, 36 insertions(+), 10 deletions(-)

New commits:
commit 321c1a6db442a6d2afee25d1d1256ff36bdb004e
Author: Eike Rathke 
AuthorDate: Mon Feb 6 22:59:44 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 11:52:37 2023 +

Resolves: tdf#139934 always apply cellXfs xf explicits (tdf#123139 related)

Change-Id: Id1e12ee8677a25a645bfd53b4968a17c9a1eabe5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146599
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 909a25d30b09ebd3a023105a9c3cc4d20add094a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146533
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 1819257383e1..1dbe7e658269 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1972,38 +1972,64 @@ void Xf::importXf( const AttributeList& rAttribs, bool 
bCellXf )
 // as xfId attribute is always created during export to .xlsx
 // Not setting "0" value is causing wrong .xlsx import by LibreOffice,
 // for spreadsheets created by external applications (ex. SAP BI).
+bool bApplyDefault;
 if ( maModel.mbCellXf )
 {
-maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, 0 );
+const sal_Int32 xfId = rAttribs.getInteger( XML_xfId, -1 );
+// No xfId => no cellStyleXfs that could overwrite this on change, thus
+// has to be applied.
+bApplyDefault = (xfId < 0);
+maModel.mnStyleXfId = std::max(0, xfId);
 }
 else
 {
 maModel.mnStyleXfId = rAttribs.getInteger( XML_xfId, -1 );
+bApplyDefault = true;
 }
 maModel.mnFontId = rAttribs.getInteger( XML_fontId, -1 );
 maModel.mnNumFmtId = rAttribs.getInteger( XML_numFmtId, -1 );
 maModel.mnBorderId = rAttribs.getInteger( XML_borderId, -1 );
 maModel.mnFillId = rAttribs.getInteger( XML_fillId, -1 );
 
-
-maModel.mbAlignUsed = maModel.mbCellXf || 
rAttribs.getBool(XML_applyAlignment, true);
-maModel.mbProtUsed = maModel.mbCellXf || 
rAttribs.getBool(XML_applyProtection, true);
-/*  Default value of the apply*** attributes is dependent on context:
-true in cellStyleXfs element, false in cellXfs element... */
-maModel.mbFontUsed   = rAttribs.getBool( XML_applyFont, 
!maModel.mbCellXf );
-maModel.mbNumFmtUsed = rAttribs.getBool( XML_applyNumberFormat, 
!maModel.mbCellXf );
-maModel.mbBorderUsed = rAttribs.getBool( XML_applyBorder,   
!maModel.mbCellXf );
-maModel.mbAreaUsed   = rAttribs.getBool( XML_applyFill, 
!maModel.mbCellXf );
+// Default value of the apply*** attributes is dependent on context:
+// true in cellStyleXfs element, false in cellXfs element...
+// But it's not as easy as it sounds, for docs see
+// 
https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/59922f8b-0edc-4e93-a822-9f22254aec46
+// and apparently in reality cellStyleXfs xf and cellXfs xf are not merged
+// at all, see
+// 
https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/bcf98682-e8d3-44b8-b8f8-0bf696878ba1
+// "b. The standard states that both the cell style xf records and cell xf
+// records must be read to understand the full set of formatting applied to
+// a cell."
+// "In Office, only the cell xf record defines the formatting applied to a 
cell."
+
+// So for reading documents this is all crap and effectively xf records
+// apply their explicit properties by default unless denied.
+// bApplyDefault==false only for cellXf xf with xfId.
+
+// For cellXf xf, mbAlignUsed and mbProtUsed will be set when actually
+// importing the element.
+maModel.mbAlignUsed  = rAttribs.getBool( XML_applyAlignment,
bApplyDefault);
+maModel.mbProtUsed   = rAttribs.getBool( XML_applyProtection,   
bApplyDefault);
+
+maModel.mbFontUsed   = rAttribs.getBool( XML_applyFont, 
bApplyDefault || maModel.mnFontId > 0);
+maModel.mbNumFmtUsed = rAttribs.getBool( XML_applyNumberFormat, 
bApplyDefault || maModel.mnNumFmtId > 0);
+maModel.mbBorderUsed = rAttribs.getBool( XML_applyBorder,   
bApplyDefault || maModel.mnBorderId > 0);
+maModel.mbAreaUsed   = rAttribs.getBool( XML_applyFill, 
bApplyDefault || maModel.mnFillId > 0);
 }
 
 void Xf::importAlignment( const AttributeList& rAttribs )
 {
 maAlignment.importAlignment( rAttribs );
+if (maModel.mbCellXf)
+maModel.mbAlignUsed = true;
 }
 
 void Xf::importProtection( const AttributeList& rAttribs )
 {
 maProtection.importProtection( rAttribs );
+if (maModel.mbCellXf)
+maModel.mbProtUsed = true;
 }
 
 void Xf::importXf( SequenceInputStream& rStrm, bool bCellXf )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-12 Thread Mike Kaganski (via logerrit)
 sc/source/core/tool/interpr2.cxx |   64 ++-
 1 file changed, 31 insertions(+), 33 deletions(-)

New commits:
commit 18e16b05503eafb81797a8bd13157b1a6fc6e828
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 16:44:37 2023 +0300
Commit: Adolfo Jayme Barrientos 
CommitDate: Mon Feb 13 00:03:05 2023 +

Flatten ScInterpreter::ScStyle

Change-Id: I64c622d2c2ca7eda02e8739657fe345f9be8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146777
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 2844670d2a47c606cbebb99f73389f30154a3c5e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146764
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 707d9c66cb3d..c8015598891f 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2592,48 +2592,46 @@ void ScInterpreter::ScCurrent()
 void ScInterpreter::ScStyle()
 {
 sal_uInt8 nParamCount = GetByte();
-if (nParamCount >= 1 && nParamCount <= 3)
-{
-OUString aStyle2;   // Template 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
+if (!MustHaveParamCount(nParamCount, 1, 3))
+return;
 
-if (nTimeOut < 0)
-nTimeOut = 0;
+OUString aStyle2;   // Template 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
 
-// Execute request to apply template
-if ( !mrDoc.IsClipOrUndo() )
+if (nTimeOut < 0)
+nTimeOut = 0;
+
+// Execute request to apply template
+if ( !mrDoc.IsClipOrUndo() )
+{
+SfxObjectShell* pShell = mrDoc.GetDocumentShell();
+if (pShell)
 {
-SfxObjectShell* pShell = mrDoc.GetDocumentShell();
-if (pShell)
+// notify object shell directly!
+bool bNotify = true;
+if (aStyle2.isEmpty())
 {
-// notify object shell directly!
-bool bNotify = true;
-if (aStyle2.isEmpty())
-{
-const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), 
aPos.Row(), aPos.Tab());
+const ScStyleSheet* pStyle = mrDoc.GetStyle(aPos.Col(), 
aPos.Row(), aPos.Tab());
 
-if (pStyle && pStyle->GetName() == aStyle1)
-bNotify = false;
-}
+if (pStyle && pStyle->GetName() == aStyle1)
+bNotify = false;
+}
 
-if (bNotify)
-{
-ScRange aRange(aPos);
-ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 
);
-pShell->Broadcast( aHint );
-}
+if (bNotify)
+{
+ScRange aRange(aPos);
+ScAutoStyleHint aHint( aRange, aStyle1, nTimeOut, aStyle2 );
+pShell->Broadcast( aHint );
 }
 }
-
-PushDouble(0.0);
 }
-else
-PushIllegalParameter();
+
+PushDouble(0.0);
 }
 
 static ScDdeLink* lcl_GetDdeLink( const sfx2::LinkManager* pLinkMgr,


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-12 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/stlpool.cxx |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit b8efa9e460f358d42662e385ef5101cca053d8c7
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 13:25:53 2023 +0300
Commit: Adolfo Jayme Barrientos 
CommitDate: Mon Feb 13 00:02:23 2023 +

tdf#153514: try to find exact match, even when searching case-insensitively

Change-Id: Ib3bec382ef80a9078ffde8612c395cb0154fd476
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146747
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 2a984c77ccb1aa77d9bbd02218d4dc76aaff4a9e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146763
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index 5ca89c37a510..b08b6c2203c9 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -408,14 +408,20 @@ ScStyleSheet* ScStyleSheetPool::FindCaseIns( const 
OUString& rName, SfxStyleFami
 CaseInsensitiveNamePredicate aPredicate(rName, eFam);
 std::vector aFoundPositions = 
GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
 
+ScStyleSheet* first = nullptr; // first case insensitive match found
 for (const auto& rPos : aFoundPositions)
 {
 SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(rPos);
 // we do not know what kind of sheets we have.
 if (pFound->isScStyleSheet())
-return static_cast(pFound);
+{
+if (pFound->GetName() == rName) // exact case sensitive match
+return static_cast(pFound);
+if (!first)
+first = static_cast(pFound);
+}
 }
-return nullptr;
+return first;
 }
 
 void ScStyleSheetPool::setAllParaStandard()


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-10 Thread Mike Kaganski (via logerrit)
 sc/source/ui/docshell/autostyl.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit a01f4a1c317520a7a3090cfb2f1c9f21bbc50922
Author: Mike Kaganski 
AuthorDate: Thu Feb 9 16:06:04 2023 +0300
Commit: Xisco Fauli 
CommitDate: Fri Feb 10 14:04:32 2023 +

Related: tdf#153510 Avoid modification of iterated container

A crash is seen when resizing a document locally; the problem is
range-based for loop, which indirectly modifies its range:

  sclo.dll!ScAutoStyleList::AddInitial(const ScRange & rRange, const 
rtl::OUString & rStyle1, unsigned __int64 nTimeout, const rtl::OUString & 
rStyle2) Line 81 C++
  sclo.dll!ScDocShell::Notify(SfxBroadcaster & __formal, const SfxHint & 
rHint) Line 685C++
  svllo.dll!SfxBroadcaster::Broadcast(const SfxHint & rHint) Line 41C++
  sclo.dll!ScInterpreter::ScStyle() Line 2628   C++
  sclo.dll!ScInterpreter::Interpret() Line 4441 C++
  sclo.dll!ScFormulaCell::InterpretTail(ScInterpreterContext & rContext, 
ScFormulaCell::ScInterpretTailParameter eTailParam) Line 1947  C++
  sclo.dll!ScFormulaCell::Interpret(long nStartOffset, long nEndOffset) 
Line 1619   C++
  sclo.dll!ScFormulaCell::MaybeInterpret() Line 470 C++
  sclo.dll!ScFormulaCell::IsValue() Line 2763   C++
  sclo.dll!ScConditionEntry::Interpret(const ScAddress & rPos) Line 670 C++
  sclo.dll!ScConditionEntry::IsCellValid(ScRefCellValue & rCell, const 
ScAddress & rPos) Line 1238  C++
  sclo.dll!ScConditionalFormat::GetData(ScRefCellValue & rCell, const 
ScAddress & rPos) Line 1836   C++
  sclo.dll!`anonymous 
namespace'::handleConditionalFormat(ScConditionalFormatList & rCondFormList, 
const o3tl::sorted_vector,o3tl::find_unique,1> & rCondFormats, ScCellInfo * pInfo, ScTableInfo * 
pTableInfo, ScStyleSheetPool * pStlPool, const ScAddress & rAddr, bool & 
bHidden, bool & bHideFormula, bool bTabProtect) Line 297C++
  sclo.dll!ScDocument::FillInfo(ScTableInfo & rTabInfo, short nCol1, long 
nRow1, short nCol2, long nRow2, short nTab, double fColScale, double fRowScale, 
bool bPageMode, bool bFormulaMode, const ScMarkData * pMarkData) Line 569 
C++
  sclo.dll!ScGridWindow::Draw(short nX1, long nY1, short nX2, long nY2, 
ScUpdateMode eMode) Line 556C++
  sclo.dll!ScGridWindow::Paint(OutputDevice & __formal, const 
tools::Rectangle & rRect) Line 458C++
  vcllo.dll!PaintHelper::DoPaint(const vcl::Region * pRegion) Line 313  C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 617C++
  vcllo.dll!PaintHelper::~PaintHelper() Line 553C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 623C++
  vcllo.dll!PaintHelper::~PaintHelper() Line 553C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 623C++
  vcllo.dll!PaintHelper::~PaintHelper() Line 553C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 623C++
  vcllo.dll!PaintHelper::~PaintHelper() Line 553C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 623C++
  vcllo.dll!PaintHelper::~PaintHelper() Line 553C++
  vcllo.dll!vcl::Window::ImplCallPaint(const vcl::Region * pRegion, 
ImplPaintFlags nPaintFlags) Line 623C++
  vcllo.dll!vcl::Window::ImplCallOverlapPaint() Line 646C++
  vcllo.dll!vcl::Window::ImplHandlePaintHdl(Timer * __formal) Line 668  C++
  vcllo.dll!vcl::Window::LinkStubImplHandlePaintHdl(void * instance, Timer 
* data) Line 648 C++
  vcllo.dll!Link::Call(Timer * data) Line 111 C++
  vcllo.dll!Timer::Invoke(Timer * arg) Line 81  C++
  vcllo.dll!vcl::Window::ImplHandleResizeTimerHdl(Timer * __formal) Line 
684C++
  vcllo.dll!vcl::Window::LinkStubImplHandleResizeTimerHdl(void * instance, 
Timer * data) Line 674   C++
  vcllo.dll!Link::Call(Timer * data) Line 111 C++
  vcllo.dll!Timer::Invoke(Timer * arg) Line 81  C++
  vcllo.dll!vcl::Window::GetSizePixel() Line 2420   C++
  sclo.dll!ScTabView::GetGridWidth(ScHSplitPos eWhich) Line 3032C++
  sclo.dll!ScViewData::CellsAtX(short nPosX, short nDir, ScHSplitPos 
eWhichX, unsigned short nScrSizeX) Line 2634   C++
  sclo.dll!ScViewData::VisibleCellsX(ScHSplitPos eWhichX) Line 2710 C++
  sclo.dll!ScTabView::PaintArea(short nStartCol, long nStartRow, short 
nEndCol, long nEndRow, ScUpdateMode eMode) Line 2386 C++
  sclo.dll!ScTabViewShell::Notify(SfxBroadcaster & rBC, const SfxHint & 
rHint) Line 63  C++
  svllo.dll!SfxBroadcaster::Broadcast(const SfxHint & rHint) Line 41C++
  sclo.dll!ScDocShell::PostPaint(const ScRangeList & rRanges, 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-09 Thread Caolán McNamara (via logerrit)
 sc/source/filter/oox/workbookfragment.cxx |4 
 sc/source/filter/oox/worksheethelper.cxx  |3 ---
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit a1f175f01ffa6102b9fdc54177ca53940a43897c
Author: Caolán McNamara 
AuthorDate: Wed Feb 1 09:40:52 2023 +
Commit: Xisco Fauli 
CommitDate: Thu Feb 9 13:11:10 2023 +

crashtesting: threaded import crash seen in forum-mso-en4-802501.xlsx

sporadically reproducible with tsan and
./instdir/program/soffice.bin --headless --convert-to pdf 
~/forum-mso-en4-802501.xlsx

move getTables().applyAutoFilters(), which wants to query tab 1 while
tab 1 is still getting imported, until after the threaded import has
completed.

This call was moved before in:

commit edd51b813005c2159426d8f2917eede5b14a4577
Date:   Thu Aug 15 16:23:46 2013 +0100

fix for bnc#834705 missing drop downs for autofilter

==
WARNING: ThreadSanitizer: data race (pid=3791886)
  Read of size 8 at 0x7b540f20 by thread T7 (mutexes: write M0, write 
M1):
#0 __gnu_cxx::__normal_iterator>>::__normal_iterator(unsigned long const* const&) 
/usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/stl_iterator.h:1073:20
 (libsclo.so+0x3d31c4) (BuildId: 4582437348063bd1c461478348ce37a0dbd28def)
#1 std::vector>::cend() 
const 
/usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/stl_vector.h:960:16
 (libsclo.so+0x3d31c4)
#2 
mdds::mtv::soa::multi_type_vector, mdds::mtv::noncopyable_managed_element_block<53, 
EditTextObject>, mdds::mtv::noncopyable_managed_element_block<54, 
ScFormulaCell>>, sc::CellStoreTrait>::cbegin() const 
core/workdir/UnpackedTarball/mdds/include/mdds/multi_type_vector/soa/main_def.inl:3771:34
 (libsclo.so+0x3d31c4)
#3 
mdds::mtv::soa::multi_type_vector, mdds::mtv::noncopyable_managed_element_block<53, 
EditTextObject>, mdds::mtv::noncopyable_managed_element_block<54, 
ScFormulaCell>>, sc::CellStoreTrait>::begin() const 
core/workdir/UnpackedTarball/mdds/include/mdds/multi_type_vector/soa/main_def.inl:3753:12
 (libsclo.so+0x3d31c4)
#4 ScColumn::InitBlockPosition(sc::ColumnBlockConstPosition&) const 
core/sc/source/core/data/column3.cxx:1135:35 (libsclo.so+0x3d31c4)
#5 ScTable::GetDataArea(short&, int&, short&, int&, bool, bool) const 
core/sc/source/core/data/table1.cxx:908:19 (libsclo.so+0x637b39) (BuildId: 
4582437348063bd1c461478348ce37a0dbd28def)
#6 ScDocument::GetDataArea(short, short&, int&, short&, int&, bool, 
bool) const core/sc/source/core/data/document.cxx:1104:23 (libsclo.so+0x49b696) 
(BuildId: 4582437348063bd1c461478348ce37a0dbd28def)
#7 ScDBData::ExtendDataArea(ScDocument const&) 
core/sc/source/core/tool/dbdata.cxx:654:10 (libsclo.so+0x741e77) (BuildId: 
4582437348063bd1c461478348ce37a0dbd28def)
#8 ScDocument::GetFilterEntries(short, int, short, ScFilterEntries&) 
core/sc/source/core/data/documen3.cxx:1577:14 (libsclo.so+0x46e7a6) (BuildId: 
4582437348063bd1c461478348ce37a0dbd28def)
#9 (anonymous namespace)::fillQueryParam(ScQueryParam&, ScDocument*, 
com::sun::star::uno::Sequence const&) 
core/sc/source/ui/unoobj/datauno.cxx:1164:27 (libsclo.so+0xf7dd72) (BuildId: 
4582437348063bd1c461478348ce37a0dbd28def)
#10 
ScFilterDescriptorBase::setFilterFields3(com::sun::star::uno::Sequence
 const&) core/sc/source/ui/unoobj/datauno.cxx:1380:5 (libsclo.so+0xf7dd72)
#11 non-virtual thunk to 
ScFilterDescriptorBase::setFilterFields3(com::sun::star::uno::Sequence
 const&) core/sc/source/ui/unoobj/datauno.cxx (libsclo.so+0xf7e2c2) (BuildId: 
4582437348063bd1c461478348ce37a0dbd28def)
#12 
oox::xls::AutoFilter::finalizeImport(com::sun::star::uno::Reference
 const&, short) core/sc/source/filter/oox/autofilterbuffer.cxx:803:22 
(libscfiltlo.so+0x3cca2c) (BuildId: 798032f9cb60957d86e47827d9e882b8931326ba)
#13 
oox::xls::AutoFilterBuffer::finalizeImport(com::sun::star::uno::Reference
 const&, short) core/sc/source/filter/oox/autofilterbuffer.cxx:950:22 
(libscfiltlo.so+0x3cdc0b) (BuildId: 798032f9cb60957d86e47827d9e882b8931326ba)
#14 oox::xls::Table::applyAutoFilters() 
core/sc/source/filter/oox/tablebuffer.cxx:143:23 (libscfiltlo.so+0x4b9268) 
(BuildId: 798032f9cb60957d86e47827d9e882b8931326ba)
#15 void std::__invoke_impl(std::__invoke_memfun_ref, void (oox::xls::Table::*&)(), 
oox::xls::Table&) 
/usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/invoke.h:67:14
 (libscfiltlo.so+0x4b9d96) (BuildId: 798032f9cb60957d86e47827d9e882b8931326ba)
#16 std::__invoke_result::type std::__invoke(void (oox::xls::Table::*&)(), oox::xls::Table&) 
/usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/invoke.h:96:14
 (libscfiltlo.so+0x4b9d96)
#17 void std::_Bind))()>::__call(std::tuple&&, std::_Index_tuple<0ul>) 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-09 Thread Tünde Tóth (via logerrit)
 sc/source/ui/app/client.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit bdbeff654038921943658a5bf6e7faf21f5776da
Author: Tünde Tóth 
AuthorDate: Fri Jan 13 09:31:38 2023 +0100
Commit: Christian Lohmaier 
CommitDate: Thu Feb 9 11:43:02 2023 +

tdf#152989 sc: fix oversized rectangle of edited embedded object

Editing resulted unusably oversized OLE objects. Keep
its original size to fix the UX problem.

Note: lost zoom is still a problem.

See also commit fdf95de18ef1891862bdce26669d1ce2c6f24764
"tdf#152991 sd: fix oversized rectangle of edited embedded object"

Change-Id: I6b73d1aea76ea4addc24ff978403893c3cbd3dac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145432
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit a1f16b4603bffddb2f6380874d63f928289de85a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145588
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
index 2c7fea5ab376..ea9ffa9ade9c 100644
--- a/sc/source/ui/app/client.cxx
+++ b/sc/source/ui/app/client.cxx
@@ -202,6 +202,12 @@ void ScClient::ViewChanged()
 if (!pDrawObj)
 return;
 
+if (!IsObjectInPlaceActive())
+{
+pDrawObj->ActionChanged();
+return;
+}
+
 tools::Rectangle aLogicRect = pDrawObj->GetLogicRect();
 Fraction aFractX = GetScaleWidth() * aVisSize.Width();
 Fraction aFractY = GetScaleHeight() * aVisSize.Height();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-04 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |   27 ---
 sc/source/ui/inc/inputwin.hxx |2 ++
 2 files changed, 22 insertions(+), 7 deletions(-)

New commits:
commit ff14364441c3f7bc0c3bc4981c9395658f9079f3
Author: Caolán McNamara 
AuthorDate: Fri Feb 3 16:18:35 2023 +
Commit: Adolfo Jayme Barrientos 
CommitDate: Sat Feb 4 08:21:46 2023 +

Resolves: tdf#153353 formula bar border area bg didn't change on theme 
change

Change-Id: I720054d540a6352b8248aa59e231878c1832d998
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146521
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 14249fe2eb04..f035eb0b7314 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -850,14 +850,8 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, 
ScTabViewShell* pViewSh)
 {
 InitControlBase(m_xContainer.get());
 
-const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
-
 SetPaintTransparent(false);
-SetBackground(rStyleSettings.GetFaceColor());
-
-// match to bg used in ScTextWnd::SetDrawingArea to the margin area is 
drawn with the
-// same desired bg
-mxBackground->set_background(rStyleSettings.GetWindowColor());
+SetBackgrounds();
 
 mxButtonUp->connect_clicked(LINK(this, ScInputBarGroup, ClickHdl));
 mxButtonDown->connect_clicked(LINK(this, ScInputBarGroup, ClickHdl));
@@ -878,6 +872,25 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, 
ScTabViewShell* pViewSh)
 mxButtonDown->show();
 }
 
+void ScInputBarGroup::SetBackgrounds()
+{
+const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+SetBackground(rStyleSettings.GetFaceColor());
+// match to bg used in ScTextWnd::SetDrawingArea to the margin area is 
drawn with the
+// same desired bg
+mxBackground->set_background(rStyleSettings.GetWindowColor());
+}
+
+void ScInputBarGroup::DataChanged(const DataChangedEvent& rDCEvt)
+{
+InterimItemWindow::DataChanged(rDCEvt);
+if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && 
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
+{
+SetBackgrounds();
+Invalidate();
+}
+}
+
 Point ScInputBarGroup::GetCursorScreenPixelPos(bool bBelow)
 {
 return mxTextWndGroup->GetCursorScreenPixelPos(bBelow);
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index ac96062af137..e8e63855ffd6 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -252,6 +252,7 @@ public:
 virtual boolHasEditView() const override;
 Point   GetCursorScreenPixelPos(bool bBelowLine);
 virtual voidResize() override;
+virtual voidDataChanged(const DataChangedEvent& rDCEvt) 
override;
 virtual const OUString& GetTextString() const override;
 virtual voidStopEditEngine(bool bAll) override;
 virtual voidTextGrabFocus() override;
@@ -272,6 +273,7 @@ public:
 
 private:
 voidTriggerToolboxLayout();
+voidSetBackgrounds();
 
 std::unique_ptr mxBackground;
 std::unique_ptr mxTextWndGroup;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-02 Thread Samuel Mehrbrodt (via logerrit)
 sc/source/ui/app/inputwin.cxx |9 +
 sc/source/ui/inc/inputwin.hxx |2 --
 2 files changed, 1 insertion(+), 10 deletions(-)

New commits:
commit 9739a874b64e770728d62713b070f37de4ec8328
Author: Samuel Mehrbrodt 
AuthorDate: Thu Jan 26 16:52:32 2023 +0100
Commit: Kohei Yoshida 
CommitDate: Fri Feb 3 02:06:13 2023 +

tdf#151682 Fix gap above input bar

Remove vertical offset, looks like it's not needed anymore.

Change-Id: If0f7f7dce7a7e4249036930b60fe353890b495fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146179
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit f7544650cc4e31da67873898e2d587afa846b9b4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146199
Reviewed-by: Kohei Yoshida 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 14ef498976ba..14249fe2eb04 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -495,7 +495,7 @@ void ScInputWindow::Resize()
 if (pGroupBar->GetNumLines() > 1)
 {
 Size aGroupBarSize = pGroupBar->GetSizePixel();
-aSize.setHeight(aGroupBarSize.Height() + 2 * 
(pGroupBar->GetVertOffset() + 1));
+aSize.setHeight(aGroupBarSize.Height());
 }
 }
 SetSizePixel(aSize);
@@ -847,7 +847,6 @@ ScInputBarGroup::ScInputBarGroup(vcl::Window* pParent, 
ScTabViewShell* pViewSh)
 , mxTextWndGroup(new ScTextWndGroup(*this, pViewSh))
 , mxButtonUp(m_xBuilder->weld_button("up"))
 , mxButtonDown(m_xBuilder->weld_button("down"))
-, mnVertOffset(0)
 {
 InitControlBase(m_xContainer.get());
 
@@ -1083,12 +1082,6 @@ void ScInputBarGroup::TriggerToolboxLayout()
 ScInputWindow  = dynamic_cast(*w);
 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
 
-// Capture the vertical position of this window in the toolbar, when we 
increase
-// the size of the toolbar to accommodate expanded line input we need to 
take this
-// into account
-if ( !mnVertOffset )
-mnVertOffset = rParent.GetItemPosRect( rParent.GetItemCount() - 1 
).Top();
-
 if ( !pViewFrm )
 return;
 
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 12bc461f2836..ac96062af137 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -262,7 +262,6 @@ public:
 voidDecrementVerticalSize();
 voidNumLinesChanged();
 virtual tools::LongGetNumLines() const override { return 
mxTextWndGroup->GetNumLines(); }
-tools::LongGetVertOffset() const { return  
mnVertOffset; }
 
 int GetPixelHeightForLines() const
 {
@@ -278,7 +277,6 @@ private:
 std::unique_ptr mxTextWndGroup;
 std::unique_ptr mxButtonUp;
 std::unique_ptr mxButtonDown;
-tools::Long   mnVertOffset;
 
 DECL_LINK(ClickHdl, weld::Button&, void);
 };


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-02-01 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/interpr3.cxx |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit d279c564a134160c5fc9b5ed6674aec58b8792a3
Author: Caolán McNamara 
AuthorDate: Thu Jan 26 20:55:57 2023 +
Commit: Xisco Fauli 
CommitDate: Wed Feb 1 10:58:46 2023 +

crashtesting: crash on forum-mso-en4-719754.xlsx with fPercentile ~== 1

input is fPercentile of near 1 where approxFloor would give nIndex of
nSize-1 resulting in a non-zero tiny negative fDiff, when the assumption
is fDiff will be 0 or some positive value.

Change-Id: I8fe5520f2b3c68f3204d435337df527185dcb0d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146218
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 1371ba2bcbcce57ba5cbd7a199ae8feceb22d0d0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146203
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index f55fc1636959..12e49de73972 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3409,8 +3409,13 @@ double ScInterpreter::GetPercentile( vector & 
rArray, double fPercentile
 OSL_ENSURE(nIndex < nSize, "GetPercentile: wrong index(1)");
 vector::iterator iter = rArray.begin() + nIndex;
 ::std::nth_element( rArray.begin(), iter, rArray.end());
-if (fDiff == 0.0)
+if (fDiff <= 0.0)
+{
+// Note: neg fDiff seen with forum-mso-en4-719754.xlsx with
+// fPercentile of near 1 where approxFloor gave nIndex of nSize-1
+// resulting in a non-zero tiny negative fDiff.
 return *iter;
+}
 else
 {
 OSL_ENSURE(nIndex < nSize-1, "GetPercentile: wrong index(2)");


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-31 Thread Andreas Heinisch (via logerrit)
 sc/source/ui/dbgui/csvgrid.cxx |   18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

New commits:
commit 626b4d63431b4cd10aed515cb6d66899b4c60502
Author: Andreas Heinisch 
AuthorDate: Tue Jan 24 16:15:13 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Jan 31 11:15:31 2023 +

tdf#45147 - CSV Import: Remove special handling for mixed script types

In the CSV import dialog, remove the special handling for mixed script 
types. Otherwise, right-to-left words appear in the wrong order.

The special handling of mixed script types was introduced in 
https://bz.apache.org/ooo/show_bug.cgi?id=60296 which is handled in the edit 
engine now.

Change-Id: Ic6dc3f2051ea41f79db5398a8442f78116da52de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146096
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit a362c0145731031834bc3a73c8e3577bf6c12720)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146331
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index b44cca04dee7..16b7ca61e35f 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -1130,22 +1130,8 @@ void ScCsvGrid::ImplDrawCellText( const Point& rPos, 
const OUString& rText )
 OUString aPlainText = rText.replaceAll( "\t", " " );
 aPlainText = aPlainText.replaceAll( "\n", " " );
 mpEditEngine->SetPaperSize( maEdEngSize );
-
-/*  #i60296# If string contains mixed script types, the space character
-U+0020 may be drawn with a wrong width (from non-fixed-width Asian or
-Complex font). Now we draw every non-space portion separately. */
-sal_Int32 nCharIxInt {aPlainText.isEmpty() ? -1 : 0};
-while (nCharIxInt>=0)
-{
-sal_Int32 nBeginIx = nCharIxInt;
-const OUString aToken = aPlainText.getToken( 0, ' ', nCharIxInt );
-if( !aToken.isEmpty() )
-{
-sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx;
-mpEditEngine->SetTextCurrentDefaults( aToken );
-mpEditEngine->Draw(*mpBackgrDev, Point(nX, rPos.Y()));
-}
-}
+mpEditEngine->SetTextCurrentDefaults(aPlainText);
+mpEditEngine->Draw(*mpBackgrDev, rPos);
 
 sal_Int32 nCharIx = 0;
 while( (nCharIx = rText.indexOf( '\t', nCharIx )) != -1 )


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-31 Thread Noel Grandin (via logerrit)
 sc/source/core/tool/scmatrix.cxx |   45 +++
 1 file changed, 23 insertions(+), 22 deletions(-)

New commits:
commit 1ce2d11a042448f81e035647a380e46662e9633e
Author: Noel Grandin 
AuthorDate: Mon Jan 30 12:12:43 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Jan 31 09:49:24 2023 +

fix data-race in ScMatrix

when doing threaded load of spreadsheets, we touch these fields from
multiple threads

Change-Id: Ia9d4dba79cfe7870a3a252a35a23acf71a3971e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146346
Reviewed-by: Michael Stahl 
Tested-by: Jenkins
(cherry picked from commit f7db0f22dcff0b08acccf326b62d72a12b6e28f6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146321

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 3c0aa14966db..7cec2602252d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -35,6 +35,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -343,8 +344,8 @@ private:
 void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const;
 };
 
-static bool bElementsMaxFetched;
-static size_t nElementsMax;
+static std::once_flag bElementsMaxFetched;
+static std::atomic nElementsMax;
 
 /** The maximum number of elements a matrix or the pool may have at runtime.
 
@@ -2813,30 +2814,30 @@ bool ScMatrix::IsSizeAllocatable( SCSIZE nC, SCSIZE nR )
 if (!nC || !nR)
 return true;
 
-if (!bElementsMaxFetched)
-{
-const char* pEnv = std::getenv("SC_MAX_MATRIX_ELEMENTS");
-if (pEnv)
-{
-// Environment specifies the overall elements pool.
-nElementsMax = std::atoi(pEnv);
-}
-else
+std::call_once(bElementsMaxFetched,
+[]()
 {
-// GetElementsMax() uses an (~arbitrary) elements limit.
-// The actual allocation depends on the types of individual matrix
-// elements and is averaged for type double.
+const char* pEnv = std::getenv("SC_MAX_MATRIX_ELEMENTS");
+if (pEnv)
+{
+// Environment specifies the overall elements pool.
+nElementsMax = std::atoi(pEnv);
+}
+else
+{
+// GetElementsMax() uses an (~arbitrary) elements limit.
+// The actual allocation depends on the types of individual 
matrix
+// elements and is averaged for type double.
 #if SAL_TYPES_SIZEOFPOINTER < 8
-// Assume 1GB memory could be consumed by matrices.
-constexpr size_t nMemMax = 0x4000;
+// Assume 1GB memory could be consumed by matrices.
+constexpr size_t nMemMax = 0x4000;
 #else
-// Assume 6GB memory could be consumed by matrices.
-constexpr size_t nMemMax = 0x18000;
+// Assume 6GB memory could be consumed by matrices.
+constexpr size_t nMemMax = 0x18000;
 #endif
-nElementsMax = GetElementsMax( nMemMax);
-}
-bElementsMaxFetched = true;
-}
+nElementsMax = GetElementsMax( nMemMax);
+}
+});
 
 if (nC > (nElementsMax / nR))
 {


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-23 Thread Miklos Vajna (via logerrit)
 sc/source/ui/view/viewdata.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 98fda531df5546ef39e24a3de00f36bb7196e28d
Author: Miklos Vajna 
AuthorDate: Fri Jan 13 08:56:29 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Jan 23 11:53:49 2023 +

sc: fix crash in ScViewData::GetCurXForTab()

Crashreport signature:

program/libsclo.so
ScViewData::GetCurXForTab(short) const
sc/source/ui/view/viewdata.cxx:1431
program/libsclo.so
ScViewFunc::OnLOKInsertDeleteColumn(short, long)
sc/source/ui/view/viewfunc.cxx:1552
program/libsclo.so
ScDocFunc::InsertCells(ScRange const&, ScMarkData const*, 
InsCellCmd, bool, bool, bool)
source/ui/docshell/docfunc.cxx:2256
program/libsclo.so
ScViewFunc::InsertCells(InsCellCmd, bool, bool)
sc/source/ui/view/viewfunc.cxx:1658

Seeing that e.g. ScViewData::WriteUserDataSequence() already checks if
the pointer in maTabData is a nullptr, do the same here.

Change-Id: I0ebdba8c8a5bedd3c3c57c36bdf0632e2fee45c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145697
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 1f8c02353d653a6d4a72d918aaf6be5f367137c9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145729
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 0ef96d96c7ae..ae68a5dfc725 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1429,7 +1429,7 @@ SCROW ScViewData::GetPosY( ScVSplitPos eWhich, SCTAB 
nForTab ) const
 
 SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const
 {
-if (!ValidTab(nTabIndex) || (nTabIndex >= 
static_cast(maTabData.size(
+if (!ValidTab(nTabIndex) || (nTabIndex >= 
static_cast(maTabData.size())) || !maTabData[nTabIndex])
 return -1;
 
 return maTabData[nTabIndex]->nCurX;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-19 Thread Eike Rathke (via logerrit)
 sc/source/ui/miscdlgs/acredlin.cxx |   96 +++--
 1 file changed, 39 insertions(+), 57 deletions(-)

New commits:
commit 7ad6682475df099643c344b5d1cfefef9189d932
Author: Eike Rathke 
AuthorDate: Wed Jan 18 18:40:50 2023 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Jan 19 08:19:03 2023 +

Resolves: tdf#153096 Split change track content action into columns again

Old SvTreeList did split a string on embedded \t Tab characters,
the new weld::TreeView does not but needs column text set
explicitly.

Regression from

commit 56dd851cfc77c362c3db5c0aae4a490c7f6782cc
CommitDate: Sat Apr 27 12:41:14 2019 +0200

weld cluster of change tracking dialogs

that did the necessary changes for
ScAcceptChgDlg::AppendFilteredAction() but not for
ScAcceptChgDlg::AppendChangeAction() and
ScAcceptChgDlg::InsertChangeActionContent().

Odd that no one reported this in all the time..

Additionally, the "Changed contents" label being used instead of
"Row inserted"/"Column inserted"/"Row deleted"/"Column deleted" as
soon as cell content change is present depending on such action,
was a copypasta fallout from

commit e7c76b30bd2ef802ce08f8739eac186253c79696
CommitDate: Mon Aug 29 17:21:12 2011 -0400

String to rtl::OUString.

Change-Id: I855c527da61723c104c743e3b3f159fb026917df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145749
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit fc441f3886330c4ae2abeb67c0758b935ba23f47)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145724
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/miscdlgs/acredlin.cxx 
b/sc/source/ui/miscdlgs/acredlin.cxx
index d1427a8a3c28..87292fe06c1e 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -369,12 +369,13 @@ std::unique_ptr 
ScAcceptChgDlg::AppendChangeAction(
 bool bFlag = false;
 
 ScRange aRef=pScChangeAction->GetBigRange().MakeRange(*pDoc);
-OUString aUser=pScChangeAction->GetUser();
 DateTime aDateTime=pScChangeAction->GetDateTime();
 
-OUString aRefStr;
 ScChangeActionType eType=pScChangeAction->GetType();
-OUStringBuffer aBuf;
+OUString aActionString;
+OUString aRefStr;
+OUString aUser;
+OUString aDate;
 OUString aDesc;
 
 std::unique_ptr pNewData(new ScRedlinData);
@@ -392,20 +393,20 @@ std::unique_ptr 
ScAcceptChgDlg::AppendChangeAction(
 {
 if(pScChangeAction->IsDialogParent())
 {
-aBuf.append(aStrContentWithChild);
+aActionString = aStrContentWithChild;
 pNewData->nInfo=RD_SPECIAL_VISCONTENT;
 pNewData->bIsRejectable=false;
 pNewData->bIsAcceptable=false;
 }
 else
 {
-aBuf.append(*MakeTypeString(eType));
+aActionString = *MakeTypeString(eType);
 aDesc = pScChangeAction->GetDescription(*pDoc, true);
 }
 }
 else
 {
-aBuf.append(aStrContentWithChild);
+aActionString = *MakeTypeString(eType);
 
 if(bDelMaster)
 {
@@ -420,27 +421,16 @@ std::unique_ptr 
ScAcceptChgDlg::AppendChangeAction(
 
 aRefStr = pScChangeAction->GetRefString(*pDoc, true);
 
-aBuf.append('\t');
-aBuf.append(aRefStr);
-aBuf.append('\t');
-
 bool bIsGenerated = false;
 
 if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
 {
-aBuf.append(aUser);
-aBuf.append('\t');
-aBuf.append(ScGlobal::getLocaleData().getDate(aDateTime));
-aBuf.append(' ');
-aBuf.append(ScGlobal::getLocaleData().getTime(aDateTime));
-aBuf.append('\t');
-
+aUser = pScChangeAction->GetUser();
+aDate = ScGlobal::getLocaleData().getDate(aDateTime) + " " + 
ScGlobal::getLocaleData().getTime(aDateTime);
 bIsGenerated = false;
 }
 else
 {
-aBuf.append('\t');
-aBuf.append('\t');
 bIsGenerated = true;
 }
 
@@ -451,8 +441,6 @@ std::unique_ptr 
ScAcceptChgDlg::AppendChangeAction(
 aComment +=  " (" + aDesc + ")";
 }
 
-aBuf.append(aComment);
-
 if (pTheView->IsValidEntry(aUser, aDateTime) || bIsGenerated)
 {
 if (pTheView->IsValidComment(aComment))
@@ -480,9 +468,15 @@ std::unique_ptr 
ScAcceptChgDlg::AppendChangeAction(
 
 weld::TreeView& rTreeView = pTheView->GetWidget();
 std::unique_ptr xEntry(rTreeView.make_iterator());
-OUString sString(aBuf.makeStringAndClear());
 OUString sId(weld::toId(pNewData.release()));
-rTreeView.insert(pParent, -1, , , nullptr, nullptr, 
bCreateOnDemand, xEntry.get());
+rTreeView.insert(pParent, -1, , , nullptr, nullptr, 
bCreateOnDemand, xEntry.get());
+rTreeView.set_text( *xEntry, aRefStr, 1);
+if (!aUser.isEmpty())
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-12 Thread Caolán McNamara (via logerrit)
 sc/source/ui/dbgui/tpsort.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 34789a2a7678435b142165647aba20b55c086fcb
Author: Caolán McNamara 
AuthorDate: Tue Jan 10 10:32:10 2023 +
Commit: Xisco Fauli 
CommitDate: Thu Jan 12 08:22:13 2023 +

Resolves: tdf#152950 don't set_active while frozen

Change-Id: I7db73e37ed426aae2282a6bf1564e5d3843442cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145230
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 3455f11006cf..35a24e633058 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -813,6 +813,8 @@ void ScTabPageSortOptions::EdOutPosModHdl()
 
 void ScTabPageSortOptions::FillAlgor()
 {
+tools::Long nCount = 0;
+
 m_xLbAlgorithm->freeze();
 m_xLbAlgorithm->clear();
 
@@ -830,18 +832,19 @@ void ScTabPageSortOptions::FillAlgor()
 lang::Locale aLocale( LanguageTag::convertToLocale( eLang ));
 const uno::Sequence aAlgos = 
m_xColWrap->listCollatorAlgorithms( aLocale );
 
-tools::Long nCount = aAlgos.getLength();
+nCount = aAlgos.getLength();
 for (const OUString& sAlg : aAlgos)
 {
 OUString sUser = m_xColRes->GetTranslation( sAlg );
 m_xLbAlgorithm->append_text(sUser);
 }
-m_xLbAlgorithm->set_active(0);   // first entry is default
-m_xFtAlgorithm->set_sensitive(nCount > 1);  // enable only if 
there is a choice
-m_xLbAlgorithm->set_sensitive(nCount > 1);  // enable only if 
there is a choice
 }
 
 m_xLbAlgorithm->thaw();
+
+m_xLbAlgorithm->set_active(nCount ? 0 : -1);// first entry is default
+m_xFtAlgorithm->set_sensitive(nCount > 1);  // enable only if there is 
a choice
+m_xLbAlgorithm->set_sensitive(nCount > 1);  // enable only if there is 
a choice
 }
 
 IMPL_LINK_NOARG(ScTabPageSortOptions, FillAlgorHdl, weld::ComboBox&, void)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-11 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/odffmap.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit a4de9d2bb2f1aea011bd1652d72b349369da03a0
Author: Eike Rathke 
AuthorDate: Tue Jan 10 01:22:38 2023 +0100
Commit: Eike Rathke 
CommitDate: Wed Jan 11 11:59:27 2023 +

Related: tdf#152948 Align AddInMap English names to Add-In implementation

... of scaddins/source/analysis/analysishelper.cxx for the few (4)
functions with the _EXCEL2003 suffix. The compiler's symbol map
for English contained both, but the reverse map contained only the
(first added) ..._ADD name, so GCD_EXCEL2003() was displayed as
GCD_ADD(), that still worked but was unexpected.

Change-Id: I8c866dc73d0146d75b29f8212a7e561a3f38fce4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145247
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit f98d04571c99b70ff753d322b1f43adc8e0433ba)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145297

diff --git a/sc/source/core/tool/odffmap.cxx b/sc/source/core/tool/odffmap.cxx
index 1a469208fc35..7fc4ac5141e4 100644
--- a/sc/source/core/tool/odffmap.cxx
+++ b/sc/source/core/tool/odffmap.cxx
@@ -34,9 +34,9 @@ const ScCompiler::AddInMap ScCompiler::g_aAddInMap[] =
 { "WORKDAY", "WORKDAY", "com.sun.star.sheet.addin.Analysis.getWorkday", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETWORKDAY" },
 { "YEARFRAC", "YEARFRAC", "com.sun.star.sheet.addin.Analysis.getYearfrac", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETYEARFRAC" },
 { "EDATE", "EDATE", "com.sun.star.sheet.addin.Analysis.getEdate", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETEDATE" },
-{ "WEEKNUM", "WEEKNUM_ADD", 
"com.sun.star.sheet.addin.Analysis.getWeeknum", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETWEEKNUM" },
+{ "WEEKNUM", "WEEKNUM_EXCEL2003", 
"com.sun.star.sheet.addin.Analysis.getWeeknum", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETWEEKNUM" },
 { "EOMONTH", "EOMONTH", "com.sun.star.sheet.addin.Analysis.getEomonth", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETEOMONTH" },
-{ "NETWORKDAYS", "NETWORKDAYS_ADD", 
"com.sun.star.sheet.addin.Analysis.getNetworkdays", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETNETWORKDAYS" },
+{ "NETWORKDAYS", "NETWORKDAYS_EXCEL2003", 
"com.sun.star.sheet.addin.Analysis.getNetworkdays", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETNETWORKDAYS" },
 { "ISEVEN", "ISEVEN_ADD", "com.sun.star.sheet.addin.Analysis.getIseven", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETISEVEN" },
 { "ISODD", "ISODD_ADD", "com.sun.star.sheet.addin.Analysis.getIsodd", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETISODD" },
 { "MULTINOMIAL", "MULTINOMIAL", 
"com.sun.star.sheet.addin.Analysis.getMultinomial", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETMULTINOMIAL" },
@@ -45,8 +45,8 @@ const ScCompiler::AddInMap ScCompiler::g_aAddInMap[] =
 { "MROUND", "MROUND", "com.sun.star.sheet.addin.Analysis.getMround", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETMROUND" },
 { "SQRTPI", "SQRTPI", "com.sun.star.sheet.addin.Analysis.getSqrtpi", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETSQRTPI" },
 { "RANDBETWEEN", "RANDBETWEEN", 
"com.sun.star.sheet.addin.Analysis.getRandbetween", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETRANDBETWEEN" },
-{ "GCD", "GCD_ADD", "com.sun.star.sheet.addin.Analysis.getGcd", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETGCD" },
-{ "LCM", "LCM_ADD", "com.sun.star.sheet.addin.Analysis.getLcm", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETLCM" },
+{ "GCD", "GCD_EXCEL2003", "com.sun.star.sheet.addin.Analysis.getGcd", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETGCD" },
+{ "LCM", "LCM_EXCEL2003", "com.sun.star.sheet.addin.Analysis.getLcm", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETLCM" },
 { "BESSELI", "BESSELI", "com.sun.star.sheet.addin.Analysis.getBesseli", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETBESSELI" },
 { "BESSELJ", "BESSELJ", "com.sun.star.sheet.addin.Analysis.getBesselj", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETBESSELJ" },
 { "BESSELK", "BESSELK", "com.sun.star.sheet.addin.Analysis.getBesselk", 
"COM.SUN.STAR.SHEET.ADDIN.ANALYSIS.GETBESSELK" },


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-10 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/addincol.cxx |   56 +--
 sc/source/core/tool/compiler.cxx |9 --
 2 files changed, 49 insertions(+), 16 deletions(-)

New commits:
commit 9e42cba14ea823705c0e26da765e4b6446ffbde5
Author: Eike Rathke 
AuthorDate: Mon Jan 9 23:18:35 2023 +0100
Commit: Eike Rathke 
CommitDate: Tue Jan 10 18:43:46 2023 +

Resolves: tdf#152948 Do not use GetExcelName() to obtain English function 
name

As the function name says, it's the Excel compatibility name and
not the Calc UI visible name and thus does not have the _ADD or
_EXCEL2003 suffixes. Theoretically the names may even be
completely different.

Change-Id: I5f52dee77009123ebc3762defe08c937a3a59a18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145246
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit b5cca905c6f3e090dae6e649381664925474a04a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145225
Reviewed-by: Michael Stahl 

diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index bf7d8652de1b..99f8061df3d2 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -739,10 +739,19 @@ void ScUnoAddInCollection::ReadFromAddIn( const 
uno::Reference&
 
 // Even if GetUseEnglishFunctionName() would return true, do not set the
 // locale to en-US to get English function names as that also would mix in
-// English descriptions and parameter names. English function names are now
-// handled below.
+// English descriptions and parameter names. Also, setting a locale will
+// reinitialize the Add-In completely, so switching back and forth isn't a
+// good idea either.
 xAddIn->setLocale( 
Application::GetSettings().GetUILanguageTag().getLocale());
 
+// Instead, in a second run with 'en-US' obtain English names.
+struct FuncNameData
+{
+OUStringaFuncU;
+ScUnoAddInFuncData* pData;
+};
+std::vector aFuncNameData;
+
 OUString aServiceName( xName->getServiceName() );
 ScUnoAddInHelpIdGenerator aHelpIdGenerator( aServiceName );
 
@@ -785,7 +794,6 @@ 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->GetUpperLocal(),
 pData );
 
-OUString aEnglishName;
-if (!pData->GetExcelName( aEnglishLanguageTag, 
aEnglishName, false /*bFallbackToAny*/))
-SAL_WARN("sc.core", "no English name for " << 
aLocalName << " " << aFuncName);
-else
-{
-pEnglishHashMap->emplace(
-
ScCompiler::GetCharClassEnglish()->uppercase(aEnglishName),
-pData );
-}
-pData->SetEnglishName(aEnglishName);// takes care of 
handling empty
+aFuncNameData.push_back({aFuncU, pData});
 }
 }
 }
 }
+
+const LanguageTag aEnglishLanguageTag(LANGUAGE_ENGLISH_US);
+xAddIn->setLocale( aEnglishLanguageTag.getLocale());
+for (const auto& rFunc : aFuncNameData)
+{
+OUString aEnglishName;
+try
+{
+aEnglishName = xAddIn->getDisplayFunctionName( rFunc.aFuncU );
+}
+catch(uno::Exception&)
+{
+}
+if (aEnglishName.isEmpty()
+&& rFunc.pData->GetExcelName( aEnglishLanguageTag, 
aEnglishName, false /*bFallbackToAny*/))
+{
+// Check our known suffixes and append if not present. Note this
+// depends on localization (that should not add such suffix, but..)
+// and is really only a last resort.
+if (rFunc.pData->GetLocalName().endsWith("_ADD") && 
!aEnglishName.endsWith("_ADD"))
+aEnglishName += "_ADD";
+else if (rFunc.pData->GetLocalName().endsWith("_EXCEL2003") && 
!aEnglishName.endsWith("_EXCEL2003"))
+aEnglishName += "_EXCEL2003";
+SAL_WARN("sc.core", "obtaining English name for " << 
rFunc.pData->GetLocalName() << " "
+<< rFunc.pData->GetOriginalName() << " as ExcelName '" << 
aEnglishName << "'");
+}
+SAL_WARN_IF(aEnglishName.isEmpty(), "sc.core", "no English name for "
+<< rFunc.pData->GetLocalName() << " " << 
rFunc.pData->GetOriginalName());
+rFunc.pData->SetEnglishName(aEnglishName);  // takes care of handling 
empty
+pEnglishHashMap->emplace( rFunc.pData->GetUpperEnglish(), rFunc.pData);
+}
 }
 
 static void 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2023-01-10 Thread Heiko Tietze (via logerrit)
 sc/source/ui/view/formatsh.cxx |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit 9d6ae0b8d2ebb3931b3c46147e14939e7ed3f3ed
Author: Heiko Tietze 
AuthorDate: Fri Jan 6 09:58:25 2023 +
Commit: Xisco Fauli 
CommitDate: Tue Jan 10 09:48:38 2023 +

Revert "Resolves tdf#143100 - Disable cell style commands when sheet is 
protected"

This reverts commit a3cb71ac80c0c2971e97c033d212cf4e464fa8f0.

Reason for revert: tdf#149857

Change-Id: I5ea780b986073a8db16d5dc2ea503aa30da7ef27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145118
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
(cherry picked from commit 3babbc31bf4bba35924c25c5fbd59e1c314d3627)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145130
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 5513c9d76b75..913915a20dc8 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -189,9 +189,6 @@ void ScFormatShell::GetStyleState( SfxItemSet& rSet )
 rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() 
) );
 else
 rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
-
-if ( bProtected )
-rSet.DisableItem( nSlotId );
 }
 break;
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-30 Thread Mike Kaganski (via logerrit)
 sc/source/core/tool/ddelink.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 7e60f5dd6422b1409204f97e4704d7163ada73c2
Author: Mike Kaganski 
AuthorDate: Thu Dec 29 17:53:42 2022 +
Commit: Xisco Fauli 
CommitDate: Fri Dec 30 08:58:45 2022 +

tdf#152717: ScDdeLink::DataChanged may get OUString directly

... after commit 94df17f58fe6269452b7252b712a89978c444bec
(tdf#151429: don't convert OUStrings to system encoding, 2022-10-08)

Change-Id: Ie9d6eb2a4465a576eefe0840a30636e898fa9028
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144810
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 37723413115baafdc7d13ad26d11aa5f917c2036)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144812
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 95591dddb461..775c71808488 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -130,7 +130,8 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged(
 return SUCCESS;
 
 OUString aLinkStr;
-ScByteSequenceToString::GetString( aLinkStr, rValue, 
osl_getThreadTextEncoding() );
+if (!(rValue >>= aLinkStr))
+ScByteSequenceToString::GetString( aLinkStr, rValue, 
osl_getThreadTextEncoding() );
 aLinkStr = convertLineEnd(aLinkStr, LINEEND_LF);
 
 //  if string ends with line end, discard:


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-21 Thread Xisco Fauli (via logerrit)
 sc/source/ui/app/inputhdl.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit f3e521c819dcbea43ff3e38912ee36165d10c897
Author: Xisco Fauli 
AuthorDate: Wed Dec 21 13:27:19 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Dec 21 20:07:36 2022 +

sc: fix null deref in ScInputHandler::InputChanged

See

https://crashreport.libreoffice.org/stats/signature/EditView::ShowCursor(bool,bool,bool)
and

https://crashreport.libreoffice.org/stats/signature/EditEngine::GetText(LineEnd)

Change-Id: Ib1486161c722c213ccc64809010f54e9ab4dc52e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144684
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit 8efbc3e7f667bc1f04db4bcf908df905a1f34e06)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144667

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 3ad56ba03cc7..75655d807b73 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -4418,6 +4418,9 @@ void ScInputHandler::InputSelection( const EditView* 
pView )
 
 void ScInputHandler::InputChanged( const EditView* pView, bool bFromNotify )
 {
+if ( !pView )
+return;
+
 UpdateActiveView();
 
 // #i20282# DataChanged needs to know if this is from the input line's 
modify handler


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-19 Thread Xisco Fauli (via logerrit)
 sc/source/filter/excel/xestream.cxx  |6 -
 sc/source/ui/docshell/datastream.cxx |   12 ++
 sc/source/ui/docshell/externalrefmgr.cxx |6 +
 sc/source/ui/miscdlgs/redcom.cxx |   10 +-
 sc/source/ui/namedlg/namepast.cxx|5 -
 sc/source/ui/undo/undoblk3.cxx   |3 
 sc/source/ui/unoobj/docuno.cxx   |  132 ---
 7 files changed, 100 insertions(+), 74 deletions(-)

New commits:
commit c0246fc9955c12cc34ea8138f44c8b874927ce57
Author: Xisco Fauli 
AuthorDate: Mon Dec 19 12:05:48 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 22:18:08 2022 +

sc: check ScDocShell::GetViewData()

ScDocShell: :GetViewData() can return nullptr
Change-Id: I39bb2dce1ab233f39b0ec687ed71089b35537f9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144490
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index 33e6fa2a8838..75c241493b07 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -1049,15 +1049,15 @@ bool XclExpXmlStream::exportDocument()
 aRoot.GetOldRoot().pER = 
 aRoot.GetOldRoot().eDateiTyp = Biff8;
 // Get the viewsettings before processing
-if( ScDocShell::GetViewData() )
-ScDocShell::GetViewData()->WriteExtOptions( mpRoot->GetExtDocOptions() 
);
+if (ScViewData* pViewData = ScDocShell::GetViewData())
+pViewData->WriteExtOptions( mpRoot->GetExtDocOptions() );
 else
 {
 // Try to get ScViewData through the current ScDocShell
 ScTabViewShell* pTabViewShell = pShell->GetBestViewShell( false );
 if ( pTabViewShell )
 {
-ScViewData* pViewData = >GetViewData();
+pViewData = >GetViewData();
 pViewData->WriteExtOptions( mpRoot->GetExtDocOptions() );
 }
 }
diff --git a/sc/source/ui/docshell/datastream.cxx 
b/sc/source/ui/docshell/datastream.cxx
index 3003b3cdac2b..4bcbbaf9978c 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -237,8 +237,12 @@ DataStream::Cell::Cell( const Cell& r ) : 
mbValue(r.mbValue)
 
 void DataStream::MakeToolbarVisible()
 {
+ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return;
+
 css::uno::Reference< css::frame::XFrame > xFrame =
-
ScDocShell::GetViewData()->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
+
pViewData->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
 if (!xFrame.is())
 return;
 
@@ -523,7 +527,11 @@ bool DataStream::ImportData()
 // We no longer support this mode. To be deleted later.
 return false;
 
-if (ScDocShell::GetViewData()->GetViewShell()->NeedsRepaint())
+ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return false;
+
+if (pViewData->GetViewShell()->NeedsRepaint())
 return mbRunning;
 
 Text2Doc();
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx 
b/sc/source/ui/docshell/externalrefmgr.cxx
index 057cb3e2ae35..933cc1ad5b11 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1482,7 +1482,11 @@ void ScExternalRefLink::Closed()
 else
 {
 // The source document has changed.
-ScDocShell* pDocShell = ScDocShell::GetViewData()->GetDocShell();
+ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return ERROR_GENERAL;
+
+ScDocShell* pDocShell = pViewData->GetDocShell();
 ScDocShellModificator aMod(*pDocShell);
 pMgr->switchSrcFile(mnFileId, aFile, aFilter);
 aMod.SetDocumentModified();
diff --git a/sc/source/ui/miscdlgs/redcom.cxx b/sc/source/ui/miscdlgs/redcom.cxx
index f81da032b481..ef04bd57e1ff 100644
--- a/sc/source/ui/miscdlgs/redcom.cxx
+++ b/sc/source/ui/miscdlgs/redcom.cxx
@@ -137,10 +137,12 @@ void ScRedComDialog::SelectCell()
 
 if(rRange.IsValid(pDocShell->GetDocument()))
 {
-ScViewData* pViewData=ScDocShell::GetViewData();
-ScRange aRef=rRange.MakeRange(pDocShell->GetDocument());
-ScTabView* pTabView=pViewData->GetView();
-pTabView->MarkRange(aRef);
+if (ScViewData* pViewData = ScDocShell::GetViewData())
+{
+ScRange aRef = rRange.MakeRange(pDocShell->GetDocument());
+ScTabView* pTabView = pViewData->GetView();
+pTabView->MarkRange(aRef);
+}
 }
 }
 
diff --git a/sc/source/ui/namedlg/namepast.cxx 
b/sc/source/ui/namedlg/namepast.cxx
index 491ebe7f79f0..1d144f3fdf5c 100644
--- a/sc/source/ui/namedlg/namepast.cxx
+++ b/sc/source/ui/namedlg/namepast.cxx
@@ -43,8 +43,9 @@ ScNamePasteDlg::ScNamePasteDlg(weld::Window* pParent, 
ScDocShell* pShell)
 m_RangeMap.insert(std::make_pair(aTemp, *pName));
 }
 
-ScViewData* 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-19 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 4908ac8ca1145a258ca8a972f86c4baa8aaf8b1f
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 08:44:11 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit 39ffd246450cbf5feb68d7f5ab058b92a951066a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144359
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d3cbd98af592..9072d2824ce4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -568,7 +568,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -595,6 +598,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -614,6 +619,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -622,6 +629,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-16 Thread Xisco Fauli (via logerrit)
 sc/source/ui/docshell/docsh4.cxx |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 6f7fed899a124a1a5a34fc9fecfe270cdf980a8c
Author: Xisco Fauli 
AuthorDate: Fri Dec 16 09:53:21 2022 +0100
Commit: Xisco Fauli 
CommitDate: Fri Dec 16 11:10:50 2022 +

sc: fix null deref in ScDocShell::Execute

See 
https://crashreport.libreoffice.org/stats/signature/ScViewData::GetDispatcher()

Change-Id: I3271738b3c7f456adad1309c52195d98646f1acc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144301
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 04b605edb57a..494057b12087 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1180,11 +1180,15 @@ void ScDocShell::Execute( SfxRequest& rReq )
 #endif
 case SID_OPEN_CALC:
 {
-SfxStringItem aApp(SID_DOC_SERVICE, 
"com.sun.star.sheet.SpreadsheetDocument");
-SfxStringItem aTarget(SID_TARGETNAME, "_blank");
-GetViewData()->GetDispatcher().ExecuteList(
-SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
-{ ,  });
+ScViewData* pViewData = GetViewData();
+if (pViewData)
+{
+SfxStringItem aApp(SID_DOC_SERVICE, 
"com.sun.star.sheet.SpreadsheetDocument");
+SfxStringItem aTarget(SID_TARGETNAME, "_blank");
+pViewData->GetDispatcher().ExecuteList(
+SID_OPENDOC, SfxCallMode::API|SfxCallMode::SYNCHRON,
+{ ,  });
+}
 }
 break;
 case SID_NOTEBOOKBAR:


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-16 Thread Caolán McNamara (via logerrit)
 sc/source/filter/oox/extlstcontext.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d97f282d8ee1d23c21e12baf814ce71491f89e55
Author: Caolán McNamara 
AuthorDate: Thu Dec 15 09:53:45 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Dec 16 08:58:48 2022 +

crashtesting: relax assert seen in forum-mso-en4-503384.xlsx

maModels.size() is 1 while maPriorities.size() is 2 with this
offending xml

http://schemas.microsoft.com/office/excel/2006/main;>
 
  
   
0
   
   
0
   
   
0
   
   
   
   
  
 
 
  
AND($A3INDEX(Sheet2!$B$2:$B$50,MATCH(C$2,Sheet2!$A$2:$A$50,0)),C3=1)
  
   

 

   
  
 
 C3:Q28


Change-Id: I3b530be9adaf8a9e98488e8dc25891721ff36244
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144212
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit a13b53e780f541ebd5ca1bf95c8b5c14df30516f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144296

diff --git a/sc/source/filter/oox/extlstcontext.cxx 
b/sc/source/filter/oox/extlstcontext.cxx
index 67d52fc69da9..45e60e7c6f5e 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -283,7 +283,7 @@ void ExtConditionalFormattingContext::onEndElement()
 
maEntries.push_back(std::unique_ptr(pEntry));
 }
 
-assert(maModels.size() == maPriorities.size());
+assert(maPriorities.size() >= maModels.size());
 maModels.clear();
 }
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-15 Thread Povilas Kanapickas (via logerrit)
 sc/source/ui/view/gridwin.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 718ee019335aaabb58750adac639efe962f4858d
Author: Povilas Kanapickas 
AuthorDate: Wed Dec 7 03:13:30 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Dec 15 19:34:48 2022 +

sc: React to touchpad zoom gestures in ScGridWindow

Change-Id: I21f0e6a820149abe4457950e7382bbc7752eeb6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143757
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144231
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 5fe0a4edd7c9..3316afdf95e4 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3035,6 +3035,15 @@ void ScGridWindow::Command( const CommandEvent& rCEvt )
 Window::Command(rCEvt);
 return;
 }
+
+if (nCmd == CommandEventId::GestureZoom)
+{
+bool bDone = mrViewData.GetView()->GestureZoomCommand(rCEvt);
+if (!bDone)
+Window::Command(rCEvt);
+return;
+}
+
 // #i7560# FormulaMode check is below scrolling - scrolling is allowed 
during formula input
 bool bDisable = pScMod->IsFormulaMode() ||
 pScMod->IsModalMode(mrViewData.GetSfxDocShell());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-15 Thread Povilas Kanapickas (via logerrit)
 sc/source/ui/inc/tabview.hxx  |4 
 sc/source/ui/view/tabview.cxx |   42 ++
 2 files changed, 46 insertions(+)

New commits:
commit 7f1f6a929335552e5adb7caba78333e44f6213c3
Author: Povilas Kanapickas 
AuthorDate: Wed Dec 7 03:13:29 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Dec 15 19:34:14 2022 +

sc: React to touchpad zoom gestures in ScTabView

Change-Id: I9a946c0caf3aab03a2055740a4f467210dc07b6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143756
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144230
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index f62b2c4f9cba..7fdb0cc3c2c2 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -214,6 +214,9 @@ private:
 boolbBlockRows:1; // are whole rows selected?
 boolmbInlineWithScrollbar:1;  // should inline with 
scrollbar?
 
+double  mfLastZoomScale = 0;
+double  mfAccumulatedZoom = 0;
+
 voidInit();
 
 voidDoAddWin( ScGridWindow* pWin );
@@ -458,6 +461,7 @@ public:
 SC_DLLPUBLIC void   ScrollLines( tools::Long nDeltaX, tools::Long 
nDeltaY );  // active
 
 boolScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos 
);
+boolGestureZoomCommand(const CommandEvent& rCEvt);
 
 voidScrollToObject( const SdrObject* pDrawObj );
 voidMakeVisible( const tools::Rectangle& rHMMRect );
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index f12327b04a5d..5b2c44ee4875 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -992,6 +992,48 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, 
ScSplitPos ePos )
 return bDone;
 }
 
+bool ScTabView::GestureZoomCommand(const CommandEvent& rCEvt)
+{
+HideNoteMarker();
+
+const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData();
+if (!pData)
+return false;
+
+if (aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace())
+return false;
+
+if (pData->meEventType == GestureEventZoomType::Begin)
+{
+mfLastZoomScale = pData->mfScaleDelta;
+return true;
+}
+
+if (pData->meEventType == GestureEventZoomType::Update)
+{
+double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / 
mfLastZoomScale;
+mfLastZoomScale = pData->mfScaleDelta;
+
+// Accumulate fractional zoom to avoid small zoom changes from being 
ignored
+mfAccumulatedZoom += deltaBetweenEvents;
+int nZoomChangePercent = mfAccumulatedZoom * 100;
+mfAccumulatedZoom -= nZoomChangePercent / 100.0;
+
+const Fraction& rOldY = aViewData.GetZoomY();
+sal_uInt16 nOld = static_cast(rOldY * 100);
+sal_uInt16 nNew = nOld + nZoomChangePercent;
+nNew = std::clamp(nNew, MINZOOM, MAXZOOM);
+
+if (nNew != nOld)
+{
+SetZoomPercentFromCommand(nNew);
+}
+
+return true;
+}
+return true;
+}
+
 IMPL_LINK_NOARG(ScTabView, HScrollLeftHdl, weld::Scrollbar&, void)
 {
 ScrollHdl(aHScrollLeft.get());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-15 Thread Povilas Kanapickas (via logerrit)
 sc/source/ui/inc/tabview.hxx  |2 ++
 sc/source/ui/view/tabview.cxx |   31 ++-
 2 files changed, 20 insertions(+), 13 deletions(-)

New commits:
commit 269b058f3eb7b00e651d13b9735f33c1faa32e5b
Author: Povilas Kanapickas 
AuthorDate: Wed Dec 7 03:13:28 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Dec 15 19:33:50 2022 +

sc: Extract ScTabView::SetZoomPercentFromCommand()

Change-Id: I06ece9a99886d94bf0b3396730951760cb199e97
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143755
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144229
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index ebb7337d78b7..f62b2c4f9cba 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -254,6 +254,8 @@ private:
 
 voidPaintRangeFinderEntry (const ScRangeFindData* pData, SCTAB 
nTab);
 
+voidSetZoomPercentFromCommand(sal_uInt16 nZoomPercent);
+
 protected:
 voidUpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr,
 const SCROW* pPosY = nullptr );
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 94a9aa144ad6..f12327b04a5d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -935,6 +935,23 @@ Point ScTabView::GetGridOffset() const
 
 // ---  Scroll-Bars  
 
+void ScTabView::SetZoomPercentFromCommand(sal_uInt16 nZoomPercent)
+{
+// scroll wheel doesn't set the AppOptions default
+
+bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
+SetZoomType(SvxZoomType::PERCENT, bSyncZoom);
+Fraction aFract(nZoomPercent, 100);
+SetZoom(aFract, aFract, bSyncZoom);
+PaintGrid();
+PaintTop();
+PaintLeft();
+aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM);
+aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER);
+aViewData.GetBindings().Invalidate( SID_ZOOM_IN);
+aViewData.GetBindings().Invalidate( SID_ZOOM_OUT);
+}
+
 bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
 {
 HideNoteMarker();
@@ -957,19 +974,7 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, 
ScSplitPos ePos )
 nNew = std::min( MAXZOOM, basegfx::zoomtools::zoomIn( nOld ));
 if ( nNew != nOld )
 {
-// scroll wheel doesn't set the AppOptions default
-
-bool bSyncZoom = 
SC_MOD()->GetAppOptions().GetSynchronizeZoom();
-SetZoomType( SvxZoomType::PERCENT, bSyncZoom );
-Fraction aFract( nNew, 100 );
-SetZoom( aFract, aFract, bSyncZoom );
-PaintGrid();
-PaintTop();
-PaintLeft();
-aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM );
-aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
-aViewData.GetBindings().Invalidate( SID_ZOOM_IN);
-aViewData.GetBindings().Invalidate( SID_ZOOM_OUT);
+SetZoomPercentFromCommand(nNew);
 }
 
 bDone = true;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-15 Thread Caolán McNamara (via logerrit)
 sc/source/filter/excel/excrecds.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit d6c714e456d21105c59b061995621f68e3b0304e
Author: Caolán McNamara 
AuthorDate: Sun Dec 11 20:06:01 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Dec 15 15:20:23 2022 +

crashtesting: assert on import of forum-mso-en4-85437.xls

aParam.nCol1 of 180
aParam.nRow1 of 0
aParam.nCol2 of 0
aParam.nRow2 of 0

so a negative nColCnt

Change-Id: Ifa58287190389b61c36f4ace864516631b025548
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143948
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 90dc1ce8a1976b3c2e26791bdbabb2651ba45224)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144127

diff --git a/sc/source/filter/excel/excrecds.cxx 
b/sc/source/filter/excel/excrecds.cxx
index 3feac86be5a2..f69a5ca431c8 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -946,7 +946,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& 
rRoot, SCTAB nTab, const
 
 ScRange aRange( aParam.nCol1, aParam.nRow1, aParam.nTab,
 aParam.nCol2, aParam.nRow2, aParam.nTab );
-SCCOL   nColCnt = aParam.nCol2 - aParam.nCol1 + 1;
+aRange.PutInOrder();
+SCCOL nColCnt = aRange.aEnd.Col() - aRange.aStart.Col() + 1;
 
 maRef = aRange;
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-12 Thread Caolán McNamara (via logerrit)
 sc/source/filter/oox/pivottablebuffer.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit afa81be4b2bf36193b338979b6707e5eb48892c8
Author: Caolán McNamara 
AuthorDate: Mon Dec 12 10:34:49 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Dec 12 14:57:27 2022 +

crashtesting: null deref see on loading forum-mso-en4-531817.xlsx

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

diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index 3425c4a6c0c5..d57c17571282 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -755,8 +755,9 @@ Reference< XDataPilotField > 
PivotTableField::convertRowColPageField( sal_Int32
 {
 ScDPSaveData* pSaveData = pDPObj->GetSaveData();
 ScDPSaveDimension* pDim = 
pSaveData->GetDimensionByName(pCacheField->getName());
+SAL_WARN_IF(!pDim, "sc.filter", 
"PivotTableField::convertRowColPageField - no Dimension found for: " << 
pCacheField->getName());
 
-try
+if (pDim) try
 {
 for( const auto& rItem : maItems )
 {