[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - 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 ade4e5cc9bb5a2026d8a9bdccd18c1645a7dd032
Author: Eike Rathke 
AuthorDate: Sat Apr 29 18:59:30 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue May 2 11:09:28 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 6b6b83b43fcae13e30a9ca67b421187a5e0d7142)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151191
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index eb77bf07e514..94964b1a081c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7063,7 +7063,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();
@@ -7197,6 +7198,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-4' - 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 01ce3266484451e0984ed1ba07944745f44fc9e0
Author: Eike Rathke 
AuthorDate: Wed Apr 26 21:11:44 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 27 09:23:23 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 9a555d79b3b00793edf1d51a8a7c76b723cc436d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151024
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index b2d43c3ac769..6718c187051a 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-4' - sc/source

2023-04-19 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx |   55 +-
 sc/source/ui/inc/inputwin.hxx |   11 +++-
 2 files changed, 33 insertions(+), 33 deletions(-)

New commits:
commit c38d91abf7e719e61a51798a7abddc81ba9ff9a9
Author: Caolán McNamara 
AuthorDate: Fri Jan 20 12:47:42 2023 +
Commit: Christian Lohmaier 
CommitDate: Wed Apr 19 17:42:52 2023 +0200

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.

also includes:

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)

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 
(cherry picked from commit 9739a874b64e770728d62713b070f37de4ec8328)

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/+/148075
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index db9752da05bf..0b31b816010a 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
@@ -465,31 +469,36 @@ void ScInputWindow::Resize()
 {
 ToolBox::Resize();
 
-Size aSize = GetSizePixel();
+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() + 2 * 
(pGroupBar->GetVertOffset() + 1));
-}
+int nTopOffset = 0;
+if (nLines > 1)
+{
+// Initially 

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

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

New commits:
commit 9374b5049ee4fb425b350489272b9354075240dc
Author: Caolán McNamara 
AuthorDate: Tue Mar 21 13:29:23 2023 +
Commit: Xisco Fauli 
CommitDate: Wed Mar 22 07:43:45 2023 +

crashreporting: CreateEmbeddedObject might fail

Change-Id: I0e1ccbea92343d18e5ff3a9af1f54ed5e0dd796b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149113
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit fa1760d0c7ac8b9fb2e88f7d6d7f9de14479cbf6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149245

diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index 1337e909d1ff..1de9da95dd6b 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1763,6 +1763,9 @@ SdrObjectUniquePtr XclImpChartObj::DoCreateSdrObj( 
XclImpDffConverter& rDffConv,
 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-4' - 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 0c1c25a97dff15ace8e9fe1fe91ab1de8adaa41b
Author: Caolán McNamara 
AuthorDate: Tue Mar 7 16:43:42 2023 +
Commit: Adolfo Jayme Barrientos 
CommitDate: Tue Mar 7 20:43:42 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/+/148403
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 739fe5c12965..db9752da05bf 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -868,6 +868,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);
 }
 
 Point ScInputBarGroup::GetCursorScreenPixelPos(bool bBelow)


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - 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 6e0c8a3dbdb83b634a30dad018e1ff5f9959d055
Author: Eike Rathke 
AuthorDate: Fri Mar 3 13:39:03 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sat Mar 4 20:53:42 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/+/148218
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index e9100d76149d..1fa4500a9baf 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-4' - 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 da8ca6920b78addc827171f53a42abdd59da9f9c
Author: Eike Rathke 
AuthorDate: Mon Feb 27 16:10:06 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Feb 27 20:31:50 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/+/147900
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index e169a87f6542..e9100d76149d 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-4' - sc/source

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

New commits:
commit 146b95e138ff38aee755f4954f3305c48e2c3963
Author: Xisco Fauli 
AuthorDate: Fri Feb 17 12:44:03 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Feb 20 19:44:58 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/+/147236
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 42cc0781d26b..6f305576b3bb 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1992,13 +1992,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-4' - 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 166a07062dd4ffedca6106f439a6fcddaeee5eb5
Author: Eike Rathke 
AuthorDate: Fri Feb 17 12:03:54 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Feb 17 19:39:42 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/+/147245
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 30e79d9272bb..c1fc5f458dcb 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 e09620605d35..eb77bf07e514 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -7628,7 +7628,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.
@@ -7675,7 +7675,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-4' - 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 d246ade4ac56cc675de56fa92e7a6bb3b7e6b431
Author: Xisco Fauli 
AuthorDate: Fri Feb 10 10:50:24 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 14:31:23 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/+/146917
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/rtf/eeimpars.cxx 
b/sc/source/filter/rtf/eeimpars.cxx
index e3cdd25adee9..8d768efa5f9f 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-4' - sc/source

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

New commits:
commit 8b4d64c8916364d96c03dd371fe802413861ba7d
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 16:44:37 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 11:54:02 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/+/146767
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index a417c9d4ba74..b1492bb1c77e 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2596,48 +2596,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-4' - sc/source

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

New commits:
commit d2185f73be42c7fa3ccf3c21b2636c51f71f41be
Author: Mike Kaganski 
AuthorDate: Fri Feb 10 13:25:53 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 11:53:40 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/+/146766
Reviewed-by: Xisco Fauli 

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-4' - 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 e53c02eac4b3d231fef7a6156321edfdea1fbb27
Author: Eike Rathke 
AuthorDate: Mon Feb 6 22:59:44 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 11:52:31 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/+/146614
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 2e594a39efd9..fd4401446685 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1971,38 +1971,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-4' - sc/source

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

New commits:
commit f6aa9d4f9f5e7b46a89bf409a40b552570cf4d5f
Author: Mike Kaganski 
AuthorDate: Thu Feb 9 16:06:04 2023 +0300
Commit: Xisco Fauli 
CommitDate: Mon Feb 13 11:52:10 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-4' - sc/source

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

New commits:
commit a6582c10f73242b74d127caca987b9144bc402f9
Author: Caolán McNamara 
AuthorDate: Thu Jan 26 20:55:57 2023 +
Commit: Xisco Fauli 
CommitDate: Thu Feb 9 15:50:40 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/+/146204
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index c0ac25b257e5..e169a87f6542 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-4' - sc/source

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

New commits:
commit 9cab31e8c3a497685a2695a774e06b2277623f91
Author: Miklos Vajna 
AuthorDate: Fri Jan 13 08:56:29 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Jan 19 15:18:18 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/+/145730
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-4' - 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 138c6f1d1371f89e379f1a58b38ef8a60d63077e
Author: Eike Rathke 
AuthorDate: Wed Jan 18 18:40:50 2023 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Jan 19 08:24:39 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/+/145725
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-4' - sc/source

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

New commits:
commit bb0ed581a5624a8827ede86658872daca1754675
Author: Heiko Tietze 
AuthorDate: Fri Jan 6 09:58:25 2023 +
Commit: Xisco Fauli 
CommitDate: Thu Jan 12 09:04:48 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 
(cherry picked from commit 9d6ae0b8d2ebb3931b3c46147e14939e7ed3f3ed)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145229

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-4' - 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 f388ea5b3734aca80d7c61c850413c649294c446
Author: Eike Rathke 
AuthorDate: Tue Jan 10 01:22:38 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jan 11 13:45:47 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/+/145298
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/odffmap.cxx b/sc/source/core/tool/odffmap.cxx
index 112854f4a71c..66756c0ab64f 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-4' - sc/source

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

New commits:
commit 9476a2c29baf8dc7880fc1ae7657a3a69df8b429
Author: Caolán McNamara 
AuthorDate: Tue Jan 10 10:32:10 2023 +
Commit: Xisco Fauli 
CommitDate: Wed Jan 11 10:09:39 2023 +

Resolves: tdf#152950 don't set_active while frozen

Change-Id: I7db73e37ed426aae2282a6bf1564e5d3843442cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145231
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-4' - 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 334e8c511957f3e42e6b05a86f74107282a54186
Author: Eike Rathke 
AuthorDate: Mon Jan 9 23:18:35 2023 +0100
Commit: Eike Rathke 
CommitDate: Tue Jan 10 16:35:37 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/+/145226
Reviewed-by: Michael Stahl 

diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 3100a09833e6..ef2ae2f445d1 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -738,10 +738,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 );
 
@@ -784,7 +793,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-4' - 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 8407a506f0cffb902190858fa67559bd2685e502
Author: Mike Kaganski 
AuthorDate: Thu Dec 29 17:53:42 2022 +
Commit: Xisco Fauli 
CommitDate: Fri Dec 30 08:58:53 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/+/144813
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 0b7d79eeb62e..eced7cd861fa 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -129,7 +129,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-4' - 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 6dddcf6ca4c418a0c97f13b902aad8abf2258245
Author: Xisco Fauli 
AuthorDate: Wed Dec 21 13:27:19 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Dec 21 19:32:11 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/+/144668

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 11a9d03f9043..884e2e696c3c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -4400,6 +4400,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-4' - sc/source

2022-12-21 Thread Xisco Fauli (via logerrit)
 sc/source/filter/excel/xestream.cxx  |4 
 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, 99 insertions(+), 73 deletions(-)

New commits:
commit df6e07d47103ae58769629a33b6ac06f207332e2
Author: Xisco Fauli 
AuthorDate: Mon Dec 19 12:05:48 2022 +0100
Commit: Eike Rathke 
CommitDate: Wed Dec 21 16:26:27 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 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144579
Reviewed-by: Eike Rathke 

diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index b94959292891..f0486cc37493 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -1047,8 +1047,8 @@ 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() );
 
 OUString const workbook = "xl/workbook.xml";
 const char* pWorkbookContentType = nullptr;
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 a0f93781b0f5..fe731684a44a 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1481,7 +1481,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 c6851abcc426..37984eb8b79d 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, 
std::make_unique(*pName)));
 }
 
-ScViewData* pViewData = ScDocShell::GetViewData();
-ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), 
pViewData->GetTabNo());
+ScAddress aPos;

[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - 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 97ad52082df46e665293c21621eab2f147db41d6
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 11:55:17 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/+/144433
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 46933719e135..f030ff8b484f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -571,7 +571,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)
 {
@@ -598,6 +601,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);
@@ -617,6 +622,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -625,6 +632,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-4' - 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 bc30e84919b698b2d3b5a7330fbf646708b55d3d
Author: Xisco Fauli 
AuthorDate: Fri Dec 16 09:53:21 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Dec 16 14:52:02 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/+/144302
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 14f0bc4a4615..8b8220106b35 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1177,11 +1177,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-4' - sc/source

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

New commits:
commit e7256105d956a1394112ebbb8a718a5126a804b5
Author: Caolán McNamara 
AuthorDate: Mon Dec 12 10:34:49 2022 +
Commit: Xisco Fauli 
CommitDate: Wed Dec 14 08:41:38 2022 +

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

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

diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index 71ecbb49f947..3aadd5860264 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 )
 {


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

2022-12-13 Thread Caolán McNamara (via logerrit)
 sc/source/ui/unoobj/chart2uno.cxx |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 0aa3c2b165e740cfa669a16808ab19c67556b77f
Author: Caolán McNamara 
AuthorDate: Sun Dec 11 21:26:01 2022 +
Commit: Michael Stahl 
CommitDate: Tue Dec 13 10:49:56 2022 +

crashtesting: use of uninitialized data in forum-mso-en4-93354.xls

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

diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index 5beaf2f55ad6..8de29306e578 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -534,7 +534,14 @@ void Chart2Positioner::glueState()
 }
 
 ScComplexRefData aData;
-ScRefTokenHelper::getDoubleRefDataFromToken(aData, mrRefTokens.front());
+if (!ScRefTokenHelper::getDoubleRefDataFromToken(aData, 
mrRefTokens.front()))
+{
+SAL_WARN("sc", "Chart2Positioner::glueState getDoubleRefDataFromToken 
failed");
+invalidateGlue();
+mnStartCol = 0;
+mnStartRow = 0;
+return;
+}
 mnStartCol = aData.Ref1.Col();
 mnStartRow = aData.Ref1.Row();
 


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

2022-12-12 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/address.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 19b7008d14ca106fdddcefaa1c43ac05ba49fd2c
Author: Caolán McNamara 
AuthorDate: Mon Dec 12 10:19:36 2022 +
Commit: Xisco Fauli 
CommitDate: Mon Dec 12 14:53:09 2022 +

crashtesting: assert seen on loading forum-mso-en4-497867.xlsx

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

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index ca1010a393bd..a1e93472f2c4 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2094,7 +2094,7 @@ static void lcl_Split_DocTab( const ScDocument& rDoc,  
SCTAB nTab,
 rDoc.GetName(nTab, rTabName);
 rDocName.clear();
 // External reference, same as in ScCompiler::MakeTabStr()
-if ( rTabName[0] == '\'' )
+if (!rTabName.isEmpty() && rTabName[0] == '\'')
 {   // "'Doc'#Tab"
 sal_Int32 nPos = ScCompiler::GetDocTabPos( rTabName);
 if (nPos != -1)


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

2022-12-08 Thread Caolán McNamara (via logerrit)
 sc/source/ui/cctrl/checklistmenu.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a52335fd454ca23db5969f661dc7cf8b22bbbfeb
Author: Caolán McNamara 
AuthorDate: Thu Dec 8 12:02:32 2022 +
Commit: Eike Rathke 
CommitDate: Thu Dec 8 16:36:09 2022 +

Resolves: tdf#152325 initial "select" may not set the cursor to that pos

but setting the cursor will 'select' for the default "single" selection
mode.

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

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx 
b/sc/source/ui/cctrl/checklistmenu.cxx
index 833857614e72..82e7488c9804 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1345,7 +1345,7 @@ size_t ScCheckListMenuControl::initMembers(int 
nMaxMemberWidth)
 }
 
 if (nVisMemCount)
-mpChecks->select(0);
+mpChecks->set_cursor(0);
 
 return nVisMemCount;
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sc/source sd/source vcl/qa

2022-11-29 Thread Michael Stahl (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |6 ++
 sd/source/ui/unoidl/unomodel.cxx   |6 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   10 ++
 3 files changed, 22 insertions(+)

New commits:
commit 5afdc179c52d4a71def825eaeb9deef53d57942d
Author: Michael Stahl 
AuthorDate: Fri Nov 25 18:52:50 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Nov 29 10:39:52 2022 +0100

tdf#67866 sc,sd: PDF/UA export: set language in Catalog

sw already does this, and it's recommended in
https://www.w3.org/WAI/GL/WCAG20-TECHS/PDF16.html

Change-Id: I0ce36442ec1b223c40f53fac3683ad7bb0e2bc6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143307
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 0e4ff2261f3c2c9dada5816f11095652e028c3dd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143435
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 2f27948d0fe2..46933719e135 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2233,6 +2233,12 @@ void SAL_CALL ScModelObj::render( sal_Int32 
nSelRenderer, const uno::Any& aSelec
 vcl::PDFExtOutDevData* pPDFData = dynamic_cast< vcl::PDFExtOutDevData* 
>(pDev->GetExtOutDevData() );
 if ( nRenderer == nTabStart )
 {
+if (pPDFData)
+{
+css::lang::Locale const 
docLocale(LanguageTag(ScGlobal::GetEditDefaultLanguage()).getLocale());
+pPDFData->SetDocumentLocale(docLocale);
+}
+
 // first page of a sheet: add outline item for the sheet name
 
 if ( pPDFData && pPDFData->GetIsExportBookmarks() )
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 69807d47dab0..758ce1380099 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1866,6 +1866,12 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
 !(pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
 return;
 
+if (pPDFExtOutDevData)
+{
+css::lang::Locale const 
docLocale(Application::GetSettings().GetLanguageTag().getLocale());
+pPDFExtOutDevData->SetDocumentLocale(docLocale);
+}
+
 ::sd::ClientView aView( mpDocShell, pOut );
 ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( 
static_cast(nPageNumber) - 1, ePageKind )->GetSize() );
 vcl::Region   aRegion( aVisArea );
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 07a0b2057d2a..6b0f90a0581f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -891,6 +891,16 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testAlternativeText)
 }
 }
 }
+
+// tdf#67866 check that Catalog contains Lang
+auto* pCatalog = aDocument.GetCatalog();
+CPPUNIT_ASSERT(pCatalog);
+auto* pCatalogDictionary = pCatalog->GetDictionary();
+CPPUNIT_ASSERT(pCatalogDictionary);
+auto pLang = dynamic_cast(
+pCatalogDictionary->LookupElement("Lang"));
+CPPUNIT_ASSERT(pLang);
+CPPUNIT_ASSERT_EQUAL(OString("en-US"), pLang->GetValue());
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972)


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

2022-11-23 Thread Balazs Varga (via logerrit)
 sc/source/core/data/drwlayer.cxx |   24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit 2194fdaef01f667dd4ef476504981867ad2c80e2
Author: Balazs Varga 
AuthorDate: Mon Nov 21 11:12:15 2022 +0100
Commit: Eike Rathke 
CommitDate: Wed Nov 23 17:19:31 2022 +0100

tdf#46444 tdf#152081 sc: hide notes in hidden rows or columns

Hide notes in hidden rows or columns just like we do
in case of other sdrobjects.

TODO: unit test

Change-Id: Ib136324d5d0dd8777fc0912af6d8b9ac39935ac1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143024
Tested-by: Jenkins
Reviewed-by: Balazs Varga 
(cherry picked from commit b71303fe1b06c1711ad80e5a0269d41ccaaad8e1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143070
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 6302f044eea7..295593712c7f 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1031,13 +1031,17 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, 
ScDrawObjData& rData, bool bNegati
 position must not be done, if the cell containing the note has not
 been moved yet in the document. The calling code now passes an
 additional boolean stating if the cells are already moved. */
-if( bUpdateNoteCaptionPos )
+/*  tdf #152081 Do not change hidden objects. That would produce zero 
height
+or width and loss of caption.*/
+if (pObj->IsVisible() && bUpdateNoteCaptionPos)
+{
 /*  When inside an undo action, there may be pending note captions
 where cell note is already deleted (thus document cannot find
 the note object anymore). The caption will be deleted later
 with drawing undo. */
 if( ScPostIt* pNote = pDoc->GetNote( rData.maStart ) )
 pNote->UpdateCaptionPos( rData.maStart );
+}
 return;
 }
 
@@ -2474,12 +2478,9 @@ ScDrawLayer::GetObjectsAnchoredToRows(SCTAB nTab, SCROW 
nStartRow, SCROW nEndRow
 ScRange aRange( 0, nStartRow, nTab, pDoc->MaxCol(), nEndRow, nTab);
 while (pObject)
 {
-if (!dynamic_cast(pObject)) // Caption objects are 
handled differently
-{
-ScDrawObjData* pObjData = GetObjData(pObject);
-if (pObjData && aRange.Contains(pObjData->maStart))
-aObjects.push_back(pObject);
-}
+ScDrawObjData* pObjData = GetObjData(pObject);
+if (pObjData && aRange.Contains(pObjData->maStart))
+aObjects.push_back(pObject);
 pObject = aIter.Next();
 }
 return aObjects;
@@ -2546,12 +2547,9 @@ std::vector 
ScDrawLayer::GetObjectsAnchoredToCols(SCTAB nTab, SCCOL
 ScRange aRange(nStartCol, 0, nTab, nEndCol, pDoc->MaxRow(), nTab);
 while (pObject)
 {
-if (!dynamic_cast(pObject)) // Caption objects are 
handled differently
-{
-ScDrawObjData* pObjData = GetObjData(pObject);
-if (pObjData && aRange.Contains(pObjData->maStart))
-aObjects.push_back(pObject);
-}
+ScDrawObjData* pObjData = GetObjData(pObject);
+if (pObjData && aRange.Contains(pObjData->maStart))
+aObjects.push_back(pObject);
 pObject = aIter.Next();
 }
 return aObjects;


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

2022-11-17 Thread Eike Rathke (via logerrit)
 sc/source/core/data/column2.cxx |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 6fb437e6cef4ca402e81ee8037f361a4de911549
Author: Eike Rathke 
AuthorDate: Tue Nov 15 18:19:23 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Nov 17 17:22:03 2022 +0100

Resolves: tdf#152053 GetOptimalColWidth() obtain number format from next row

... if 1st or 2nd row doesn't have one applied, i.e. is header.

Change-Id: I4b33fa4abcbe74b02d416cfa494c0813a8f0086e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142744
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 8309f94001ec29faff288cb8f920ee00978bb85a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142687
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 9d93bc6fd032..b7922d740a96 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -739,7 +739,8 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
 
 if ( pParam && pParam->mbSimpleText )
 {   // all the same except for number format
-const ScPatternAttr* pPattern = GetPattern( 0 );
+SCROW nRow = 0;
+const ScPatternAttr* pPattern = GetPattern( nRow );
 vcl::Font aFont;
 // font color doesn't matter here
 pPattern->GetFont( aFont, SC_AUTOCOL_BLACK, pDev,  );
@@ -751,6 +752,17 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
 // Try to find the row that has the longest string, and measure the 
width of that string.
 SvNumberFormatter* pFormatter = rDocument.GetFormatTable();
 sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter );
+while ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && nRow <= 2)
+{
+// This is often used with CSV import or other data having a header
+// row; if there is no specific format set try next row for actual
+// data format.
+// Or again in case there was a leading sep=";" row or two header
+// rows..
+const ScPatternAttr* pNextPattern = GetPattern( ++nRow );
+if (pNextPattern != pPattern)
+nFormat = pNextPattern->GetNumberFormat( pFormatter );
+}
 OUString aLongStr;
 const Color* pColor;
 if (pParam->mnMaxTextRow >= 0)


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

2022-11-15 Thread Eike Rathke (via logerrit)
 sc/source/ui/docshell/impex.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 881fb6f7c06444c58551f71730d97c51a840fbf5
Author: Eike Rathke 
AuthorDate: Thu Nov 10 20:40:44 2022 +0100
Commit: Michael Stahl 
CommitDate: Tue Nov 15 11:13:06 2022 +0100

Resolves: tdf#151947 Merging separators must not scan for field end

Regression introduced with

commit cf777cfcb22647b1f2d6ace307fbcc4f6d2cca30
CommitDate: Sun Oct 2 17:07:06 2022 +0200

Resolves: tdf#125110 tdf#151211 Disentangle the convoluted 
CSV/TSV-clip import

a copy-paste replacement logic error.

Change-Id: Ibd699a4edfa9f88da26d888afa8567ee34e78a5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142572
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 5db9d8356c8fdc732942357cd2171ba27eda8647)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142527
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 3be11884ca72..3f80f88ef9b6 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1924,7 +1924,7 @@ const sal_Unicode* 
ScImportExport::ScanNextFieldFromString( const sal_Unicode* p
 }
 if ( bMergeSeps )   // skip following delimiters
 {
-while (!lcl_isFieldEnd( *p, pSeps))
+while (*p && ScGlobal::UnicodeStrChr( pSeps, *p))
 p++;
 }
 return p;


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

2022-11-13 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpretercontext.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit f7f4b00185318c1f2949ca42316e1a92c57da23b
Author: Eike Rathke 
AuthorDate: Sat Nov 12 21:12:18 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Nov 13 18:33:55 2022 +0100

Resolves: tdf#152014 When reusing interpreter context slot clear lookup 
cache

... if different doc

As is, unthreaded the same slot gets reused for every calculation.
That could benefit from keeping 2-3 documents cached to not throw
away the lookup cache each time when alternating between
documents.

Change-Id: Id024333f72bcdcd6109042dec1104f3029955d3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142639
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit f86a0666ac337363b470c9c67fa0970a330b26a2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142630
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpretercontext.cxx 
b/sc/source/core/tool/interpretercontext.cxx
index 0df4a8407c9c..e66a8b977446 100644
--- a/sc/source/core/tool/interpretercontext.cxx
+++ b/sc/source/core/tool/interpretercontext.cxx
@@ -53,7 +53,11 @@ void ScInterpreterContext::ResetTokens()
 
 void ScInterpreterContext::SetDocAndFormatter(const ScDocument& rDoc, 
SvNumberFormatter* pFormatter)
 {
-mpDoc = 
+if (mpDoc != )
+{
+mxScLookupCache.reset();
+mpDoc = 
+}
 mpFormatter = pFormatter;
 }
 


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

2022-11-09 Thread Balazs Varga (via logerrit)
 sc/source/filter/xml/xmlrowi.cxx |   29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

New commits:
commit ba59e8e3544190f4c1464d2ce18b1386c0d8a678
Author: Balazs Varga 
AuthorDate: Tue Oct 11 09:43:20 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Nov 9 16:34:03 2022 +0100

tdf#124098: sc, ods import: do not recalculate row heights

if we have already optimal heights in the xml, because it is
not necessary and it takes a lot of time loading a file.

Citing here for completeness:
a) if there is no height attribute and the "use_optimal-row-height"
attribute is set then calculate the row height

b) if there is a height attribute just use it and do not recalculate.

Maybe TODO for later: optimize row height calculation more in sc

Change-Id: I9d964aad744970e5d36f239c0ce39ce98c00f273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141204
Tested-by: Jenkins
Tested-by: Balazs Varga 
Reviewed-by: Balazs Varga 
(cherry picked from commit e8fae4d0fb2994a7b4ac00e9da35e1deccb296dd)
(cherry picked from commit b57307e8f3553fcb292c9c11fcf58bcef3a6cb3c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141317
Reviewed-by: Eike Rathke 

diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index fc6a3a7c36c4..d510d5557eed 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -21,6 +21,7 @@
 #include "xmlimprt.hxx"
 #include "xmlcelli.hxx"
 #include "xmlstyli.hxx"
+#include "xmlstyle.hxx"
 #include 
 #include 
 #include 
@@ -28,6 +29,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -166,6 +168,8 @@ void SAL_CALL 
ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
 if (!xRowProperties.is())
 return;
 
+XMLTableStyleContext* ptmpStyle = nullptr;
+
 if (!sStyleName.isEmpty())
 {
 XMLTableStylesContext *pStyles(static_cast(rXMLImport.GetAutoStyles()));
@@ -183,6 +187,9 @@ void SAL_CALL 
ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
 pSheetData->AddRowStyle( sStyleName, ScAddress( 0, 
static_cast(nFirstRow), nSheet ) );
 pStyle->SetLastSheet(nSheet);
 }
+
+// for later checking of optimal row height
+ptmpStyle = pStyle;
 }
 }
 }
@@ -209,14 +216,32 @@ void SAL_CALL 
ScXMLTableRowContext::endFastElement(sal_Int32 /*nElement*/)
 any >>= bOptionalHeight;
 if (bOptionalHeight)
 {
-// Save this row for later height update
+// Save this row for later height update, only if we have no already 
optimal row heights
+// If we have already optimal row heights, recalc only the first 200 
row in case of optimal document loading
 std::vector& rRecalcRanges = 
rXMLImport.GetRecalcRowRanges();
 while (static_cast(rRecalcRanges.size()) <= nSheet)
 {
 rRecalcRanges.emplace_back(0, pDoc->MaxRow());
 }
 rRecalcRanges.at(nSheet).mnTab = nSheet;
-rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow);
+
+// check that, we already have valid optimal row heights
+if (nCurrentRow > 200 && ptmpStyle && 
!ptmpStyle->FindProperty(CTF_SC_ROWHEIGHT))
+{
+XMLPropertyState* pOptimalHeight = 
ptmpStyle->FindProperty(CTF_SC_ROWOPTIMALHEIGHT);
+if (pOptimalHeight && ::cppu::any2bool(pOptimalHeight->maValue))
+{
+rRecalcRanges.at(nSheet).maRanges.setFalse(nFirstRow, 
nCurrentRow);
+}
+else
+{
+rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, 
nCurrentRow);
+}
+}
+else
+{
+rRecalcRanges.at(nSheet).maRanges.setTrue(nFirstRow, nCurrentRow);
+}
 }
 }
 


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

2022-11-09 Thread Caolán McNamara (via logerrit)
 sc/source/filter/excel/xlstyle.cxx |   10 --
 sc/source/filter/inc/xlstyle.hxx   |2 --
 2 files changed, 4 insertions(+), 8 deletions(-)

New commits:
commit 61fb619b43534e47c5d3fbc125257b0e48499213
Author: Caolán McNamara 
AuthorDate: Tue Nov 8 09:53:26 2022 +
Commit: Eike Rathke 
CommitDate: Wed Nov 9 16:29:43 2022 +0100

tdf#122188 border colors should be the same regardless of the desktop theme

Change-Id: Ifc0297135981b315ce8646e0ca2fe8a899d49f32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142423
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 2e97f7596c2d933e87391a5648341f885975c51b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142481

diff --git a/sc/source/filter/excel/xlstyle.cxx 
b/sc/source/filter/excel/xlstyle.cxx
index 886a3a657617..ae4a6f1f6f37 100644
--- a/sc/source/filter/excel/xlstyle.cxx
+++ b/sc/source/filter/excel/xlstyle.cxx
@@ -94,8 +94,6 @@ XclDefaultPalette::XclDefaultPalette( const XclRoot& rRoot ) :
 mnTableSize( 0 )
 {
 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
-mnWindowText = rSett.GetWindowTextColor();
-mnWindowBack = rSett.GetWindowColor();
 mnFaceColor = rSett.GetFaceColor();
 // Don't use the system HelpBack and HelpText colours as it causes problems
 // with modern gnome. This is because mnNoteText and mnNoteBack are used
@@ -147,12 +145,12 @@ Color XclDefaultPalette::GetDefColor( sal_uInt16 
nXclIndex ) const
 else switch( nXclIndex )
 {
 case EXC_COLOR_WINDOWTEXT3:
-case EXC_COLOR_WINDOWTEXT:  nColor = mnWindowText;  break;
-case EXC_COLOR_WINDOWBACK3:
-case EXC_COLOR_WINDOWBACK:  nColor = mnWindowBack;  break;
-case EXC_COLOR_BUTTONBACK:  nColor = mnFaceColor;   break;
+case EXC_COLOR_WINDOWTEXT:
 case EXC_COLOR_CHWINDOWTEXT:nColor = COL_BLACK; break;
+case EXC_COLOR_WINDOWBACK3:
+case EXC_COLOR_WINDOWBACK:
 case EXC_COLOR_CHWINDOWBACK:nColor = COL_WHITE; break;
+case EXC_COLOR_BUTTONBACK:  nColor = mnFaceColor;   break;
 case EXC_COLOR_CHBORDERAUTO:nColor = COL_BLACK; break;  // 
TODO: really always black?
 case EXC_COLOR_NOTEBACK:nColor = mnNoteBack;break;
 case EXC_COLOR_NOTETEXT:nColor = mnNoteText;break;
diff --git a/sc/source/filter/inc/xlstyle.hxx b/sc/source/filter/inc/xlstyle.hxx
index 69f4f9dabc15..098d2d3346b8 100644
--- a/sc/source/filter/inc/xlstyle.hxx
+++ b/sc/source/filter/inc/xlstyle.hxx
@@ -263,8 +263,6 @@ public:
 
 private:
 const Color*mpnColorTable;  /// The table with RGB values.
-Color   mnWindowText;   /// System window text color.
-Color   mnWindowBack;   /// System window background color.
 Color   mnFaceColor;/// System button background color.
 Color   mnNoteText; /// Note text color.
 Color   mnNoteBack; /// Note background color.


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

2022-11-09 Thread Caolán McNamara (via logerrit)
 sc/source/filter/excel/xlstyle.cxx |8 
 sc/source/filter/inc/xlstyle.hxx   |4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit ba9780ab214b725122b211b5a9545ba0f8d5b430
Author: Caolán McNamara 
AuthorDate: Mon Nov 7 12:55:33 2022 +
Commit: Adolfo Jayme Barrientos 
CommitDate: Wed Nov 9 13:05:41 2022 +0100

tdf#151610 chart colors should be the same regardless of the desktop theme

Change-Id: I47ae80f744401bd13452ec8879cb8f420e35b9ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142383
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit f8ad054de38a6592b60ab850e938e6e81ec4cc0d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142310
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/filter/excel/xlstyle.cxx 
b/sc/source/filter/excel/xlstyle.cxx
index b5de24df06a4..886a3a657617 100644
--- a/sc/source/filter/excel/xlstyle.cxx
+++ b/sc/source/filter/excel/xlstyle.cxx
@@ -147,12 +147,12 @@ Color XclDefaultPalette::GetDefColor( sal_uInt16 
nXclIndex ) const
 else switch( nXclIndex )
 {
 case EXC_COLOR_WINDOWTEXT3:
-case EXC_COLOR_WINDOWTEXT:
-case EXC_COLOR_CHWINDOWTEXT:nColor = mnWindowText;  break;
+case EXC_COLOR_WINDOWTEXT:  nColor = mnWindowText;  break;
 case EXC_COLOR_WINDOWBACK3:
-case EXC_COLOR_WINDOWBACK:
-case EXC_COLOR_CHWINDOWBACK:nColor = mnWindowBack;  break;
+case EXC_COLOR_WINDOWBACK:  nColor = mnWindowBack;  break;
 case EXC_COLOR_BUTTONBACK:  nColor = mnFaceColor;   break;
+case EXC_COLOR_CHWINDOWTEXT:nColor = COL_BLACK; break;
+case EXC_COLOR_CHWINDOWBACK:nColor = COL_WHITE; break;
 case EXC_COLOR_CHBORDERAUTO:nColor = COL_BLACK; break;  // 
TODO: really always black?
 case EXC_COLOR_NOTEBACK:nColor = mnNoteBack;break;
 case EXC_COLOR_NOTETEXT:nColor = mnNoteText;break;
diff --git a/sc/source/filter/inc/xlstyle.hxx b/sc/source/filter/inc/xlstyle.hxx
index 3581f77f0162..69f4f9dabc15 100644
--- a/sc/source/filter/inc/xlstyle.hxx
+++ b/sc/source/filter/inc/xlstyle.hxx
@@ -207,8 +207,8 @@ const sal_uInt16 EXC_COLOR_WINDOWBACK3  = 25;   /// 
System window backgr
 const sal_uInt16 EXC_COLOR_WINDOWTEXT   = 64;   /// System window text 
color (>=BIFF5).
 const sal_uInt16 EXC_COLOR_WINDOWBACK   = 65;   /// System window 
background color (>=BIFF5).
 const sal_uInt16 EXC_COLOR_BUTTONBACK   = 67;   /// System button 
background color (face color).
-const sal_uInt16 EXC_COLOR_CHWINDOWTEXT = 77;   /// System window text 
color (BIFF8 charts).
-const sal_uInt16 EXC_COLOR_CHWINDOWBACK = 78;   /// System window 
background color (BIFF8 charts).
+const sal_uInt16 EXC_COLOR_CHWINDOWTEXT = 77;   /// Chart window text 
color (BIFF8 charts).
+const sal_uInt16 EXC_COLOR_CHWINDOWBACK = 78;   /// Chart window 
background color (BIFF8 charts).
 const sal_uInt16 EXC_COLOR_CHBORDERAUTO = 79;   /// Automatic frame 
border for series (BIFF8 charts).
 const sal_uInt16 EXC_COLOR_NOTEBACK = 80;   /// Note background 
color.
 const sal_uInt16 EXC_COLOR_NOTETEXT = 81;   /// Note text color.


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

2022-11-02 Thread Eike Rathke (via logerrit)
 sc/source/filter/xml/XMLTableMasterPageExport.cxx |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit b6ed0378b4ae893c7631f36d754497a1162244b5
Author: Eike Rathke 
AuthorDate: Wed Nov 2 00:12:30 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Nov 2 09:34:21 2022 +0100

Resolves: tdf#147141 style:header-first/footer-first only ODF 
1.3|1.2-extended

For ODF 1.2-extended write with loext namespace, for ODF 1.2 and
earlier do not write them at all.

LO versions <7.2.5 not having the fix for tdf#144940 need ODF 1.2
written (without header-first and footer-first) to not lose the
header/footer.

Change-Id: Id856459eac487ddd8ba0c6963db5d4e227d82093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142127
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 71081a2a79a7b5a1eefec60fc687c533a95d190d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142140
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/xml/XMLTableMasterPageExport.cxx 
b/sc/source/filter/xml/XMLTableMasterPageExport.cxx
index 59b29378ea16..61899e651e53 100644
--- a/sc/source/filter/xml/XMLTableMasterPageExport.cxx
+++ b/sc/source/filter/xml/XMLTableMasterPageExport.cxx
@@ -68,6 +68,17 @@ void XMLTableMasterPageExport::exportHeaderFooter(const 
css::uno::Reference < cs
 if( !xHeaderFooter.is() )
 return;
 
+sal_uInt16 nNameSpace = XML_NAMESPACE_STYLE;
+if (aName == XML_HEADER_FIRST || aName == XML_FOOTER_FIRST)
+{
+// Since ODF 1.3 OFFICE-3789 or 1.2-extended.
+auto const nVersion(GetExport().getSaneDefaultVersion());
+if (nVersion <= SvtSaveOptions::ODFSVER_012)
+return;
+if (nVersion < SvtSaveOptions::ODFSVER_013)
+nNameSpace = XML_NAMESPACE_LO_EXT;
+}
+
 Reference < XText > xCenter(xHeaderFooter->getCenterText());
 Reference < XText > xLeft(xHeaderFooter->getLeftText());
 Reference < XText > xRight(xHeaderFooter->getRightText());
@@ -81,7 +92,7 @@ void XMLTableMasterPageExport::exportHeaderFooter(const 
css::uno::Reference < cs
 if( !bDisplay )
 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
 XML_DISPLAY, XML_FALSE );
-SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
+SvXMLElementExport aElem( GetExport(), nNameSpace,
   aName, true, true );
 if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
 exportHeaderFooterContent( xCenter, false, false );


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

2022-10-24 Thread Eike Rathke (via logerrit)
 sc/source/core/data/funcdesc.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9d0f9c199b8875d2d185c1848d4d5cfaff7cf260
Author: Eike Rathke 
AuthorDate: Mon Oct 24 15:13:22 2022 +0200
Commit: Caolán McNamara 
CommitDate: Mon Oct 24 22:15:26 2022 +0200

Resolves: tdf#140554 Function Wizard, FIXED() second parameter is optional

Change-Id: I1d559601f0cace4719aa6f8adc4e4230494e905d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141766
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 633db8a099e3041bc10fb1709311bd6055ab61a2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141744
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 1fa47a5db718..060cda7a5f6d 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -602,7 +602,7 @@ ScFunctionList::ScFunctionList( bool bEnglishFunctionNames )
 { SC_OPCODE_AREAS, ENTRY(SC_OPCODE_AREAS_ARY), 0, 
ID_FUNCTION_GRP_TABLE, HID_FUNC_BEREICHE, 1, { 0 }, 0 },
 { SC_OPCODE_CURRENCY, ENTRY(SC_OPCODE_CURRENCY_ARY), 0, 
ID_FUNCTION_GRP_TEXT, HID_FUNC_DM, 2, { 0, 1 }, 0 },
 { SC_OPCODE_REPLACE, ENTRY(SC_OPCODE_REPLACE_ARY), 0, 
ID_FUNCTION_GRP_TEXT, HID_FUNC_ERSETZEN, 4, { 0, 0, 0, 0 }, 0 },
-{ SC_OPCODE_FIXED, ENTRY(SC_OPCODE_FIXED_ARY), 0, 
ID_FUNCTION_GRP_TEXT, HID_FUNC_FEST, 3, { 0, 0, 1 }, 0 },
+{ SC_OPCODE_FIXED, ENTRY(SC_OPCODE_FIXED_ARY), 0, 
ID_FUNCTION_GRP_TEXT, HID_FUNC_FEST, 3, { 0, 1, 1 }, 0 },
 { SC_OPCODE_FIND, ENTRY(SC_OPCODE_FIND_ARY), 0, ID_FUNCTION_GRP_TEXT, 
HID_FUNC_FINDEN, 3, { 0, 0, 1 }, 0 },
 { SC_OPCODE_EXACT, ENTRY(SC_OPCODE_EXACT_ARY), 0, 
ID_FUNCTION_GRP_TEXT, HID_FUNC_IDENTISCH, 2, { 0, 0 }, 0 },
 { SC_OPCODE_LEFT, ENTRY(SC_OPCODE_LEFT_ARY), 0, ID_FUNCTION_GRP_TEXT, 
HID_FUNC_LINKS, 2, { 0, 1 }, 0 },


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

2022-10-24 Thread Eike Rathke (via logerrit)
 sc/source/ui/app/inputhdl.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit cde779398e0924e77d630cbe3fbb71c0439939f7
Author: Eike Rathke 
AuthorDate: Sat Oct 22 23:22:15 2022 +0200
Commit: Caolán McNamara 
CommitDate: Mon Oct 24 18:18:21 2022 +0200

Resolves: tdf#150780 Overtyping is not editing

Change-Id: Ie83245479e4f356cf120dae1da39d35a9bb1a2e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141676
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 9d1d668a608cc5b406601c2f7f3d8581e8f47d1c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141593
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index dd1f9f61958a..11a9d03f9043 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2560,7 +2560,9 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool 
bFromCommand, bool bIn
 }
 else
 aStr = GetEditText(mpEditEngine.get());
-mbEditingExistingContent = !aStr.isEmpty();
+
+// cTyped!=0 is overtyping, not editing.
+mbEditingExistingContent = !cTyped && !aStr.isEmpty();
 
 if (aStr.startsWith("{=") && aStr.endsWith("}") )  // Matrix 
formula?
 {


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

2022-10-13 Thread Samuel Mehrbrodt (via logerrit)
 sc/source/ui/view/tabvwsh4.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 36c1be166c991611e4f164e7b7d82f8c81c8ebce
Author: Samuel Mehrbrodt 
AuthorDate: Thu Oct 13 09:16:35 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Thu Oct 13 21:35:41 2022 +0200

tdf#150664 Initialize input line correctly

Initialize code was not called when xlsx file was loaded
(line count is only stored in ods format).

Change-Id: I5b01f6079921af77ffd6da09ae5d5388b8beff1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141281
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit f13606b613585b5e6611429dc3e699740dfeed5a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141193
Reviewed-by: Thorsten Behrens 

diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index fb41a4b1d715..edf1c5c3efd9 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -133,7 +133,7 @@ void ScTabViewShell::Activate(bool bMDI)
 ScInputWindow* pWin = 
static_cast(pChild->GetWindow());
 if (pWin && pWin->IsVisible())
 {
-
+pWin->NumLinesChanged(); // tdf#150664
 ScInputHandler* pOldHdl=pWin->GetInputHandler();
 
 SfxViewShell* pSh = SfxViewShell::GetFirst( true, 
checkSfxViewShell );


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

2022-10-11 Thread Mike Kaganski (via logerrit)
 sc/source/ui/docshell/impex.cxx  |   22 --
 sw/source/core/fields/ddefld.cxx |   10 +++---
 2 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit 2df4bd1dda0b233aadd8e09012df7b8530fa631c
Author: Mike Kaganski 
AuthorDate: Sat Oct 8 22:10:44 2022 +0300
Commit: Xisco Fauli 
CommitDate: Tue Oct 11 16:34:54 2022 +0200

tdf#151429: don't convert OUStrings to system encoding

... just to convert back to OUString in the end.

Change-Id: I727d5e4c03d1a49f64bd5ca3d64157a9149cd9ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141125
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 94df17f58fe6269452b7252b712a89978c444bec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141073
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 9c43453f2fc3..3be11884ca72 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -288,14 +288,24 @@ bool ScImportExport::ExportData( const OUString& 
rMimeType,
  css::uno::Any & rValue )
 {
 SvMemoryStream aStrm;
+SotClipboardFormatId fmtId = 
SotExchange::GetFormatIdFromMimeType(rMimeType);
+if (fmtId == SotClipboardFormatId::STRING)
+aStrm.SetStreamCharSet(RTL_TEXTENCODING_UNICODE);
 // mba: no BaseURL for data exchange
-if( ExportStream( aStrm, OUString(),
-SotExchange::GetFormatIdFromMimeType( rMimeType ) ))
+if (ExportStream(aStrm, OUString(), fmtId))
 {
-aStrm.WriteUChar( 0 );
-rValue <<= css::uno::Sequence< sal_Int8 >(
-static_cast(aStrm.GetData()),
-aStrm.TellEnd() );
+if (fmtId == SotClipboardFormatId::STRING)
+{
+assert(aStrm.TellEnd() % sizeof(sal_Unicode) == 0);
+rValue <<= OUString(static_cast(aStrm.GetData()),
+aStrm.TellEnd() / sizeof(sal_Unicode));
+}
+else
+{
+aStrm.WriteUChar(0);
+rValue <<= css::uno::Sequence(static_cast(aStrm.GetData()),
+aStrm.TellEnd());
+}
 return true;
 }
 return false;
diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index 8b326d02cd62..f73a2b641820 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -69,9 +69,13 @@ public:
 case SotClipboardFormatId::STRING:
 if( !IsNoDataFlag() )
 {
-uno::Sequence< sal_Int8 > aSeq;
-rValue >>= aSeq;
-OUString sStr( reinterpret_cast(aSeq.getConstArray()), aSeq.getLength(), osl_getThreadTextEncoding() );
+OUString sStr;
+if (!(rValue >>= sStr))
+{
+uno::Sequence< sal_Int8 > aSeq;
+rValue >>= aSeq;
+sStr = OUString(reinterpret_cast(aSeq.getConstArray()), aSeq.getLength(), osl_getThreadTextEncoding());
+}
 
 // remove not needed CR-LF at the end
 sal_Int32 n = sStr.getLength();


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

2022-10-11 Thread Eike Rathke (via logerrit)
 sc/source/core/data/table4.cxx |   35 ++-
 1 file changed, 30 insertions(+), 5 deletions(-)

New commits:
commit 50baf45b122d4a0e32a5b63cfa5b51606b37bc9e
Author: Eike Rathke 
AuthorDate: Tue Oct 11 12:33:22 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Tue Oct 11 15:38:31 2022 +0200

Resolves: tdf#151460 Scale and round time diff fiddling with floating point

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141216
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit abd42a63f65f810c821085149c095682247e0d0d)

 Conflicts:
sc/source/core/data/table4.cxx

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

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 8ec1512136e7..f6f926c86a96 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -214,6 +214,28 @@ double approxDiff( double a, double b )
 const int nExpArg = static_cast(floor(log10(std::max(aa, ab - 15;
 return rtl::math::round(c, -std::max(nExp, nExpArg));
 }
+
+double approxTimeDiff( double a, double b )
+{
+// Scale to hours, round to "nanohours" (multiple nanoseconds), scale back.
+// Get back 0.0417 instead of 0.04166700621136 or
+// 0.0414241347 (raw a-b) for one hour, or worse the approxDiff()
+// 0.0416665997 value. Though there is no such correct value,
+// IEEE-754 nearest values are
+// 0.041664353702032030923874117434024810791015625
+// (0x3FA5) and
+// 0.04167129259593593815225176513195037841796875
+// (0x3FA6).
+// This works also for a diff of seconds, unless corner cases would be
+// discovered, which would make it necessary to ditch the floating point
+// and convert to/from time structure values instead.
+return rtl::math::round((a - b) * 24, 9) / 24;
+}
+
+double approxTypedDiff( double a, double b, bool bTime )
+{
+return bTime ? approxTimeDiff( a, b) : approxDiff( a, b);
+}
 }
 
 void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
@@ -399,7 +421,9 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 aCurrCell = GetCellValue(nColCurr, nRowCurr);
 if (aCurrCell.meType == CELLTYPE_VALUE)
 {
-double nDiff = approxDiff(aCurrCell.mfValue, 
aPrevCell.mfValue);
+double nDiff = approxTypedDiff(aCurrCell.mfValue, 
aPrevCell.mfValue,
+(nCurrCellFormatType == 
SvNumFormatType::TIME ||
+ nCurrCellFormatType == 
SvNumFormatType::DATETIME));
 if (i == 1)
 rInc = nDiff;
 if (!::rtl::math::approxEqual(nDiff, rInc, 13))
@@ -516,8 +540,9 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 double fVal;
 sal_uInt32 nFormat = GetAttr(nCol,nRow,ATTR_VALUE_FORMAT)->GetValue();
 const SvNumFormatType nFormatType = 
rDocument.GetFormatTable()->GetType(nFormat);
-bool bDate = (nFormatType  == SvNumFormatType::DATE );
-bool bBooleanCell = (!bDate && nFormatType == 
SvNumFormatType::LOGICAL);
+bool bDate = (nFormatType == SvNumFormatType::DATE);// date 
without time
+bool bTime = (nFormatType == SvNumFormatType::TIME || nFormatType == 
SvNumFormatType::DATETIME);
+bool bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
 if (bDate)
 {
 if (nCount > 1)
@@ -622,7 +647,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 {
 double nVal1 = aFirstCell.mfValue;
 double nVal2 = GetValue(nCol+nAddX, nRow+nAddY);
-rInc = approxDiff( nVal2, nVal1);
+rInc = approxTypedDiff( nVal2, nVal1, bTime);
 nCol = sal::static_int_cast( nCol + nAddX );
 nRow = sal::static_int_cast( nRow + nAddY );
 bool bVal = true;
@@ -632,7 +657,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 if (aCell.meType == CELLTYPE_VALUE)
 {
 nVal2 = aCell.mfValue;
-double nDiff = approxDiff( nVal2, nVal1);
+double nDiff = approxTypedDiff( nVal2, nVal1, bTime);
 if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
 bVal = false;
 else if ((nVal2 == 0.0 || nVal2 == 1.0) &&


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

2022-10-03 Thread Julien Nabet (via logerrit)
 sc/source/ui/view/cellsh1.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 9330757e4c39b9cecfc2b08294de337129bca317
Author: Julien Nabet 
AuthorDate: Tue Sep 20 21:25:48 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Mon Oct 3 16:06:00 2022 +0200

tdf#117764: fix context menu item "Conditional formatting"

Respond to https://bugs.documentfoundation.org/show_bug.cgi?id=117764#c1
a) the function should be *available* on "clean" cells (removed after 
comment in gerrit)
b) answering "No", one would not edit the existing format, *but will edit a 
new format instead*
c) answering "Yes", one would edit the existing format

Change-Id: I8c578a59084c557939a853d4746efffbaf4e56e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140266
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
(cherry picked from commit 45bee7678319325942664d23688367c639bdf83b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140882
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 17c4936567f9..a48c7ece8e46 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2213,6 +2213,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 {
 pCondFormat = pList->GetFormat(rCondFormats[0]);
 assert(pCondFormat);
+nIndex = pCondFormat->GetKey();
 bCondFormatDlg = true;
 }
 else
@@ -2225,7 +2226,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 else
 {
 // define an overlapping conditional format
-// does not need to be handled here
+pCondFormat = pList->GetFormat(rCondFormats[0]);
+assert(pCondFormat);
+bCondFormatDlg = true;
 }
 }
 


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

2022-10-01 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/dbdata.cxx |   59 -
 1 file changed, 41 insertions(+), 18 deletions(-)

New commits:
commit 9c0a3206d8eec4076f72448585efd027399697ae
Author: Eike Rathke 
AuthorDate: Fri Sep 30 00:23:34 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Oct 1 09:49:15 2022 +0200

Fix incrementing number in dbrange names during copying, tdf#145054 
follow-up

 This is a combination of 2 commits.

fix bug in lcl_IncrementNumberInNamedRange

from
commit 690e4852809ea21b5fd909298c5fa2a053fa0458
Date:   Mon Jan 31 09:02:33 2022 +0100
Fix copying range when it doesn't contain a number

OUString::lastIndexOf() eithers returns an index or -1, so adding 1 to
it, means that nLastIndex is __always__ >= 0.

xChange-Id: I197f8c856a52534690d7a0d28e49cecf296dccb3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140704
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 36003e7644014cde9330bf45fee3815278a74035)

Fix incrementing number in dbrange names during copying, tdf#145054 
follow-up

lcl_IncrementNumberInNamedRange() during copying a sheet didn't do
what it was supposed to do, it could generate names that would had
been cell references, and the loop it was called from could had
prematurely ended because it inserted into the set it was
iterating over; also the loop ended as soon as it encountered just
one dbrange that wasn't on the sheet that was copied. That never
worked as intended with more than just a very few names only on
the same sheet.

Additionally after the actual change loplugin:stringviewparam
forced me to pass a std::u16string_view parameter, for that some
adaptions had to be made.

xChange-Id: Ib83d317c69d821e8e8a2f1cd6791da9616ed188d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140717
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 48b9cbc742de3f6120986cb6cafc92eb5009da82)

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

diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index e060fb25e422..0e36eb9604ea 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -1010,30 +1010,47 @@ public:
 };
 
 OUString lcl_IncrementNumberInNamedRange(ScDBCollection::NamedDBs& namedDBs,
- const OUString& sOldName)
-{
-sal_Int32 nLastIndex = sOldName.lastIndexOf('_') + 1;
+ std::u16string_view rOldName)
+{
+// Append or increment a numeric suffix and do not generate names that
+// could result in a cell reference by ensuring at least one underscore is
+// present.
+// "aa" => "aa_2"
+// "1"  => "1_2"
+// "aa_a"   => "aa_a_2"
+// "aa_a_"  => "aa_a__2"
+// "aa_a1"  => "aa_a1_2"
+// "aa_1a"  => "aa_1a_2"
+// "aa_1"   => "aa_2"
+// "aa_2"   => "aa_3"
+
+size_t nLastIndex = rOldName.rfind('_');
 sal_Int32 nOldNumber = 1;
-if (nLastIndex >= 0)
+OUString aPrefix;
+if (nLastIndex != std::u16string_view::npos)
 {
-std::u16string_view sLastPart(sOldName.subView(nLastIndex));
+++nLastIndex;
+std::u16string_view sLastPart(rOldName.substr(nLastIndex));
 nOldNumber = o3tl::toInt32(sLastPart);
 
-// When no number found, add number at the end.
-// When there is a literal "0" at the end, keep the "lastIndex" from 
above
-// (OUString::toInt32() also returns 0 on failure)
-if (nOldNumber == 0 && sLastPart != u"0")
+// If that number is exactly at the end then increment the number; else
+// append "_" and number.
+// toInt32() returns 0 on failure and also stops at trailing non-digit
+// characters (toInt32("1a")==1).
+if (OUString::number(nOldNumber) == sLastPart)
+aPrefix = rOldName.substr(0, nLastIndex);
+else
 {
+aPrefix = OUString::Concat(rOldName) + "_";
 nOldNumber = 1;
-nLastIndex = sOldName.getLength();
 }
 }
-else // No "_" found, add number at the end
-nLastIndex = sOldName.getLength();
+else // No "_" found, append "_" and number.
+aPrefix = OUString::Concat(rOldName) + "_";
 OUString sNewName;
 do
 {
-sNewName = sOldName.subView(0, nLastIndex) + 
OUString::number(++nOldNumber);
+sNewName = aPrefix + OUString::number(++nOldNumber);
 } while (namedDBs.findByName(sNewName) != nullptr);
 return sNewName;
 }
@@ -1546,17 +1563,23 @@ void ScDBCollection::UpdateMoveTab( SCTAB nOldPos, 
SCTAB nNewPos )
 
 void ScDBCollection::CopyToTable(SCTAB nOldPos, SCTAB nNewPos)
 {
+// 

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

2022-09-23 Thread Eike Rathke (via logerrit)
 sc/source/ui/app/inputhdl.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit a7c3c938ec7cb1380e67eb03aeacd1633cda8ee2
Author: Eike Rathke 
AuthorDate: Thu Sep 22 18:32:13 2022 +0200
Commit: Michael Stahl 
CommitDate: Fri Sep 23 12:22:25 2022 +0200

Fix string length assertion and handle parentheses in multi-line formula

soffice.bin: include/rtl/ustring.hxx:842: sal_Unicode 
rtl::OUString::operator[](sal_Int32) const: Assert ion `index >= 0 && 
static_cast(index) < static_cast(getLength())' failed.

when editing a paragraph (line) longer than the first, because the
string was always obtained from the first paragraph but the
position from the current selection.

Also match parentheses in the current paragraph, not somewhere
else in the first paragraph.. still we're matching only within one
paragraph.

Change-Id: I955fd371c1e248ce58735a5b61603bbce6c997db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140446
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 1df910dac84b4690371f2fc84299e3a918529484)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140386
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index b837cb2d089b..dd1f9f61958a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2171,10 +2171,11 @@ void ScInputHandler::UpdateParenthesis()
 {
 // Examine character left to the cursor
 sal_Int32 nPos = aSel.nStartPos - 1;
-OUString aFormula = mpEditEngine->GetText(0);
+OUString aFormula = mpEditEngine->GetText(aSel.nStartPara);
 sal_Unicode c = aFormula[nPos];
 if ( c == '(' || c == ')' )
 {
+// Note this matches only within one paragraph.
 sal_Int32 nOther = lcl_MatchParenthesis( aFormula, nPos );
 if ( nOther != -1 )
 {
@@ -2190,9 +2191,9 @@ void ScInputHandler::UpdateParenthesis()
 mpEditEngine->RemoveCharAttribs( i, 
EE_CHAR_WEIGHT );
 }
 
-ESelection aSelThis( 0,nPos, 0,nPos+1 );
+ESelection aSelThis( aSel.nStartPara, nPos, 
aSel.nStartPara, nPos+1);
 mpEditEngine->QuickSetAttribs( aSet, aSelThis );
-ESelection aSelOther( 0,nOther, 0,nOther+1 );
+ESelection aSelOther( aSel.nStartPara, nOther, 
aSel.nStartPara, nOther+1);
 mpEditEngine->QuickSetAttribs( aSet, aSelOther );
 
 // Dummy InsertText for Update and Paint (selection is 
empty)


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

2022-09-19 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/interpr1.cxx |   20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit d700377556ca6e1adf5972fcbc8eef658adc0b53
Author: Eike Rathke 
AuthorDate: Thu Sep 15 17:07:38 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Sep 19 17:21:51 2022 +0200

Resolves: tdf#132519 Use string reference syntax for CELL("ADDRESS";...)

... so the result can be used with INDIRECT().

Change-Id: I76e4d7739e22c53a3cfa3e004a9b24dc3dfcd233
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140021
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit c7bb9521ba67f52e9d665fdd24d40d8b42f0387d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140155
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index bfb897590070..25f334d6835d 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2308,8 +2308,26 @@ void ScInterpreter::ScCell()
 }
 else if( aInfoType == "ADDRESS" )
 {   // address formatted as [['FILENAME'#]$TABLE.]$COL$ROW
+
+// Follow the configurable string reference address syntax as also
+// used by INDIRECT() (and ADDRESS() for the sheet separator).
+FormulaGrammar::AddressConvention eConv = 
maCalcConfig.meStringRefAddressSyntax;
+switch (eConv)
+{
+default:
+// Use the current address syntax if unspecified or says
+// one or the other or one we don't explicitly handle.
+eConv = mrDoc.GetAddressConvention();
+break;
+case FormulaGrammar::CONV_OOO:
+case FormulaGrammar::CONV_XL_A1:
+case FormulaGrammar::CONV_XL_R1C1:
+// Use that.
+break;
+}
+
 ScRefFlags nFlags = (aCellPos.Tab() == aPos.Tab()) ? 
ScRefFlags::ADDR_ABS : ScRefFlags::ADDR_ABS_3D;
-OUString aStr(aCellPos.Format(nFlags, , 
mrDoc.GetAddressConvention()));
+OUString aStr(aCellPos.Format(nFlags, , eConv));
 PushString(aStr);
 }
 else if( aInfoType == "FILENAME" )


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

2022-09-15 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/fillinfo.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b2a5fa061c7e254a39b08523f2c6988baf699938
Author: Luboš Luňák 
AuthorDate: Wed Sep 14 08:02:13 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Sep 15 10:09:08 2022 +0200

fix off-by-one in Calc shadow handling (tdf#150931)

A mistake from d48e68407931fc33044aa7f3fc9e971897fac610, the number
is off as can be seen when compared to the bRightDiff part above.

Change-Id: Id87d69c45cd3336ab8a122a2cae505a16848cdf7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139902
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit 308174945174bfd67f0444ef0c29634a4ecd961b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139844
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index e76ef808b8b6..a6fa1b3183e9 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -807,8 +807,8 @@ void ScDocument::FillInfo(
 }
 if (bBottomDiff && bRightDiff)
 {
-
pRowInfo[nArrRow+1].cellInfo(nCol).pHShadowOrigin = pThisAttr;
-
pRowInfo[nArrRow+1].cellInfo(nCol).eHShadowPart = SC_SHADOW_CORNER;
+
pRowInfo[nArrRow+1].cellInfo(nCol+1).pHShadowOrigin = pThisAttr;
+
pRowInfo[nArrRow+1].cellInfo(nCol+1).eHShadowPart = SC_SHADOW_CORNER;
 }
 break;
 


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

2022-09-12 Thread Eike Rathke (via logerrit)
 sc/source/core/data/column3.cxx |   34 ++
 1 file changed, 34 insertions(+)

New commits:
commit 23d607b104013e412295ac83956edc74e94ed2df
Author: Eike Rathke 
AuthorDate: Sat Sep 10 00:12:22 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Sep 12 10:39:23 2022 +0200

Resolves: tdf#150766 Listen to entire shared formula group instead of a 
slice

Change-Id: I677602bd3401dbd401e35f7db64cd34d164d9d92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139744
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 0919d8a389cba5626c14b08549243546830cfb8d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139662
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 424beb65e500..1a65d3edad5a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -569,6 +569,40 @@ void ScColumn::AttachFormulaCells( 
sc::StartListeningContext& rCxt, SCROW nRow1,
 if (GetDoc().IsClipOrUndo())
 return;
 
+// Need to process (start listening) entire shared formula groups, not just
+// a slice thereof.
+bool bEnlargedDown = false;
+aPos = maCells.position(nRow1);
+it = aPos.first;
+if (it->type == sc::element_type_formula)
+{
+ScFormulaCell& rCell = *sc::formula_block::at(*it->data, aPos.second);
+if (rCell.IsShared())
+{
+nRow1 = std::min( nRow1, rCell.GetSharedTopRow());
+if (nRow2 < rCell.GetSharedTopRow() + rCell.GetSharedLength())
+{
+nRow2 = rCell.GetSharedTopRow() + rCell.GetSharedLength() - 1;
+bEnlargedDown = true;
+// Same end row is also enlarged, i.e. doesn't need to be
+// checked for another group.
+}
+}
+}
+if (!bEnlargedDown)
+{
+aPos = maCells.position(it, nRow2);
+it = aPos.first;
+if (it->type == sc::element_type_formula)
+{
+ScFormulaCell& rCell = *sc::formula_block::at(*it->data, 
aPos.second);
+if (rCell.IsShared())
+{
+nRow2 = std::max( nRow2, rCell.GetSharedTopRow() + 
rCell.GetSharedLength() - 1);
+}
+}
+}
+
 AttachFormulaCellsHandler aFunc(rCxt);
 sc::ProcessFormula(it, maCells, nRow1, nRow2, aFunc);
 }


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

2022-09-08 Thread Eike Rathke (via logerrit)
 sc/source/core/data/dpsave.cxx |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 555d0dca78a261af8c18a9ab66e2456f272dff73
Author: Eike Rathke 
AuthorDate: Wed Sep 7 18:34:05 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Sep 8 11:31:28 2022 +0200

crashtesting: prevent nullptr access

There's a xlsx export crash on *2nd* export with data pilot data
of forum-en-38962.ods. We export without crash this .ods to xlsx
*once*, but on saving again to xlsx it crashes. It also crashes with an
export to .xls and then an export to .xlsx. Repeated exports to xls are
crash free.

Already on the first export there are loads of warning messages of

ScDPMember::GetItemData: what data? nDim 0, mnDataId #
ScNameToIndexAccess getByIndex failed 
com.sun.star.container.NoSuchElementException message: "at 
sc/source/core/data/dptabsrc.cxx:2267

The pivot tables are broken on both exports.

This smells like some sort of data pilot cache
corruption/insufficiency during .xlsx export but the root cause is
yet unknown. This only fixes the crash symptom.

Change-Id: Ie479f7f0abc4af284e61f6aa5a69943ccdd72eab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139611
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 5aa3f046f934092fbfd7cc92b93d79b4f548cc13)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139565
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 0f8bfbf11712..16de535bd85d 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1285,8 +1285,20 @@ void 
ScDPSaveData::SyncAllDimensionMembers(ScDPTableData* pData)
 for (size_t j = 0; j < nMemberCount; ++j)
 {
 const ScDPItemData* pMemberData = pData->GetMemberById(nDimIndex, 
rMembers[j]);
-OUString aMemName = pData->GetFormattedString(nDimIndex, 
*pMemberData, false);
-aMemNames.insert(aMemName);
+// ScDPCache::GetItemDataById() (via
+// ScDPTableData::GetMemberById(),
+// ScDPGroupTableData::GetMemberById() through
+// GetCacheTable().getCache()) may return nullptr.
+if (pMemberData)
+{
+OUString aMemName = pData->GetFormattedString(nDimIndex, 
*pMemberData, false);
+aMemNames.insert(aMemName);
+}
+else
+{
+SAL_WARN("sc.core", "No pMemberData for nDimIndex " << 
nDimIndex << ", rMembers[j] " << rMembers[j]
+<< ", j " << j);
+}
 }
 
 it->RemoveObsoleteMembers(aMemNames);


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

2022-09-07 Thread Heiko Tietze (via logerrit)
 sc/source/ui/pagedlg/tphfedit.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit 695dc7484afd2af9c88b3d1032a6a4bbadecaefa
Author: Heiko Tietze 
AuthorDate: Mon Aug 29 15:16:17 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Sep 7 08:26:30 2022 +0200

Resolves tdf#145159 - Use display colors in Header/Footer dialog

Change-Id: Ia19babe3603f653fa631f3d138b43103a553e944
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138998
Reviewed-by: Heiko Tietze 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139412
Tested-by: Jenkins

diff --git a/sc/source/ui/pagedlg/tphfedit.cxx 
b/sc/source/ui/pagedlg/tphfedit.cxx
index c71c67b0842b..fa5209850b07 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -87,6 +88,10 @@ void ScEditWindow::SetDrawingArea(weld::DrawingArea* 
pDrawingArea)
 if (mbRTL)
 
m_xEditEngine->SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::R2L);
 
+Color aBgColor = 
svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+rDevice.SetBackground(aBgColor);
+m_xEditView->SetBackgroundColor(aBgColor);
+
 auto tmpAcc = mxAcc.get();
 if (!tmpAcc)
 return;
@@ -145,6 +150,13 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
 pSet->Put( 
rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) );
 pSet->Put( 
rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) );
 pSet->Put( 
rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) );
+// font color used, suitable header/footer background color set in 
ScEditWindow::SetDrawingArea
+Color aFgColor = svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR, 
false).nColor;
+if (aFgColor == COL_AUTO) {
+Color aBgColor = 
svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+aFgColor = aBgColor.IsDark() ? COL_WHITE : COL_BLACK;
+}
+pSet->Put(SvxColorItem(aFgColor, EE_CHAR_COLOR));
 if (mbRTL)
 pSet->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
 GetEditEngine()->SetDefaults( std::move(pSet) );


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

2022-09-06 Thread Eike Rathke (via logerrit)
 sc/source/ui/docshell/docfunc.cxx |1 +
 sc/source/ui/undo/undotab.cxx |1 +
 sc/source/ui/view/viewfun2.cxx|1 +
 3 files changed, 3 insertions(+)

New commits:
commit 662fdaadfeaa2a8d3fe1f78cf54332056956e351
Author: Eike Rathke 
AuthorDate: Mon Sep 5 20:06:56 2022 +0200
Commit: Caolán McNamara 
CommitDate: Tue Sep 6 14:57:08 2022 +0200

Resolves: tdf#150307 Broadcast missing ScAreasChanged hint on sheet deletion

... and Undo.

Change-Id: I59413d5470294c415c51e7d7ada9134f4173c872
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139450
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit d4411be66c199f379723dab5052b054f029ff3d0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139430
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 9c4d8848ffc7..d187570fec02 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -3407,6 +3407,7 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
 
 SfxApplication* pSfxApp = SfxGetpApp();
// Navigator
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
+pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
 
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index b898faf8075f..0fab08ecfd3d 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -366,6 +366,7 @@ void ScUndoDeleteTab::Undo()
 }
 SfxApplication* pSfxApp = SfxGetpApp();// 
Navigator
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
+pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
 
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 7fe941e33dd6..dbee405f1740 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2631,6 +2631,7 @@ bool ScViewFunc::DeleteTables(const vector 
, bool bRecord )
 
 SfxApplication* pSfxApp = SfxGetpApp();
// Navigator
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScTablesChanged ) );
+pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScDbAreasChanged ) );
 pSfxApp->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) );
 }


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

2022-09-05 Thread Caolán McNamara (via logerrit)
 sc/source/ui/app/inputwin.cxx  |8 
 starmath/source/edit.cxx   |8 
 svx/source/dialog/weldeditview.cxx |7 ---
 3 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 0cd1a953d1191de1d5c9eb09e31ca5f672c29837
Author: Caolán McNamara 
AuthorDate: Tue Aug 30 10:45:19 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Sep 5 16:04:25 2022 +0200

its not ideal to wait until Paint to set the bg color

set it at construction time

Change-Id: I8923ea8f79c4bf18054fc697e2b35caad1b12486
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139024
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139413

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 817a68dc044f..5e28dd9c643e 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1550,6 +1550,10 @@ void ScTextWnd::InitEditEngine()
 m_xEditView->setEditViewCallbacks(this);
 m_xEditView->SetInsertMode(bIsInsertMode);
 
+const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+Color aBgColor = rStyleSettings.GetWindowColor();
+m_xEditView->SetBackgroundColor(aBgColor);
+
 if (pAcc)
 {
 pAcc->InitAcc(nullptr, m_xEditView.get(),
@@ -2064,6 +2068,10 @@ void ScTextWnd::MakeDialogEditView()
 m_xEditView = std::make_unique(m_xEditEngine.get(), nullptr);
 m_xEditView->setEditViewCallbacks(this);
 
+const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+Color aBgColor = rStyleSettings.GetWindowColor();
+m_xEditView->SetBackgroundColor(aBgColor);
+
 if (pAcc)
 {
 pAcc->InitAcc(nullptr, m_xEditView.get(),
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index a0e75f18b408..1c92b03fb2b1 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -100,6 +100,12 @@ void SmEditTextWindow::SetDrawingArea(weld::DrawingArea* 
pDrawingArea)
 {
 weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
 
+const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+Color aBgColor = rStyleSettings.GetWindowColor();
+
+OutputDevice& rDevice = pDrawingArea->get_ref_device();
+rDevice.SetBackground(aBgColor);
+
 SetHelpId(HID_SMA_COMMAND_WIN_EDIT);
 
 EnableRTL(false);
@@ -113,6 +119,8 @@ void SmEditTextWindow::SetDrawingArea(weld::DrawingArea* 
pDrawingArea)
 
 m_xEditView->SetOutputArea(mrEditWindow.AdjustScrollBars());
 
+m_xEditView->SetBackgroundColor(aBgColor);
+
 pDrawingArea->set_cursor(PointerStyle::Text);
 
 pEditEngine->SetStatusEventHdl(LINK(this, SmEditTextWindow, 
EditStatusHdl));
diff --git a/svx/source/dialog/weldeditview.cxx 
b/svx/source/dialog/weldeditview.cxx
index 4d900093b044..c00c887f3c71 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -161,13 +161,6 @@ void WeldEditView::Resize()
 
 void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect)
 {
-const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
-Color aBgColor = rStyleSettings.GetWindowColor();
-
-rRenderContext.SetBackground(aBgColor);
-if (EditView* pEditView = GetEditView())
-pEditView->SetBackgroundColor(aBgColor);
-
 DoPaint(rRenderContext, rRect);
 }
 


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

2022-09-01 Thread Luboš Luňák (via logerrit)
 sc/source/core/tool/interpr1.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit e20d52afe5a33ae9490e238e7b5833d3df68f004
Author: Luboš Luňák 
AuthorDate: Fri Aug 26 16:10:38 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Sep 1 13:11:03 2022 +0200

fix undoing range reducing to apply only to COUNTIFS (tdf#150618)

Before 7674399aac661eb503d7badc53b9a4d68bd9839d the code tried
to range-reduce all operations except for COUNTIFS, the commit added
handling also COUNTIFS and then later undo the rare cases when it
shouldn't be done, but the undo wasn't specific to COUNTIFS even
though it should have.

Change-Id: Ibdb6516a1ac7bc7d34f16f8a99781859e9fc7b60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138880
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit 5367616819e232e7ef2405c614bbfa3ca0d2aecf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138974
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index cc485e383038..0fd78f8b1a99 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6092,9 +6092,10 @@ void ScInterpreter::IterateParametersIfs( 
double(*ResultFunc)( const sc::ParamIf
 rParam.eSearchType = 
DetectSearchType(rItem.maString.getString(), mrDoc);
 }
 
-// Undo bRangeReduce if asked to match empty cells (which should 
be rare).
+// Undo bRangeReduce if asked to match empty cells for COUNTIFS 
(which should be rare).
 assert(rEntry.GetQueryItems().size() == 1);
-if((rEntry.IsQueryByEmpty() || rItem.mbMatchEmpty) && bRangeReduce)
+const bool isCountIfs = (nParamCount % 2) == 0;
+if(isCountIfs && (rEntry.IsQueryByEmpty() || rItem.mbMatchEmpty) 
&& bRangeReduce)
 {
 bRangeReduce = false;
 // All criteria ranges are svDoubleRef's, so only vConditions 
needs adjusting.


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

2022-09-01 Thread Maxim Monastirsky (via logerrit)
 sc/source/ui/drawfunc/drtxtob.cxx|2 +-
 sc/source/ui/view/editsh.cxx |2 +-
 sd/source/ui/view/drtxtob.cxx|2 +-
 sw/source/uibase/shells/annotsh.cxx  |2 +-
 sw/source/uibase/shells/drwtxtex.cxx |2 +-
 sw/source/uibase/shells/textsh1.cxx  |2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 3e39f667590355843336edda9b2f8f7676bbc870
Author: Maxim Monastirsky 
AuthorDate: Wed Aug 31 16:55:41 2022 +0300
Commit: Caolán McNamara 
CommitDate: Thu Sep 1 13:09:35 2022 +0200

tdf#150506 Execution parameter confused with slot state

Regression of a6eddceda5d376cd73922123a3bb3a5683307c41
("rename some SID to FN_PARAM").

Change-Id: I5bcafdcec16cc91b1b77f7a3affd630a2f6cc556
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139121
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 
(cherry picked from commit a72861e3be5b89544ae943c0c5cc6d43e8e70a7d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138992
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 3e8a7f975f23..ec796f4a8521 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -450,7 +450,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
 EditView& rEditView = pOutView->GetEditView();
 bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, 
nLang, rEditView );
 }
-rSet.Put( SfxStringItem( FN_PARAM_THES_WORD_REPLACE, aStatusVal ) );
+rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
 
 // disable thesaurus main menu and context menu entry if there is 
nothing to look up
 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index dbfd28404fd7..0fd33f62ed6d 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -817,7 +817,7 @@ void ScEditShell::GetState( SfxItemSet& rSet )
 LanguageTypenLang = LANGUAGE_NONE;
 bool bIsLookUpWord = pActiveView &&
 GetStatusValueForThesaurusFromContext(aStatusVal, 
nLang, *pActiveView);
-rSet.Put( SfxStringItem( FN_PARAM_THES_WORD_REPLACE, 
aStatusVal ) );
+rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
 
 // disable thesaurus context menu entry if there is 
nothing to look up
 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( 
nLang );
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
index b3f53c7a6860..b10af08289fa 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -415,7 +415,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
 OUStringaStatusVal;
 LanguageTypenLang = LANGUAGE_NONE;
 bool bIsLookUpWord = 
GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
-rSet.Put( SfxStringItem( FN_PARAM_THES_WORD_REPLACE, 
aStatusVal ) );
+rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
 
 // disable "Thesaurus" context menu entry if there is 
nothing to look up
 uno::Reference< linguistic2::XThesaurus > xThes( 
LinguMgr::GetThesaurus() );
diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index 3801f0489da7..4089a84970c5 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1399,7 +1399,7 @@ void SwAnnotationShell::GetLinguState(SfxItemSet )
 OUStringaStatusVal;
 LanguageTypenLang = LANGUAGE_NONE;
 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( 
aStatusVal, nLang, pOLV->GetEditView() );
-rSet.Put( SfxStringItem( FN_PARAM_THES_WORD_REPLACE, 
aStatusVal ) );
+rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
 
 // disable "Thesaurus" context menu entry if there is nothing 
to look up
 uno::Reference< linguistic2::XThesaurus >  xThes( 
::GetThesaurus() );
diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index 0891d65c57d8..1a5f3a8665d4 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -703,7 +703,7 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet)
 LanguageType nLang = LANGUAGE_NONE;
 bool bIsLookUpWord
 = GetStatusValueForThesaurusFromContext(aStatusVal, nLang, 
pOLV->GetEditView());
-rSet.Put(SfxStringItem(FN_PARAM_THES_WORD_REPLACE, 
aStatusVal));
+rSet.Put(SfxStringItem(SID_THES, aStatusVal));
 
 // disable "Thesaurus" context menu 

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

2022-08-25 Thread Eike Rathke (via logerrit)
 sc/source/filter/dif/difimp.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5b6b1f230529070259d81193a78d38b00fb8aec3
Author: Eike Rathke 
AuthorDate: Thu Aug 25 12:53:51 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Aug 25 23:03:20 2022 +0200

Resolves: tdf#150599 Move obtaining data into loop again

Regression from

commit a23a7eea5cfcdc50d09be248828cb1e6293e5ebb
CommitDate: Sun Dec 26 20:36:26 2021 +0100

Avoid OUStringBuffer::toString where possible

that erroneously also moved obtaining the data string outside the
loop, whyever..

Change-Id: I329108d42db43c1ab22ba82650d801e595dd7ece
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138805
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit b5629341edecf10c18087811c77708b01dd15a15)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138815
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index f6e1fd0b0a36..fd88cdf4cfd4 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -122,7 +122,6 @@ ErrCode ScFormatFilterPluginImpl::ScImportDif(SvStream& 
rIn, ScDocument* pDoc, c
 
 ScSetStringParam aStrParam; // used to set string value without number 
detection.
 aStrParam.setTextInput();
-const OUString aData = rData.makeStringAndClear();
 
 while( eCurrent != D_EOD )
 {
@@ -130,6 +129,7 @@ ErrCode ScFormatFilterPluginImpl::ScImportDif(SvStream& 
rIn, ScDocument* pDoc, c
 
 aPrgrsBar.Progress();
 ScAddress aPos(nColCnt, nRowCnt, nBaseTab);
+const OUString aData = rData.makeStringAndClear();
 
 switch( eCurrent )
 {


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

2022-08-18 Thread Thierry Emery (via logerrit)
 sc/source/ui/view/cliputil.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit 77a0a504540c36159271622fda1be47d4f6cb180
Author: Thierry Emery 
AuthorDate: Mon Aug 8 22:07:40 2022 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Thu Aug 18 08:14:38 2022 +0200

tdf#133299 Anchor pasted images 'to cell' by default

This is already the default when inserting images via menu,
do this also when pasting images from other applications
(currently it would anchor 'to page').

Change-Id: I5e1d010b026fc8eba2d3a7cca80ea96814a2ebe8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138005
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit d5fd15eb7afc45b92c3ae81991e20a85d3368e7d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138281

diff --git a/sc/source/ui/view/cliputil.cxx b/sc/source/ui/view/cliputil.cxx
index bbf80bce33ad..770e309dbe97 100644
--- a/sc/source/ui/view/cliputil.cxx
+++ b/sc/source/ui/view/cliputil.cxx
@@ -81,7 +81,19 @@ void ScClipUtil::PasteFromClipboard( ScViewData& rViewData, 
ScTabViewShell* pTab
 // normal paste
 weld::WaitObject aWait( rViewData.GetDialogParent() );
 if (!pOwnClip)
+{
 pTabViewShell->PasteFromSystem();
+// Anchor To Cell rather than To Page
+ScDrawView* pDrawView = pTabViewShell->GetScDrawView();
+if(pDrawView && 1 == pDrawView->GetMarkedObjectCount())
+{
+SdrObject* pPickObj = pDrawView->GetMarkedObjectByIndex(0);
+if(pPickObj)
+{
+ScDrawLayer::SetCellAnchoredFromPosition( *pPickObj,  
rThisDoc, nThisTab, false );
+}
+}
+}
 else
 {
 ScDocument* pClipDoc = pOwnClip->GetDocument();


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

2022-08-10 Thread Noel Grandin (via logerrit)
 sc/source/core/data/drwlayer.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 81c8e3a92ba1da28f3c03ff5bcb873d63a1b857f
Author: Noel Grandin 
AuthorDate: Thu Aug 4 20:24:31 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Aug 10 09:07:06 2022 +0200

tdf#150219 Crash when cutting trace dependent with precedent on different 
sheet

not sure exactly where the real bug is. This only started to show up
when I changed the data structures in

commit 3596c9891e16e108b18bdcdc9909c2f02d0f
Date:   Thu Jan 16 12:10:54 2020 +0200
use std::vector in ScMarkArray, instead of re-inventing the wheel

before that it would harmlessly read from adjacent memory because nCol and
nRow are -1.

Change-Id: Iddf109eed04ddc57d5b6743f232eea940e42bd9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137834
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 
(cherry picked from commit f705132f20eb9e0cbe57f11f1f9594a287a63900)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137958
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index bd4bd01b6f3e..6302f044eea7 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1658,7 +1658,8 @@ void ScDrawLayer::DeleteObjectsInSelection( const 
ScMarkData& rMark )
 ScAnchorType aAnchorType = 
ScDrawLayer::GetAnchorType(*pObject);
 bool bObjectAnchoredToMarkedCell
 = ((aAnchorType == SCA_CELL || aAnchorType == 
SCA_CELL_RESIZE)
-   && pObjData && 
rMark.IsCellMarked(pObjData->maStart.Col(),
+   && pObjData && pObjData->maStart.IsValid()
+   && rMark.IsCellMarked(pObjData->maStart.Col(),
  
pObjData->maStart.Row()));
 if (bObjectInMarkArea || bObjectAnchoredToMarkedCell)
 {


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

2022-08-03 Thread Caolán McNamara (via logerrit)
 sc/source/filter/xml/xmlexprt.cxx |   26 +-
 sc/source/ui/unoobj/chart2uno.cxx |3 +++
 2 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit ecf0074b1582842620ce9057a27fbe10f1812b61
Author: Caolán McNamara 
AuthorDate: Tue Aug 2 11:52:23 2022 +0100
Commit: Michael Stahl 
CommitDate: Wed Aug 3 12:15:27 2022 +0200

crashtesting: assert on export of forum-mso-en3-17256.xlsx to ods

a lang::IllegalArgumentException is thrown on seeing myEB_Y_Pos
and the xml tags become unbalanced

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

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 44abae0ee455..37b155bf937a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -111,6 +111,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3418,16 +3419,23 @@ void ScXMLExport::ExportShape(const uno::Reference < 
drawing::XShape >& xShape,
 uno::Sequence< OUString > aRepresentations(
 xReceiver->getUsedRangeRepresentations());
 rtl::Reference pAttrList;
-if(aRepresentations.hasElements())
+try
 {
-// add the ranges used by the chart to the 
shape
-// element to be able to start listening 
after
-// load (when the chart is not yet loaded)
-uno::Reference< 
chart2::data::XRangeXMLConversion > xRangeConverter( 
xChartDoc->getDataProvider(), uno::UNO_QUERY );
-sRanges = lcl_RangeSequenceToString( 
aRepresentations, xRangeConverter );
-pAttrList = new SvXMLAttributeList();
-pAttrList->AddAttribute(
-GetNamespaceMap().GetQNameByKey( 
XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
+if (aRepresentations.hasElements())
+{
+// add the ranges used by the chart to 
the shape
+// element to be able to start 
listening after
+// load (when the chart is not yet 
loaded)
+uno::Reference< 
chart2::data::XRangeXMLConversion > xRangeConverter( 
xChartDoc->getDataProvider(), uno::UNO_QUERY );
+sRanges = lcl_RangeSequenceToString( 
aRepresentations, xRangeConverter );
+pAttrList = new SvXMLAttributeList();
+pAttrList->AddAttribute(
+GetNamespaceMap().GetQNameByKey( 
XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
+}
+}
+catch (const lang::IllegalArgumentException&)
+{
+TOOLS_WARN_EXCEPTION("sc", "Exception in 
lcl_RangeSequenceToString - invalid range?");
 }
 GetShapeExport()->exportShape(xShape, 
SEF_DEFAULT, pPoint, pAttrList.get());
 }
diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index d2fec774e125..8cbdfd6c2b64 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2241,7 +2241,10 @@ OUString SAL_CALL 
ScChart2DataProvider::convertRangeToXML( const OUString& sRang
 ScRefTokenHelper::compileRangeRepresentation(
 aRefTokens, sRangeRepresentation, *m_pDocument, cSep, 
m_pDocument->GetGrammar(), true);
 if (aRefTokens.empty())
+{
+SAL_WARN("sc", "convertRangeToXML throw IllegalArgumentException from 
input of: " << sRangeRepresentation);
 throw lang::IllegalArgumentException();
+}
 
 Tokens2RangeStringXML converter(*m_pDocument);
 converter = ::std::for_each(aRefTokens.begin(), aRefTokens.end(), 
converter);


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

2022-07-19 Thread Balazs Varga (via logerrit)
 sc/source/ui/docshell/docsh.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit e0688221202176cb4d5dfb91ae777afb3075d956
Author: Balazs Varga 
AuthorDate: Sun Jul 17 12:36:15 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Tue Jul 19 19:55:28 2022 +0200

tdf#119491 sc odf export: fix password protection of shared files

Handle SID_ENCRYPTIONDATA for shared password protected docs.

Change-Id: If9554a991a39d6be45ed688a0bd638cd166589c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137146
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 8fa6a1f628ca9df5d910db2b2aa7328e1d6220d7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137181
Reviewed-by: Balazs Varga 
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index e46c3df81742..219101f72a0c 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -910,6 +910,14 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
 pValues[1].Name = "Password";
 pValues[1].Value <<= 
pPasswordItem->GetValue();
 }
+const SfxUnoAnyItem* 
pEncryptionItem = SfxItemSet::GetItem(GetMedium()->GetItemSet(), 
SID_ENCRYPTIONDATA, false);
+if (pEncryptionItem)
+{
+
aValues.realloc(aValues.getLength() + 1);
+auto pValues = 
aValues.getArray();
+pValues[aValues.getLength() - 
1].Name = "EncryptionData";
+pValues[aValues.getLength() - 
1].Value = pEncryptionItem->GetValue();
+}
 
 SC_MOD()->SetInSharedDocSaving( 
true );
 xStor->storeToURL( 
GetSharedFileURL(), aValues );


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

2022-07-16 Thread Michael Meeks (via logerrit)
 sc/source/ui/view/gridwin4.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 679102b057377c23c3582b0a6d26e218cfd6e773
Author: Michael Meeks 
AuthorDate: Thu Jul 7 15:28:59 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Jul 16 13:45:31 2022 +0200

lok: skip app background rendering for lok case.

this is/was mis-placed and tends to make a mess of large sheets'
tiles close to the bottom at ~2^20 rows.

Change-Id: Iac0977d58428707ff56c0ac30a7740c0ed0b27c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136866
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit a4acae686c2c55b18b5c27e832827d3c2d8e0f63)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136870
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index af87b086ca7c..42cc0781d26b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -817,8 +817,8 @@ void ScGridWindow::DrawContent(OutputDevice , const 
ScTableInfo& rTableI
 }
 }
 
-// edge (area) (Pixel)
-if ( nX2==rDoc.MaxCol() || nY2==rDoc.MaxRow() )
+// app-background / document edge (area) (Pixel)
+if ( !bIsTiledRendering && ( nX2 == rDoc.MaxCol() || nY2 == rDoc.MaxRow() 
) )
 {
 // save MapMode and set to pixel
 MapMode aCurrentMapMode(pContentDev->GetMapMode());


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

2022-07-15 Thread Balazs Varga (via logerrit)
 sc/source/ui/view/tabview3.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit d58f93b47c82f386b6e8f59ff1384e4cb433374e
Author: Balazs Varga 
AuthorDate: Wed Jul 13 22:05:54 2022 +0200
Commit: Thorsten Behrens 
CommitDate: Fri Jul 15 11:22:59 2022 +0200

tdf#61623 sc update current cell view if we switch or create a new tab

Testing:
- create a new validation list in the A1 cell with some value.
- add a new tab while you are on the A1 cell on the original tab.
or
- switch to an existing tab from the original A1 cell.

TODO: UNIT test

Change-Id: Ic13afdca45cf31fb50a7446b6eb6d64069d30200
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137040
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Tested-by: Balazs Varga 
Reviewed-by: Balazs Varga 
(cherry picked from commit cf936b57117b9bd4a9b1ae4c77244d544cc2bfec)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137059
Reviewed-by: Thorsten Behrens 

diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index ae960b0a8c1f..0fe06e1c4a0f 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1883,6 +1883,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool 
bExtendSelection, bool bSa
 // UpdateShow before SetCursor, so that UpdateAutoFillMark finds the 
correct
 // window  (is called from SetCursor)
 UpdateShow();
+aViewData.GetView()->TestHintWindow();
 
 SfxBindings& rBindings = aViewData.GetBindings();
 ScMarkData& rMark = aViewData.GetMarkData();


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

2022-07-05 Thread Eike Rathke (via logerrit)
 sc/source/core/data/column3.cxx |   27 +++
 sc/source/ui/view/tabvwsha.cxx  |   12 ++--
 2 files changed, 29 insertions(+), 10 deletions(-)

New commits:
commit ff1c2cd5ea8049fe0dc4283a8990c67eb19b8219
Author: Eike Rathke 
AuthorDate: Tue Jul 5 18:37:54 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Jul 5 21:12:52 2022 +0200

Resolves: tdf#149665 Strip first ' also for multiple '' if following is 
numeric

... and prepend accordingly when editing content.

Change-Id: I9b35c4e370323966400e8e7ef3bce95026052f10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136837
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit ce95b6a2eeca1ac1f2e9385af69e8ca8f644)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136854

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e8000bdc9797..6436bff414b0 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2078,14 +2078,25 @@ bool ScColumn::ParseString(
 bool bNumeric = false;
 if (aParam.mbHandleApostrophe)
 {
-// Cell format is not 'Text', and the first char
-// is an apostrophe. Check if the input is considered a number.
-OUString aTest = rString.copy(1);
-double fTest;
-bNumeric = aParam.mpNumFormatter->IsNumberFormat(aTest, nIndex, 
fTest);
-if (bNumeric)
-// This is a number. Strip out the first char.
-rCell.set(rPool.intern(aTest));
+// Cell format is not 'Text', and the first char is an apostrophe.
+// Check if the input is considered a number with all leading
+// apostrophes removed. All because ''1 should produce '1 not ''1,
+// thus '''1 be ''1 and so on.
+// NOTE: this corresponds with sc/source/ui/view/tabvwsha.cxx
+// ScTabViewShell::UpdateInputHandler() prepending an apostrophe if
+// necessary.
+sal_Int32 i = 1;
+while (i < rString.getLength() && rString[i] == '\'')
+++i;
+if (i < rString.getLength())
+{
+OUString aTest = rString.copy(i);
+double fTest;
+bNumeric = aParam.mpNumFormatter->IsNumberFormat(aTest, 
nIndex, fTest);
+if (bNumeric)
+// This is a number. Strip out the first apostrophe.
+rCell.set(rPool.intern(rString.copy(1)));
+}
 }
 if (!bNumeric)
 // This is normal text. Take it as-is.
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 99877fdaf589..d44bd6b0034b 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -722,11 +722,19 @@ void ScTabViewShell::UpdateInputHandler( bool bForce /* = 
sal_False */, bool bSt
 aString = ScCellFormat::GetInputString( rCell, nNumFmt, 
*pFormatter, rDoc );
 if (rCell.meType == CELLTYPE_STRING)
 {
+sal_Int32 i = 0;
+while (i < aString.getLength() && aString[i] == '\'')
+++i;
+OUString aTest((i && i < aString.getLength()) ? 
aString.copy(i) : aString);
 // Put a ' in front if necessary, so that the string is not
 // unintentionally interpreted as a number, and to show the
 // user that it is a string (#35060#).
-//! also for numberformat "Text"? -> then remove when 
editing
-if ( pFormatter->IsNumberFormat(aString, nNumFmt, 
o3tl::temporary(double())) )
+// NOTE: this corresponds with
+// sc/source/core/data/column3.cxx ScColumn::ParseString()
+// removing one apostrophe also for multiple consecutive
+// apostrophes.
+// For number format 'Text' this never results in numeric.
+if (pFormatter->IsNumberFormat(aTest, nNumFmt, 
o3tl::temporary(double(
 aString = "'" + aString;
 }
 }


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

2022-06-30 Thread Eike Rathke (via logerrit)
 sc/source/filter/oox/revisionfragment.cxx|   14 +-
 xmloff/source/chart/SchXMLCalculationSettingsContext.cxx |6 --
 xmloff/source/core/DocumentSettingsContext.cxx   |6 --
 3 files changed, 17 insertions(+), 9 deletions(-)

New commits:
commit 9c4cfb6a95e851f5651e024e798699d71e16d968
Author: Eike Rathke 
AuthorDate: Thu Jun 30 23:49:03 2022 +0200
Commit: Eike Rathke 
CommitDate: Fri Jul 1 02:02:04 2022 +0200

Check sax::Converter::parseDateTime() success return value

Change-Id: Ia843a1437a8c97e2dafc3f22d43a3dc61873269b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136686
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit bc5380b751d2c062575afb19db28545b7512be17)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136702

diff --git a/sc/source/filter/oox/revisionfragment.cxx 
b/sc/source/filter/oox/revisionfragment.cxx
index f6fee91c4051..350adbea90e3 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -286,11 +286,15 @@ void RevisionHeadersFragment::importHeader( const 
AttributeList& rAttribs )
 if (!aDateTimeStr.isEmpty())
 {
 util::DateTime aDateTime;
-sax::Converter::parseDateTime(aDateTime, aDateTimeStr);
-Date aDate(aDateTime);
-tools::Time aTime(aDateTime);
-aMetadata.maDateTime.SetDate(aDate.GetDate());
-aMetadata.maDateTime.SetTime(aTime.GetTime());
+if (sax::Converter::parseDateTime(aDateTime, aDateTimeStr))
+{
+Date aDate(aDateTime);
+tools::Time aTime(aDateTime);
+aMetadata.maDateTime.SetDate(aDate.GetDate());
+aMetadata.maDateTime.SetTime(aTime.GetTime());
+}
+else
+SAL_WARN("sc.filter", "RevisionHeadersFragment: broken DateTime '" 
<< aDateTimeStr << "'");
 }
 
 aMetadata.maUserName = rAttribs.getString(XML_userName, OUString());
diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx 
b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
index 9365a791c901..fbe54c96d0f8 100644
--- a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
+++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
@@ -44,8 +44,10 @@ 
SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport&
 if ( aIter.getToken() == XML_ELEMENT(TABLE, XML_DATE_VALUE) )
 {
 util::DateTime aNullDate;
-::sax::Converter::parseDateTime(aNullDate, aIter.toView());
-m_aNullDate <<= aNullDate;
+if (::sax::Converter::parseDateTime(aNullDate, aIter.toView()))
+m_aNullDate <<= aNullDate;
+else
+SAL_WARN("xmloff", "SchXMLCalculationSettingsContext: broken 
DateTime '" << aIter.toView() << "'");
 }
 else
 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx 
b/xmloff/source/core/DocumentSettingsContext.cxx
index b21010b07c81..9052a8dbaa81 100644
--- a/xmloff/source/core/DocumentSettingsContext.cxx
+++ b/xmloff/source/core/DocumentSettingsContext.cxx
@@ -462,8 +462,10 @@ void XMLConfigItemContext::endFastElement(sal_Int32 )
 else if (IsXMLToken(msType, XML_DATETIME))
 {
 util::DateTime aDateTime;
-::sax::Converter::parseDateTime(aDateTime, sValue);
-mrAny <<= aDateTime;
+if (::sax::Converter::parseDateTime(aDateTime, sValue))
+mrAny <<= aDateTime;
+else
+SAL_WARN("xmloff.core", "XMLConfigItemContext: broken DateTime 
'" << sValue << "'");
 }
 else if (IsXMLToken(msType, XML_BASE64BINARY))
 {


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

2022-06-30 Thread Eike Rathke (via logerrit)
 sc/source/filter/xml/XMLCalculationSettingsContext.cxx |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit a60e3c28dbf561b0d1eb190baf32f06151bf32a0
Author: Eike Rathke 
AuthorDate: Thu Jun 30 01:38:43 2022 +0200
Commit: Eike Rathke 
CommitDate: Thu Jun 30 23:44:05 2022 +0200

crashtesting: assert on reexport to ods of forum-it-7248.ods

source document available from:
https://forum.openoffice.org/it/forum/download/file.php?id=7248

The actual cause is already a bad



imported unchecked. For this, sax::Converter::parseDateTime()
returns a success value, just use it..
If bad keep the default NullDate.

Change-Id: If4caa57e302cfe8304e6cb49bf9d330245a97660
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136611
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 626458eaec9a1c6ef2c29fd25dc5612d3dd1555c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136646

diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx 
b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index 1989b337faf2..43da1437eb5c 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -150,12 +150,14 @@ ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& 
rImport,
 if (aIter != rAttrList->end())
 {
 util::DateTime aDateTime;
-::sax::Converter::parseDateTime(aDateTime, aIter.toView());
-util::Date aDate;
-aDate.Day = aDateTime.Day;
-aDate.Month = aDateTime.Month;
-aDate.Year = aDateTime.Year;
-pCalcSet->SetNullDate(aDate);
+if (::sax::Converter::parseDateTime(aDateTime, aIter.toView()))
+{
+util::Date aDate;
+aDate.Day = aDateTime.Day;
+aDate.Month = aDateTime.Month;
+aDate.Year = aDateTime.Year;
+pCalcSet->SetNullDate(aDate);
+}
 }
 }
 


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

2022-06-29 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/queryiter.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 3fa4220729c707a66b411033e1c068a2091b3fdd
Author: Luboš Luňák 
AuthorDate: Tue Jun 28 17:52:43 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed Jun 29 09:29:32 2022 +0200

don't try to use self-referencing ScSortedRangeCache (tdf#149752)

Both the documents from the bugreport use COUNTIF where the range
includes the cell itself. So trying to create ScSortedRangeCache
for the range would try to read the values of the cells in the range
including the cell itself, which would try to interpret COUNTIF,
which would recurse and deadlock on the mutex.

Change-Id: I95c33d0b75015dcd1d628740ef52c2d680864791
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136581
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit 33f1b7eab3a3550052fb4215de5ab33cea522fa7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136547

diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index adc6006adf94..b2d43c3ac769 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -1259,7 +1259,9 @@ static bool CanBeUsedForSorterCache(ScDocument& rDoc, 
const ScQueryParam& rParam
 if(!inUnitTest)
 return false;
 }
-if( !cell || !cell->GetCellGroup() || cell->GetCellGroup()->mnLength < 10 )
+if( !cell )
+return false;
+if( !cell->GetCellGroup() || cell->GetCellGroup()->mnLength < 10 )
 {
 if(!inUnitTest)
 return false;
@@ -1269,6 +1271,8 @@ static bool CanBeUsedForSorterCache(ScDocument& rDoc, 
const ScQueryParam& rParam
 for(SCCOL col : rDoc.GetAllocatedColumnsRange(nTab, rParam.nCol1, 
rParam.nCol2))
 {
 ScRange aSortedRangeRange( col, rParam.nRow1, nTab, col, rParam.nRow2, 
nTab);
+if( aSortedRangeRange.Contains( cell->aPos ))
+return false; // self-referencing, can't create cache
 ScSortedRangeCache& cache = rDoc.GetSortedRangeCache( 
aSortedRangeRange, rParam,  );
 if(!cache.isValid())
 return false;


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

2022-06-27 Thread Olivier Hallot (via logerrit)
 sc/source/core/data/funcdesc.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6ea86593851c731e2e2b969e458255e4159c80d9
Author: Olivier Hallot 
AuthorDate: Mon Jun 27 11:24:34 2022 -0300
Commit: Eike Rathke 
CommitDate: Tue Jun 28 01:10:39 2022 +0200

tdf#137747 Fix POISSON.DIST required argument

Cumulative argument of POISSON.DIST was marked optional and is actually
required.

Change-Id: Ib3be6fe97f6d2441c6c5d3b9186b04d7b83b7821
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136499
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 2e01d80d272c73c1601428871a85c1863c92084a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136473

diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 01d8143a16f8..dfbfd9a3a78e 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -738,7 +738,7 @@ ScFunctionList::ScFunctionList()
 { SC_OPCODE_F_TEST_MS, ENTRY(SC_OPCODE_F_TEST_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_F_TEST_MS, 2, { 0, 0 }, 0 },
 { SC_OPCODE_EXP_DIST_MS, ENTRY(SC_OPCODE_EXP_DIST_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_EXP_DIST_MS, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_HYP_GEOM_DIST_MS, ENTRY(SC_OPCODE_HYP_GEOM_DIST_MS_ARY), 
0, ID_FUNCTION_GRP_STATISTIC, HID_FUNC_HYP_GEOM_DIST_MS, 5, { 0, 0, 0, 0, 0 }, 
0 },
-{ SC_OPCODE_POISSON_DIST_MS, ENTRY(SC_OPCODE_POISSON_DIST_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_POISSON_DIST_MS, 3, { 0, 0, 1 }, 0 },
+{ SC_OPCODE_POISSON_DIST_MS, ENTRY(SC_OPCODE_POISSON_DIST_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_POISSON_DIST_MS, 3, { 0, 0, 0 }, 0 },
 { SC_OPCODE_WEIBULL_MS, ENTRY(SC_OPCODE_WEIBULL_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_WEIBULL_DIST_MS, 4, { 0, 0, 0, 0 }, 0 },
 { SC_OPCODE_GAMMA_DIST_MS, ENTRY(SC_OPCODE_GAMMA_DIST_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_GAMMADIST_MS, 4, { 0, 0, 0, 0 }, 0 },
 { SC_OPCODE_GAMMA_INV_MS, ENTRY(SC_OPCODE_GAMMA_INV_MS_ARY), 0, 
ID_FUNCTION_GRP_STATISTIC, HID_FUNC_GAMMAINV_MS, 3, { 0, 0, 0 }, 0 },


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

2022-06-24 Thread Heiko Tietze (via logerrit)
 sc/source/ui/condformat/condformatmgr.cxx |   10 ++
 1 file changed, 10 insertions(+)

New commits:
commit f777a25f32b3c98a45cf1a24e130a5cce153f5d0
Author: Heiko Tietze 
AuthorDate: Wed Jun 15 12:07:31 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Fri Jun 24 19:41:37 2022 +0200

Related tdf#101285 - Remember position of conditional format dialog

Change-Id: I4094fb46bb6130f4befcc25136424a45b90b9d92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135897
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
(cherry picked from commit 3d3341aa156e089a6ebcf399d9ec6ad1f183d063)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135889
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/condformat/condformatmgr.cxx 
b/sc/source/ui/condformat/condformatmgr.cxx
index 06954a7f65d1..d4a2980a6dfa 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 ScCondFormatManagerWindow::ScCondFormatManagerWindow(weld::TreeView& rTreeView,
 ScDocument& rDoc, ScConditionalFormatList* pFormatList)
@@ -99,11 +100,20 @@ 
ScCondFormatManagerDlg::ScCondFormatManagerDlg(weld::Window* pParent, ScDocument
 m_xBtnAdd->connect_clicked(LINK(this, ScCondFormatManagerDlg, AddBtnHdl));
 m_xTreeView->connect_row_activated(LINK(this, ScCondFormatManagerDlg, 
EditBtnHdl));
 
+SvtViewOptions aDlgOpt(EViewType::Dialog, "CondFormatDialog");
+if (aDlgOpt.Exists())
+m_xDialog->set_window_state(aDlgOpt.GetWindowState().toUtf8());
+
 UpdateButtonSensitivity();
 }
 
 ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
 {
+   // tdf#101285 - Remember position of dialog
+SvtViewOptions aDlgOpt(EViewType::Dialog, "CondFormatDialog");
+OString sWindowState
+= m_xDialog->get_window_state(vcl::WindowDataMask::Pos);
+aDlgOpt.SetWindowState(OUString::fromUtf8(sWindowState));
 }
 
 std::unique_ptr 
ScCondFormatManagerDlg::GetConditionalFormatList()


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

2022-06-24 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/compiler.cxx |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

New commits:
commit 39cd1c5b261262e0c9630f2e047979d64a4e58d6
Author: Eike Rathke 
AuthorDate: Thu Jun 23 23:59:40 2022 +0200
Commit: Adolfo Jayme Barrientos 
CommitDate: Fri Jun 24 17:20:18 2022 +0200

Twice uppercase is one too much

In both cases if ToUpperAsciiOrI18nIsAscii() returned
bAsciiUpper=true or the pCharClass->uppercase() was executed and
its CharClass locale differs from ScGlobal::getCharClass(), the
ScGlobal::getCharClass().uppercase() was executed after. If
pCharClass has the same locale as ScGlobal::getCharClass()
(mbCharClassesDiffer==false) that was executed once. In any case
the result is a ScGlobal::getCharClass() locale's uppercase. Do
that only once.

Change-Id: I1928b73b35b50068f96d809d9fa0734ec80a446d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136353
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit c5ddccf7376c75ad1f1b963c84f39e7bbc5807ae)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136387
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 2945062f1b37..b1de55436f9c 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3350,10 +3350,7 @@ bool ScCompiler::ParseSingleReference( const OUString& 
rName, const OUString* pE
 // A named range named e.g. 'num1' is valid with 1k columns, but 
would become a reference
 // when the document is opened later with 16k columns. Resolve the 
conflict by not
 // considering it a reference.
-OUString aUpper;
-bool bAsciiUpper = ToUpperAsciiOrI18nIsAscii( aUpper, rName );
-if (bAsciiUpper || mbCharClassesDiffer)
-aUpper = ScGlobal::getCharClass().uppercase( rName );
+OUString aUpper( ScGlobal::getCharClass().uppercase( rName ));
 mnCurrentSheetTab = aAddr.Tab(); // temporarily set for 
ParseNamedRange()
 if(ParseNamedRange( aUpper, true )) // only check
 return false;


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

2022-06-24 Thread Caolán McNamara (via logerrit)
 sc/source/filter/xml/XMLExportDataPilot.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 52d177825a8ee9bcaf055466f456e394391ab00f
Author: Caolán McNamara 
AuthorDate: Thu Jun 23 11:26:03 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Jun 24 16:05:12 2022 +0200

crashtesting: forum-mso-en-13233.xlsx exports duplicate grouped-by 
attributes

there is a warning that "there should be no NumGroup and Group at the
same field", here just prefer Group to Numgroup if both are present.

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

diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx 
b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 7f0e7b4b4fa8..cd6f26b1135e 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -631,11 +631,12 @@ void ScXMLExportDataPilot::WriteGroupDimElements(const 
ScDPSaveDimension* pDim,
 if (pDimData)
 {
 pGroupDim = pDimData->GetNamedGroupDim(pDim->GetName());
-WriteGroupDimAttributes(pGroupDim);
 pNumGroupDim = pDimData->GetNumGroupDim(pDim->GetName());
-WriteNumGroupDim(pNumGroupDim);
-
 OSL_ENSURE((!pGroupDim || !pNumGroupDim), "there should be no NumGroup 
and Group at the same field");
+if (pGroupDim)
+WriteGroupDimAttributes(pGroupDim);
+else if (pNumGroupDim)
+WriteNumGroupDim(pNumGroupDim);
 }
 if (!(pGroupDim || pNumGroupDim))
 return;


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

2022-06-24 Thread Caolán McNamara (via logerrit)
 sc/source/ui/view/gridwin.cxx |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit a60aaaf4bfcc2700af3ced4fd2de0ce3ecb8dfc6
Author: Caolán McNamara 
AuthorDate: Thu Jun 23 16:16:15 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Jun 24 16:00:22 2022 +0200

tdf#149609 release mouse before showing popups from calc grid window

If we capture the mouse in the course of the mouse down handler, then
release it before showing a popup to undo any unhelpful seleng capture.

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

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0a5a8454c8ec..8a7dd8b82bdc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -478,6 +478,7 @@ IMPL_LINK_NOARG(ScGridWindow, PopupModeEndHdl, 
weld::Popover&, void)
 mpFilterBox->SetCancelled(); // cancel select
 // restore the mouse capture state of the GridWindow to
 // what it was at initial popup time
+SAL_WARN_IF(bMouseWasCaptured, "sc.ui", "Is there a scenario where the 
mouse was captured before mouse down?");
 if (bMouseWasCaptured)
 CaptureMouse();
 }
@@ -1817,6 +1818,9 @@ void ScGridWindow::HandleMouseButtonDown( const 
MouseEvent& rMEvt, MouseEventSta
 if (pScMod->IsModalMode(mrViewData.GetSfxDocShell()))
 return;
 
+const bool bWasMouseCaptured = IsMouseCaptured();
+SAL_WARN_IF(bWasMouseCaptured, "sc.ui", "Is there a scenario where the 
mouse is captured before mouse down?");
+
 pScActiveViewShell = mrViewData.GetViewShell(); // if left is 
clicked
 nScClickMouseModifier = rMEvt.GetModifier();// to always catch 
a control click
 
@@ -2073,9 +2077,11 @@ void ScGridWindow::HandleMouseButtonDown( const 
MouseEvent& rMEvt, MouseEventSta
 tools::Rectangle aButtonRect = GetListValButtonRect( aListValPos );
 if ( aButtonRect.Contains( aPos ) )
 {
-// tdf#125917 typically we have the mouse captured already, 
except if are editing the cell.
-// Ensure its captured before the menu is launched even in the 
cell editing case
-CaptureMouse();
+// tdf#149609 if we captured the mouse in the course of this 
function
+// release it before showing the data select menu to undo any 
unhelpful
+// seleng capture
+if (!bWasMouseCaptured && IsMouseCaptured())
+ReleaseMouse();
 
 LaunchDataSelectMenu( aListValPos.Col(), aListValPos.Row() );
 
@@ -2091,7 +2097,11 @@ void ScGridWindow::HandleMouseButtonDown( const 
MouseEvent& rMEvt, MouseEventSta
 ScRange aScenRange;
 if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) )
 {
-CaptureMouse();
+// tdf#149609 if we captured the mouse in the course of this function
+// release it before showing the data scenario menu to undo any 
unhelpful
+// seleng capture
+if (!bWasMouseCaptured && IsMouseCaptured())
+ReleaseMouse();
 
 DoScenarioMenu( aScenRange );
 


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

2022-06-24 Thread Attila Szűcs (via logerrit)
 sc/source/ui/view/viewdata.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cb232588e15e9b80cbba1ce698a962eb02e15e5e
Author: Attila Szűcs 
AuthorDate: Tue Jun 21 15:27:35 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jun 24 13:48:41 2022 +0200

tdf#149574 sc: fix missing nullptr check

Regression from commit 605b4ba57b2daa447af9d43d3759079e15df8148
"tdf#43958 sc: fix fill by selecting merged cell".

Check if GetPattern(actual cell) is not nullptr, before using it.
This is not the real problem of Bug 149574, but it is a problem
anyway, and it fixes this bug. The real problem is the wrong
ViewData::nTabNo, that point to an already deleted table,
(fixed in 954d119db932434dc976ef739c643be0d9c7023c
"tdf#149502 sc: crash fix: Change in Table destruction").

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I26fc629ccf354c9e0c2662d61254d01be91d08f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136230
Tested-by: László Németh 
Reviewed-by: László Németh 
(cherry picked from commit c4c827e1d370dcc351c4dddc601b3c37fc71564b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136322
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 88d57f106a3b..69ebe09d22d4 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1155,7 +1155,7 @@ ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, 
ScMarkData & rNewMark )
 if (eMarkType == SC_MARK_NONE)
 eMarkType = SC_MARK_SIMPLE;
 const ScPatternAttr* pMarkPattern = mrDoc.GetPattern(GetCurX(), 
GetCurY(), GetTabNo());
-if (pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == 
SfxItemState::SET)
+if (pMarkPattern && 
pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == SfxItemState::SET)
 {
 SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge();
 SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge();


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

2022-06-24 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/queryevaluator.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit ec287f4f884c94ca5490d6d5139df44fc32cd03c
Author: Luboš Luňák 
AuthorDate: Thu Jun 23 16:39:39 2022 +0200
Commit: Luboš Luňák 
CommitDate: Fri Jun 24 11:11:59 2022 +0200

handle nullptr SharedString in ScQueryEvaluator (tdf#149679)

This may be the case if the string comes from ScMatrix::Get()
for ScMatValType::Empty.

Change-Id: I35013449611bf7ffd1bc74e023d76597af010724
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136347
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit ba59bd11521373f800c6b718e7e21439c1452e84)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136331

diff --git a/sc/source/core/data/queryevaluator.cxx 
b/sc/source/core/data/queryevaluator.cxx
index 0d55c226bc62..93b2960a489f 100644
--- a/sc/source/core/data/queryevaluator.cxx
+++ b/sc/source/core/data/queryevaluator.cxx
@@ -489,8 +489,9 @@ std::pair 
ScQueryEvaluator::compareByString(const ScQueryEntry& rEnt
 const rtl_uString* pQuer = 
rItem.maString.getDataIgnoreCase();
 const rtl_uString* pCellStr = rSource.getDataIgnoreCase();
 
-assert(pQuer != nullptr);
 assert(pCellStr != nullptr);
+if (pQuer == nullptr)
+pQuer = 
svl::SharedString::getEmptyString().getDataIgnoreCase();
 
 const sal_Int32 nIndex
 = (rEntry.eOp == SC_ENDS_WITH || rEntry.eOp == 
SC_DOES_NOT_END_WITH)


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

2022-06-24 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/interpr1.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 46708d87d32e99a7db26f3325565d52e2df2a126
Author: Caolán McNamara 
AuthorDate: Wed Jun 22 19:56:15 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Jun 24 11:01:08 2022 +0200

crashtesting: assert in rtl_uString_iterateCodePoints with 
forum-en-32401.ods

probably since:

commit 78b7e5f76e72647e0cab662ad2c9342d4538704f
Date:   Thu Nov 23 18:21:19 2017 +0100

tdf#97198 Make Calc function SEARCH work with UniCode non-BMP 
characters.

Change-Id: I538c034820e606ba4397f42567dd3087f14129fa
(cherry picked from commit 05299b4205fa0960c3b2ed55a8c4963ee76238be)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136325
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0b3592976a71..4badca5e1483 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -9046,12 +9046,12 @@ void ScInterpreter::ScFind()
 {
 sal_Int32 nIdx = 0;
 nCnt = 0;
-while ( nIdx <= nPos )
+while ( nIdx < nPos )
 {
 sStr.iterateCodePoints(  );
 ++nCnt;
 }
-PushDouble( static_cast(nCnt) );
+PushDouble( static_cast(nCnt + 1) );
 }
 }
 }
@@ -9445,12 +9445,12 @@ void ScInterpreter::ScSearch()
 {
 sal_Int32 nIdx = 0;
 sal_Int32 nCnt = 0;
-while ( nIdx <= nPos )
+while ( nIdx < nPos )
 {
 sStr.iterateCodePoints(  );
 ++nCnt;
 }
-PushDouble( static_cast(nCnt) );
+PushDouble( static_cast(nCnt + 1) );
 }
 }
 }


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

2022-06-23 Thread Stephan Bergmann (via logerrit)
 sc/source/filter/orcus/filterdetect.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 928349f84eff4b5340170519d090b12b5f077153
Author: Stephan Bergmann 
AuthorDate: Wed Jun 22 20:37:34 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Jun 23 11:20:36 2022 +0200

Pump XInputStream into an SvMemoryStream rather than an OStringBuffer

...to avoid overflow with streams >= 2^31 bytes.  This should fix


which I could reproduce with a recent master Linux build with

> $ truncate -s 3G test.xml
> $ instdir/program/soffice test.xml

causing a SIGSEGV at

> #0  0x77f193a0 in rtl::str::stringbuffer_insert<_rtl_String, 
char>(_rtl_String**, int*, int, char const*, int) (ppThis=0x7fffb330, 
capacity=, offset=2147479552, pStr=0x20a92e8 "", len=4096) at 
sal/rtl/strtmpl.hxx:1424
> #1  0x7fffb6af04e5 in rtl::OStringBuffer::append(char const*, int) 
(len=4096, str=, this=0x7fffb330) at 
include/rtl/strbuf.hxx:594
> #2  (anonymous 
namespace)::OrcusFormatDetect::detect(com::sun::star::uno::Sequence&)
 (this=, rMediaDescSeq=) at 
sc/source/filter/orcus/filterdetect.cxx:80
[...]

(Ideally, orcus::detect would only need a short prefix of the stream's 
content,
but the implementation in
workdir/UnpackedTarball/liborcus/src/liborcus/format_detection.cpp 
delegates to
functions like orcus_ods::detect in
workdir/UnpackedTarball/liborcus/src/liborcus/orcus_ods.cpp, which passes 
the
content through some zip_archive that presumably needs the full content.)

Change-Id: Ifaa37ee887d8296cbcf971313bde347ddfb17c12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136297
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 
(cherry picked from commit a95c585433246813096e8890b7ed6ef4fe30c621)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136251

diff --git a/sc/source/filter/orcus/filterdetect.cxx 
b/sc/source/filter/orcus/filterdetect.cxx
index 4e299f1d9371..21eb1d492440 100644
--- a/sc/source/filter/orcus/filterdetect.cxx
+++ b/sc/source/filter/orcus/filterdetect.cxx
@@ -14,7 +14,7 @@
 
 #include 
 
-#include 
+#include 
 
 #include 
 
@@ -68,7 +68,7 @@ OUString 
OrcusFormatDetect::detect(css::uno::Sequence
 return OUString();
 
 css::uno::Reference 
xInputStream(aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], 
css::uno::UNO_QUERY );
-OStringBuffer aContent(xInputStream->available());
+SvMemoryStream aContent(xInputStream->available());
 
 static const sal_Int32 nBytes = 4096;
 css::uno::Sequence aSeq(nBytes);
@@ -77,10 +77,10 @@ OUString 
OrcusFormatDetect::detect(css::uno::Sequence
 {
 sal_Int32 nReadBytes = xInputStream->readBytes(aSeq, nBytes);
 bEnd = (nReadBytes != nBytes);
-aContent.append(reinterpret_cast(aSeq.getConstArray()), 
nReadBytes);
+aContent.WriteBytes(aSeq.getConstArray(), nReadBytes);
 }
 
-orcus::format_t eFormat = orcus::detect(reinterpret_cast(aContent.getStr()), aContent.getLength());
+orcus::format_t eFormat = orcus::detect(static_cast(aContent.GetData()), aContent.GetSize());
 
 switch (eFormat)
 {


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

2022-06-21 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/compiler.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 9f3bce835e81dbdf07da9850a5157f4403819417
Author: Eike Rathke 
AuthorDate: Tue Jun 21 23:06:45 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Jun 22 01:19:04 2022 +0200

Related: tdf#142293 Consider bAsciiUpper for matching CharClass to lowercase

... as also that may had lead to the locale's uppercase.

Change-Id: I5c75b4e52260539f5b66c0d2195b2137c9b1b8ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136265
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 537d69b6f1c32e5b938d9ef24c4154a08d565363)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136237

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 301d90ed3b7a..2945062f1b37 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4464,6 +4464,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
 // ParseReference().
 
 OUString aUpper;
+bool bAsciiUpper = false;
 
 Label_Rewind:
 
@@ -4483,7 +4484,7 @@ Label_Rewind:
 
 mbRewind = false;
 aUpper.clear();
-bool bAsciiUpper = false;
+bAsciiUpper = false;
 
 if (bAsciiNonAlnum)
 {
@@ -4554,6 +4555,8 @@ Label_Rewind:
 // more likely in that localized language than in the formula
 // language. This in corner cases needs to continue to work for
 // existing documents and environments.
+// Do not change bAsciiUpper from here on for the lowercase() call
+// below in the ocBad case to use the correct CharClass.
 aUpper = ScGlobal::getCharClass().uppercase( aOrg );
 }
 
@@ -4618,7 +4621,7 @@ Label_Rewind:
 // would prematurely end compilation. Simple unknown names are handled by
 // the interpreter.
 // Use the same CharClass that was used for uppercase.
-aUpper = (mbCharClassesDiffer ? ScGlobal::getCharClass() : 
*pCharClass).lowercase( aUpper );
+aUpper = ((bAsciiUpper || mbCharClassesDiffer) ? ScGlobal::getCharClass() 
: *pCharClass).lowercase( aUpper );
 svl::SharedString aSS = rDoc.GetSharedStringPool().intern(aUpper);
 maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
 maRawToken.NewOpCode( ocBad );


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

2022-06-21 Thread Eike Rathke (via logerrit)
 sc/source/ui/app/inputhdl.cxx |   20 
 sc/source/ui/inc/inputhdl.hxx |2 ++
 2 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 34745c2fdc6a9f75512f793310f95e17c72b6267
Author: Eike Rathke 
AuthorDate: Tue Jun 21 09:49:31 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Jun 21 14:21:12 2022 +0200

Resolves: tdf#142293 No "+ or - may start formula" when editing content

If it was a formula already it would start with = anyway.

Change-Id: Ib3c0ebcaf99231d387f1aace8e1a5642061de3a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136208
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 3a7907664f0e0c6a8357953d244c7e96af9c1622)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136172

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index c5ca8a5a8493..9ad38d7d321d 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -828,6 +828,7 @@ ScInputHandler::ScInputHandler()
 bLastIsSymbol( false ),
 mbDocumentDisposing(false),
 mbPartialPrefix(false),
+mbEditingExistingContent(false),
 nValidation( 0 ),
 eAttrAdjust( SvxCellHorJustify::Standard ),
 aScaleX( 1,1 ),
@@ -1760,6 +1761,9 @@ void ScInputHandler::LOKPasteFunctionData(const OUString& 
rFunctionName)
 if (pEditEngine)
 {
 aFormula = pEditEngine->GetText(0);
+/* TODO: LOK: are you sure you want '+' and '-' let start formulas with
+ * function names? That was meant for "data typist" numeric keyboard
+ * input. */
 bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] 
== '+' || aFormula[0] == '-');
 }
 
@@ -2564,6 +2568,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool 
bFromCommand, bool bIn
 }
 else
 aStr = GetEditText(mpEditEngine.get());
+mbEditingExistingContent = !aStr.isEmpty();
 
 if (aStr.startsWith("{=") && aStr.endsWith("}") )  // Matrix 
formula?
 {
@@ -2578,8 +2583,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool 
bFromCommand, bool bIn
 if ( SC_MOD()->GetAppOptions().GetAutoComplete() )
 GetColData();
 
-if ( !aStr.isEmpty() && ( aStr[0] == '=' || aStr[0] == '+' || 
aStr[0] == '-' ) &&
- !cTyped && !bCreatingFuncView )
+if (!cTyped && !bCreatingFuncView && StartsLikeFormula(aStr))
 InitRangeFinder(aStr); // Formula is being edited -> 
RangeFinder
 
 bNewTable = true; // -> PostEditView Call
@@ -2781,6 +2785,13 @@ void ScInputHandler::DataChanged( bool bFromTopNotify, 
bool bSetModified )
 bInOwnChange = false;
 }
 
+bool ScInputHandler::StartsLikeFormula( std::u16string_view rStr ) const
+{
+// For new input '+' and '-' may start the dreaded "lazy data typist"
+// formula input, editing existing formula content can only start with '='.
+return !rStr.empty() && (rStr[0] == '=' || (!mbEditingExistingContent && 
(rStr[0] == '+' || rStr[0] == '-')));
+}
+
 void ScInputHandler::UpdateFormulaMode()
 {
 SfxApplication* pSfxApp = SfxGetpApp();
@@ -2789,8 +2800,7 @@ void ScInputHandler::UpdateFormulaMode()
 if (bIsFormula)
 {
 const OUString& rText = mpEditEngine->GetText(0);
-bIsFormula = !rText.isEmpty() &&
-(rText[0] == '=' || rText[0] == '+' || rText[0] == '-');
+bIsFormula = StartsLikeFormula(rText);
 }
 
 if ( bIsFormula )
@@ -3399,6 +3409,7 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode, bool bBeforeSavingInL
 nFormSelStart = nFormSelEnd = 0;
 aFormText.clear();
 
+mbEditingExistingContent = false;
 bInOwnChange = false;
 bInEnterHandler = false;
 if (bUpdateLayout)
@@ -3413,6 +3424,7 @@ void ScInputHandler::CancelHandler()
 
 bModified = false;
 mbPartialPrefix = false;
+mbEditingExistingContent = false;
 
 // Don't rely on ShowRefFrame switching the active view synchronously
 // execute the function directly on the correct view's bindings instead
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 7b06ee3320ed..765c32522b29 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -105,6 +105,7 @@ private:
 boolmbDocumentDisposing:1;
 /// To indicate if there is a partial prefix completion.
 boolmbPartialPrefix:1;
+boolmbEditingExistingContent:1;
 
 sal_uLong   nValidation;
 SvxCellHorJustify   eAttrAdjust;
@@ -144,6 +145,7 @@ private:
 boolStartTable( sal_Unicode cTyped, bool bFromCommand, bool 
bInputActivated,
 ScEditEngineDefaulter* pTopEngine );
 voidRemoveSelection();
+boolStartsLikeFormula( 

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

2022-06-21 Thread Andreas Heinisch (via logerrit)
 sc/source/core/data/dptabres.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit b013342bf7b16cb2393bd7e020707ff58f4d88de
Author: Andreas Heinisch 
AuthorDate: Wed Jun 15 17:33:53 2022 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jun 21 14:10:44 2022 +0200

tdf#113002 - Add numeric flag to recurring data fields

Change-Id: Ife6ace86807f85c644ff919621f562c251c6690f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135915
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 
(cherry picked from commit 30529311ffbbe193765aff0ff353d3409fce3a3e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136133
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index d41604eee45e..1037eac1c013 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -1408,7 +1408,13 @@ void ScDPResultMember::FillMemberResults(
 
 //  set "continue" flag (removed for subtotals later)
 for (tools::Long i=1; igetRepeatItemLabels() )
 {
 tools::Long nSizeNonEmpty = nSize;


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

2022-06-18 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/compiler.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 0c44a7b29c7ee393fa209b7fdf4c940cbace0fb5
Author: Eike Rathke 
AuthorDate: Sat Jun 18 01:08:27 2022 +0200
Commit: Eike Rathke 
CommitDate: Sat Jun 18 19:58:36 2022 +0200

Related: tdf#142293 Use the same locale to lowercase as was to uppercase

... so a #NAME? bad token isn't mixed up like it was with the
stored loaded from document
com.sun.star.sheet.addin.Analysis.getEdate
upper-cased in tr-TR to
COM.SUN.STAR.SHEET.ADDİN.ANALYSİS.GETEDATE
and then lower-cased in en-US to
com.sun.star.sheet.addİn.analysİs.getedate
which confusingly was the user-visible token string.

Change-Id: I341648fcf34fa1cae164d24ad2023bd74573bd3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136071
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 994d517a48f7e092ec57d179abb855ef5a86eacb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136046

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 34accc2593df..301d90ed3b7a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4617,7 +4617,8 @@ Label_Rewind:
 // Provide single token information and continue. Do not set an error, that
 // would prematurely end compilation. Simple unknown names are handled by
 // the interpreter.
-aUpper = pCharClass->lowercase( aUpper );
+// Use the same CharClass that was used for uppercase.
+aUpper = (mbCharClassesDiffer ? ScGlobal::getCharClass() : 
*pCharClass).lowercase( aUpper );
 svl::SharedString aSS = rDoc.GetSharedStringPool().intern(aUpper);
 maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase());
 maRawToken.NewOpCode( ocBad );


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

2022-06-18 Thread Eike Rathke (via logerrit)
 sc/source/core/tool/addincol.cxx |2 +-
 sc/source/core/tool/interpr4.cxx |2 +-
 sc/source/core/tool/parclass.cxx |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 9f7ab29857a552be0f7141a7e49e3dd5291f19a6
Author: Eike Rathke 
AuthorDate: Sat Jun 18 00:56:30 2022 +0200
Commit: Eike Rathke 
CommitDate: Sat Jun 18 19:58:20 2022 +0200

Related: tdf#142293 Do not use locale's uppercase for Add-In programmatic 
name

... so in a tr-TR locale
com.sun.star.sheet.addin.Analysis.getEdate
is not upper-cased to
COM.SUN.STAR.SHEET.ADDİN.ANALYSİS.GETEDATE

Which didn't matter as long as it was consistent and only used for
lookup and mapping, if so..

Additionally, the programmatic name does not need the CharClass
overhead and toAsciiUpperCase() is sufficient and faster.

Change-Id: I1c987cc56dc3a62b5285a0bc367c754e7acb6815
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136070
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 36cb12bce80836a29e5124167b588490b3f7700d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136045

diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 26b7baa9ed7f..addb1512806f 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -92,7 +92,7 @@ ScUnoAddInFuncData::ScUnoAddInFuncData( const OUString& rNam, 
const OUString& rL
 pArgDescs[i] = pAD[i];
 }
 
-aUpperName = ScGlobal::getCharClass().uppercase(aUpperName);
+aUpperName = aUpperName.toAsciiUpperCase();  // programmatic name
 aUpperLocal = ScGlobal::getCharClass().uppercase(aUpperLocal);
 }
 
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 540928f0bee6..c123374c745d 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2530,7 +2530,7 @@ void ScInterpreter::ScExternal()
 {
 sal_uInt8 nParamCount = GetByte();
 OUString aUnoName;
-OUString aFuncName( ScGlobal::getCharClass().uppercase( 
pCur->GetExternal() ) );
+OUString aFuncName( pCur->GetExternal().toAsciiUpperCase());// 
programmatic name
 LegacyFuncData* pLegacyFuncData = 
ScGlobal::GetLegacyFuncCollection()->findByName(aFuncName);
 if (pLegacyFuncData)
 {
diff --git a/sc/source/core/tool/parclass.cxx b/sc/source/core/tool/parclass.cxx
index 81c6df1b0b39..473177c8fca0 100644
--- a/sc/source/core/tool/parclass.cxx
+++ b/sc/source/core/tool/parclass.cxx
@@ -407,7 +407,7 @@ formula::ParamClass 
ScParameterClassification::GetExternalParameterType( const f
 return eRet;
 
 // similar to ScInterpreter::ScExternal()
-OUString aFuncName = ScGlobal::getCharClass().uppercase( 
pToken->GetExternal());
+OUString aFuncName = pToken->GetExternal().toAsciiUpperCase();  // 
programmatic name
 {
 const LegacyFuncData* pLegacyFuncData = 
ScGlobal::GetLegacyFuncCollection()->findByName(aFuncName);
 if (pLegacyFuncData)


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

2022-06-16 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/colorscale.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 12e8dd5c12918ba9c2a048a8a26e830455d1e302
Author: Caolán McNamara 
AuthorDate: Thu Jun 16 13:47:31 2022 +0100
Commit: Eike Rathke 
CommitDate: Thu Jun 16 20:13:19 2022 +0200

tdf#149529 crash on deref deleted ScDocument*

maybe a problem since

commit 46419cd7a2d453c6f252c28dfb9dbfb08605e1c4
Date:   Tue Jun 18 15:11:30 2013 -0400

ScFormulaCell is no longer a child class of ScBaseCell.

Change-Id: Id33072f193045e2eaf51373b47dac803f9a5d52c

presumably the cloned ScColorScaleEntry should end up with
a ScFormulaCell for the destination document and not the source one

Change-Id: I451d5827be183198b61116ab8c582cfda03b2031
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135998
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 81c95dd499f50f75f84cf73d2e78964d19c8f4db)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135991

diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 75f94d3bc2ed..0a357828c61e 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -190,7 +190,7 @@ ScColorScaleEntry::ScColorScaleEntry(ScDocument* pDoc, 
const ScColorScaleEntry&
 setListener();
 if(rEntry.mpCell)
 {
-mpCell.reset(new ScFormulaCell(*rEntry.mpCell, 
rEntry.mpCell->GetDocument(), rEntry.mpCell->aPos, 
ScCloneFlags::NoMakeAbsExternal));
+mpCell.reset(new ScFormulaCell(*rEntry.mpCell, *pDoc, 
rEntry.mpCell->aPos, ScCloneFlags::NoMakeAbsExternal));
 mpCell->StartListeningTo( *pDoc );
 mpListener.reset(new ScFormulaListener(mpCell.get()));
 if (mpFormat)


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

2022-06-16 Thread Eike Rathke (via logerrit)
 sc/source/ui/vba/vbarange.cxx |   27 +--
 1 file changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 7c34db88f3ee99dbb495f3643ab956d7467d5e00
Author: Eike Rathke 
AuthorDate: Thu Jun 16 14:27:13 2022 +0200
Commit: Eike Rathke 
CommitDate: Thu Jun 16 17:46:34 2022 +0200

Resolves: tdf#149579 Expand Range.Sort single cell to Range.CurrentRegion

Change-Id: Ib0ab1c2d0dd45f35f43cf710f7c15791d282ad4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135997
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 350ae0a3f5e5b115070c2371a805bf7ab981d242)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135987

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 93b217f1d632..99933f165c24 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -3420,8 +3420,23 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& 
Order1, const uno::Any&
 
 ScDocument& rDoc = getScDocument();
 
-RangeHelper thisRange( mxRange );
+uno::Reference< table::XCellRange > xRangeCurrent;
+if (isSingleCellRange())
+{
+// Expand to CurrentRegion
+uno::Reference< excel::XRange > xCurrent( CurrentRegion());
+if (xCurrent.is())
+{
+const ScVbaRange* pRange = getImplementation( xCurrent );
+if (pRange)
+xRangeCurrent = pRange->mxRange;
+}
+}
+if (!xRangeCurrent.is())
+xRangeCurrent = mxRange;
+RangeHelper thisRange( xRangeCurrent );
 table::CellRangeAddress thisRangeAddress = 
thisRange.getCellRangeAddressable()->getRangeAddress();
+
 ScSortParam aSortParam;
 SCTAB nTab = thisRangeAddress.Sheet;
 rDoc.GetSortParam( aSortParam, nTab );
@@ -3435,7 +3450,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& 
Order1, const uno::Any&
 
 // 1) #TODO #FIXME need to process DataOption[1..3] not used currently
 // 2) #TODO #FIXME need to refactor this ( below ) into an IsSingleCell() 
method
-uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, 
uno::UNO_QUERY_THROW );
+uno::Reference< table::XColumnRowRange > xColumnRowRange(xRangeCurrent, 
uno::UNO_QUERY_THROW );
 
 // set up defaults
 
@@ -3548,24 +3563,24 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& 
Order1, const uno::Any&
 if ( Key3.hasValue() )
 xKey3 = processKey( Key3, mxContext, pDocShell );
 
-uno::Reference< util::XSortable > xSort( mxRange, uno::UNO_QUERY_THROW );
+uno::Reference< util::XSortable > xSort( xRangeCurrent, 
uno::UNO_QUERY_THROW );
 uno::Sequence< beans::PropertyValue > sortDescriptor = 
xSort->createSortDescriptor();
 auto psortDescriptor = sortDescriptor.getArray();
 sal_Int32 nTableSortFieldIndex = findSortPropertyIndex( sortDescriptor, 
"SortFields" );
 
 uno::Sequence< table::TableSortField > sTableFields(1);
 sal_Int32 nTableIndex = 0;
-updateTableSortField(  mxRange, xKey1, nOrder1, sTableFields.getArray()[ 
nTableIndex++ ], bIsSortColumns, bMatchCase );
+updateTableSortField(  xRangeCurrent, xKey1, nOrder1, 
sTableFields.getArray()[ nTableIndex++ ], bIsSortColumns, bMatchCase );
 
 if ( xKey2.is() )
 {
 sTableFields.realloc( sTableFields.getLength() + 1 );
-updateTableSortField(  mxRange, xKey2, nOrder2, 
sTableFields.getArray()[ nTableIndex++ ], bIsSortColumns, bMatchCase );
+updateTableSortField(  xRangeCurrent, xKey2, nOrder2, 
sTableFields.getArray()[ nTableIndex++ ], bIsSortColumns, bMatchCase );
 }
 if ( xKey3.is()  )
 {
 sTableFields.realloc( sTableFields.getLength() + 1 );
-updateTableSortField(  mxRange, xKey3, nOrder3, 
sTableFields.getArray()[ nTableIndex++ ], bIsSortColumns, bMatchCase );
+updateTableSortField(  xRangeCurrent, xKey3, nOrder3, 
sTableFields.getArray()[ nTableIndex++ ], bIsSortColumns, bMatchCase );
 }
 psortDescriptor[ nTableSortFieldIndex ].Value <<= sTableFields;
 


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

2022-06-16 Thread Eike Rathke (via logerrit)
 sc/source/ui/vba/vbarange.cxx |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit e4173f2831c7147813806b192f27266d1c437018
Author: Eike Rathke 
AuthorDate: Thu Jun 16 13:14:43 2022 +0200
Commit: Eike Rathke 
CommitDate: Thu Jun 16 16:27:15 2022 +0200

One call to XCellRangeAddressable::getRangeAddress() is enough

... each needs to obtain it via ScUnoConversion::FillApiRange().

Change-Id: Ie98d5130067701f40c441d08bdb9faf7913bcdb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135972
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 796a4c9eca7cb1172b9ab8bcbf32db30e7ef4dfc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135982

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index b98b5471ff7b..93b217f1d632 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1140,12 +1140,9 @@ public:
 static uno::Reference< excel::XRange > createRangeFromRange( const 
uno::Reference< XHelperInterface >& xParent, const 
uno::Reference& xContext,
 const uno::Reference< table::XCellRange >& xRange, const 
uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable )
 {
+const table::CellRangeAddress aRA( 
xCellRangeAddressable->getRangeAddress());
 return uno::Reference< excel::XRange >( new ScVbaRange( xParent, 
xContext,
-xRange->getCellRangeByPosition(
-xCellRangeAddressable->getRangeAddress().StartColumn,
-xCellRangeAddressable->getRangeAddress().StartRow,
-xCellRangeAddressable->getRangeAddress().EndColumn,
-xCellRangeAddressable->getRangeAddress().EndRow ) ) );
+xRange->getCellRangeByPosition( aRA.StartColumn, 
aRA.StartRow, aRA.EndColumn, aRA.EndRow)));
 }
 
 };


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

2022-06-16 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/table7.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b2b8cfe9c8d035be6ba86e5e13f295059c105384
Author: Luboš Luňák 
AuthorDate: Wed Jun 15 09:29:20 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Jun 16 15:14:50 2022 +0200

allocate column in ScTable::DeleteBeforeCopyFromClip() (tdf#149554)

Change-Id: I22607f1dd0ec1c083f6a52a2ecccb976fc133687
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135864
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit e445eac863ac616fb99c9d6bf5510b965fd15957)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135949

diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index f7576361c8a1..9af01cba748e 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -115,7 +115,7 @@ void ScTable::DeleteBeforeCopyFromClip(
 if (nClipCol > aClipRange.aEnd.Col())
 nClipCol = aClipRange.aStart.Col(); // loop through columns.
 
-const ScColumn& rClipCol = rClipTab.aCol[nClipCol];
+const ScColumn& rClipCol = 
const_cast(rClipTab).CreateColumnIfNotExists(nClipCol);
 aCol[nCol].DeleteBeforeCopyFromClip(rCxt, rClipCol, 
rBroadcastSpans);
 }
 }


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

2022-06-16 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/colorscale.cxx |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 2af4b268032a52905f75684c5b5a226b5dbc3027
Author: Mike Kaganski 
AuthorDate: Wed Jun 15 09:59:46 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 16 11:04:42 2022 +0200

Negative percentile should be treated as 0

Change-Id: I460cd2ea6950cf9f8bc656a94c71973bd93c1fae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135879
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit fdde571c6a5ec65a24c496af4c5928e22bd89ba2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135945
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 96aeef2819c1..75f94d3bc2ed 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -540,10 +540,14 @@ Color CalcColor( double nVal, double nVal1, const Color& 
rCol1, double nVal2, co
  */
 double GetPercentile( const std::vector& rArray, double fPercentile )
 {
+assert(!rArray.empty());
+SAL_WARN_IF(fPercentile < 0, "sc", "negative percentile");
+if (fPercentile < 0)
+return rArray.front();
+assert(fPercentile <= 1);
 size_t nSize = rArray.size();
 double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
-SAL_WARN_IF(fFloor < 0, "sc", "negative percentile");
-size_t nIndex = fFloor >= 0 ? static_cast(fFloor) : 0;
+size_t nIndex = static_cast(fFloor);
 double fDiff = fPercentile * (nSize-1) - fFloor;
 std::vector::const_iterator iter = rArray.begin() + nIndex;
 if (fDiff == 0.0)


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

2022-06-15 Thread Eike Rathke (via logerrit)
 sc/source/ui/unoobj/cellsuno.cxx |4 +++-
 sc/source/ui/vba/vbarange.cxx|9 ++---
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 31e47d1e76052b52a4aa058306cd17a1c0ef36aa
Author: Eike Rathke 
AuthorDate: Tue Jun 14 13:55:09 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Jun 15 11:18:54 2022 +0200

Related: tdf#149325 Fix yet another VbaRange empty ScRangeList access

Change-Id: If2c44795ab794482b841138bdd55f37c4d30b592
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135824
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 0834cda6ae8e7bd4306d2a0464492344ebf1c104)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135853

diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 529830d6f510..b2117cefccf8 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6714,7 +6714,9 @@ uno::Reference SAL_CALL 
ScTableSheetObj::createCursorBy
 if (pRangesImp)
 {
 const ScRangeList& rRanges = pRangesImp->GetRangeList();
-OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
+SAL_WARN_IF( rRanges.size() != 1, "sc", 
"ScTableSheetObj::createCursorByRange: Range? Ranges?");
+if (rRanges.empty())
+return nullptr;
 return new ScCellCursorObj( pDocSh, rRanges[ 0 ] );
 }
 }
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index d277d444901b..b98b5471ff7b 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1288,9 +1288,12 @@ uno::Reference< sheet::XSheetCellRange > 
lclExpandToMerged( const uno::Reference
 {
 aOldAddress = aNewAddress;
 uno::Reference< sheet::XSheetCellCursor > xCursor( 
xSheet->createCursorByRange( xNewCellRange ), uno::UNO_SET_THROW );
-xCursor->collapseToMergedArea();
-xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW );
-aNewAddress = lclGetRangeAddress( xNewCellRange );
+if (xCursor.is())
+{
+xCursor->collapseToMergedArea();
+xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW );
+aNewAddress = lclGetRangeAddress( xNewCellRange );
+}
 }
 while( bRecursive && (aOldAddress != aNewAddress) );
 return xNewCellRange;


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

2022-06-14 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/dpobject.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 93302d4c32f99a7691777564d04ce82172e48d44
Author: Caolán McNamara 
AuthorDate: Tue Jun 14 12:56:41 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Jun 15 06:28:29 2022 +0200

crashtesting: assert seen on loading forum-en-38962.ods

mismatched Push/Pop, catch offending exception

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

diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index e6b312e51add..fc31af3c6e28 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1022,7 +1022,16 @@ bool ScDPObject::GetMembers( sal_Int32 nDim, sal_Int32 
nHier, vector xMember(xMembersIA->getByIndex(i), 
UNO_QUERY);
+Reference xMember;
+try
+{
+xMember = Reference(xMembersIA->getByIndex(i), 
UNO_QUERY);
+}
+catch (const container::NoSuchElementException&)
+{
+TOOLS_WARN_EXCEPTION("sc", "ScNameToIndexAccess getByIndex 
failed");
+}
+
 ScDPLabelData::Member aMem;
 
 if (xMember.is())


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

2022-06-14 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/colorscale.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit c599c26967db0cd606c3ce9e7ee0153a65be28bb
Author: Caolán McNamara 
AuthorDate: Tue Jun 14 12:24:41 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Jun 15 06:27:35 2022 +0200

crashtesting: negative index seen on loading forum-de3-15472.ods

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

diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index ee8bf407ba0e..96aeef2819c1 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -541,8 +541,10 @@ Color CalcColor( double nVal, double nVal1, const Color& 
rCol1, double nVal2, co
 double GetPercentile( const std::vector& rArray, double fPercentile )
 {
 size_t nSize = rArray.size();
-size_t nIndex = static_cast(::rtl::math::approxFloor( fPercentile 
* (nSize-1)));
-double fDiff = fPercentile * (nSize-1) - ::rtl::math::approxFloor( 
fPercentile * (nSize-1));
+double fFloor = ::rtl::math::approxFloor(fPercentile * (nSize-1));
+SAL_WARN_IF(fFloor < 0, "sc", "negative percentile");
+size_t nIndex = fFloor >= 0 ? static_cast(fFloor) : 0;
+double fDiff = fPercentile * (nSize-1) - fFloor;
 std::vector::const_iterator iter = rArray.begin() + nIndex;
 if (fDiff == 0.0)
 return *iter;


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

2022-06-14 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/table2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 650c3477aa4120cafcb9f0e77b341b1ac70de048
Author: Luboš Luňák 
AuthorDate: Mon Jun 13 19:51:43 2022 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jun 15 06:25:43 2022 +0200

allocate columns in ScTable::TransposeClip() (tdf#149554)

Change-Id: I2ae151ed9656884bca6963ba09bdf236e09096b7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135774
Tested-by: Xisco Fauli 
Reviewed-by: Luboš Luňák 
(cherry picked from commit ef1be22efb3e1625da1683ea98392cc41657b1cd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135747
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 3ba4ce9b5bfd..ab3532b70236 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -990,7 +990,7 @@ void ScTable::TransposeClip(SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
 {
 bool bWasCut = rDocument.IsCutMode();
 
-for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
+for (SCCOL nCol : GetWritableColumnsRange(nCol1, nCol2))
 {
 std::vector aFilteredRows;
 


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

2022-06-14 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/dptabres.cxx |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit dbb0522741a88c878be9a89675e83bb79ddb7733
Author: Caolán McNamara 
AuthorDate: Tue Jun 14 10:51:13 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Jun 14 22:13:35 2022 +0200

crashtesting: crash seen on exporting forum-it-5909.ods to xlsx

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

diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index c29648d95d8b..d41604eee45e 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -2767,7 +2767,10 @@ ScDPResultDimension::~ScDPResultDimension()
 ScDPResultMember *ScDPResultDimension::FindMember(  SCROW  iData ) const
 {
 if( bIsDataLayout )
-return maMemberArray[0].get();
+{
+SAL_WARN_IF(maMemberArray.empty(), "sc.core", "MemberArray is empty");
+return !maMemberArray.empty() ? maMemberArray[0].get() : nullptr;
+}
 
 MemberHash::const_iterator aRes = maMemberHash.find( iData );
 if( aRes != maMemberHash.end()) {
@@ -2974,8 +2977,11 @@ void ScDPResultDimension::LateInitFrom(
 
 tools::Long ScDPResultDimension::GetSize(tools::Long nMeasure) const
 {
-tools::Long nTotal = 0;
 tools::Long nMemberCount = maMemberArray.size();
+if (!nMemberCount)
+return 0;
+
+tools::Long nTotal = 0;
 if (bIsDataLayout)
 {
 OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || 
pResultData->GetMeasureCount() == 1,
@@ -3128,7 +3134,7 @@ void ScDPResultDimension::SortMembers( ScDPResultMember* 
pRefMember )
 // handle children
 
 // for data layout, call only once - sorting measure is always taken from 
settings
-tools::Long nLoopCount = bIsDataLayout ? 1 : nCount;
+tools::Long nLoopCount = bIsDataLayout ? std::min(1, nCount) 
: nCount;
 for (tools::Long i=0; i

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

2022-06-14 Thread Michael Stahl (via logerrit)
 sc/source/filter/xml/xmlexprt.cxx |   28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

New commits:
commit 3c921ea2f33dbd04dcde2dedac2b103aeefee053
Author: Michael Stahl 
AuthorDate: Sun Jun 12 21:48:58 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Jun 14 14:05:28 2022 +0200

sc: ODF export: fix style:font-name on EE text/paragraph styles

The problem is that sc contains its own duplicate export of EditEngine
styles, where the SvxFontItem aFamilyName is exported directly to
style:font-name.

But style:font-name refers to a style:font-face, and for a given font
family name there may be multiple font-face elements whose names have a
counter appended, and they are written in some non-deterministic order,
so effectively this picks font-face at random.

In XMLTextExportPropertySetMapper::ContextFontFilter() there is already
code to do the lookup, and also a fallback when the lookup fails to a
set of individual attributes fo:font-family style:font-style-name
style:font-family-generic etc., which is actually used for fonts in
control shapes, which have "unknown" for one of the components, so there
could be some other problem with them.

It doesn't look possible for the lookup to fail for EditEngine items, as
ScXMLFontAutoStylePool_Impl should have added all of them.

This problem was detected by current ODFunDiff in 22 of 2000 ODS files;
with this fix only other problems remain.

Change-Id: I276f705296df628b0869526f4ea676c47a014328
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135684
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 22e3fafb95072cd7027ad64c474a9709037402ea)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135713
Reviewed-by: Eike Rathke 

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 654299294d71..023165f56c95 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -924,6 +924,7 @@ void ScXMLExport::ExportExternalRefCacheStyles()
 namespace {
 
 void handleFont(
+SvXMLExport & rExport,
 std::vector& rPropStates,
 const SfxPoolItem* p, const rtl::Reference& xMapper, 
std::u16string_view rXMLName )
 {
@@ -937,14 +938,23 @@ void handleFont(
 if (nIndexFontName == -1 || nIndexFontName >= nEntryCount)
 return;
 
-uno::Any aAny;
-if (!pItem->QueryValue(aAny, MID_FONT_FAMILY_NAME))
-return;
+OUString const sFamilyName(pItem->GetFamilyName());
+OUString const sStyleName(pItem->GetStyleName());
+auto const nFamily(pItem->GetFamily());
+auto const nPitch(pItem->GetPitch());
+auto const eEnc(pItem->GetCharSet());
+OUString const sName(rExport.GetFontAutoStylePool()->Find(
+sFamilyName, sStyleName, nFamily, nPitch, eEnc));
+if (sName.isEmpty())
+{
+assert(false); // fallback to fo:font-family etc. probably not needed
+}
 
-rPropStates.emplace_back(nIndexFontName, aAny);
+rPropStates.emplace_back(nIndexFontName, uno::Any(sName));
 }
 
 const SvxFieldData* toXMLPropertyStates(
+SvXMLExport & rExport,
 std::vector& rPropStates, const std::vector& rSecAttrs,
 const rtl::Reference& xMapper, const 
ScXMLEditAttributeMap& rAttrMap )
 {
@@ -973,13 +983,13 @@ const SvxFieldData* toXMLPropertyStates(
 switch (p->Which())
 {
 case EE_CHAR_FONTINFO:
-handleFont(rPropStates, p, xMapper, u"font-name");
+handleFont(rExport, rPropStates, p, xMapper, u"font-name");
 break;
 case EE_CHAR_FONTINFO_CJK:
-handleFont(rPropStates, p, xMapper, u"font-name-asian");
+handleFont(rExport, rPropStates, p, xMapper, 
u"font-name-asian");
 break;
 case EE_CHAR_FONTINFO_CTL:
-handleFont(rPropStates, p, xMapper, u"font-name-complex");
+handleFont(rExport, rPropStates, p, xMapper, 
u"font-name-complex");
 break;
 case EE_CHAR_WEIGHT:
 case EE_CHAR_WEIGHT_CJK:
@@ -1264,7 +1274,7 @@ void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 
nTable)
 continue;
 
 std::vector aPropStates;
-toXMLPropertyStates(aPropStates, rSecAttrs, xMapper, rAttrMap);
+toXMLPropertyStates(*this, aPropStates, rSecAttrs, xMapper, 
rAttrMap);
 if (!aPropStates.empty())
 xStylePool->Add(XmlStyleFamily::TEXT_TEXT, OUString(), 
std::move(aPropStates));
 }
@@ -3101,7 +3111,7 @@ void flushParagraph(
 OUString aContent(rParaText.substr(rSec.mnStart, rSec.mnEnd - 
rSec.mnStart));
 
 std::vector aPropStates;
-const SvxFieldData* pField = toXMLPropertyStates(aPropStates, 
rSec.maAttributes, xMapper, rAttrMap);
+const SvxFieldData* pField = 

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

2022-06-13 Thread Eike Rathke (via logerrit)
 sc/source/ui/vba/vbarange.cxx |   57 +++---
 sc/source/ui/vba/vbarange.hxx |2 -
 2 files changed, 33 insertions(+), 26 deletions(-)

New commits:
commit 7039bb3413476199448d76e3a454cf929217d7bd
Author: Eike Rathke 
AuthorDate: Mon Jun 13 19:38:59 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Jun 14 02:12:21 2022 +0200

Related: tdf#149325 Eliminate all unconditional ScRangeList::front() access

... to prevent crashes, and where possible substitute a missing
element with the original sheet object range.

Change-Id: I245844e89fa3eb7d6ec07e279bdd23022fd77958
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135773
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit d6331fc7abe545ff0a369c41ab3f55b8f44a2cc1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135741

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 44e565700f71..d277d444901b 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -874,15 +874,18 @@ protected:
 ScCellRangesBase* pUnoRangesBase = dynamic_cast< 
ScCellRangesBase* >( xIf.get() );
 if ( pUnoRangesBase )
 {
-ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
-ScCompiler aCompiler( m_rDoc, aCellRanges.front().aStart, 
m_eGrammar );
-// compile the string in the format passed in
-std::unique_ptr 
pArray(aCompiler.CompileString(sFormula));
-// convert to API grammar
-aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_API );
-OUString sConverted;
-aCompiler.CreateStringFromTokenArray(sConverted);
-sFormula = EQUALS + sConverted;
+const ScRangeList& rCellRanges = 
pUnoRangesBase->GetRangeList();
+if (!rCellRanges.empty())
+{
+ScCompiler aCompiler( m_rDoc, 
rCellRanges.front().aStart, m_eGrammar );
+// compile the string in the format passed in
+std::unique_ptr 
pArray(aCompiler.CompileString(sFormula));
+// convert to API grammar
+aCompiler.SetGrammar( 
formula::FormulaGrammar::GRAM_API );
+OUString sConverted;
+aCompiler.CreateStringFromTokenArray(sConverted);
+sFormula = EQUALS + sConverted;
+}
 }
 }
 
@@ -920,16 +923,19 @@ public:
 {
 OUString sVal;
 aValue >>= sVal;
-ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
-// Compile string from API grammar.
-ScCompiler aCompiler( m_rDoc, aCellRanges.front().aStart, 
formula::FormulaGrammar::GRAM_API );
-std::unique_ptr 
pArray(aCompiler.CompileString(sVal));
-// Convert to desired grammar.
-aCompiler.SetGrammar( m_eGrammar );
-OUString sConverted;
-aCompiler.CreateStringFromTokenArray(sConverted);
-sVal = EQUALS + sConverted;
-aValue <<= sVal;
+const ScRangeList& rCellRanges = 
pUnoRangesBase->GetRangeList();
+if (!rCellRanges.empty())
+{
+// Compile string from API grammar.
+ScCompiler aCompiler( m_rDoc, rCellRanges.front().aStart, 
formula::FormulaGrammar::GRAM_API );
+std::unique_ptr 
pArray(aCompiler.CompileString(sVal));
+// Convert to desired grammar.
+aCompiler.SetGrammar( m_eGrammar );
+OUString sConverted;
+aCompiler.CreateStringFromTokenArray(sConverted);
+sVal = EQUALS + sConverted;
+aValue <<= sVal;
+}
 }
 }
 
@@ -1923,7 +1929,8 @@ ScVbaRange::Offset( const ::uno::Any , const 
uno::Any  )
 return new ScVbaRange( mxParent, mxContext, xRanges );
 }
 // normal range
-uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( 
pUnoRangesBase->GetDocShell(), aCellRanges.front() ) );
+const ScRange aRange( obtainRangeEvenIfRangeListIsEmpty( aCellRanges));
+uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( 
pUnoRangesBase->GetDocShell(), aRange));
 return new ScVbaRange( mxParent, mxContext, xRange  );
 }
 
@@ -2374,12 +2381,11 @@ ScVbaRange::Activate()
 
 }
 
-ScRange ScVbaRange::obtainRangeEvenIfRangeListIsEmpty( const ScCellRangesBase* 
pUnoRangesBase ) const
+ScRange ScVbaRange::obtainRangeEvenIfRangeListIsEmpty( const ScRangeList& 
rCellRanges ) const
 {
 // XXX It may be that using the current range list was 

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

2022-06-13 Thread Eike Rathke (via logerrit)
 sc/source/ui/vba/vbarange.cxx |   23 +--
 sc/source/ui/vba/vbarange.hxx |3 +++
 2 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit e6294617b93a8d763d9355c5ce517428dea38e09
Author: Eike Rathke 
AuthorDate: Mon Jun 13 17:00:43 2022 +0200
Commit: Eike Rathke 
CommitDate: Tue Jun 14 01:19:47 2022 +0200

Resolves: tdf#149531 Use initial sheet range for VBA Columns and Rows

... if the ScTableSheetObj's ScRangeList is empty. It might even
be that was never intended to be used and worked only by accident
in the past (pre 6.0), but it's somewhat unclear. It may even get
in the way in case it exists and the (first) range was modified,
e.g. shrunk by a Delete, as the resulting column or row object
could be different from the initial sheet range.

Change-Id: Ib9911df1b23802054a5bb0621bb7f5559ef3f39b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135732
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
(cherry picked from commit 3ad12672e924f7aef394119f9fe5f0b06a900b9e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135738

diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 5a6c1f2f18b7..44e565700f71 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -2374,17 +2374,29 @@ ScVbaRange::Activate()
 
 }
 
+ScRange ScVbaRange::obtainRangeEvenIfRangeListIsEmpty( const ScCellRangesBase* 
pUnoRangesBase ) const
+{
+// XXX It may be that using the current range list was never correct, but
+// always the initial sheet range would be instead, history is unclear.
+
+const ScRangeList& rCellRanges = pUnoRangesBase->GetRangeList();
+if (!rCellRanges.empty())
+return rCellRanges.front();
+
+table::CellRangeAddress aRA( lclGetRangeAddress( mxRange ));
+return ScRange( aRA.StartColumn, aRA.StartRow, aRA.Sheet, aRA.EndColumn, 
aRA.EndRow, aRA.Sheet);
+}
+
 uno::Reference< excel::XRange >
 ScVbaRange::Rows(const uno::Any& aIndex )
 {
 if ( aIndex.hasValue() )
 {
-sal_Int32 nValue = 0;
 ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
-ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
-OUString sAddress;
+ScRange aRange( obtainRangeEvenIfRangeListIsEmpty( pUnoRangesBase));
 
-ScRange aRange = aCellRanges.front();
+sal_Int32 nValue = 0;
+OUString sAddress;
 if( aIndex >>= nValue )
 {
 aRange.aStart.SetRow( aRange.aStart.Row() + --nValue );
@@ -2420,9 +2432,8 @@ uno::Reference< excel::XRange >
 ScVbaRange::Columns(const uno::Any& aIndex )
 {
 ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
-ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+ScRange aRange( obtainRangeEvenIfRangeListIsEmpty( pUnoRangesBase));
 
-ScRange aRange = aCellRanges.front();
 if ( aIndex.hasValue() )
 {
 OUString sAddress;
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index b32cc1ba3a5d..a893115d3a75 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -119,6 +119,9 @@ class ScVbaRange : public ScVbaRange_BASE
 /** Fires a Worksheet_Change event for this range or range list. */
 void fireChangeEvent();
 
+/// @throws css::uno::RuntimeException
+ScRange obtainRangeEvenIfRangeListIsEmpty( const ScCellRangesBase* 
pUnoRangesBase ) const;
+
 protected:
 virtual ScCellRangesBase* getCellRangesBase() override;
 /// @throws css::uno::RuntimeException


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

2022-06-13 Thread Luboš Luňák (via logerrit)
 sc/source/core/data/table1.cxx |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 371f8bd277deb78d1fe8f1201360849fd32ff127
Author: Luboš Luňák 
AuthorDate: Fri Jun 10 17:39:46 2022 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jun 13 17:14:43 2022 +0200

find last data row before searching for first data row

GetLastDataRow() is more efficient than iterating every cell
with HasDataAt(), so first reduce the row range from the end
(in case the whole range is empty cells it's just one call).

Change-Id: Idc494795f68492ed8b05b2cd575598a9c5868b7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135605
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
(cherry picked from commit 7689bf445264d1b54038ec0b8d134c26847af40f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135704
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 4a293f5068de..0eaf10c786da 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1118,6 +1118,18 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, 
SCCOL& rStartCol, SCROW& rS
 
 if (!bColumnsOnly)
 {
+while (rStartRow < rEndRow)
+{
+SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, 
pDataAreaExtras);
+if (0 <= nLastDataRow && nLastDataRow < rEndRow)
+{
+rEndRow = std::max( rStartRow, nLastDataRow);
+o_bShrunk = true;
+}
+else
+break;  // while
+}
+
 if (!bStickyTopRow)
 {
 while (rStartRow < rEndRow)
@@ -1137,18 +1149,6 @@ bool ScTable::ShrinkToUsedDataArea( bool& o_bShrunk, 
SCCOL& rStartCol, SCROW& rS
 break;  // while
 }
 }
-
-while (rStartRow < rEndRow)
-{
-SCROW nLastDataRow = GetLastDataRow(rStartCol, rEndCol, rEndRow, 
pDataAreaExtras);
-if (0 <= nLastDataRow && nLastDataRow < rEndRow)
-{
-rEndRow = std::max( rStartRow, nLastDataRow);
-o_bShrunk = true;
-}
-else
-break;  // while
-}
 }
 
 return rStartCol != rEndCol || (bColumnsOnly ?