core.git: Branch 'libreoffice-24-2' - sc/source

2024-05-07 Thread Patrick Luby (via logerrit)
 sc/source/ui/app/transobj.cxx |   31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

New commits:
commit b11c9b5f205907390ef210ae3c1f9f54fee84820
Author: Patrick Luby 
AuthorDate: Sat May 4 19:58:03 2024 -0400
Commit: Noel Grandin 
CommitDate: Tue May 7 08:47:20 2024 +0200

tdf#160855 fix crash due to Skia's internal maximum pixel limit

Somewhere in the tens of thousands of selected fill cells,
the size of the VirtualDevice exceeds 1 GB of pixels. But
Skia, at least on macOS, will fail to create a surface.
Even if there is ample free memory, Skia/Raster will fail.

The second problem is that even if you disable Skia, the
crash is just delayed when a BitmapEx is created from the
VirtualDevice and malloc() fails.

Since this data flavor really triggers one or more system
memory limits, lower the resolution of the bitmap by keeping
the VirtualDevice pixel size within an arbitrary number of
pixels.

Note: the artibrary "maximum number of pixels" limit that
that Skia can handle may need to be raised or lowered for
platforms other than macOS.

Change-Id: Ie087f2db152470aa70521fbe5fe6c7cedd8504af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167145
Reviewed-by: Noel Grandin 
Tested-by: Jenkins
Reviewed-by: Patrick Luby 
(cherry picked from commit 8d9f54165d28d83092667b7bfcd0ee48ade54c87)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167215

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 5f0599c888b3..e5ed3b1afe2a 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -405,11 +405,38 @@ bool ScTransferObj::GetData( const 
datatransfer::DataFlavor& rFlavor, const OUSt
  aReducedBlock.aEnd.Col(), 
aReducedBlock.aEnd.Row(),
  aReducedBlock.aStart.Tab() );
 ScopedVclPtrInstance< VirtualDevice > pVirtDev;
-
pVirtDev->SetOutputSizePixel(pVirtDev->LogicToPixel(aMMRect.GetSize(), 
MapMode(MapUnit::Map100thMM)));
+
+// tdf#160855 fix crash due to Skia's internal maximum pixel limit
+// Somewhere in the tens of thousands of selected fill cells,
+// the size of the VirtualDevice exceeds 1 GB of pixels. But
+// Skia, at least on macOS, will fail to create a surface.
+// Even if there is ample free memory, Skia/Raster will fail.
+// The second problem is that even if you disable Skia, the
+// crash is just delayed when a BitmapEx is created from the
+// VirtualDevice and malloc() fails.
+// Since this data flavor really triggers one or more system
+// memory limits, lower the resolution of the bitmap by keeping
+// the VirtualDevice pixel size within an arbitrary number of
+// pixels.
+// Note: the artibrary "maximum number of pixels" limit that
+// that Skia can handle may need to be raised or lowered for
+// platforms other than macOS.
+static constexpr tools::Long nCopyToImageMaxPixels = 8192 * 8192;
+Fraction aScale(1.0);
+Size aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), 
MapMode(MapUnit::Map100thMM));
+tools::Long nPixels(aPixelSize.Width() * aPixelSize.Height());
+if (nPixels < 0 || nPixels > nCopyToImageMaxPixels)
+{
+aScale = Fraction(nCopyToImageMaxPixels, nPixels);
+aPixelSize = pVirtDev->LogicToPixel(aMMRect.GetSize(), 
MapMode(MapUnit::Map100thMM, Point(), aScale, aScale));
+nPixels = aPixelSize.Width() * aPixelSize.Height();
+}
+
+pVirtDev->SetOutputSizePixel(aPixelSize);
 
 PaintToDev( pVirtDev, *m_pDoc, 1.0, aReducedBlock );
 
-pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel ) );
+pVirtDev->SetMapMode( MapMode( MapUnit::MapPixel, Point(), aScale, 
aScale ) );
 BitmapEx aBmp = pVirtDev->GetBitmapEx( Point(), 
pVirtDev->GetOutputSize() );
 bOK = SetBitmapEx( aBmp, rFlavor );
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-05-06 Thread Caolán McNamara (via logerrit)
 sc/source/ui/navipi/content.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit fb7e3ebf22a120fa0055d556616aeb69abe49bec
Author: Caolán McNamara 
AuthorDate: Sun May 5 20:54:59 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon May 6 16:34:24 2024 +0200

wrong ScContentTree::SelectEntryByName early return condition

Change-Id: I974f5aea545a80b0e48b50e2a2eae0729ff59691
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167174
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins
(cherry picked from commit 18b70ec7d9c4a0288f206cb64708f87a83789c00)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167085
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 89d77642558a..374ee934389e 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1435,7 +1435,7 @@ void ScContentTree::SelectEntryByName(const ScContentId 
nRoot, std::u16string_vi
 {
 weld::TreeIter* pParent = m_aRootNodes[nRoot].get();
 
-if (pParent || !m_xTreeView->iter_has_child(*pParent))
+if (!pParent || !m_xTreeView->iter_has_child(*pParent))
 return;
 
 std::unique_ptr 
xEntry(m_xTreeView->make_iterator(pParent));


core.git: Branch 'libreoffice-24-2' - sc/source

2024-05-06 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/interpr4.cxx |   31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

New commits:
commit 34126d6fceb054b7ba05ceeae76e32c89fac580f
Author: Caolán McNamara 
AuthorDate: Fri Apr 12 12:24:06 2024 +0100
Commit: Eike Rathke 
CommitDate: Mon May 6 15:10:12 2024 +0200

Related: tdf#160056 don't call GetParamCount twice

GetParamCount: 290ms -> 175ms
Change-Id: Ic3a26b1e8035744dcab2da69a8ebd3b29dd2160a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166031
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 030b655963c182693c7b657dc6aa4d2fe85c17c6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166301
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 9a483103e3f9..959b04a70e10 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -4042,8 +4042,9 @@ StackVar ScInterpreter::Interpret()
 (*aTokenMatrixMapIter).second->GetType() != svJumpMatrix)
 {
 // Path already calculated, reuse result.
-if (sp >= pCur->GetParamCount())
-nStackBase = sp - pCur->GetParamCount();
+const sal_uInt8 nParamCount = pCur->GetParamCount();
+if (sp >= nParamCount)
+nStackBase = sp - nParamCount;
 else
 {
 SAL_WARN("sc.core", "Stack anomaly with calculated path at "
@@ -4051,7 +4052,7 @@ StackVar ScInterpreter::Interpret()
 << "  " << aPos.Format(
 ScRefFlags::VALID | ScRefFlags::FORCE_DOC | 
ScRefFlags::TAB_3D, )
 << "  eOp: " << static_cast(eOp)
-<< "  params: " << 
static_cast(pCur->GetParamCount())
+<< "  params: " << static_cast(nParamCount)
 << "  nStackBase: " << nStackBase << "  sp: " << sp);
 nStackBase = sp;
 assert(!"underflow");
@@ -4080,18 +4081,22 @@ StackVar ScInterpreter::Interpret()
 eOp = ocNone;   // JumpMatrix created
 nStackBase = sp;
 }
-else if (sp >= pCur->GetParamCount())
-nStackBase = sp - pCur->GetParamCount();
 else
 {
-SAL_WARN("sc.core", "Stack anomaly at " << aPos.Tab() << 
"," << aPos.Col() << "," << aPos.Row()
-<< "  " << aPos.Format(
-ScRefFlags::VALID | ScRefFlags::FORCE_DOC | 
ScRefFlags::TAB_3D, )
-<< "  eOp: " << static_cast(eOp)
-<< "  params: " << 
static_cast(pCur->GetParamCount())
-<< "  nStackBase: " << nStackBase << "  sp: " << 
sp);
-nStackBase = sp;
-assert(!"underflow");
+const sal_uInt8 nParamCount = pCur->GetParamCount();
+if (sp >= nParamCount)
+nStackBase = sp - nParamCount;
+else
+{
+SAL_WARN("sc.core", "Stack anomaly at " << aPos.Tab() 
<< "," << aPos.Col() << "," << aPos.Row()
+<< "  " << aPos.Format(
+ScRefFlags::VALID | ScRefFlags::FORCE_DOC 
| ScRefFlags::TAB_3D, )
+<< "  eOp: " << static_cast(eOp)
+<< "  params: " << 
static_cast(nParamCount)
+<< "  nStackBase: " << nStackBase << "  sp: " 
<< sp);
+nStackBase = sp;
+assert(!"underflow");
+}
 }
 }
 


core.git: Branch 'libreoffice-24-2' - sc/source

2024-05-06 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/interpr4.cxx |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 9757290668b50827ab22597a73a4850ebf3f6521
Author: Caolán McNamara 
AuthorDate: Sat Apr 13 16:35:28 2024 +0100
Commit: Eike Rathke 
CommitDate: Mon May 6 15:09:55 2024 +0200

Related: tdf#160056 don't set nVal twice

Change-Id: I0da3e0c7f18271f6104d52b50d65e96564650b8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166054
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 63b237e1e8147f54e6d4db4671f612a656200e2f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166300
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 95dff9f1cc18..9a483103e3f9 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2099,7 +2099,7 @@ double ScInterpreter::GetDoubleFromMatrix(const 
ScMatrixRef& pMat)
 
 double ScInterpreter::GetDouble()
 {
-double nVal(0.0);
+double nVal;
 switch( GetRawStackType() )
 {
 case svDouble:
@@ -2134,13 +2134,16 @@ double ScInterpreter::GetDouble()
 {
 ScExternalRefCache::TokenRef pToken;
 PopExternalSingleRef(pToken);
-if (nGlobalError == FormulaError::NONE)
+if (nGlobalError != FormulaError::NONE)
 {
-if (pToken->GetType() == svDouble || pToken->GetType() == 
svEmptyCell)
-nVal = pToken->GetDouble();
-else
-nVal = ConvertStringToValue( 
pToken->GetString().getString());
+nVal = 0.0;
+break;
 }
+
+if (pToken->GetType() == svDouble || pToken->GetType() == 
svEmptyCell)
+nVal = pToken->GetDouble();
+else
+nVal = ConvertStringToValue( pToken->GetString().getString());
 }
 break;
 case svExternalDoubleRef:
@@ -2148,7 +2151,10 @@ double ScInterpreter::GetDouble()
 ScMatrixRef pMat;
 PopExternalDoubleRef(pMat);
 if (nGlobalError != FormulaError::NONE)
+{
+nVal = 0.0;
 break;
+}
 
 nVal = GetDoubleFromMatrix(pMat);
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-05-06 Thread Noel Grandin (via logerrit)
 sc/source/filter/oox/extlstcontext.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f99b8fc6ef3cd311b8bab52b3674d2637cb547e2
Author: Noel Grandin 
AuthorDate: Wed Apr 17 14:06:57 2024 +0200
Commit: Noel Grandin 
CommitDate: Mon May 6 13:13:49 2024 +0200

tdf#160706 speed up loading conditional formatting rule in XLS

we only need to finalizeImport on the last ExtDxf we loaded, otherwise
we end up with an O(n^2) performance problem

Change-Id: I566ef43189a1bb7ac7c55e1bccf9445c9cea19b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166179
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 
(cherry picked from commit dac30c44c606232ce23d52a423d0bf8010f25d4f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167077
Tested-by: Jenkins

diff --git a/sc/source/filter/oox/extlstcontext.cxx 
b/sc/source/filter/oox/extlstcontext.cxx
index 58e4c7931729..d6af04240572 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -292,7 +292,8 @@ void ExtConditionalFormattingContext::onEndElement()
 maModel.eOperator = ScConditionMode::Direct;
 }
 
-getStyles().getExtDxfs().forEachMem( ::finalizeImport );
+if (Dxf* pDxf = getStyles().getExtDxfs().get(rStyleIdx).get())
+pDxf->finalizeImport();
 maModel.aStyle = getStyles().createExtDxfStyle(rStyleIdx);
 rStyleIdx++;
 nFormulaCount = 0;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-29 Thread Miklos Vajna (via logerrit)
 sc/source/core/data/column3.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit e49f965e6e0ae7f643ecc012c0fffce02a9cef29
Author: Miklos Vajna 
AuthorDate: Wed Apr 24 09:37:35 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 29 18:30:26 2024 +0200

sc: fix crash in ScColumn::SetEditText()

Crashreport:

> SIG   Fatal signal received: SIGSEGV code: 128 for address: 0x0
> program/libsclo.so
>   ScColumn::SetEditText(int, std::unique_ptr >)
>   sc/source/core/data/column3.cxx:2362
> program/libsclo.so
>   ScTable::SetEditText(short, int, std::unique_ptr >)
>   
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:395
> program/libsclo.so
>   ScDocument::SetEditText(ScAddress const&, 
std::unique_ptr >)
>   
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:395
> program/libsclo.so
>   ScDocFunc::SetEditCell(ScAddress const&, EditTextObject const&, 
bool)
>   
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/unique_ptr.h:395
> program/libsclo.so
>   (anonymous 
namespace)::finalizeFormulaProcessing(std::shared_ptr<(anonymous 
namespace)::FormulaProcessingContext>)
>   sc/source/ui/view/viewfunc.cxx:565

Change-Id: I331ca8784702fdcb0ebad6a0a73390dbe2615ece
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166612
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit e3ce4aad47c052dcd67107f7c91336f4ecc949be)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166525
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f0f4cc83263b..5a1582e560d7 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2358,6 +2358,11 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const 
OUString& rString,
 
 void ScColumn::SetEditText( SCROW nRow, std::unique_ptr 
pEditText )
 {
+if (!pEditText)
+{
+return;
+}
+
 pEditText->NormalizeString(GetDoc().GetSharedStringPool());
 std::vector aNewSharedRows;
 sc::CellStoreType::iterator it = GetPositionToInsert(nRow, aNewSharedRows, 
false);


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-22 Thread Justin Luth (via logerrit)
 sc/source/filter/excel/excrecds.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit c3bbc3b5c06b743a206a33111c061d4d7d011f21
Author: Justin Luth 
AuthorDate: Thu Apr 18 14:46:30 2024 -0400
Commit: Miklos Vajna 
CommitDate: Mon Apr 22 08:38:57 2024 +0200

xlsx export: fix corrupt file for Excel: protectedRange must have sqref

Excel refuses to open a file if there is no sqref specified

  


In this case, import failed to import sqref="10:131".
A follow-up commit avoids exporting these shorthand ranges.

I don't see much point in trying to create a unit test for this.
(I assume protectedRange is simply round-tripped
because I doubt LO has working support for protectedRanges.)

commit 9cee6a45632623d3d7e5a574128940f96d8c926b
Author: Eike Rathke on Thu Mar 20 10:16:50 2014 +0100
added ScEnhancedProtection to ScTableProtection

Change-Id: I97ef1ee801898bdcace067d62890c4ce0e7cf1d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166265
Reviewed-by: Justin Luth 
Reviewed-by: Miklos Vajna 
Tested-by: Justin Luth 
(cherry picked from commit 78bd5e2523d077a67468b752d4788a2c3b43fb5f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166220
Tested-by: Jenkins

diff --git a/sc/source/filter/excel/excrecds.cxx 
b/sc/source/filter/excel/excrecds.cxx
index 86afa5a6c163..f18e9f829bbe 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -478,6 +478,9 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm 
)
 rWorksheet->startElement(XML_protectedRanges);
 for (const auto& rProt : rProts)
 {
+if (!rProt.maRangeList.is())
+continue; // Excel refuses to open if sqref is missing from a 
protectedRange
+
 SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && 
!rProt.maSecurityDescriptor.empty(),
 "sc.filter", "XclExpSheetProtection::SaveXml: losing BIFF 
security descriptor");
 rWorksheet->singleElement( XML_protectedRange,
@@ -492,7 +495,7 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm 
)
 XML_hashValue, 
sax_fastparser::UseIf(rProt.maPasswordHash.maHashValue, 
!rProt.maPasswordHash.maHashValue.isEmpty()),
 XML_saltValue, 
sax_fastparser::UseIf(rProt.maPasswordHash.maSaltValue, 
!rProt.maPasswordHash.maSaltValue.isEmpty()),
 XML_spinCount, 
sax_fastparser::UseIf(OString::number(rProt.maPasswordHash.mnSpinCount), 
rProt.maPasswordHash.mnSpinCount != 0),
-XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( 
rStrm.GetRoot().GetDoc(), *rProt.maRangeList).getStr() : nullptr);
+XML_sqref, XclXmlUtils::ToOString(rStrm.GetRoot().GetDoc(), 
*rProt.maRangeList).getStr());
 }
 rWorksheet->endElement( XML_protectedRanges);
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-18 Thread Laurent Balland (via logerrit)
 sc/source/ui/docshell/impex.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 637312e2aa682ca11543a421a8de0bbbe72bf86b
Author: Laurent Balland 
AuthorDate: Mon Apr 15 18:43:35 2024 +0200
Commit: Eike Rathke 
CommitDate: Thu Apr 18 14:44:15 2024 +0200

tdf#129701 Follow-up of previous change

According to comments in https://gerrit.libreoffice.org/c/core/+/163536
Follow-up of previous change

Change-Id: Icd7b6798d6ef35ca9574125cd3d4c4d89044569c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166133
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 47187acee758680cda8086b6e295ef7beea3491b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166178

diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 8e6315db9419..a61ee53d2526 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1662,7 +1662,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
 ScDocumentImport aDocImport(rDoc);
 do
 {
-SCCOL nLastCol = nEndCol; // tdf#129701 preserve value of nEndCol
+const SCCOL nLastCol = nEndCol; // tdf#129701 preserve value of nEndCol
 for( ;; )
 {
 aLine = ReadCsvLine(rStrm, !bFixed, aSeps, cStr, cDetectSep);
@@ -1784,15 +1784,15 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm )
 aTransliteration, aCalendar,
 pEnglishTransliteration.get(), 
pEnglishCalendar.get());
 }
+++nCol;
 if (bIsLastColEmpty)
 {
 bIsLastColEmpty = false; // toggle to stop
 }
 else
 {
-++nCol;
 // tdf#129701 detect if there is a last empty 
column when we need it
-bIsLastColEmpty = !(*p) && !bSkipEmptyCells && 
!bDetermineRange && nCol == nLastCol;
+bIsLastColEmpty = (nCol == nLastCol) && !(*p) && 
!bSkipEmptyCells && !bDetermineRange;
 }
 
 }


core.git: Branch 'libreoffice-24-2' - sc/source

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

New commits:
commit 257ba94f52c36d42ae05272dc9d42a35828ef993
Author: Caolán McNamara 
AuthorDate: Tue Apr 16 17:34:35 2024 +0100
Commit: Xisco Fauli 
CommitDate: Wed Apr 17 15:46:50 2024 +0200

ofz#68081 keep within bounds

Change-Id: Ib7f11f2447d5a2cc6b9b559727f2a0127c15913e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166154
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit c09c61f5e3f7207006c3a26f5a79fabc29600350)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166098
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 36d0fbeb7fab..ee698a157827 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -894,7 +894,7 @@ void ScHTMLLayoutParser::Colonize( ScEEParseEntry* pE )
 {   // Replaced
 nCol = pE->nCol - nColCntStart;
 SCCOL nCount = static_cast(xLocalColOffset->size());
-if ( nCol < nCount )
+if (nCol >= 0 && nCol < nCount)
 nColOffset = static_cast((*xLocalColOffset)[nCol]);
 else
 nColOffset = static_cast((*xLocalColOffset)[nCount - 
1]);


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-15 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 24fa67d72fbc4aa0474ffc243938c5dcb10349ae
Author: Caolán McNamara 
AuthorDate: Mon Apr 8 22:07:11 2024 +0100
Commit: Michael Stahl 
CommitDate: Mon Apr 15 09:38:18 2024 +0200

ofz#67906 Integer-overflow

Change-Id: I459bdeef6bb7577c5388202374c981c7b01fa137
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165899
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166026
Reviewed-by: Michael Stahl 

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index c6507bd54e15..36d0fbeb7fab 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1039,7 +1039,7 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
 case HtmlOptionId::COLSPAN:
 {
 sal_Int32 nColOverlap = rOption.GetString().toInt32();
-if (nColOverlap >= 0 && nColOverlap <= SCCOL_MAX)
+if (nColOverlap >= 0 && nColOverlap <= mpDoc->MaxCol())
 mxActEntry->nColOverlap = static_cast(nColOverlap);
 else
 SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
colspan: " << nColOverlap);
@@ -1048,7 +1048,7 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
 case HtmlOptionId::ROWSPAN:
 {
 sal_Int32 nRowOverlap = rOption.GetString().toInt32();
-if (nRowOverlap >= 0)
+if (nRowOverlap >= 0 && nRowOverlap <= mpDoc->MaxRow())
 mxActEntry->nRowOverlap = static_cast(nRowOverlap);
 else
 SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
rowspan: " << nRowOverlap);


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-14 Thread Caolán McNamara (via logerrit)
 sc/source/core/inc/interpre.hxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit cce100f72dda8f5d4ae0c75c69a81603dc62e247
Author: Caolán McNamara 
AuthorDate: Tue Mar 12 13:08:09 2024 +
Commit: Eike Rathke 
CommitDate: Sun Apr 14 16:10:53 2024 +0200

tdf#160056 don't need to create a boost::intrusive_ptr to do search

with more recent c++ versions we can elide that construction for the
purposes of this comparison

Change-Id: I6a88219ef4451d2775b3b7ab1d9cf8adfb53e04d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164713
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit e5548dceb9086a6f0c8fa70bce8de6da0be72e40)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165713
Reviewed-by: Eike Rathke 

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 64b9a8ae5b2c..ab456a4dca86 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -131,6 +131,12 @@ struct FormulaTokenRef_less
 {
 bool operator () ( const formula::FormulaConstTokenRef& r1, const 
formula::FormulaConstTokenRef& r2 ) const
 { return r1.get() < r2.get(); }
+// So we don't have to create a FormulaConstTokenRef to search by 
formula::FormulaToken*
+using is_transparent = void;
+bool operator () ( const formula::FormulaToken* p1, const 
formula::FormulaConstTokenRef& r2 ) const
+{ return p1 < r2.get(); }
+bool operator () ( const formula::FormulaConstTokenRef& r1, const 
formula::FormulaToken* p2 ) const
+{ return r1.get() < p2; }
 };
 typedef ::std::map< const formula::FormulaConstTokenRef, 
formula::FormulaConstTokenRef, FormulaTokenRef_less> ScTokenMatrixMap;
 


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-08 Thread Noel Grandin (via logerrit)
 sc/source/core/data/table1.cxx |   16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 02b100e8ecbe47bd8d70d81dbefcb24be0501b8b
Author: Noel Grandin 
AuthorDate: Thu Mar 28 13:17:50 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 8 16:54:28 2024 +0200

tdf#160399 speed up print preview

takes time from 11s to 5s for me

Change-Id: Ic874b9168f9caaf697007e586df8499a849ccfd6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165460
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 6931a596350086d52ba32bf8a84cb36fbfdb34d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165617
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 93d023f96246..4df5d92ec5e5 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2091,17 +2091,19 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev,
 else
 {
 // These columns are visible.  Check for empty columns.
-for (SCCOL j = i; j <= nLastCol; ++j)
+SCCOL nEmptyCount = 0;
+SCCOL j = i;
+for (; j <= nLastCol; ++j)
 {
 if ( j >= aCol.size() )
-{
-aSkipCols.setTrue( j, rDocument.MaxCol() );
 break;
-}
-if (aCol[j].GetCellCount() == 0)
-// empty
-aSkipCols.setTrue(j,j);
+if (aCol[j].GetCellCount() == 0) // empty
+nEmptyCount++;
 }
+if (nEmptyCount)
+aSkipCols.setTrue(i,i+nEmptyCount);
+if ( j >= aCol.size() )
+aSkipCols.setTrue( j, rDocument.MaxCol() );
 }
 i = nLastCol;
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-08 Thread Noel Grandin (via logerrit)
 sc/source/core/data/documen9.cxx |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

New commits:
commit 8f53eb5dc5cc7f90a2b134c5b5ad66988bcc9842
Author: Noel Grandin 
AuthorDate: Thu Mar 28 13:25:10 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 8 16:52:53 2024 +0200

tdf#160399 speed up print preview

takes time from 5s to 2.5s for me

Change-Id: I7e62e4a47d5b2aae982273cc3ea38c5c9b04256d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165461
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 3819e4f6f70ee60fc5c805f0d33c0062a396918c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165616
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index a9f04943c0d1..ee72637fa9da 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -440,13 +440,8 @@ bool ScDocument::IsPrintEmpty( SCCOL nStartCol, SCROW 
nStartRow,
 //  keep vertical part of aMMRect, only update horizontal position
 aMMRect = *pLastMM;
 
-tools::Long nLeft = 0;
-SCCOL i;
-for (i=0; i

core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-08 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit cbac2445612be0c78ca7e46ca5abd5860025b396
Author: Caolán McNamara 
AuthorDate: Fri Apr 5 10:40:36 2024 +0100
Commit: Michael Stahl 
CommitDate: Mon Apr 8 12:23:29 2024 +0200

ofz#67854 UNKNOWN READ

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 2130e1119fa0..c6507bd54e15 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -671,8 +671,8 @@ void ScHTMLLayoutParser::Adjust()
 SkipLocked(pE.get(), false);
 if ( pE->nCol != nColBeforeSkip )
 {
-SCCOL nCount = static_cast(maColOffset.size());
-if ( nCount <= pE->nCol )
+size_t nCount = maColOffset.size();
+if ( nCount <= o3tl::make_unsigned(pE->nCol) )
 {
 pE->nOffset = static_cast(maColOffset[nCount-1]);
 MakeCol( , pE->nOffset, pE->nWidth, 
nOffsetTolerance, nOffsetTolerance );


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-07 Thread Tibor Nagy (via logerrit)
 sc/source/ui/view/output2.cxx |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 09a055c7457b005e1d7c733dc951dd8469c75411
Author: Tibor Nagy 
AuthorDate: Wed Mar 13 08:28:41 2024 +0100
Commit: Thorsten Behrens 
CommitDate: Sun Apr 7 21:38:18 2024 +0200

tdf#156655 sc: fix disappear text in merged cell

The text does not appear if the first row or column of the merged cell
is hidden.

Change-Id: I398f0d572226e44ffaa4e33c066b51480ad124cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164757
Tested-by: Jenkins
Reviewed-by: Nagy Tibor 
(cherry picked from commit d5f25d9c0026ec06a0b46e1560e26adba2725290)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165835
Reviewed-by: Thorsten Behrens 

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index d419981d8edb..877675c0ac48 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1877,8 +1877,7 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic)
 //  Cells to the left are marked directly, cells to the
 //  right are handled by the flag for nX2
 SCCOL nMarkX = ( nCellX <= nX2 ) ? nCellX : nX2;
-RowInfo* pMarkRowInfo = ( nCellY == nY ) ? pThisRowInfo : 
[0];
-pMarkRowInfo->basicCellInfo(nMarkX).bEditEngine = true;
+pThisRowInfo->basicCellInfo(nMarkX).bEditEngine = true;
 bDoCell = false;// don't draw here
 }
 if ( bDoCell )
@@ -4429,14 +4428,17 @@ void ScOutputData::DrawEdit(bool bPixelToLogic)
 SCROW nCellY = nY;
 bool bDoCell = false;
 
+// if merged cell contains hidden row or column or both
+const ScMergeFlagAttr* pMergeFlag = mpDoc->GetAttr(nX, nY, 
nTab, ATTR_MERGE_FLAG);
+bool bOverlapped = (pMergeFlag->IsHorOverlapped() || 
pMergeFlag->IsVerOverlapped());
+
 tools::Long nPosY = nRowPosY;
-if ( nArrY == 0 )
+if (bOverlapped)
 {
-nPosY = nScrY;
-nY = pRowInfo[1].nRowNo;
+nY = pRowInfo[nArrY].nRowNo;
 SCCOL nOverX;   // start of the merged 
cells
 SCROW nOverY;
-if (GetMergeOrigin( nX,nY, 1, nOverX,nOverY, true ))
+if (GetMergeOrigin( nX,nY, nArrY, nOverX,nOverY, true 
))
 {
 nCellX = nOverX;
 nCellY = nOverY;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-04 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |   15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

New commits:
commit b772466960bbdf4785ff071dea05e834df732f52
Author: Caolán McNamara 
AuthorDate: Sat Mar 23 21:31:51 2024 +
Commit: Michael Stahl 
CommitDate: Thu Apr 4 11:22:43 2024 +0200

ofz#67563 infinite loop

Change-Id: I1654d23fd8768a77d32fc3150a9d8554afa2e91f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165220
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit b866019e6ee82ce19dacd653861f8d2b701d2a8e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165715
Reviewed-by: Michael Stahl 

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 82aef16fed9a..2130e1119fa0 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -718,7 +718,6 @@ sal_uInt16 ScHTMLLayoutParser::GetWidth( const 
ScEEParseEntry* pE )
 
 void ScHTMLLayoutParser::SetWidths()
 {
-SCCOL nCol;
 if ( !nTableWidth )
 nTableWidth = static_cast(aPageSize.Width());
 SCCOL nColsPerRow = nMaxCol - nColCntStart;
@@ -729,7 +728,7 @@ void ScHTMLLayoutParser::SetWidths()
 sal_uInt16 nWidth = nTableWidth / static_cast(nColsPerRow);
 sal_uInt16 nOff = nColOffsetStart;
 xLocalColOffset->clear();
-for ( nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth )
+for (int nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth)
 {
 MakeColNoRef( xLocalColOffset.get(), nOff, 0, 0, 0 );
 }
@@ -759,7 +758,7 @@ void ScHTMLLayoutParser::SetWidths()
 auto& pE = maList[ i ];
 if ( pE->nTab == nTable && pE->nWidth )
 {
-nCol = pE->nCol - nColCntStart;
+SCCOL nCol = pE->nCol - nColCntStart;
 if ( nCol < nColsPerRow )
 {
 if ( pE->nColOverlap == 1 )
@@ -796,7 +795,7 @@ void ScHTMLLayoutParser::SetWidths()
 }
 sal_uInt16 nWidths = 0;
 sal_uInt16 nUnknown = 0;
-for ( nCol = 0; nCol < nColsPerRow; nCol++ )
+for (SCCOL nCol = 0; nCol < nColsPerRow; nCol++)
 {
 if ( pWidths[nCol] )
 nWidths = nWidths + pWidths[nCol];
@@ -808,18 +807,18 @@ void ScHTMLLayoutParser::SetWidths()
 sal_uInt16 nW = ((nWidths < nTableWidth) ?
 ((nTableWidth - nWidths) / nUnknown) :
 (nTableWidth / nUnknown));
-for ( nCol = 0; nCol < nColsPerRow; nCol++ )
+for (SCCOL nCol = 0; nCol < nColsPerRow; nCol++)
 {
 if ( !pWidths[nCol] )
 pWidths[nCol] = nW;
 }
 }
-for ( nCol = 1; nCol <= nColsPerRow; nCol++ )
+for (SCCOL nCol = 1; nCol <= nColsPerRow; nCol++)
 {
 pOffsets[nCol] = pOffsets[nCol-1] + pWidths[nCol-1];
 }
 xLocalColOffset->clear();
-for ( nCol = 0; nCol <= nColsPerRow; nCol++ )
+for (SCCOL nCol = 0; nCol <= nColsPerRow; nCol++)
 {
 MakeColNoRef( xLocalColOffset.get(), pOffsets[nCol], 0, 0, 0 );
 }
@@ -830,7 +829,7 @@ void ScHTMLLayoutParser::SetWidths()
 auto& pE = maList[ i ];
 if (pE->nTab != nTable)
 continue;
-nCol = pE->nCol - nColCntStart;
+SCCOL nCol = pE->nCol - nColCntStart;
 OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
 if (nCol >= nColsPerRow)
 continue;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-03 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 666e4e6fc9202577b91addb9054c7b1160a2b7b7
Author: Caolán McNamara 
AuthorDate: Thu Mar 28 09:09:00 2024 +
Commit: Michael Stahl 
CommitDate: Wed Apr 3 14:26:23 2024 +0200

ofz: negative column offset

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index d67cc7de4cdc..82aef16fed9a 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -834,6 +834,11 @@ void ScHTMLLayoutParser::SetWidths()
 OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
 if (nCol >= nColsPerRow)
 continue;
+if (nCol < 0)
+{
+SAL_WARN("sc", "negative offset: " << nCol);
+continue;
+}
 pE->nOffset = pOffsets[nCol];
 nCol = nCol + pE->nColOverlap;
 if ( nCol > nColsPerRow )


core.git: Branch 'libreoffice-24-2' - sc/source

2024-04-01 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit ae495a198fc63ab65ae054c59e2b69bffba4c1a2
Author: Caolán McNamara 
AuthorDate: Fri Mar 29 19:53:17 2024 +
Commit: Xisco Fauli 
CommitDate: Mon Apr 1 13:42:00 2024 +0200

ofz#67708 ignore oversized colspans

that can't fit in SCCOL

ignore negative colspan and rowspans too

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 70a2a10302fd..d67cc7de4cdc 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1034,12 +1034,20 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
 {
 case HtmlOptionId::COLSPAN:
 {
-mxActEntry->nColOverlap = 
static_cast(rOption.GetString().toInt32());
+sal_Int32 nColOverlap = rOption.GetString().toInt32();
+if (nColOverlap >= 0 && nColOverlap <= SCCOL_MAX)
+mxActEntry->nColOverlap = static_cast(nColOverlap);
+else
+SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
colspan: " << nColOverlap);
 }
 break;
 case HtmlOptionId::ROWSPAN:
 {
-mxActEntry->nRowOverlap = 
static_cast(rOption.GetString().toInt32());
+sal_Int32 nRowOverlap = rOption.GetString().toInt32();
+if (nRowOverlap >= 0)
+mxActEntry->nRowOverlap = static_cast(nRowOverlap);
+else
+SAL_WARN("sc", "ScHTMLLayoutParser::TableDataOn ignoring 
rowspan: " << nRowOverlap);
 }
 break;
 case HtmlOptionId::ALIGN:


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-25 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |   25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 26706d907e043f10d92aa81433d712f07c6ee16b
Author: Caolán McNamara 
AuthorDate: Sat Mar 23 15:40:26 2024 +
Commit: Xisco Fauli 
CommitDate: Mon Mar 25 09:59:13 2024 +0100

ofz#67540 negative offset

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 8b50901f7050..70a2a10302fd 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -828,19 +828,22 @@ void ScHTMLLayoutParser::SetWidths()
 for ( size_t i = nFirstTableCell, nListSize = maList.size(); i < 
nListSize; ++i )
 {
 auto& pE = maList[ i ];
-if ( pE->nTab == nTable )
+if (pE->nTab != nTable)
+continue;
+nCol = pE->nCol - nColCntStart;
+OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
+if (nCol >= nColsPerRow)
+continue;
+pE->nOffset = pOffsets[nCol];
+nCol = nCol + pE->nColOverlap;
+if ( nCol > nColsPerRow )
+nCol = nColsPerRow;
+if (nCol < 0)
 {
-nCol = pE->nCol - nColCntStart;
-OSL_ENSURE( nCol < nColsPerRow, 
"ScHTMLLayoutParser::SetWidths: column overflow" );
-if ( nCol < nColsPerRow )
-{
-pE->nOffset = pOffsets[nCol];
-nCol = nCol + pE->nColOverlap;
-if ( nCol > nColsPerRow )
-nCol = nColsPerRow;
-pE->nWidth = pOffsets[nCol] - pE->nOffset;
-}
+SAL_WARN("sc", "negative offset: " << nCol);
+continue;
 }
+pE->nWidth = pOffsets[nCol] - pE->nOffset;
 }
 }
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-22 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f2feac3d2ab19fdbcec85194579a88b3995ae335
Author: Caolán McNamara 
AuthorDate: Tue Mar 19 08:46:45 2024 +
Commit: Xisco Fauli 
CommitDate: Fri Mar 22 20:48:32 2024 +0100

null deref in initial sc html fuzzing

Change-Id: I368db8fec4cfd9409197d17f2892153aca2ba502
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165019
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 85c40af4e9d4c679f66e7f7e004c018dd28994ee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165005
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 525cebef10fa..8b50901f7050 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -908,7 +908,8 @@ void ScHTMLLayoutParser::CloseEntry( const HtmlImportInfo* 
pInfo )
 if ( bTabInTabCell )
 {   // From the stack in TableOff
 bTabInTabCell = false;
-NewActEntry(maList.back().get()); // New free flying mxActEntry
+SAL_WARN_IF(maList.empty(), "sc", "unexpected close entry without 
open");
+NewActEntry(maList.empty() ? nullptr : maList.back().get()); // New 
free flying mxActEntry
 return ;
 }
 if (mxActEntry->nTab == 0)


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-20 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |   62 -
 sc/source/filter/inc/htmlpars.hxx  |8 ++--
 2 files changed, 32 insertions(+), 38 deletions(-)

New commits:
commit 58f6f62552595acf1da4777ccd1ff11e5b1a55d0
Author: Caolán McNamara 
AuthorDate: Mon Mar 18 19:32:26 2024 +
Commit: Michael Stahl 
CommitDate: Wed Mar 20 11:55:33 2024 +0100

leaks in initial corpus for sc html import fuzzing

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index e563ff60b8ea..525cebef10fa 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -301,7 +301,7 @@ ScHTMLLayoutParser::ScHTMLLayoutParser(
 aPageSize( aPageSizeP ),
 aBaseURL(std::move( _aBaseURL )),
 xLockedList( new ScRangeList ),
-pLocalColOffset( new ScHTMLColOffset ),
+xLocalColOffset( new ScHTMLColOffset ),
 nFirstTableCell(0),
 nTableLevel(0),
 nTable(0),
@@ -317,20 +317,15 @@ ScHTMLLayoutParser::ScHTMLLayoutParser(
 bInCell( false ),
 bInTitle( false )
 {
-MakeColNoRef( pLocalColOffset, 0, 0, 0, 0 );
+MakeColNoRef( xLocalColOffset.get(), 0, 0, 0, 0 );
 MakeColNoRef( , 0, 0, 0, 0 );
 }
 
 ScHTMLLayoutParser::~ScHTMLLayoutParser()
 {
-while ( !aTableStack.empty() )
-{
-ScHTMLTableStackEntry * pS = aTableStack.top().get();
-if ( pS->pLocalColOffset != pLocalColOffset )
- delete pS->pLocalColOffset;
+while (!aTableStack.empty())
 aTableStack.pop();
-}
-delete pLocalColOffset;
+xLocalColOffset.reset();
 if ( pTables )
 {
 for( const auto& rEntry : *pTables)
@@ -713,9 +708,9 @@ sal_uInt16 ScHTMLLayoutParser::GetWidth( const 
ScEEParseEntry* pE )
 return pE->nWidth;
 sal_Int32 nTmp = std::min( static_cast( pE->nCol -
 nColCntStart + pE->nColOverlap),
-static_cast( pLocalColOffset->size() - 1));
+static_cast( xLocalColOffset->size() - 1));
 SCCOL nPos = (nTmp < 0 ? 0 : static_cast(nTmp));
-sal_uInt16 nOff2 = static_cast((*pLocalColOffset)[nPos]);
+sal_uInt16 nOff2 = static_cast((*xLocalColOffset)[nPos]);
 if ( pE->nOffset < nOff2 )
 return nOff2 - pE->nOffset;
 return 0;
@@ -729,22 +724,22 @@ void ScHTMLLayoutParser::SetWidths()
 SCCOL nColsPerRow = nMaxCol - nColCntStart;
 if ( nColsPerRow <= 0 )
 nColsPerRow = 1;
-if ( pLocalColOffset->size() <= 2 )
+if ( xLocalColOffset->size() <= 2 )
 {   // Only PageSize, there was no width setting
 sal_uInt16 nWidth = nTableWidth / static_cast(nColsPerRow);
 sal_uInt16 nOff = nColOffsetStart;
-pLocalColOffset->clear();
+xLocalColOffset->clear();
 for ( nCol = 0; nCol <= nColsPerRow; ++nCol, nOff = nOff + nWidth )
 {
-MakeColNoRef( pLocalColOffset, nOff, 0, 0, 0 );
+MakeColNoRef( xLocalColOffset.get(), nOff, 0, 0, 0 );
 }
-nTableWidth = static_cast(pLocalColOffset->back() - 
pLocalColOffset->front());
+nTableWidth = static_cast(xLocalColOffset->back() - 
xLocalColOffset->front());
 for ( size_t i = nFirstTableCell, nListSize = maList.size(); i < 
nListSize; ++i )
 {
 auto& pE = maList[ i ];
 if ( pE->nTab == nTable )
 {
-pE->nOffset = 
static_cast((*pLocalColOffset)[pE->nCol - nColCntStart]);
+pE->nOffset = 
static_cast((*xLocalColOffset)[pE->nCol - nColCntStart]);
 pE->nWidth = 0; // to be recalculated later
 }
 }
@@ -823,10 +818,10 @@ void ScHTMLLayoutParser::SetWidths()
 {
 pOffsets[nCol] = pOffsets[nCol-1] + pWidths[nCol-1];
 }
-pLocalColOffset->clear();
+xLocalColOffset->clear();
 for ( nCol = 0; nCol <= nColsPerRow; nCol++ )
 {
-MakeColNoRef( pLocalColOffset, pOffsets[nCol], 0, 0, 0 );
+MakeColNoRef( xLocalColOffset.get(), pOffsets[nCol], 0, 0, 0 );
 }
 nTableWidth = pOffsets[nColsPerRow] - pOffsets[0];
 
@@ -849,15 +844,15 @@ void ScHTMLLayoutParser::SetWidths()
 }
 }
 }
-if ( !pLocalColOffset->empty() )
+if ( !xLocalColOffset->empty() )
 {
-sal_uInt16 nMax = static_cast(pLocalColOffset->back());
+sal_uInt16 nMax = static_cast(xLocalColOffset->back());
 if ( aPageSize.Width() < nMax )
 aPageSize.setWidth( nMax );
 if (nTableLevel == 0)
 {
 // Local table is very outer table, create missing offsets.
-for (auto it = pLocalColOffset->begin(); it != 
pLocalColOffset->end(); ++it)
+

core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-19 Thread Caolán McNamara (via logerrit)
 sc/source/filter/html/htmlpars.cxx |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

New commits:
commit b25a88677ce2d713b0f454ef2d4cf5a202a005a7
Author: Caolán McNamara 
AuthorDate: Mon Mar 18 17:06:33 2024 +
Commit: Xisco Fauli 
CommitDate: Tue Mar 19 18:53:25 2024 +0100

calc html filter ScDocShell* deref for document properties

ScDocShell is optional in other parts of this filter

Change-Id: If219cfa6ef737a9695b85bf6db5d45e9750a7ed9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164974
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 1dc579ae9cd7fcf504016ef510a9484173c9392d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164994
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index c9d53d93bed7..e563ff60b8ea 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1595,13 +1595,14 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* 
pInfo )
 switch ( pInfo->nToken )
 {
 case HtmlTokenId::META:
+if (ScDocShell* pDocSh = mpDoc->GetDocumentShell())
 {
 HTMLParser* pParser = static_cast(pInfo->pParser);
 uno::Reference xDPS(
-
static_cast(mpDoc->GetDocumentShell()->GetModel()), 
uno::UNO_QUERY_THROW);
+static_cast(pDocSh->GetModel()), 
uno::UNO_QUERY_THROW);
 pParser->ParseMetaOptions(
 xDPS->getDocumentProperties(),
-mpDoc->GetDocumentShell()->GetHeaderAttributes() );
+pDocSh->GetHeaderAttributes() );
 }
 break;
 case HtmlTokenId::TITLE_ON:
@@ -1612,12 +1613,13 @@ void ScHTMLLayoutParser::ProcToken( HtmlImportInfo* 
pInfo )
 break;
 case HtmlTokenId::TITLE_OFF:
 {
-if ( bInTitle && !aString.isEmpty() )
+ScDocShell* pDocSh = mpDoc->GetDocumentShell();
+if ( bInTitle && !aString.isEmpty() && pDocSh )
 {
 // Remove blanks from line breaks
 aString = aString.trim();
 uno::Reference xDPS(
-
static_cast(mpDoc->GetDocumentShell()->GetModel()),
+static_cast(pDocSh->GetModel()),
 uno::UNO_QUERY_THROW);
 xDPS->getDocumentProperties()->setTitle(aString);
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-18 Thread Mike Kaganski (via logerrit)
 sc/source/ui/docshell/docfunc.cxx |   25 +
 sc/source/ui/inc/undoblk.hxx  |6 --
 sc/source/ui/undo/undoblk.cxx |   26 +-
 3 files changed, 30 insertions(+), 27 deletions(-)

New commits:
commit c2979145899db161e2659d69ad2f478123254694
Author: Mike Kaganski 
AuthorDate: Sun Mar 17 13:31:42 2024 +0500
Commit: Xisco Fauli 
CommitDate: Mon Mar 18 20:45:23 2024 +0100

tdf#160149: save and restore the whole set of tab's conditional formats

... instead of restoring it only for a range, and then have troubles
deciding how to join the range's formatting with the rest of tab's
formatting.

Change-Id: Ie422893c7847b1473a86c0cd8fc3916144eb24ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164937
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit c492de66a077f3a2a960209b0b8b278b3901f361)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164886
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 1a8d902bea19..4c333b0502a0 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5611,26 +5611,12 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong 
nOldFormat, std::unique_ptr<
 bool bUndo = rDoc.IsUndoEnabled();
 ScDocumentUniquePtr pUndoDoc;
 ScRange aCombinedRange = rRanges.Combine();
-ScRange aCompleteRange;
 if(bUndo)
 {
 pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
 pUndoDoc->InitUndo( rDoc, nTab, nTab );
-
-if(pFormat)
-{
-aCompleteRange = aCombinedRange;
-}
-if(nOldFormat)
-{
-ScConditionalFormat* pOldFormat = 
rDoc.GetCondFormList(nTab)->GetFormat(nOldFormat);
-if(pOldFormat)
-aCompleteRange.ExtendTo(pOldFormat->GetRange().Combine());
-}
-
-
rDoc.CopyToDocument(aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab,
-
aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab,
-InsertDeleteFlags::ALL, false, *pUndoDoc);
+if (const auto* pList = rDoc.GetCondFormList(nTab))
+pUndoDoc->SetCondFormList(new ScConditionalFormatList(*pUndoDoc, 
*pList), nTab);
 }
 
 std::unique_ptr pRepaintRange;
@@ -5663,11 +5649,10 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong 
nOldFormat, std::unique_ptr<
 {
 ScDocumentUniquePtr pRedoDoc(new ScDocument(SCDOCMODE_UNDO));
 pRedoDoc->InitUndo( rDoc, nTab, nTab );
-
rDoc.CopyToDocument(aCompleteRange.aStart.Col(),aCompleteRange.aStart.Row(),nTab,
-
aCompleteRange.aEnd.Col(),aCompleteRange.aEnd.Row(),nTab,
-InsertDeleteFlags::ALL, false, *pRedoDoc);
+if (const auto* pList = rDoc.GetCondFormList(nTab))
+pRedoDoc->SetCondFormList(new ScConditionalFormatList(*pRedoDoc, 
*pList), nTab);
 rDocShell.GetUndoManager()->AddUndoAction(
-std::make_unique(, 
std::move(pUndoDoc), std::move(pRedoDoc), aCompleteRange));
+std::make_unique(, 
std::move(pUndoDoc), std::move(pRedoDoc), nTab));
 }
 
 if(pRepaintRange)
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 9bda36a1e176..c6cb432d8e24 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -613,11 +613,13 @@ private:
 voidDoChange( ScDocument* pSrcDoc ) const;
 };
 
+// This class only uses conditional format lists in the undo/redo documents;
+// no other tab data is needed in the documents
 class ScUndoConditionalFormat : public ScSimpleUndo
 {
 public:
 ScUndoConditionalFormat( ScDocShell* pNewDocShell,
-ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const 
ScRange& rRange);
+ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB 
nTab);
 virtual ~ScUndoConditionalFormat() override;
 
 virtual voidUndo() override;
@@ -631,7 +633,7 @@ private:
 void DoChange(ScDocument* pDoc);
 ScDocumentUniquePtr mpUndoDoc;
 ScDocumentUniquePtr mpRedoDoc;
-ScRange maRange;
+SCTAB mnTab;
 };
 
 class ScUndoConditionalFormatList : public ScSimpleUndo
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index d352ba143ba8..c74d23f6e7a7 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1563,11 +1563,11 @@ bool ScUndoListNames::CanRepeat(SfxRepeatTarget& 
rTarget) const
 }
 
 ScUndoConditionalFormat::ScUndoConditionalFormat(ScDocShell* pNewDocShell,
-ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const 
ScRange& rRange):
+ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB 
nTab):
 ScSimpleUndo( pNewDocShell ),
 mpUndoDoc(std::move(pUndoDoc)),
 

core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-17 Thread Rafael Lima (via logerrit)
 sc/source/ui/miscdlgs/solveroptions.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 765242935149dca7cb41e10462708739b71f2810
Author: Rafael Lima 
AuthorDate: Wed Mar 13 23:30:17 2024 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Sun Mar 17 17:12:27 2024 +0100

tdf#160122 Increase height of the Solver Options dialog

Currently the Solver Options dialog (Tools - Solver and then click the 
Options button) has a height of 6 rows, which is good for the Linear and Swarm 
non-linear solvers, since they have 4-5 options.

However, the SCO and DEPS engines have 12 and 19 options, respectively, so 
it is very unconfortable to view and scroll through these options with such a 
small dialog.

This patch raises the height of the dialog to 12, so that scrolling is 
minimized, making it more confortable to navigate through the solver options.

Change-Id: I51c1c6880613818dd91c6bb8494775c863e8b406
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164749
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
Reviewed-by: Adolfo Jayme Barrientos 
(cherry picked from commit 58f565cb2dcf6e7b7eb2eb269776993516a29bf0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164875

diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx 
b/sc/source/ui/miscdlgs/solveroptions.cxx
index 3d5b2b47c178..81f5c8b7b4ce 100644
--- a/sc/source/ui/miscdlgs/solveroptions.cxx
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -69,7 +69,7 @@ ScSolverOptionsDialog::ScSolverOptionsDialog(weld::Window* 
pParent,
 , m_xBtnEdit(m_xBuilder->weld_button("edit"))
 {
 
m_xLbSettings->set_size_request(m_xLbSettings->get_approximate_digit_width() * 
32,
-m_xLbSettings->get_height_rows(6));
+m_xLbSettings->get_height_rows(12));
 
 m_xLbSettings->enable_toggle_buttons(weld::ColumnToggleType::Check);
 


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-13 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/fillinfo.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 53b8a4c687df83a91e584fb6afa6729d9669f454
Author: Mike Kaganski 
AuthorDate: Tue Mar 12 14:16:14 2024 +0100
Commit: Xisco Fauli 
CommitDate: Wed Mar 13 12:20:59 2024 +0100

tdf#160117: check bAnyCondition

Commit edbc3a09edcf58a4738b4648811a065f3f55bc7c (sc: Don't end
handleConditionalFormat early, 2023-11-02) intended to allow to apply
several different categories of conditions to the same cell: e.g.,
color scale or databar, in addition to the normal style application
depending on a condition.

This change fixes a regression, when the found matching condition did
not stop search for the matching conditions to apply a style.

Change-Id: Ia4cf1dd35a964c6ca523050dc727184ca22a8dfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164687
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 61580fcbd10bad2e0aab663d4c8fe43c1e01f92c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164735
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 4a573e1c21da..659a539799ac 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -296,7 +296,7 @@ bool handleConditionalFormat(ScConditionalFormatList& 
rCondFormList, const ScCon
 
 ScCondFormatData aData = pCondForm->GetData(
 pInfo->maCell, rAddr);
-if (!aData.aStyleName.isEmpty())
+if (!bAnyCondition && !aData.aStyleName.isEmpty())
 {
 SfxStyleSheetBase* pStyleSheet =
 pStlPool->Find( aData.aStyleName, SfxStyleFamily::Para );
@@ -337,7 +337,7 @@ bool handleConditionalFormat(ScConditionalFormatList& 
rCondFormList, const ScCon
 pTableInfo->addIconSetInfo(std::move(aData.pIconSet));
 }
 
-if (pInfo->mxColorScale && pInfo->pIconSet && pInfo->pDataBar)
+if (bAnyCondition && pInfo->mxColorScale && pInfo->pIconSet && 
pInfo->pDataBar)
 break;
 }
 


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-11 Thread Julien Nabet (via logerrit)
 sc/source/ui/docshell/docsh3.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 2ffba480017a44522cb6c8946d75f6ad5f1c9026
Author: Julien Nabet 
AuthorDate: Mon Mar 4 13:21:06 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 11 12:19:11 2024 +0100

tdf#159373: band-aid for crash in: ScTable::HasAttrib

band-aid because as Eike indicated in 
https://bugs.documentfoundation.org/show_bug.cgi?id=159373#c8
"Question remains why this PostPaint() is called at all for an invalid 
range.."

Change-Id: Ie44378119202addd8ddb46f0be4b0124be9fd48b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164354
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164644

diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 96546d11a5fe..4634c5cbf191 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -118,6 +118,9 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, 
PaintPartFlags nPart, sa
 SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
 SCTAB nTab1 = rRange.aStart.Tab(), nTab2 = std::min(nMaxTab, 
rRange.aEnd.Tab());
 
+if (nTab1 < 0 || nTab2 < 0)
+continue;
+
 if (!m_pDocument->ValidCol(nCol1)) nCol1 = m_pDocument->MaxCol();
 if (!m_pDocument->ValidRow(nRow1)) nRow1 = m_pDocument->MaxRow();
 if (!m_pDocument->ValidCol(nCol2)) nCol2 = m_pDocument->MaxCol();


core.git: Branch 'libreoffice-24-2' - sc/source

2024-03-07 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 2bf9246a0388c1d3002f4fa90ba759d7d119cdbf
Author: Tomaž Vajngerl 
AuthorDate: Thu Feb 29 23:51:26 2024 +0900
Commit: Christian Lohmaier 
CommitDate: Thu Mar 7 12:12:19 2024 +0100

tdf#83720 Pivot Table: Data field should always at last place

In the pivot table dialog we should always put the "Data" field to
the last place or the cell formats won't be shown correct in the
pivot table.

Change-Id: If4befe4fff1e6f04d9b709615a1955e3b5f4b4cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164161
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 78065e3798439dd790d1be5ac5c219477285c888)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164126
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx 
b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index 45af29a4f1a4..672de9559c4e 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -67,6 +67,9 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 std::unique_ptr xEachEntry(mxControl->make_iterator());
 if (!mxControl->get_iter_first(*xEachEntry))
 return;
+
+std::optional oDataField;
+
 do
 {
 ScItemValue* pItemValue = 
weld::fromId(mxControl->get_id(*xEachEntry));
@@ -78,8 +81,15 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 aField.nFuncMask = rFunctionData.mnFuncMask;
 aField.mnDupCount= rFunctionData.mnDupCount;
 aField.maFieldRef= rFunctionData.maFieldRef;
-rVector.push_back(aField);
+
+if (aField.nCol == PIVOT_DATA_FIELD)
+oDataField = aField;
+else
+rVector.push_back(aField);
 } while (mxControl->iter_next(*xEachEntry));
+
+if (oDataField)
+rVector.push_back(*oDataField);
 }
 
 void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& 
/*pSource*/, int /*nTarget*/)


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-29 Thread Tomaž Vajngerl (via logerrit)
 sc/source/filter/excel/excel.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit b3223e1f236e450fcbb71c415dc64dbd10a7ae0a
Author: Tomaž Vajngerl 
AuthorDate: Fri Feb 16 23:56:52 2024 +0900
Commit: Miklos Vajna 
CommitDate: Thu Feb 29 11:52:58 2024 +0100

sc: Handle xls documents with unknown DRM encryption better

If we can't decrypt the document, don't set the SotStorage to
an empty SvRef. It is possible the document contains a "fallback"
un-encrypted document, which we can show. This is typical for some
Excel add-ons, which encrypt the document, but also add a part
that is un-encrypted to write the instructions on how to get the
add-on.

Change-Id: I6079786b1d0dce3a819a70e057699d0a461a5be5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163511
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 1e1072afa3726266f83d7ef8895ed406580a3450)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163535
Reviewed-by: Miklos Vajna 

diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 8420cc696a90..c92ef75d6998 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -183,7 +183,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
 tools::SvRef xDRMStrm = 
ScfTools::OpenStorageStreamRead(xRootStrg, " DRMContent");
 if (xDRMStrm.is())
 {
-xRootStrg = lcl_DRMDecrypt(rMedium, xRootStrg, aNewStorageStrm);
+auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
+if (pDecryptedStorage)
+xRootStrg = pDecryptedStorage;
 }
 
 // try to open the "Book" stream


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-28 Thread Mike Kaganski (via logerrit)
 sc/source/ui/app/inputhdl.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 153b3bae5ea6d0d59cf80c1ca1c32df8bfef57ef
Author: Mike Kaganski 
AuthorDate: Wed Feb 28 17:47:04 2024 +0600
Commit: Xisco Fauli 
CommitDate: Wed Feb 28 17:07:55 2024 +0100

tdf#159938: only apply wrap when the content was modified

Change-Id: I2f18739239401085a06bbdce6623a484c13d680b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164091
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit f0d8f72eb3447b705d1dcdc35a6f3c66a880ab7e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164111
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index a640d71cb2df..519ebea36b8d 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3143,7 +3143,7 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode, bool bBeforeSavingInL
 lcl_RemoveTabs(aString);
 lcl_RemoveTabs(aPreAutoCorrectString);
 
-if (aString.indexOf('
') != -1)
+if (bModified && aString.indexOf('
') != -1)
 {
 // Cell contains line breaks, enable wrapping
 ScLineBreakCell aBreakItem(true);


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-17 Thread Noel Grandin (via logerrit)
 sc/source/filter/rtf/rtfparse.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b5a5cae0e78e989c421a376bb55a724981c74d87
Author: Noel Grandin 
AuthorDate: Fri Feb 16 19:31:57 2024 +0200
Commit: Noel Grandin 
CommitDate: Sat Feb 17 20:16:35 2024 +0100

tdf#101313 Copy-paste table from writer to calc

With Merged Cells from Writer to Calc,
Cells Placed in Wrong Position (Wrong cell offsets).

regression from
commit ed24564ce11683731b820c29d5a46e073ab7a2a7
Author: Noel Grandin 
Date:   Thu Jul 19 15:22:31 2012 +0200
SV_DECL_VARARR_SORT(ScRTFColTwips) o3tl::sorted_vector

Change-Id: I8c90c19f6a27a368fd5807b3eaab84ce820e26e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163518
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 4df426e429e1aed92f074d8acd3ba3a5ec335ba9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163532

diff --git a/sc/source/filter/rtf/rtfparse.cxx 
b/sc/source/filter/rtf/rtfparse.cxx
index b2d2b8c2521f..0617a86c62b1 100644
--- a/sc/source/filter/rtf/rtfparse.cxx
+++ b/sc/source/filter/rtf/rtfparse.cxx
@@ -101,8 +101,8 @@ inline void ScRTFParser::NextRow()
 
 bool ScRTFParser::SeekTwips( sal_uInt16 nTwips, SCCOL* pCol )
 {
-ScRTFColTwips::const_iterator it = aColTwips.find( nTwips );
-bool bFound = it != aColTwips.end();
+ScRTFColTwips::const_iterator it = aColTwips.lower_bound( nTwips );
+bool bFound = it != aColTwips.end() && *it == nTwips;
 sal_uInt16 nPos = it - aColTwips.begin();
 *pCol = static_cast(nPos);
 if ( bFound )


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-09 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/document.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit ba81230114cfcd7b61ccfb7cb522d2d2630e375c
Author: Caolán McNamara 
AuthorDate: Thu Feb 8 11:53:43 2024 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 9 12:37:44 2024 +0100

calc null-deref

probably seen after a sheet was deleted

/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f259a642520]

/opt/collaboraoffice/program/../program/libsclo.so(+0x5b3db8)[0x7f25873b3db8]

/opt/collaboraoffice/program/../program/libsclo.so(+0x4964a1)[0x7f25872964a1]

this looks most likely:

005b3db0  ScTable::ContainsNotesInRange(ScRange const&) const
00496440  ScDocument::ContainsNotesInRange(ScRangeList const&) const

Change-Id: Ib019fe8abc18538eee7096e1fe5589e83e4849da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163136
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 1fd89488d282cad8386af12064876f8ba0ac2956)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163145

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ff6d77b432f7..15bb28fe61f1 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6896,6 +6896,8 @@ void ScDocument::GetNotesInRange( const ScRangeList& 
rRangeList, std::vectorGetNotesInRange( rRange, rNotes );
 }
 }
@@ -6914,6 +6916,8 @@ bool ScDocument::ContainsNotesInRange( const ScRangeList& 
rRangeList ) const
 const ScRange & rRange = rRangeList[i];
 for( SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); 
++nTab )
 {
+if (!maTabs[nTab])
+continue;
 bool bContainsNote = maTabs[nTab]->ContainsNotesInRange( rRange );
 if(bContainsNote)
 return true;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-08 Thread Julien Nabet (via logerrit)
 sc/source/core/data/validat.cxx |3 +++
 sc/source/ui/app/inputhdl.cxx   |3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit b7a1ff456629549f66c93a5258073f1394598174
Author: Julien Nabet 
AuthorDate: Tue Feb 6 21:42:06 2024 +0100
Commit: Xisco Fauli 
CommitDate: Thu Feb 8 23:28:58 2024 +0100

tdf#159595: Data validation without error check allows to enter wrong data

Change-Id: If5660f462a07ca571e05a44abcb0e378b6de613e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163064
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
(cherry picked from commit 9925937bb6b9be70befb8886ccc5665eff4ef227)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163020
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index a46b09986b3d..5a569ef94487 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -381,6 +381,9 @@ bool ScValidationData::DoError(weld::Window* pParent, const 
OUString& rInput,
 if ( eErrorStyle == SC_VALERR_MACRO )
 return DoMacro(rPos, rInput, nullptr, pParent);
 
+if (!bShowError)
+return true;
+
 //  Output error message
 
 OUString aTitle = aErrorTitle;
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 809ba8520e33..a640d71cb2df 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3159,7 +3159,7 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode, bool bBeforeSavingInL
 {
 ScDocument& rDoc = pActiveViewSh->GetViewData().GetDocument();
 const ScValidationData* pData = rDoc.GetValidationEntry( nValidation );
-if (pData && pData->HasErrMsg())
+if (pData)
 {
 // #i67990# don't use pLastPattern in EnterHandler
 const ScPatternAttr* pPattern = rDoc.GetPattern( aCursorPos.Col(), 
aCursorPos.Row(), aCursorPos.Tab() );
@@ -3200,6 +3200,7 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode, bool bBeforeSavingInL
 
 if (pData->DoError(pActiveViewSh->GetFrameWeld(), aString, 
aCursorPos))
 bForget = true; // Do not take over input
+
 }
 }
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-08 Thread Henry Castro (via logerrit)
 sc/source/core/data/table4.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d2ba2fa1123a07a9853124218342cc83c5176491
Author: Henry Castro 
AuthorDate: Mon Feb 5 12:29:40 2024 -0400
Commit: Caolán McNamara 
CommitDate: Thu Feb 8 17:10:53 2024 +0100

tdf#158440: do not extend transparent color

Avoid to extend the area of transparent colors.

Signed-off-by: Henry Castro 
Change-Id: Ie492e6fea2c3d8b785cfbb96fe7cfc31d87b9996
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163030
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit c44e12ddb952c78dd08aba1774863554d7ecc7fa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163024
Tested-by: Jenkins

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 62b9dbb9e006..f8a03dd4c7ec 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1314,7 +1314,7 @@ void ScTable::GetBackColorArea(SCCOL& rStartCol, SCROW& 
/*rStartRow*/,
 const ScPatternAttr* pPattern = 
ColumnData(nCol).GetPattern(rEndRow + 1);
 const SvxBrushItem* pBackground = 
>GetItem(ATTR_BACKGROUND);
 if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty() ||
-pBackground != pDefBackground)
+(pBackground->GetColor() != COL_TRANSPARENT && pBackground 
!= pDefBackground))
 {
 bExtend = true;
 break;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-02-07 Thread Caolán McNamara (via logerrit)
 sc/source/core/tool/compiler.cxx |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit c7e9e3a35c00cae8cea13cbef1de9c696a881cdb
Author: Caolán McNamara 
AuthorDate: Mon Jan 29 10:53:32 2024 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 7 22:28:03 2024 +0100

ofz: Use-of-uninitialized-value

keep a high water mark of the highest initialized level

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

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 63b1f0969225..c9934c26fff6 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4738,6 +4738,7 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 pFunctionStack[0].eOp = ocNone;
 pFunctionStack[0].nSep = 0;
 size_t nFunction = 0;
+size_t nHighWatermark = 0;
 short nBrackets = 0;
 bool bInArray = false;
 eLastOp = ocOpen;
@@ -4757,6 +4758,7 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 ++nFunction;
 pFunctionStack[ nFunction ].eOp = eLastOp;
 pFunctionStack[ nFunction ].nSep = 0;
+nHighWatermark = nFunction;
 }
 }
 break;
@@ -4795,6 +4797,7 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 ++nFunction;
 pFunctionStack[ nFunction ].eOp = eOp;
 pFunctionStack[ nFunction ].nSep = 0;
+nHighWatermark = nFunction;
 }
 }
 break;
@@ -4825,6 +4828,7 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 ++nFunction;
 pFunctionStack[ nFunction ].eOp = eOp;
 pFunctionStack[ nFunction ].nSep = 0;
+nHighWatermark = nFunction;
 }
 }
 break;
@@ -4867,9 +4871,9 @@ std::unique_ptr ScCompiler::CompileString( 
const OUString& rFormul
 // Append a parameter for WEEKNUM, all 1.0
 // Function is already closed, parameter count is nSep+1
 size_t nFunc = nFunction + 1;
-if (eOp == ocClose &&
-(pFunctionStack[ nFunc ].eOp == ocWeek &&   // 2nd week 
start
- pFunctionStack[ nFunc ].nSep == 0))
+if (eOp == ocClose && nFunc <= nHighWatermark &&
+ pFunctionStack[ nFunc ].nSep == 0 &&
+ pFunctionStack[ nFunc ].eOp == ocWeek)   // 2nd week start
 {
 if (!static_cast(pArr)->Add( new 
FormulaToken( svSep, ocSep)) ||
 !static_cast(pArr)->Add( new 
FormulaDoubleToken( 1.0)))


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-31 Thread Noel Grandin (via logerrit)
 sc/source/core/data/colcontainer.cxx |5 ++---
 sc/source/core/data/table2.cxx   |2 ++
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit d891af6d9b876b172a77df5315c0a176f8dbdc6f
Author: Noel Grandin 
AuthorDate: Tue Jan 30 13:51:20 2024 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jan 31 20:58:28 2024 +0100

tdf#159131 Calc is laggy when moving a line (row)

revert  69910b540ae5140123fd2d4d67a9d338f980db53 and
add a couple of pre-emptive reserve calls, to prevent repeated
resizing.

I'm not sure why the above commit causes trouble on Windows, but
not Linux, something in the std::vector::reserve implementation
no doubt.

Change-Id: I858303a0a1e12d204fd3bbccc6c6c7ce57564e5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162746
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit 21dd07f95d7dcb95f243753306108c18d9ba115a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162726
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/colcontainer.cxx 
b/sc/source/core/data/colcontainer.cxx
index f6ef8ff7da17..a0a9d845772f 100644
--- a/sc/source/core/data/colcontainer.cxx
+++ b/sc/source/core/data/colcontainer.cxx
@@ -47,10 +47,9 @@ void ScColContainer::Clear()
 void ScColContainer::resize( ScSheetLimits const & rSheetLimits, const size_t 
aNewColSize )
 {
 size_t aOldColSize = aCols.size();
-if (aNewColSize > aCols.capacity())
-aCols.reserve( aNewColSize );
+aCols.resize( aNewColSize );
 for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol )
-aCols.emplace_back(new ScColumn(rSheetLimits));
+aCols[nCol].reset(new ScColumn(rSheetLimits));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a871a1fb82c8..6d7c5b0ac874 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -503,6 +503,7 @@ void ScTable::CopyToClip(
 
 nCol2 = ClampToAllocatedColumns(nCol2);
 
+pTable->CreateColumnIfNotExists(nCol2);  // prevent repeated resizing
 for ( SCCOL i = nCol1; i <= nCol2; i++)
 aCol[i].CopyToClip(rCxt, nRow1, nRow2, 
pTable->CreateColumnIfNotExists(i));  // notes are handled at column level
 
@@ -1351,6 +1352,7 @@ void ScTable::CopyToTable(
 // can lead to repetitive splitting and rejoining of the same formula 
group, which can get
 // quadratically expensive with large groups. So do the grouping just 
once at the end.
 sc::DelayFormulaGroupingSwitch delayGrouping( pDestTab->rDocument, 
true );
+pDestTab->CreateColumnIfNotExists(ClampToAllocatedColumns(nCol2)); // 
avoid repeated resizing
 for (SCCOL i = nCol1; i <= ClampToAllocatedColumns(nCol2); i++)
 aCol[i].CopyToColumn(rCxt, nRow1, nRow2, bToUndoDoc ? nFlags : 
nTempFlags, bMarked,
  pDestTab->CreateColumnIfNotExists(i), 
pMarkData, bAsLink, bGlobalNamesToLocal);


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-29 Thread Rafael Lima (via logerrit)
 sc/source/ui/cctrl/checklistmenu.cxx |9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

New commits:
commit d60520f8aabefd8f2893b8656c555c25be93c16c
Author: Rafael Lima 
AuthorDate: Tue Jan 23 23:36:11 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon Jan 29 10:22:19 2024 +0100

tdf#159329 Fix AutoFilter arrow color in dark mode

When using dark mode, the arrow is black over a dark background. This patch 
makes it use the dialog text color for better contrast.

Change-Id: Icf07d50599191417dee294e1f4c925fe1a8a7655
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162460
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
(cherry picked from commit b0f678ca59a65a3c302c3c3a499230fbc52ed5bd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162615
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx 
b/sc/source/ui/cctrl/checklistmenu.cxx
index 92e7096fc25a..578c248b7f9c 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -171,14 +171,7 @@ void ScCheckListMenuControl::CreateDropDown()
 {
 const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
 
-// tdf#151820 The color used for the arrow head depends on the background 
color
-Color aBackgroundColor = rStyleSettings.GetWindowColor();
-Color aSpinColor;
-if (aBackgroundColor.IsDark())
-aSpinColor = rStyleSettings.GetLightColor();
-else
-aSpinColor = rStyleSettings.GetDarkShadowColor();
-
+Color aSpinColor = rStyleSettings.GetDialogTextColor();
 int nWidth = (mxMenu->get_text_height() * 3) / 4;
 mxDropDown->SetOutputSizePixel(Size(nWidth, nWidth), /*bErase*/true, 
/*bAlphaMaskTransparent*/true);
 DecorationView aDecoView(mxDropDown.get());


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-23 Thread Caolán McNamara (via logerrit)
 sc/source/ui/view/gridwin.cxx |   51 --
 1 file changed, 30 insertions(+), 21 deletions(-)

New commits:
commit bdc5f71c94d44834aa8ad863d9c19325d59ce36a
Author: Caolán McNamara 
AuthorDate: Fri Jan 19 11:48:01 2024 +
Commit: Caolán McNamara 
CommitDate: Tue Jan 23 11:28:37 2024 +0100

use a ScopeGuard to restore the original map mode

in these cases the original map mode was *not* always restored,
but the intent seems to be like the others that the mapmode should
be the same on exit as on enter.

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

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 187f760b50d8..ddbc8e250709 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6169,10 +6169,16 @@ void ScGridWindow::DeleteCopySourceOverlay()
 
 void ScGridWindow::UpdateCopySourceOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteCopySourceOverlay();
 
@@ -6223,9 +6229,6 @@ void ScGridWindow::UpdateCopySourceOverlay()
 xOverlayManager->add(*pDashedBorder);
 mpOOSelectionBorder->append(std::move(pDashedBorder));
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 static std::vector convertPixelToLogical(
@@ -6416,10 +6419,16 @@ void ScGridWindow::UpdateCursorOverlay()
 {
 ScDocument& rDoc = mrViewData.GetDocument();
 
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 // Existing OverlayObjects may be transformed in later versions.
 // For now, just re-create them.
@@ -6578,9 +6587,6 @@ void ScGridWindow::UpdateCursorOverlay()
 }
 }
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::GetCellSelection(std::vector& rLogicRects)
@@ -6748,10 +6754,16 @@ void ScGridWindow::DeleteAutoFillOverlay()
 
 void ScGridWindow::UpdateAutoFillOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteAutoFillOverlay();
 
@@ -6830,9 +6842,6 @@ void ScGridWindow::UpdateAutoFillOverlay()
 mpOOAutoFill.reset(new sdr::overlay::OverlayObjectList);
 mpOOAutoFill->append(std::move(pOverlay));
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::DeleteDragRectOverlay()


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-23 Thread Caolán McNamara (via logerrit)
 sc/source/ui/view/gridwin.cxx |   82 --
 1 file changed, 48 insertions(+), 34 deletions(-)

New commits:
commit 9f14ca93e1f1d31b453cd4403eb146e63949e6e0
Author: Caolán McNamara 
AuthorDate: Fri Jan 19 11:43:36 2024 +
Commit: Michael Stahl 
CommitDate: Tue Jan 23 10:32:18 2024 +0100

use a ScopeGuard to restore the original map mode

in all these cases the original map mode was always restored so
there is no change for these examples.

Change-Id: Iec24b2cd269b9408dac6404e054b3bb989ec7744
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162306
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 30ed30b1117a41f016aa5b09ce21d2cb3004fdc3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162275
Reviewed-by: Michael Stahl 

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9848cc522036..187f760b50d8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6602,10 +6602,16 @@ void ScGridWindow::DeleteSelectionOverlay()
 
 void ScGridWindow::UpdateSelectionOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteSelectionOverlay();
 std::vector aRects;
@@ -6677,9 +6683,6 @@ void ScGridWindow::UpdateSelectionOverlay()
 ScInputHandler::SendReferenceMarks(pViewShell, aReferenceMarks);
 }
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::UpdateHighlightOverlay()
@@ -6842,10 +6845,16 @@ void ScGridWindow::UpdateDragRectOverlay()
 bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet(
 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
 
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteDragRectOverlay();
 
@@ -6998,9 +7007,6 @@ void ScGridWindow::UpdateDragRectOverlay()
 
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, 
aRectsString);
 }
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::DeleteHeaderOverlay()
@@ -7010,10 +7016,16 @@ void ScGridWindow::DeleteHeaderOverlay()
 
 void ScGridWindow::UpdateHeaderOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteHeaderOverlay();
 
@@ -7044,9 +7056,6 @@ void ScGridWindow::UpdateHeaderOverlay()
 mpOOHeader->append(std::move(pOverlay));
 }
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::DeleteShrinkOverlay()
@@ -7056,10 +7065,16 @@ void ScGridWindow::DeleteShrinkOverlay()
 
 void ScGridWindow::UpdateShrinkOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-MapMode aOldMode = GetMapMode();
-if ( aOldMode != aDrawMode )
-SetMapMode( aDrawMode );
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode aOldMode = GetMapMode();
+comphelper::ScopeGuard aMapModeGuard(
+[, , this] {
+if (aOldMode != aDrawMode)
+SetMapMode(aOldMode);
+}
+);
+if (aOldMode != aDrawMode)
+SetMapMode(aDrawMode);
 
 DeleteShrinkOverlay();
 
@@ -7111,9 +7126,6 @@ void ScGridWindow::UpdateShrinkOverlay()
 mpOOShrink->append(std::move(pOverlay));
 }
 }
-
-if ( aOldMode != aDrawMode )
-SetMapMode( aOldMode );
 }
 
 void ScGridWindow::DeleteSparklineGroupOverlay()
@@ -7123,9 +7135,14 @@ void ScGridWindow::DeleteSparklineGroupOverlay()
 
 void ScGridWindow::UpdateSparklineGroupOverlay()
 {
-MapMode aDrawMode = GetDrawMapMode();
-
-MapMode aOldMode = GetMapMode();
+const MapMode aDrawMode = GetDrawMapMode();
+const MapMode 

core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-16 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/table2.cxx |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit e7285c5e520a35d34bce66fd1fe5bcd7771f9978
Author: Mike Kaganski 
AuthorDate: Mon Jan 15 17:22:35 2024 +0600
Commit: Xisco Fauli 
CommitDate: Tue Jan 16 09:29:40 2024 +0100

tdf#140330: do not deduplicate conditional formatting in undo context

Change-Id: If9c64a7af46ca601b3c47a80642d914facafdc62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162084
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit dc75960fdee6cac2d9dd6b45ac3090f30f92b3ce)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162104
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index afe2216b1abe..a871a1fb82c8 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -638,6 +638,9 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCRO
 {
 ScRange aOldRange( nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, 
nRow2 - nDy, pTable->nTab);
 ScRange aNewRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
+// Don't deduplicate when undoing or creating an Undo document! It would 
disallow correct undo
+bool bUndoContext = rDocument.IsUndo() || pTable->rDocument.IsUndo();
+// Note that Undo documents use same pool as the original document
 bool bSameDoc = rDocument.GetStyleSheetPool() == 
pTable->rDocument.GetStyleSheetPool();
 
 for(const auto& rxCondFormat : *pTable->mpCondFormatList)
@@ -658,7 +661,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCRO
 aRefCxt.mnTabDelta = nTab - pTable->nTab;
 pNewFormat->UpdateReference(aRefCxt, true);
 
-if (bSameDoc && pTable->nTab == nTab && 
CheckAndDeduplicateCondFormat(rDocument, 
mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab))
+if (!bUndoContext && bSameDoc && pTable->nTab == nTab && 
CheckAndDeduplicateCondFormat(rDocument, 
mpCondFormatList->GetFormat(rxCondFormat->GetKey()), pNewFormat.get(), nTab))
 {
 continue;
 }
@@ -668,7 +671,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCRO
 {
 // Check if there is the same format in the destination
 // If there is, then simply expand its range
-if (CheckAndDeduplicateCondFormat(rDocument, rxCond.get(), 
pNewFormat.get(), nTab))
+if (!bUndoContext && CheckAndDeduplicateCondFormat(rDocument, 
rxCond.get(), pNewFormat.get(), nTab))
 {
 bDuplicate = true;
 break;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-15 Thread Mike Kaganski (via logerrit)
 sc/source/ui/view/printfun.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 41afcf4fa89abe23177e6a26d1a9e8611f351852
Author: Mike Kaganski 
AuthorDate: Sun Jan 14 12:16:48 2024 +0600
Commit: Xisco Fauli 
CommitDate: Mon Jan 15 13:33:48 2024 +0100

tdf#159174: there may be no tabs in the clipboard document

Change-Id: I053d91bf44e39e14ade9face14084a107d0df898
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162041
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 0b93cc83993b3cd78aa05556342839a21c96dc5a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162092
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index a61520875238..84e21da02214 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -466,6 +466,9 @@ static void lcl_HidePrint( const ScTableInfo& rTabInfo, 
SCCOL nX1, SCCOL nX2 )
 void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* pDev, double /* 
nPrintFactor */,
 const tools::Rectangle& rBound, ScViewData* 
pViewData, bool bMetaFile)
 {
+if (rDoc.GetMaxTableNumber() < 0)
+return;
+
 //! evaluate nPrintFactor !!!
 
 SCTAB nTab = 0;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-15 Thread Matt K (via logerrit)
 sc/source/ui/app/transobj.cxx |   46 +++---
 1 file changed, 26 insertions(+), 20 deletions(-)

New commits:
commit fe1d56b3bc895d23f7e53fb7e2414862403099a0
Author: Matt K 
AuthorDate: Sat Jan 13 18:12:16 2024 -0600
Commit: Xisco Fauli 
CommitDate: Mon Jan 15 12:48:42 2024 +0100

tdf#159171 Prevent crash after selecting unprotected cells 2 times

The problem is that the code tries to check for a table on a clip-
board doc, but doesn't find any so it propagates nullptr back to
the caller, which is then used without being checked thereby
leading to a crash.  The fix is to check the result of the table
check of clipboard doc before doing any operations with it, thus
preventing the crash.

Change-Id: Ieb4a52d0c1cb713d5c14930e5e559e5bf520b330
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162033
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 3b10bbacb8a12a00c35683eeaae4a75046a84aac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162091
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 6a1ef6a04650..5f0599c888b3 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -312,28 +312,34 @@ bool ScTransferObj::GetData( const 
datatransfer::DataFlavor& rFlavor, const OUSt
 ScAddress aPos(nCol, nRow, nTab);
 
 const ScPatternAttr* pPattern = m_pDoc->GetPattern( nCol, nRow, 
nTab );
-ScTabEditEngine aEngine( *pPattern, m_pDoc->GetEditPool(), 
m_pDoc.get() );
-ScRefCellValue aCell(*m_pDoc, aPos);
-if (aCell.getType() == CELLTYPE_EDIT)
+if (pPattern)
 {
-const EditTextObject* pObj = aCell.getEditText();
-aEngine.SetTextCurrentDefaults(*pObj);
-}
-else
-{
-SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
-sal_uInt32 nNumFmt = pPattern->GetNumberFormat(pFormatter);
-const Color* pColor;
-OUString aText = ScCellFormat::GetString(aCell, nNumFmt, 
, *pFormatter, *m_pDoc);
-if (!aText.isEmpty())
-aEngine.SetTextCurrentDefaults(aText);
-}
+ScTabEditEngine aEngine(*pPattern, m_pDoc->GetEditPool(), 
m_pDoc.get());
+ScRefCellValue aCell(*m_pDoc, aPos);
+if (aCell.getType() == CELLTYPE_EDIT)
+{
+const EditTextObject* pObj = aCell.getEditText();
+aEngine.SetTextCurrentDefaults(*pObj);
+}
+else
+{
+SvNumberFormatter* pFormatter = m_pDoc->GetFormatTable();
+sal_uInt32 nNumFmt = pPattern->GetNumberFormat(pFormatter);
+const Color* pColor;
+OUString aText
+= ScCellFormat::GetString(aCell, nNumFmt, , 
*pFormatter, *m_pDoc);
+if (!aText.isEmpty())
+aEngine.SetTextCurrentDefaults(aText);
+}
 
-bOK = SetObject( ,
-((nFormat == SotClipboardFormatId::RTF) ? 
SCTRANS_TYPE_EDIT_RTF :
- ((nFormat == 
SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT) ?
-  SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT : 
SCTRANS_TYPE_EDIT_BIN)),
-rFlavor );
+bOK = SetObject(,
+((nFormat == SotClipboardFormatId::RTF)
+ ? SCTRANS_TYPE_EDIT_RTF
+ : ((nFormat == 
SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT)
+? SCTRANS_TYPE_EDIT_ODF_TEXT_FLAT
+: SCTRANS_TYPE_EDIT_BIN)),
+rFlavor);
+}
 }
 else if ( ScImportExport::IsFormatSupported( nFormat ) || nFormat == 
SotClipboardFormatId::RTF
 || nFormat == SotClipboardFormatId::RICHTEXT )


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-15 Thread Matt K (via logerrit)
 sc/source/core/data/document.cxx |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit a381ac7b0fa95ce340bd1b384c946fbd19d87393
Author: Matt K 
AuthorDate: Sat Jan 13 17:30:59 2024 -0600
Commit: Xisco Fauli 
CommitDate: Mon Jan 15 11:45:59 2024 +0100

tdf#151752 Fix crash when selecting unprotected cells and copy/pasting

The problem is that the code attemps to index into maTabs when looping
through clipboard ranges, but maTabs.size() can be 0 at that point
thus resulting in a crash.  The fix is to first check if maTabs.size()
is greater than 0 before doing the looping.

Change-Id: Ib2fc4c9f847f87f44a68ad6d73c2745d79b5caa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162032
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 59927dedc31eb5d51b417a02ae927eb578b90bd6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162090
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 060bd85eebbc..ff6d77b432f7 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3254,12 +3254,16 @@ bool ScDocument::HasClipFilteredRows()
 if ( rClipRanges.empty() )
 return false;
 
-for ( size_t i = 0, n = rClipRanges.size(); i < n; ++i )
+if (maTabs.size() > 0)
 {
-ScRange & rRange = rClipRanges[ i ];
-bool bAnswer = maTabs[nCountTab]->HasFilteredRows(rRange.aStart.Row(), 
rRange.aEnd.Row());
-if (bAnswer)
-return true;
+for (size_t i = 0, n = rClipRanges.size(); i < n; ++i)
+{
+ScRange& rRange = rClipRanges[i];
+bool bAnswer
+= maTabs[nCountTab]->HasFilteredRows(rRange.aStart.Row(), 
rRange.aEnd.Row());
+if (bAnswer)
+return true;
+}
 }
 return false;
 }


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-08 Thread Andras Timar (via logerrit)
 sc/source/ui/view/editsh.cxx |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit a0096182d3b027d5e71aaef4e4d1595683605210
Author: Andras Timar 
AuthorDate: Fri Jan 5 14:44:21 2024 +0100
Commit: Andras Timar 
CommitDate: Mon Jan 8 15:59:53 2024 +0100

LOK: disallow entering multiple hyperlinks in spreadsheet cells

This is for UX consistency. Previously it was allowed to enter
multiple hyperlinks in spreadsheet cells when the spreadsheet
was in OpenDocument format. Only in case of XLS/XLSX it was
not possible. But we got a feedback that it is desirable to have
a similar user experience for all spreadsheet file formats in
Online. In LibreOffice nothing changes, it works according to the
setting in Options - LibreOffice Calc - Compatibility - Hyperlinks.

Change-Id: I7eece4307289711e9c925c05085497afaafe600e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161667
Reviewed-by: Attila Szűcs 
Tested-by: Jenkins CollaboraOffice 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161688
Tested-by: Jenkins

diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 9ed398fb9876..c392f111e203 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -572,8 +573,9 @@ void ScEditShell::Execute( SfxRequest& rReq )
 SvxLinkInsertMode eMode = pHyper->GetInsertMode();
 
 bool bCellLinksOnly
-= 
SC_MOD()->GetAppOptions().GetLinksInsertedLikeMSExcel()
-  && 
rViewData.GetSfxDocShell()->GetMedium()->GetFilter()->IsMSOFormat();
+= 
(SC_MOD()->GetAppOptions().GetLinksInsertedLikeMSExcel()
+  && 
rViewData.GetSfxDocShell()->GetMedium()->GetFilter()->IsMSOFormat())
+  || comphelper::LibreOfficeKit::isActive();
 
 bool bDone = false;
 if ( (eMode == HLINK_DEFAULT || eMode == HLINK_FIELD) && 
!bCellLinksOnly )
@@ -786,8 +788,9 @@ void ScEditShell::GetState( SfxItemSet& rSet )
 {
 SvxHyperlinkItem aHLinkItem;
 bool bCellLinksOnly
-= 
SC_MOD()->GetAppOptions().GetLinksInsertedLikeMSExcel()
-  && 
rViewData.GetSfxDocShell()->GetMedium()->GetFilter()->IsMSOFormat();
+= 
(SC_MOD()->GetAppOptions().GetLinksInsertedLikeMSExcel()
+  && 
rViewData.GetSfxDocShell()->GetMedium()->GetFilter()->IsMSOFormat())
+  || comphelper::LibreOfficeKit::isActive();
 std::unique_ptr 
aSvxFieldDataPtr(GetURLField());
 const SvxURLField* pURLField(static_cast(aSvxFieldDataPtr.get()));
 if (!bCellLinksOnly)


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-08 Thread Mike Kaganski (via logerrit)
 sc/source/core/data/attarray.cxx |1 +
 sc/source/ui/view/viewfunc.cxx   |1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

New commits:
commit fd1f76d1f45329d45ec22eff63e05f43c95fec83
Author: Mike Kaganski 
AuthorDate: Sat Dec 30 18:37:58 2023 +0600
Commit: Xisco Fauli 
CommitDate: Mon Jan 8 09:51:17 2024 +0100

tdf#158254: don't shrink to data area when applying to entire sheet

Commit ac859a4c6a7fce4efee9cdd45821a0c9e40e9e9a (tdf#147842 shrink
selection to data area when applying to entire sheet, 2022-10-18)
tried to workaround the problem of applying to the massive amount
of columns. This caused regressions, where it was impossible to pre-
format entire rows.

This change removes the call to ShrinkToDataArea from
ScViewFunc::ApplySelectionPattern (it is used elsewhere, so the
commit is not reverted completely).

Instead, it addresses the bottleneck in the bugdoc in tdf#147842,
which is ScAttrArray::RemoveCellCharAttribs: since the document
had hidden rows, selecting all made multi-selection split into
separate stripes, and the fulction was called repeatedly, and
itself called ScEditUtil::RemoveCharAttribs for every cell in
~ 1000 columns * 100 rows, even though most of the cells in
that range were empty - so no char attribs could exist. Asking
for the last used row (the same as done in ShrinkToDataArea)
makes the operation fast again, and keeps assigning the format
to the entire range.

Change-Id: I9635ea1a392b3a1e048c0888f4786a3628675fc9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161442
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 46b06663ae767d3423f2135fa91800cfa304877b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161422
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 7124e78be37e..4c31fb86e3cc 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -410,6 +410,7 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, 
SCROW nEndRow,
 // cache mdds position, this doesn't modify the mdds container, just 
EditTextObject's
 sc::ColumnBlockPosition blockPos;
 rDocument.InitColumnBlockPosition( blockPos, nTab, nCol );
+nEndRow = rDocument.GetLastDataRow(nTab, nCol, nCol, nEndRow);
 for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
 {
 ScAddress aPos(nCol, nRow, nTab);
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 0b8b0865f0fc..25633cae38f7 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1252,7 +1252,6 @@ void ScViewFunc::ApplySelectionPattern( const 
ScPatternAttr& rAttr, bool bCursor
 ScDocShell* pDocSh  = rViewData.GetDocShell();
 ScDocument& rDoc= pDocSh->GetDocument();
 ScMarkData aFuncMark( rViewData.GetMarkData() );   // local copy for 
UnmarkFiltered
-ShrinkToDataArea( aFuncMark, rDoc );
 ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
 
 bool bRecord = true;


core.git: Branch 'libreoffice-24-2' - sc/source

2024-01-07 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/column2.cxx |2 ++
 sc/source/ui/view/output2.cxx   |4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 000aa433fd7a112b83ee0b629aa6edf4d9833277
Author: Caolán McNamara 
AuthorDate: Fri Jan 5 13:23:31 2024 +
Commit: Adolfo Jayme Barrientos 
CommitDate: Mon Jan 8 07:15:15 2024 +0100

Resolves: tdf#158997 optimal col width too narrow to render text

optimal is measured with kerning on, while text is rendered with
kerning off

possibly a problem since:

commit 36eed54d3dfed6551fd2ad944feff7e217c56e82
Date:   Tue Jul 3 15:00:26 2018 +0200

Resolves: tdf#118221 whole cell kerning default is off

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

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 28d928cacea1..0592c97e580c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -283,6 +283,7 @@ tools::Long ScColumn::GetNeededSize(
 {
 Fraction aFontZoom = ( eOrient == SvxCellOrientation::Standard ) ? 
rZoomX : rZoomY;
 vcl::Font aFont;
+aFont.SetKerning(FontKerning::NONE); // like 
ScDrawStringsVars::SetPattern
 // font color doesn't matter here
 pPattern->fillFontOnly(aFont, pDev, , pCondSet, nScript);
 pDev->SetFont(aFont);
@@ -754,6 +755,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
 SCROW nRow = 0;
 const ScPatternAttr* pPattern = GetPattern( nRow );
 vcl::Font aFont;
+aFont.SetKerning(FontKerning::NONE); // like 
ScDrawStringsVars::SetPattern
 // font color doesn't matter here
 pPattern->fillFontOnly(aFont, pDev, );
 pDev->SetFont(aFont);
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 473671ea1cf3..d419981d8edb 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -407,7 +407,9 @@ void ScDrawStringsVars::SetPattern(
 
 // There is no cell attribute for kerning, default is kerning OFF, all
 // kerning is stored at an EditText object that is drawn using EditEngine.
-aFont.SetKerning( FontKerning::NONE);
+// See also matching kerning cases in ScColumn::GetNeededSize and
+// ScColumn::GetOptimalColWidth.
+aFont.SetKerning(FontKerning::NONE);
 
 pDev->SetFont( aFont );
 if ( pFmtDevice != pDev )


core.git: Branch 'libreoffice-24-2' - sc/source vcl/osx

2024-01-05 Thread Patrick Luby (via logerrit)
 sc/source/ui/inc/tabview.hxx  |2 +
 sc/source/ui/view/tabview.cxx |   46 ++
 vcl/osx/salframeview.mm   |8 +++
 3 files changed, 52 insertions(+), 4 deletions(-)

New commits:
commit 24effe0edd9ae1ea9e4dd8e0bdabd5f25e1b9a68
Author: Patrick Luby 
AuthorDate: Mon Dec 25 09:19:48 2023 -0500
Commit: Caolán McNamara 
CommitDate: Fri Jan 5 15:48:41 2024 +0100

tdf#135478 Reduce sensitivity of horizontal scrollwheel

Problem: at least on macOS, swipe events are very
precise. So, when swiping at a slight angle off of
vertical, swipe events will include a small amount
of horizontal movement. Since horizontal swipe units
are measured in cell widths, these small amounts of
horizontal movement results in shifting many columns
to the right or left while swiping almost vertically.

So my hacky fix is to reduce the amount of horizontal
swipe events to roughly match the "visual distance"
of vertical swipe events.

The reduction factor is arbitrary but is set to
roughly the ratio of default cell width divided by
default cell height. This hacky fix isn't a perfect
fix, but hopefully it reduces the amount of
unexpected horizontal shifting while swiping
vertically to a tolerable amount for most users.

Note: the potential downside of doing this is that
some users might find horizontal swiping to be
slower than they are used to. If that becomes an
issue for enough users, the reduction factor may
need to be lowered to find a good balance point.

Lastly, fix the unbalanced rounding of delta X and Y
values due to using floor() for macOS native swipe
and scroll wheel events.

Change-Id: I8c0c9a3aa688e411c47ebb5e7500f3a50f6f673b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161278
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-by: Patrick Luby 
(cherry picked from commit 689ddab27bb0658e43ab0e0d4d8235e45d8904d4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161317
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 23419f463923..66bbc010eae1 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -217,6 +217,8 @@ private:
 
 double  mfLastZoomScale = 0;
 double  mfAccumulatedZoom = 0;
+tools::Long mnPendingaHScrollLeftDelta = 0;
+tools::Long mnPendingaHScrollRightDelta = 0;
 
 voidInit();
 
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index fd9e88d18f31..9eff50195e84 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1217,6 +1217,52 @@ void ScTabView::ScrollHdl(ScrollAdaptor* pScroll)
 else
 nDelta = 0;
 }
+else if ( bHoriz )
+{
+// tdf#135478 Reduce sensitivity of horizontal scrollwheel
+// Problem: at least on macOS, swipe events are very
+// precise. So, when swiping at a slight angle off of
+// vertical, swipe events will include a small amount
+// of horizontal movement. Since horizontal swipe units
+// are measured in cell widths, these small amounts of
+// horizontal movement results in shifting many columns
+// to the right or left while swiping almost vertically.
+// So my hacky fix is to reduce the amount of horizontal
+// swipe events to roughly match the "visual distance"
+// of vertical swipe events.
+// The reduction factor is arbitrary but is set to
+// roughly the ratio of default cell width divided by
+// default cell height. This hacky fix isn't a perfect
+// fix, but hopefully it reduces the amount of
+// unexpected horizontal shifting while swiping
+// vertically to a tolerable amount for most users.
+// Note: the potential downside of doing this is that
+// some users might find horizontal swiping to be
+// slower than they are used to. If that becomes an
+// issue for enough users, the reduction factor may
+// need to be lowered to find a good balance point.
+static const sal_uInt16 nHScrollReductionFactor = 8;
+if ( pScroll == aHScrollLeft.get() )
+{
+mnPendingaHScrollLeftDelta += nDelta;
+nDelta = 0;
+if ( abs(mnPendingaHScrollLeftDelta) > 
nHScrollReductionFactor )
+{
+ 

core.git: Branch 'libreoffice-24-2' - sc/source svtools/source

2023-12-21 Thread Andreas Heinisch (via logerrit)
 sc/source/ui/view/tabview.cxx |3 +--
 svtools/source/control/tabbar.cxx |4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit a735f64391b5c194b38cacb577f14ef60556bcbc
Author: Andreas Heinisch 
AuthorDate: Thu Dec 21 20:29:32 2023 +0100
Commit: Adolfo Jayme Barrientos 
CommitDate: Thu Dec 21 23:32:56 2023 +0100

Revert "tdf#100584, tdf#157784 - Arrange sheets depending on the RTL 
settings"

This reverts commit 4f1b3c16f5530a2a190cab07c07c7bf63acf42c7.

Reason for revert: To many regressions.

Change-Id: I7352bb3c192d5e6c72e95c387ee551764007e97b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161152
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 
(cherry picked from commit 19e856aa1ade6686fa495e57386b81cabae47495)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161157
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index f580198f9bfc..44c74c5455a7 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -281,8 +281,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& 
rSize, bool bInner )
 if (bHasHint)
 RemoveHintWindow();
 
-// tdf#100584 - arrange sheets depending on the RTL settings
-bool bLayoutRTL = AllSettings::GetLayoutRTL();
+bool bLayoutRTL = aViewData.GetDocument().IsLayoutRTL( 
aViewData.GetTabNo() );
 tools::Long nTotalWidth = rSize.Width();
 if ( bLayoutRTL )
 nTotalWidth += 2*rOffset.X();
diff --git a/svtools/source/control/tabbar.cxx 
b/svtools/source/control/tabbar.cxx
index 02a23b8aea33..1690269ba234 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -715,7 +715,9 @@ void TabBar::ImplFormat()
 const size_t nItemListSize = mpImpl->maItemList.size();
 for (size_t nItemIndex = 0; nItemIndex < nItemListSize; nItemIndex++)
 {
-auto& rItem = mpImpl->maItemList[nItemIndex];
+// tdf#100584 - arrange sheets depending on the RTL settings
+auto& rItem = mbMirrored ? mpImpl->maItemList[nItemListSize - 
nItemIndex - 1]
+ : mpImpl->maItemList[nItemIndex];
 
 // At all non-visible tabs an empty rectangle is set
 if ((nItemIndex + 1 < mnFirstPos) || (x > mnLastOffX))


core.git: Branch 'libreoffice-24-2' - sc/source

2023-12-19 Thread Caolán McNamara (via logerrit)
 sc/source/core/data/dociter.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1eb2d67ded3856134404928c32b0e0fb35076934
Author: Caolán McNamara 
AuthorDate: Thu Dec 14 16:46:55 2023 +
Commit: Xisco Fauli 
CommitDate: Tue Dec 19 12:51:53 2023 +0100

Related: cool#6893 ScFormulaGroupIterator::next creates columns

that didn't exist before. Lots of time spent in ScColContainer::resize
on getting document statistics.

ScColContainer: :resize
ScTable: :CreateColumnIfNotExistsImpl
ScTable: :FetchColumn
ScFormulaGroupIterator: :next
ScDocument: :GetFormulaGroupCount
ScDocument: :GetDocStat
Change-Id: I52d4ab052e21215eb650bdccf4abc056ee2dd405
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160784
Reviewed-by: Michael Meeks 
Reviewed-by: Noel Grandin 
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit f3af1998741aeb7897aa5306ff16e7788bda2aa0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160800
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 35c0d2caa8fd..b1fca78c86be 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -803,7 +803,7 @@ sc::FormulaGroupEntry* ScFormulaGroupIterator::next()
 return nullptr;
 }
 ScTable *pTab = mrDoc.FetchTable(mnTab);
-ScColumn *pCol = pTab ? pTab->FetchColumn(mnCol) : nullptr;
+ScColumn *pCol = (pTab && pTab->IsColValid(mnCol)) ? 
pTab->FetchColumn(mnCol) : nullptr;
 if (pCol)
 {
 mbNullCol = false;


core.git: Branch 'libreoffice-24-2' - sc/source

2023-12-14 Thread Julien Nabet (via logerrit)
 sc/source/core/data/table2.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 78da3fde2df128d8d7caa2acd97d56cb374daf57
Author: Julien Nabet 
AuthorDate: Wed Dec 6 13:08:33 2023 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 14 17:04:33 2023 +0100

tdf#158551: fix crash Paste Special with Operation (mdds)

Change-Id: I0be1056261c6ef7f90fe9244265aa038c36a7dd2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160389
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
(cherry picked from commit 3282756b7984457c79044d08127a4def64905979)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160705
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 89ded6428766..f527bb10f83e 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -786,8 +786,8 @@ void ScTable::MixData(
 sc::MixDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2,
 ScPasteFunc nFunction, bool bSkipEmpty, const ScTable* pSrcTab )
 {
-for (SCCOL i=nCol1; i<=nCol2; i++)
-aCol[i].MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, 
pSrcTab->aCol[i]);
+for (SCCOL nCol : pSrcTab->GetAllocatedColumnsRange(nCol1, nCol2))
+aCol[nCol].MixData(rCxt, nRow1, nRow2, nFunction, bSkipEmpty, 
pSrcTab->aCol[nCol]);
 }
 
 // Selection form this document


core.git: Branch 'libreoffice-24-2' - sc/source

2023-12-14 Thread Julien Nabet (via logerrit)
 sc/source/ui/inc/SparklineRenderer.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 691876554f6acbe9665a391fe78e476b049dffdb
Author: Julien Nabet 
AuthorDate: Wed Dec 13 22:11:03 2023 +0100
Commit: Julien Nabet 
CommitDate: Thu Dec 14 11:01:52 2023 +0100

tdf#152929: Sparkline ignore "High points" color when all values are 
negative

See https://en.cppreference.com/w/cpp/types/numeric_limits/min
"min() returns the minimum positive value"

https://en.cppreference.com/w/cpp/types/numeric_limits/lowest (since C++11)
"Returns the lowest finite value representable by the numeric type T, that 
is, a finite value x such that there is no other finite value y where y < x."

Change-Id: I322cd84f8124aa6f3f306c168f33cb633418b3f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160719
Reviewed-by: Julien Nabet 
Tested-by: Jenkins
(cherry picked from commit b2fd2c247f7f62f9ae6826c4f1b9065a50313217)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160701

diff --git a/sc/source/ui/inc/SparklineRenderer.hxx 
b/sc/source/ui/inc/SparklineRenderer.hxx
index 23d62d6d6ae6..1a8adc39a828 100644
--- a/sc/source/ui/inc/SparklineRenderer.hxx
+++ b/sc/source/ui/inc/SparklineRenderer.hxx
@@ -72,7 +72,7 @@ public:
 size_t mnLastIndex = 0;
 
 double mfMinimum = std::numeric_limits::max();
-double mfMaximum = std::numeric_limits::min();
+double mfMaximum = std::numeric_limits::lowest();
 
 std::vector const& getValuesList() const { return 
maValueList; }