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

2015-02-27 Thread Eike Rathke
 sc/inc/tokenarray.hxx  |3 
 sc/source/core/data/column.cxx |   29 +
 sc/source/core/tool/token.cxx  |  132 +++--
 3 files changed, 158 insertions(+), 6 deletions(-)

New commits:
commit 58deeaea725eca0e8140b09420d5144d5d3f800c
Author: Eike Rathke er...@redhat.com
Date:   Thu Feb 26 12:54:13 2015 +0100

Resolves: tdf#81659 handle expand reference edge correctly

split formula grouping for reference edge expansion, tdf#81659 related

Edge expansion may change expressions individually, which must be split
off the group.

(cherry picked from commit 0cd15b4494f8e8abe67a258fb10189135bf5a8ac)

tdf#81659 check that references are at least 2 cols/rows to expand edge

Needs also 0cd15b4494f8e8abe67a258fb10189135bf5a8ac if edges are to be
expanded and formula grouping is affected.

(cherry picked from commit 23b0112ecea2f8796a4e237e9061de1a36997a30)

Backported.

b3cee8dd214d216907248316a2ac5a290399b169

Change-Id: Id4328bd8c42f2ff9f83d2edc845537971f3a39d3
Reviewed-on: https://gerrit.libreoffice.org/14656
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 1768ba9..e134f12 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -233,6 +233,9 @@ public:
 void CheckRelativeReferenceBounds(
 const ScAddress rPos, SCROW nGroupLen, const ScRange rRange, 
std::vectorSCROW rBounds ) const;
 
+void CheckExpandReferenceBounds(
+const sc::RefUpdateContext rCxt, const ScAddress rPos, SCROW 
nGroupLen, std::vectorSCROW rBounds ) const;
+
 /**
  * Create a string representation of formula token array without modifying
  * the internal state of the token array.
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 64174ab..431e9b1 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2300,6 +2300,27 @@ public:
 }
 };
 
+class UpdateRefExpandGroupBoundChecker : public SharedTopFormulaCellPicker
+{
+const sc::RefUpdateContext mrCxt;
+std::vectorSCROW mrBounds;
+
+public:
+UpdateRefExpandGroupBoundChecker(const sc::RefUpdateContext rCxt, 
std::vectorSCROW rBounds) :
+mrCxt(rCxt), mrBounds(rBounds) {}
+
+virtual ~UpdateRefExpandGroupBoundChecker() {}
+
+virtual void processSharedTop( ScFormulaCell** ppCells, size_t /*nRow*/, 
size_t /*nLength*/ ) SAL_OVERRIDE
+{
+// Check its tokens and record its reference boundaries.
+ScFormulaCell rCell = **ppCells;
+const ScTokenArray rCode = *rCell.GetCode();
+rCode.CheckExpandReferenceBounds(
+mrCxt, rCell.aPos, rCell.GetSharedLength(), mrBounds);
+}
+};
+
 class FormulaGroupPicker : public SharedTopFormulaCellPicker
 {
 std::vectorsc::FormulaGroupEntry mrGroups;
@@ -2385,6 +2406,14 @@ bool ScColumn::UpdateReference( sc::RefUpdateContext 
rCxt, ScDocument* pUndoDoc
 UpdateRefGroupBoundChecker aBoundChecker(rCxt, aBounds);
 std::for_each(maCells.begin(), maCells.end(), aBoundChecker);
 
+// If expand reference edges is on, splitting groups may happen anywhere
+// where a reference points to an adjacent row of the insertion.
+if (rCxt.mnRowDelta  0  rCxt.mrDoc.IsExpandRefs())
+{
+UpdateRefExpandGroupBoundChecker aExpandChecker(rCxt, aBounds);
+std::for_each(maCells.begin(), maCells.end(), aExpandChecker);
+}
+
 // Do the actual splitting.
 sc::SharedFormulaUtil::splitFormulaCellGroups(maCells, aBounds);
 
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 1b550af..9961b58 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2642,9 +2642,18 @@ bool expandRange( const sc::RefUpdateContext rCxt, 
ScRange rRefRange, const Sc
 // Selected range is only partially overlapping in vertical 
direction. Bail out.
 return false;
 
-if (!rCxt.mrDoc.IsExpandRefs()  rSelectedRange.aStart.Col() = 
rRefRange.aStart.Col())
-// Selected range is at the left end and the edge expansion is 
turned off.  No expansion.
-return false;
+if (rCxt.mrDoc.IsExpandRefs())
+{
+if (rRefRange.aEnd.Col() - rRefRange.aStart.Col()  1)
+// Reference must be at least two columns wide.
+return false;
+}
+else
+{
+if (rSelectedRange.aStart.Col() = rRefRange.aStart.Col())
+// Selected range is at the left end and the edge expansion is 
turned off.  No expansion.
+return false;
+}
 
 // Move the last column position to the right.
 SCCOL nDelta = rSelectedRange.aEnd.Col() - rSelectedRange.aStart.Col() 
+ 1;
@@ -2658,9 +2667,18 @@ bool expandRange( const sc::RefUpdateContext 

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

2015-02-16 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |9 ++---
 sc/source/core/tool/interpr4.cxx |   10 ++
 sc/source/core/tool/scmatrix.cxx |   23 +++
 3 files changed, 35 insertions(+), 7 deletions(-)

New commits:
commit 5b952ced5b2ae6151079206c3e397de653f0ced2
Author: Eike Rathke er...@redhat.com
Date:   Wed Feb 11 21:47:23 2015 +0100

Resolves: tdf#39316 add matrix empty cells to 
ScInterpreter::QueryMatrixType()

(cherry picked from commit eccbc97c7c224269fe261b8924e7866c3758ec91)

add ScMatrix::IsEmptyResult() for tdf#39316 fix preparation

(cherry picked from commit cf3f1d8dfeb45249eb60a30dba3243fe9a4a65e5)

9f2a3e6fa9f4ef43df672661afef996269b90a7a

Change-Id: Ifa5d59e90afcfff66f2e8683fac2a9090ed615da
Reviewed-on: https://gerrit.libreoffice.org/14430
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 851caa4..aebe0e7 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -322,13 +322,16 @@ public:
 /// @return TRUE/ if string or empty or empty path, in fact non-value.
 bool IsString( SCSIZE nC, SCSIZE nR ) const;
 
-/// @return TRUE/ if empty or empty path.
+/// @return TRUE/ if empty or empty cell or empty result, not empty path.
 bool IsEmpty( SCSIZE nC, SCSIZE nR ) const;
 
-/// @return TRUE/ if empty, not empty result or empty path.
+/// @return TRUE/ if empty cell, not empty or empty result or empty path.
 bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const;
 
-/// @return TRUE/ if empty path.
+/// @return TRUE/ if empty result, not empty or empty cell or empty path.
+bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const;
+
+/// @return TRUE/ if empty path, not empty or empty cell or empty result.
 bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
 
 /// @return TRUE/ if value or boolean.
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 58bc004..473f40d 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1879,6 +1879,16 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef xMat, 
short rRetTypeExpr, sal_
 PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, 
xMat, xRes.get()));
 rRetTypeExpr = NUMBERFORMAT_LOGICAL;
 }
+else if ( xMat-IsEmptyResult( 0, 0))
+{   // empty formula result
+FormulaTokenRef xRes = new ScEmptyCellToken( true, true);   // 
inherited, display empty
+PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, 
xMat, xRes.get()));
+}
+else if ( xMat-IsEmpty( 0, 0))
+{   // empty or empty cell
+FormulaTokenRef xRes = new ScEmptyCellToken( false, true);  // 
not inherited, display empty
+PushTempToken( new ScMatrixFormulaCellToken(nCols, nRows, 
xMat, xRes.get()));
+}
 else
 {
 svl::SharedString aStr( nMatVal.GetString());
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b71cc1d..9afb2a6 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -254,6 +254,7 @@ public:
 bool IsString( SCSIZE nC, SCSIZE nR ) const;
 bool IsEmpty( SCSIZE nC, SCSIZE nR ) const;
 bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const;
+bool IsEmptyResult( SCSIZE nC, SCSIZE nR ) const;
 bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
 bool IsValue( SCSIZE nIndex ) const;
 bool IsValue( SCSIZE nC, SCSIZE nR ) const;
@@ -686,8 +687,8 @@ bool ScMatrixImpl::IsString( SCSIZE nC, SCSIZE nR ) const
 
 bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
 {
-// Flag must indicate an empty element instead of an
-// 'empty path' element.
+// Flag must indicate an 'empty' or 'empty cell' or 'empty result' element,
+// but not an 'empty path' element.
 ValidColRowReplicated( nC, nR );
 return maMat.get_type(nR, nC) == mdds::mtm::element_empty 
 maMatFlag.getTMatFlag(nR, nC) != SC_MATFLAG_EMPTYPATH;
@@ -695,13 +696,22 @@ bool ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
 
 bool ScMatrixImpl::IsEmptyCell( SCSIZE nC, SCSIZE nR ) const
 {
-// Flag must indicate an 'empty' element instead of an
-// 'empty result' or 'empty path' element.
+// Flag must indicate an 'empty cell' element instead of an
+// 'empty' or 'empty result' or 'empty path' element.
 ValidColRowReplicated( nC, nR );
 return maMat.get_type(nR, nC) == mdds::mtm::element_empty 
 maMatFlag.getTMatFlag(nR, nC) == SC_MATFLAG_EMPTYCELL;
 }
 
+bool ScMatrixImpl::IsEmptyResult( SCSIZE nC, SCSIZE nR ) const
+{
+// Flag must indicate an 'empty result' element instead of an
+// 'empty' or 'empty cell' or 'empty path' element.
+

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

2015-01-14 Thread Eike Rathke
 sc/inc/document.hxx|6 +-
 sc/inc/table.hxx   |6 +-
 sc/source/core/data/documen3.cxx   |2 +-
 sc/source/core/data/table3.cxx |   25 ++---
 sc/source/ui/docshell/dbdocfun.cxx |1 +
 5 files changed, 26 insertions(+), 14 deletions(-)

New commits:
commit 198c14e95693bd8af3fc36ec5d97d95a2180f85a
Author: Eike Rathke er...@redhat.com
Date:   Fri Dec 5 22:54:41 2014 +0100

Ctrl+A and Data Sort took ages to broadcast ALL cells, fdo#81501 related

Noticed when investigating fdo#81501
Squashed commits:

Fix high memory usage when sorting cells in Calc. (fdo#81501)

Empty columns were being unnecessarily included in the sorting
range which caused extra allocation. This happens when you select
the entire sheet to sort. There was already code to skip empty
trailing cells in rows but not to skip empty columns.

Reviewed-on: https://gerrit.libreoffice.org/13294
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com
(cherry picked from commit c50d8bf596f527bb53b86dd04da652ed72f2c549)

actually use identical code for both byRow and byCol, fdo#81501 follow-up

(cherry picked from commit 1e4235f8b2dc693b0fb1edade9db25a631bdbf94)

trim also empty leading column ranges, fdo#81501 follow-up

(cherry picked from commit c7b57c6c2b15a4b9f65dafb642e3f1da402e62ca)

Ctrl+A and Data Sort took ages to broadcast ALL cells

... now that also empty cells are to be broadcasted.

Set dirty and broadcast only the effective data range as determined by Sort.

This is more a workaround, a cleaner solution would be to refactor the
SetDirty() algorithm to iterate only through broadcasters and use
AreaBroadcast() to notify area listeners.

However, this can also be easily backported to 4-3.

(cherry picked from commit 9a568c41ccd1ccf6073758973da5914a44f629d2)

982e03a12dd80be0787f22dce4495065775e7de0
eaeea85149e4b6d263b112205bb17c155e2d12be
6d68ca0088cec6a8328a3e93364ac928ef69babe

Change-Id: Ieac22647bb13165cbf66cb1a93f567e5169fff6a
Reviewed-on: https://gerrit.libreoffice.org/13323
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f37bfa2..31da470 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1678,8 +1678,12 @@ public:
 SC_DLLPUBLIC SvNumberFormatter* GetFormatTable() const;
 SC_DLLPUBLIC SvNumberFormatter* CreateFormatTable() const;
 
+/** Sort a range of data.
+@param  rSortParam may get adjusted to the actual range used if it did
+encompass leading or trailing empty blocks
+ */
 void Sort(
-SCTAB nTab, const ScSortParam rSortParam, bool bKeepQuery, bool 
bUpdateRefs,
+SCTAB nTab, ScSortParam rSortParam, bool bKeepQuery, bool bUpdateRefs,
 ScProgress* pProgress, sc::ReorderParam* pUndo );
 
 void Reorder( const sc::ReorderParam rParam, ScProgress* pProgress );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 49b8571..8a01b9e 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -825,8 +825,12 @@ public:
 voidStripHidden( SCCOL rX1, SCROW rY1, SCCOL rX2, SCROW rY2 );
 voidExtendHidden( SCCOL rX1, SCROW rY1, SCCOL rX2, SCROW rY2 );
 
+/** Sort a range of data.
+@param  rSortParam may get adjusted to the actual range used if it did
+encompass leading or trailing empty blocks
+ */
 void Sort(
-const ScSortParam rSortParam, bool bKeepQuery, bool bUpdateRefs,
+ScSortParam rSortParam, bool bKeepQuery, bool bUpdateRefs,
 ScProgress* pProgress, sc::ReorderParam* pUndo );
 
 void Reorder( const sc::ReorderParam rParam, ScProgress* pProgress );
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index ef39f33..3cb62a9 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1366,7 +1366,7 @@ bool ScDocument::UpdateOutlineRow( SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab, b
 }
 
 void ScDocument::Sort(
-SCTAB nTab, const ScSortParam rSortParam, bool bKeepQuery, bool 
bUpdateRefs,
+SCTAB nTab, ScSortParam rSortParam, bool bKeepQuery, bool bUpdateRefs,
 ScProgress* pProgress, sc::ReorderParam* pUndo )
 {
 if ( ValidTab(nTab)  nTab  static_castSCTAB(maTabs.size())  
maTabs[nTab] )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index fd22ead..65e3c37 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1402,10 +1402,9 @@ void ScTable::DecoladeRow( ScSortInfoArray* pArray, 
SCROW nRow1, SCROW nRow2 )
 }
 
 void ScTable::Sort(
-const ScSortParam rSortParam, bool bKeepQuery, bool bUpdateRefs,
+ScSortParam rSortParam, bool bKeepQuery, bool 

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

2015-01-12 Thread Markus Mohrhard
 sc/inc/column.hxx |1 +
 sc/source/core/data/cellvalue.cxx |4 ++--
 sc/source/core/data/column3.cxx   |   13 -
 3 files changed, 15 insertions(+), 3 deletions(-)

New commits:
commit aa6e3cbcdc8bd4190bec9afb17357fdd785a6183
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Sat Jan 10 13:16:20 2015 +0100

only delete cell content for CELLTYPE_NONE, fdo#88200

Change-Id: I43463b56cabfea4c9ee2b98445f7fb51197d
Reviewed-on: https://gerrit.libreoffice.org/13843
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index dee712f..539c916 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -186,6 +186,7 @@ public:
 const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition 
rBlockPos, SCROW nRow ) const;
 
 voidDelete( SCROW nRow );
+voidDeleteContent( SCROW nRow, bool bBroadcast = true );
 voidFreeAll();
 voidFreeNotes();
 void Swap( ScColumn rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index b9eb32b..d162211 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -123,7 +123,7 @@ static void commitToColumn( const ScCellValue rCell, 
ScColumn rColumn, SCROW n
 }
 break;
 default:
-rColumn.Delete(nRow);
+rColumn.DeleteContent(nRow);
 }
 }
 
@@ -463,7 +463,7 @@ void ScCellValue::release( ScColumn rColumn, SCROW nRow )
 rColumn.SetFormulaCell(nRow, mpFormula);
 break;
 default:
-rColumn.Delete(nRow);
+rColumn.DeleteContent(nRow);
 }
 
 meType = CELLTYPE_NONE;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3c39880..90f9b65 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -108,7 +108,7 @@ void ScColumn::InterpretDirtyCells( SCROW nRow1, SCROW 
nRow2 )
 sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
 }
 
-void ScColumn::Delete( SCROW nRow )
+void ScColumn::DeleteContent( SCROW nRow, bool bBroadcast )
 {
 sc::CellStoreType::position_type aPos = maCells.position(nRow);
 sc::CellStoreType::iterator it = aPos.first;
@@ -122,6 +122,17 @@ void ScColumn::Delete( SCROW nRow )
 sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p);
 }
 maCells.set_empty(nRow, nRow);
+
+if (bBroadcast)
+{
+Broadcast(nRow);
+CellStorageModified();
+}
+}
+
+void ScColumn::Delete( SCROW nRow )
+{
+DeleteContent(nRow, false);
 maCellTextAttrs.set_empty(nRow, nRow);
 maCellNotes.set_empty(nRow, nRow);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-01-07 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |6 +++
 sc/source/core/data/column2.cxx  |   27 +++--
 sc/source/core/tool/interpr1.cxx |4 +-
 sc/source/core/tool/scmatrix.cxx |   77 +++
 4 files changed, 93 insertions(+), 21 deletions(-)

New commits:
commit 007bede69824b2caee948d21acefc2f5b0f63b3a
Author: Eike Rathke er...@redhat.com
Date:   Mon Dec 22 21:14:11 2014 +0100

fdo#85258 differentiate between empty cell and empty result in matrix

Change-Id: I79259224e411f9c1a6e852623d9d49cf89a03c27
(cherry picked from commit 069698de192ef7e8d3582398e4542c175cabb987)
Reviewed-on: https://gerrit.libreoffice.org/13617
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 1e4c74f..851caa4 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -278,6 +278,9 @@ public:
 /** Put a column vector of empties, starting at row nR, must fit into 
dimensions. */
 void PutEmptyVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR );
 
+/** Put a column vector of empty results, starting at row nR, must fit 
into dimensions. */
+void PutEmptyResultVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR );
+
 /** Put a column vector of empty paths, starting at row nR, must fit into 
dimensions. */
 void PutEmptyPathVector( SCSIZE nCount, SCSIZE nC, SCSIZE nR );
 
@@ -322,6 +325,9 @@ public:
 /// @return TRUE/ if empty or empty path.
 bool IsEmpty( SCSIZE nC, SCSIZE nR ) const;
 
+/// @return TRUE/ if empty, not empty result or empty path.
+bool IsEmptyCell( SCSIZE nC, SCSIZE nR ) const;
+
 /// @return TRUE/ if empty path.
 bool IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 08a00c0..06ee75a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2065,16 +2065,23 @@ namespace {
 
 struct CellBucket
 {
+SCSIZE mnEmpValStart;
 SCSIZE mnNumValStart;
 SCSIZE mnStrValStart;
+SCSIZE mnEmpValCount;
 std::vectordouble maNumVals;
 std::vectorsvl::SharedString maStrVals;
 
-CellBucket() : mnNumValStart(0), mnStrValStart(0) {}
+CellBucket() : mnEmpValStart(0), mnNumValStart(0), mnStrValStart(0), 
mnEmpValCount(0) {}
 
 void flush(ScMatrix rMat, SCSIZE nCol)
 {
-if (!maNumVals.empty())
+if (mnEmpValCount)
+{
+rMat.PutEmptyResultVector(mnEmpValCount, nCol, mnEmpValStart);
+reset();
+}
+else if (!maNumVals.empty())
 {
 const double* p = maNumVals[0];
 rMat.PutDouble(p, maNumVals.size(), nCol, mnNumValStart);
@@ -2090,7 +2097,8 @@ struct CellBucket
 
 void reset()
 {
-mnNumValStart = mnStrValStart = 0;
+mnEmpValStart = mnNumValStart = mnStrValStart = 0;
+mnEmpValCount = 0;
 maNumVals.clear();
 maStrVals.clear();
 }
@@ -2162,7 +2170,18 @@ public:
 
 if (rCell.IsEmpty())
 {
-aBucket.flush(mrMat, mnMatCol);
+if (aBucket.mnEmpValCount  nThisRow == nPrevRow + 1)
+{
+// Secondary empty results.
+++aBucket.mnEmpValCount;
+}
+else
+{
+// First empty result.
+aBucket.flush(mrMat, mnMatCol);
+aBucket.mnEmpValStart = nThisRow - mnTopRow;
+++aBucket.mnEmpValCount;
+}
 continue;
 }
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 493080a..4a63f14 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1893,14 +1893,14 @@ void ScInterpreter::ScIsEmpty()
 if ( !pMat )
 ;   // nothing
 else if ( !pJumpMatrix )
-nRes = pMat-IsEmpty( 0, 0) ? 1 : 0;
+nRes = pMat-IsEmptyCell( 0, 0) ? 1 : 0;
 else
 {
 SCSIZE nCols, nRows, nC, nR;
 pMat-GetDimensions( nCols, nRows);
 pJumpMatrix-GetPos( nC, nR);
 if ( nC  nCols  nR  nRows )
-nRes = pMat-IsEmpty( nC, nR) ? 1 : 0;
+nRes = pMat-IsEmptyCell( nC, nR) ? 1 : 0;
 // else: false, not empty (which is what Xcl does)
 }
 }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 19f65dd..b71cc1d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -194,6 +194,13 @@ _Comp CompareMatrixElemFunc_Comp::maComp;
 
 }
 
+/* TODO: it would be good if mdds 

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

2014-12-17 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |2 
 sc/source/core/tool/scmatrix.cxx |   96 +--
 2 files changed, 53 insertions(+), 45 deletions(-)

New commits:
commit 6b80793b919520e443024da5499e7ab9f6720d6c
Author: Eike Rathke er...@redhat.com
Date:   Thu Dec 11 16:39:58 2014 +0100

resolved fdo#87237 propagate error values through matrix comparisons

Apparently introduced with 8e8b43a03e77dd251876c1de0ac06eeeb09192cd the
comparison results were stored as boolean values, effectively discarding
any infinite double values and error values encoded as NaN values.

Change-Id: I1fb6f46894a0bee02a37e28b7e6cc84f8c051f28
(cherry picked from commit 3c405ff82fcc9f8f044833420485c54658064636)
Reviewed-on: https://gerrit.libreoffice.org/13439
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 1eab349..1e4c74f 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -202,7 +202,7 @@ public:
 ScMatrix(SCSIZE nC, SCSIZE nR);
 ScMatrix(SCSIZE nC, SCSIZE nR, double fInitVal);
 
-ScMatrix( size_t nC, size_t nR, const std::vectorbool rInitVals );
+ScMatrix( size_t nC, size_t nR, const std::vectordouble rInitVals );
 
 /** Clone the matrix. */
 ScMatrix* Clone() const;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 18aeb5d..19f65dd 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -70,51 +70,63 @@ typedef mdds::multi_type_matrixcustom_string_trait 
MatrixImplType;
 
 namespace {
 
-struct ElemEqualZero : public unary_functiondouble, bool
+struct ElemEqualZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val == 0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val == 0.0 ? 1.0 : 0.0;
 }
 };
 
-struct ElemNotEqualZero : public unary_functiondouble, bool
+struct ElemNotEqualZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val != 0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val != 0.0 ? 1.0 : 0.0;
 }
 };
 
-struct ElemGreaterZero : public unary_functiondouble, bool
+struct ElemGreaterZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val  0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val  0.0 ? 1.0 : 0.0;
 }
 };
 
-struct ElemLessZero : public unary_functiondouble, bool
+struct ElemLessZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val  0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val  0.0 ? 1.0 : 0.0;
 }
 };
 
-struct ElemGreaterEqualZero : public unary_functiondouble, bool
+struct ElemGreaterEqualZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val = 0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val = 0.0 ? 1.0 : 0.0;
 }
 };
 
-struct ElemLessEqualZero : public unary_functiondouble, bool
+struct ElemLessEqualZero : public unary_functiondouble, double
 {
-bool operator() (double val) const
+double operator() (double val) const
 {
-return val = 0.0;
+if (!::rtl::math::isFinite(val))
+return val;
+return val = 0.0 ? 1.0 : 0.0;
 }
 };
 
@@ -123,7 +135,7 @@ class CompareMatrixElemFunc : 
std::unary_functionMatrixImplType::element_block_
 {
 static _Comp maComp;
 
-std::vectorbool maNewMatValues;
+std::vectordouble maNewMatValues; // double instead of bool to 
transport error values
 size_t mnRow;
 size_t mnCol;
 public:
@@ -145,13 +157,6 @@ public:
 for (; it != itEnd; ++it)
 {
 double fVal = *it;
-if (!rtl::math::isFinite(fVal))
-{
-/* FIXME: this silently skips an error instead of 
propagating it! */
-maNewMatValues.push_back(false);
-continue;
-}
-
 maNewMatValues.push_back(maComp(fVal));
 }
 }
@@ -173,7 +178,7 @@ public:
 case mdds::mtm::element_empty:
 default:
 // Fill it with false.
-maNewMatValues.resize(maNewMatValues.size() + node.size, 
false);
+maNewMatValues.resize(maNewMatValues.size() + node.size, 0.0);
 }
 

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

2014-12-09 Thread Markus Mohrhard
 sc/inc/column.hxx   |1 +
 sc/source/core/data/column3.cxx |6 ++
 sc/source/core/data/table1.cxx  |4 
 3 files changed, 11 insertions(+)

New commits:
commit 8efdd9909cc46b4a00236f148f2f5c8349377c33
Author: Markus Mohrhard markus.mohrh...@collabora.co.uk
Date:   Mon Dec 8 07:43:14 2014 +0100

we need the SdrPage for deleting the notes, fdo#86166

The SdrPage that contains the shapes for the note captions is deleted
before the notes. Prevent that case by deleting the notes before
deleting the SdrPage.

Change-Id: I13727cea7df0b033fb386a6a8e20dcadec743335
Reviewed-on: https://gerrit.libreoffice.org/13362
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 6911ca0..dee712f 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -187,6 +187,7 @@ public:
 
 voidDelete( SCROW nRow );
 voidFreeAll();
+voidFreeNotes();
 void Swap( ScColumn rOther, SCROW nRow1, SCROW nRow2, bool bPattern );
 
 boolHasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 924c9e3..3c39880 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -141,6 +141,12 @@ void ScColumn::FreeAll()
 CellStorageModified();
 }
 
+void ScColumn::FreeNotes()
+{
+maCellNotes.clear();
+maCellNotes.resize(MAXROWCOUNT);
+}
+
 namespace {
 
 class ShiftFormulaPosHandler
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 94cf672..2b1c2c9 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -319,6 +319,10 @@ ScTable::~ScTable()
 {
 if (!pDocument-IsInDtorClear())
 {
+for (SCCOL nCol = 0; nCol  MAXCOL; ++nCol)
+{
+aCol[nCol].FreeNotes();
+}
 //  nicht im dtor die Pages in der falschen Reihenfolge loeschen
 //  (nTab stimmt dann als Page-Number nicht!)
 //  In ScDocument::Clear wird hinterher per Clear am Draw Layer alles 
geloescht.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-12-09 Thread Caolán McNamara
 sc/inc/address.hxx  |   20 ++--
 sc/source/core/tool/detfunc.cxx |4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit fc95fb6eb235331b2564b78f2c026364263db6e1
Author: Caolán McNamara caol...@redhat.com
Date:   Tue Dec 9 09:22:39 2014 +

surely it makes no sense to ignore return of Sanitize[Col|Row]

Change-Id: I24ef940bcf4b2a7c5f40185f91ee234c844185f8
(cherry picked from commit e5c2fe0412585bc83bd6a99fc37a7c47eb8c3641)
(cherry picked from commit a403bddc0fe29f69e3fb2b0c04fd540fa2cec218)
Reviewed-on: https://gerrit.libreoffice.org/13389
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 7fcdee1..2018dfe 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -108,52 +108,52 @@ const SCROW W16MAXROW = W16MAXROWCOUNT - 1;
 #endif
 
 //  old stuff defines end
-inline bool ValidCol( SCCOL nCol )
+SAL_WARN_UNUSED_RESULT inline bool ValidCol( SCCOL nCol )
 {
 return static_castSCCOL(0) = nCol  nCol = MAXCOL;
 }
 
-inline bool ValidRow( SCROW nRow )
+SAL_WARN_UNUSED_RESULT inline bool ValidRow( SCROW nRow )
 {
 return static_castSCROW(0) = nRow  nRow = MAXROW;
 }
 
-inline bool ValidTab( SCTAB nTab )
+SAL_WARN_UNUSED_RESULT inline bool ValidTab( SCTAB nTab )
 {
 return static_castSCTAB(0) = nTab  nTab = MAXTAB;
 }
 
-inline bool ValidTab( SCTAB nTab, SCTAB nMaxTab )
+SAL_WARN_UNUSED_RESULT inline bool ValidTab( SCTAB nTab, SCTAB nMaxTab )
 {
 return static_castSCTAB(0) = nTab  nTab = nMaxTab;
 }
 
-inline bool ValidColRow( SCCOL nCol, SCROW nRow )
+SAL_WARN_UNUSED_RESULT inline bool ValidColRow( SCCOL nCol, SCROW nRow )
 {
 return ValidCol( nCol)  ValidRow( nRow);
 }
 
-inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB nTab )
+SAL_WARN_UNUSED_RESULT inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, 
SCTAB nTab )
 {
 return ValidCol( nCol)  ValidRow( nRow)  ValidTab( nTab);
 }
 
-inline SCCOL SanitizeCol( SCCOL nCol )
+SAL_WARN_UNUSED_RESULT inline SCCOL SanitizeCol( SCCOL nCol )
 {
 return nCol  0 ? 0 : (nCol  MAXCOL ? MAXCOL : nCol);
 }
 
-inline SCROW SanitizeRow( SCROW nRow )
+SAL_WARN_UNUSED_RESULT inline SCROW SanitizeRow( SCROW nRow )
 {
 return nRow  0 ? 0 : (nRow  MAXROW ? MAXROW : nRow);
 }
 
-inline SCTAB SanitizeTab( SCTAB nTab )
+SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab )
 {
 return nTab  0 ? 0 : (nTab  MAXTAB ? MAXTAB : nTab);
 }
 
-inline SCTAB SanitizeTab( SCTAB nTab, SCTAB nMaxTab )
+SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab, SCTAB nMaxTab )
 {
 return nTab  0 ? 0 : (nTab  nMaxTab ? nMaxTab : nTab);
 }
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 14d6aae..5c24396 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -303,8 +303,8 @@ bool ScDetectiveFunc::HasError( const ScRange rRange, 
ScAddress rErrPos )
 Point ScDetectiveFunc::GetDrawPos( SCCOL nCol, SCROW nRow, DrawPosMode eMode ) 
const
 {
 OSL_ENSURE( ValidColRow( nCol, nRow ), ScDetectiveFunc::GetDrawPos - 
invalid cell address );
-SanitizeCol( nCol );
-SanitizeRow( nRow );
+nCol = SanitizeCol( nCol );
+nRow = SanitizeRow( nRow );
 
 Point aPos;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-12-09 Thread Eike Rathke
 sc/inc/sortparam.hxx   |1 +
 sc/source/core/data/table3.cxx |1 +
 sc/source/ui/undo/undosort.cxx |   20 +++-
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 6293a90ea5026c06a0fba622831ae7e92168c3f3
Author: Eike Rathke er...@redhat.com
Date:   Sun Dec 7 17:32:09 2014 +0100

add ReorderParam.mbHasHeaders to include in Undo range mark

Undo Sort did not select/mark the original range if it included header
row/column.

(cherry picked from commit ec1b1af8af7ead149f96c09e16402e66e0973372)

Backported with merge conflicts.

umm.. row is row and col is col

(cherry picked from commit 413a0655adec3e9364bc94afff638a5a9f88560c)

26c62fa1fc97aa0dd4eda1102422e5f012a126eb

Change-Id: Ie4c800e7a44fd910c871731673093400c6400e4a
Reviewed-on: https://gerrit.libreoffice.org/13379
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/sortparam.hxx b/sc/inc/sortparam.hxx
index 6f6364a..6735a13 100644
--- a/sc/inc/sortparam.hxx
+++ b/sc/inc/sortparam.hxx
@@ -98,6 +98,7 @@ struct SC_DLLPUBLIC ReorderParam
 bool mbPattern;
 bool mbHiddenFiltered;
 bool mbUpdateRefs;
+bool mbHasHeaders;
 
 /**
  * Reorder the position indices such that it can be used to undo the
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b226c62..6a1a305 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1416,6 +1416,7 @@ void ScTable::Sort(
 pUndo-mbPattern = rSortParam.bIncludePattern;
 pUndo-mbHiddenFiltered = bKeepQuery;
 pUndo-mbUpdateRefs = bUpdateRefs;
+pUndo-mbHasHeaders = rSortParam.bHasHeader;
 }
 
 if (rSortParam.bByRow)
diff --git a/sc/source/ui/undo/undosort.cxx b/sc/source/ui/undo/undosort.cxx
index f86bdc2..ea847cc 100644
--- a/sc/source/ui/undo/undosort.cxx
+++ b/sc/source/ui/undo/undosort.cxx
@@ -44,7 +44,25 @@ void UndoSort::Execute( bool bUndo )
 aParam.reverse();
 rDoc.Reorder(aParam, NULL);
 
-ScUndoUtil::MarkSimpleBlock(pDocShell, maParam.maSortRange);
+if (maParam.mbHasHeaders)
+{
+ScRange aMarkRange( maParam.maSortRange);
+if (maParam.mbByRow)
+{
+if (aMarkRange.aStart.Row()  0)
+aMarkRange.aStart.IncRow(-1);
+}
+else
+{
+if (aMarkRange.aStart.Col()  0)
+aMarkRange.aStart.IncCol(-1);
+}
+ScUndoUtil::MarkSimpleBlock(pDocShell, aMarkRange);
+}
+else
+{
+ScUndoUtil::MarkSimpleBlock(pDocShell, maParam.maSortRange);
+}
 
 rDoc.SetDirty(maParam.maSortRange);
 if (!aParam.mbUpdateRefs)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-12-02 Thread Eike Rathke
 sc/inc/column.hxx   |2 
 sc/inc/document.hxx |2 
 sc/inc/refhint.hxx  |   18 ++
 sc/inc/table.hxx|2 
 sc/source/core/data/column.cxx  |   17 ++
 sc/source/core/data/document.cxx|5 
 sc/source/core/data/formulacell.cxx |   10 +
 sc/source/core/data/table2.cxx  |4 
 sc/source/core/data/table3.cxx  |  245 +++-
 sc/source/core/tool/refhint.cxx |6 
 sc/source/ui/docshell/dbdocfun.cxx  |2 
 11 files changed, 219 insertions(+), 94 deletions(-)

New commits:
commit fd1ae18d54f4a57aaa67c0a011fef7e6c20fdbeb
Author: Eike Rathke er...@redhat.com
Date:   Mon Dec 1 23:56:44 2014 +0100

fdo#86762 re-establish listeners to move cell broadcasters

... for UpdateReferenceOnSort=false

(cherry picked from commit 6c2111f17089eb667bf526561d7667d17825e822)

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

fdo#86762 broadcast also empty cells after sort

(cherry picked from commit 08793e08c7e9cefe594c49130f782725e386c463)

Conflicts:
sc/inc/column.hxx
sc/source/core/data/column.cxx
sc/source/core/data/document.cxx
sc/source/core/data/table2.cxx
sc/source/ui/docshell/dbdocfun.cxx

fdo#86762 re-establish listeners on moved broadcasters

...  also in SortReorderByColumn() similar to SortReorderByRow()

(cherry picked from commit e119f3883513aeaa49f332362620e955dc8b453f)

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

e275a754c530d6039ed14304900dd71416f36e46
7665dcc90d70fcf3b08bef0adb9ab6aaff1cdcdf

Change-Id: Id90288660e317d6e47ee01ee3b5ff9058cfa18df
Reviewed-on: https://gerrit.libreoffice.org/13273
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 097c377..6911ca0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -343,7 +343,7 @@ public:
 bool IsFormulaDirty( SCROW nRow ) const;
 
 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext rCxt );
-voidSetDirty( SCROW nRow1, SCROW nRow2 );
+voidSetDirty( SCROW nRow1, SCROW nRow2, bool bIncludeEmptyCells = 
false );
 voidSetDirtyVar();
 voidSetDirtyAfterLoad();
 voidSetTableOpDirty( const ScRange );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1052e6c..f37bfa2 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1011,7 +1011,7 @@ public:
 voidResetChanged( const ScRange rRange );
 
 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext rCxt );
-voidSetDirty( const ScRange );
+voidSetDirty( const ScRange, bool bIncludeEmptyCells = false 
);
 voidSetTableOpDirty( const ScRange );  // for Interpreter 
TableOp
 voidInterpretDirtyCells( const ScRangeList rRanges );
 SC_DLLPUBLIC void CalcAll();
diff --git a/sc/inc/refhint.hxx b/sc/inc/refhint.hxx
index 1eff906..a61e4b6 100644
--- a/sc/inc/refhint.hxx
+++ b/sc/inc/refhint.hxx
@@ -21,7 +21,9 @@ public:
 enum Type {
 Moved,
 ColumnReordered,
-RowReordered
+RowReordered,
+StartListening,
+StopListening
 };
 
 private:
@@ -95,6 +97,20 @@ public:
 SCCOL getEndColumn() const;
 };
 
+class RefStartListeningHint : public RefHint
+{
+public:
+RefStartListeningHint();
+virtual ~RefStartListeningHint();
+};
+
+class RefStopListeningHint : public RefHint
+{
+public:
+RefStopListeningHint();
+virtual ~RefStopListeningHint();
+};
+
 }
 
 #endif
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index fe36dac..49b8571 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -522,7 +522,7 @@ public:
 voidResetChanged( const ScRange rRange );
 
 void SetAllFormulasDirty( const sc::SetFormulaDirtyContext rCxt );
-voidSetDirty( const ScRange );
+voidSetDirty( const ScRange, bool bIncludeEmptyCells = false );
 voidSetDirtyAfterLoad();
 voidSetDirtyVar();
 voidSetTableOpDirty( const ScRange );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 42da658..64174ab 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -3050,14 +3050,27 @@ void ScColumn::SetAllFormulasDirty( const 
sc::SetFormulaDirtyContext rCxt )
 sc::ProcessFormula(maCells, aFunc);
 }
 
-void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2 )
+void ScColumn::SetDirty( SCROW nRow1, SCROW nRow2, bool bIncludeEmptyCells )
 {
 // broadcasts everything within the range, with FormulaTracking
 sc::AutoCalcSwitch aSwitch(*pDocument, false);
 
 SetDirtyOnRangeHandler aHdl(*this);
 sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aHdl, aHdl);
-aHdl.broadcast();
+if 

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

2014-11-25 Thread Eike Rathke
 sc/inc/column.hxx   |   12 +++-
 sc/source/core/data/column4.cxx |   10 ++
 sc/source/core/data/table3.cxx  |3 ++-
 3 files changed, 15 insertions(+), 10 deletions(-)

New commits:
commit d1d41626387391d72c0e495a43b6190e6d0fec02
Author: Eike Rathke er...@redhat.com
Date:   Mon Nov 17 22:44:56 2014 +0100

fdo#83765 do not update references in SortReorderByColumn() if disabled

Similar to SortReorderByRow()

(cherry picked from commit 115a4b7ca36f65d93070d2e81048320d202e87a3)

Conflicts:
sc/inc/column.hxx

Change-Id: I39f8d62b79994196b9c5933355dbbc66a5f60a5d
Reviewed-on: https://gerrit.libreoffice.org/13113
Reviewed-by: Kohei Yoshida libreoff...@kohei.us
Tested-by: Kohei Yoshida libreoff...@kohei.us

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 8f8a93c..097c377 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -584,18 +584,20 @@ public:
 
 /**
  * Reset column position of formula cells within specified row range.
- * Reference positions are also adjusted to reflect the new position so
- * that the formula cells still reference the same cells or ranges after
- * the the position change.  The position of a formula cell before the
- * call is interpreted as the old position of that cell.
+ * If bUpdateRefs==true then reference positions are also adjusted to
+ * reflect the new position so that the formula cells still reference the
+ * same cells or ranges after the the position change.
+ * The position of a formula cell before the call is interpreted as the old
+ * position of that cell.
  *
  * Caller needs to ensure that no formula groups cross the top and bottom
  * row boundaries.
  *
  * @param nRow1 top row boundary
  * @param nRow2 bottom row boundary
+ * @param bUpdateRefs whether to adjust references
  */
-void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2 );
+void ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool bUpdateRefs 
);
 
 void SplitFormulaGroupByRelativeRef( const ScRange rBoundRange );
 
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 93fca48..c1cf89e 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -856,8 +856,9 @@ namespace {
 class FormulaColPosSetter
 {
 SCCOL mnCol;
+bool  mbUpdateRefs;
 public:
-FormulaColPosSetter( SCCOL nCol ) : mnCol(nCol) {}
+FormulaColPosSetter( SCCOL nCol, bool bUpdateRefs ) : mnCol(nCol), 
mbUpdateRefs(bUpdateRefs) {}
 
 void operator() ( size_t nRow, ScFormulaCell* pCell )
 {
@@ -868,7 +869,8 @@ public:
 ScAddress aOldPos = pCell-aPos;
 pCell-aPos.SetCol(mnCol);
 pCell-aPos.SetRow(nRow);
-pCell-GetCode()-AdjustReferenceOnMovedOrigin(aOldPos, 
pCell-aPos);
+if (mbUpdateRefs)
+pCell-GetCode()-AdjustReferenceOnMovedOrigin(aOldPos, 
pCell-aPos);
 }
 else
 {
@@ -880,9 +882,9 @@ public:
 
 }
 
-void ScColumn::ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2 )
+void ScColumn::ResetFormulaCellPositions( SCROW nRow1, SCROW nRow2, bool 
bUpdateRefs )
 {
-FormulaColPosSetter aFunc(nCol);
+FormulaColPosSetter aFunc(nCol, bUpdateRefs);
 sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
 }
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index af9793d..3b02d62 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -718,8 +718,9 @@ void ScTable::SortReorderByColumn(
 }
 
 // Reset formula cell positions which became out-of-sync after column 
reordering.
+bool bUpdateRefs = pArray-IsUpdateRefs();
 for (SCCOL nCol = nStart; nCol = nLast; ++nCol)
-aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2);
+aCol[nCol].ResetFormulaCellPositions(nRow1, nRow2, bUpdateRefs);
 
 // Set up column reorder map (for later broadcasting of reference updates).
 sc::ColRowReorderMapType aColMap;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-11-25 Thread Eike Rathke
 sc/inc/tokenarray.hxx   |6 +
 sc/source/core/data/column4.cxx |2 +
 sc/source/core/data/table3.cxx  |4 +++
 sc/source/core/tool/token.cxx   |   43 
 4 files changed, 55 insertions(+)

New commits:
commit 867c9072b146d3f15b27df6b906d4ac2e3f8bf9f
Author: Eike Rathke er...@redhat.com
Date:   Mon Nov 24 23:29:32 2014 +0100

fix fdo#79441 again and keep references to other sheets during sort

... also if other references are not updated. References to other sheets
are never to be treated as relative during sort, they are always
absolute, even if they have relative row/column part references.

Broken again during the big sort mess. Even if there was a unit test,
which didn't help as it got disabled / adapted to the change..

(cherry picked from commit f0e7364603c9566bc158303c515c3274ccba62ca)

Backported.

Change-Id: Ic0e61c5e1cb0728e20725c29e450ab0eb55c3305
Reviewed-on: https://gerrit.libreoffice.org/13114
Reviewed-by: Kohei Yoshida libreoff...@kohei.us
Tested-by: Kohei Yoshida libreoff...@kohei.us

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 0ce6f71..1768ba9 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -210,6 +210,12 @@ public:
 void AdjustReferenceOnMovedOrigin( const ScAddress rOldPos, const 
ScAddress rNewPos );
 
 /**
+ * Adjust all internal references on base position change if they point to
+ * a sheet other than the one of rOldPos.
+ */
+void AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress rOldPos, 
const ScAddress rNewPos );
+
+/**
  * Clear sheet deleted flag from internal reference tokens if the sheet
  * index falls within specified range.  Note that when a reference is on a
  * sheet that's been deleted, its referenced sheet index retains the
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c1cf89e..aeaecb0 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -871,6 +871,8 @@ public:
 pCell-aPos.SetRow(nRow);
 if (mbUpdateRefs)
 pCell-GetCode()-AdjustReferenceOnMovedOrigin(aOldPos, 
pCell-aPos);
+else
+
pCell-GetCode()-AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, 
pCell-aPos);
 }
 else
 {
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 3b02d62..db6125f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -872,6 +872,10 @@ void ScTable::SortReorderByRow(
 pNew-CopyAllBroadcasters(*rCell.maCell.mpFormula);
 pNew-GetCode()-AdjustReferenceOnMovedOrigin(aOldPos, 
aCellPos);
 }
+else
+{
+
pNew-GetCode()-AdjustReferenceOnMovedOriginIfOtherSheet(aOldPos, aCellPos);
+}
 
 sc::CellStoreType::iterator itBlk = 
rCellStore.push_back(pNew);
 }
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index b0a495a..74c61a5 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -3604,6 +3604,49 @@ void ScTokenArray::AdjustReferenceOnMovedOrigin( const 
ScAddress rOldPos, const
 }
 }
 
+void ScTokenArray::AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress 
rOldPos, const ScAddress rNewPos )
+{
+FormulaToken** p = pCode;
+FormulaToken** pEnd = p + static_castsize_t(nLen);
+for (; p != pEnd; ++p)
+{
+bool bAdjust = false;
+switch ((*p)-GetType())
+{
+case svExternalSingleRef:
+bAdjust = true; // always
+// fallthru
+case svSingleRef:
+{
+ScToken* pToken = static_castScToken*(*p);
+ScSingleRefData rRef = pToken-GetSingleRef();
+ScAddress aAbs = rRef.toAbs(rOldPos);
+if (!bAdjust)
+bAdjust = (aAbs.Tab() != rOldPos.Tab());
+if (bAdjust)
+rRef.SetAddress(aAbs, rNewPos);
+}
+break;
+case svExternalDoubleRef:
+bAdjust = true; // always
+// fallthru
+case svDoubleRef:
+{
+ScToken* pToken = static_castScToken*(*p);
+ScComplexRefData rRef = pToken-GetDoubleRef();
+ScRange aAbs = rRef.toAbs(rOldPos);
+if (!bAdjust)
+bAdjust = (rOldPos.Tab()  aAbs.aStart.Tab() || 
aAbs.aEnd.Tab()  rOldPos.Tab());
+if (bAdjust)
+rRef.SetRange(aAbs, rNewPos);
+}
+break;
+default:
+;
+}
+}
+}
+
 namespace {
 
 void clearTabDeletedFlag( ScSingleRefData rRef, 

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

2014-11-24 Thread Seyeong Kim
 sc/inc/column.hxx |3 ++-
 sc/inc/columnspanset.hxx  |3 +++
 sc/source/core/data/column2.cxx   |4 ++--
 sc/source/core/data/columnspanset.cxx |   12 ++--
 sc/source/core/data/table2.cxx|   31 +++
 sc/source/core/data/table3.cxx|4 +++-
 6 files changed, 43 insertions(+), 14 deletions(-)

New commits:
commit ec4d045328d4651fe666169272fc5a2d0bcd1362
Author: Seyeong Kim seyeong@canonical.com
Date:   Sat Aug 16 05:25:32 2014 +0200

fdo#77382, lp#1342175: fix poor performance with find  replace with empty 
value

this cherry-picks three master commits:
 1cf19ea84794ca065749667b480dfed2d27d47b7
don't call ScMarkData::GetMarkedRanges in ScColumn, related fdo#79422
 1e721077b43de84edab2a3ed2f316ddcbec6e3ec
fdo#83141: optimize slow performance after when using replaceall or 
searchall
Reviewed-on: https://gerrit.libreoffice.org/11829
 91502a72c12c559442e8bf77c27a516b49c2a68d
fdo#83141: also optimize ScTable::HasAttribSelection
Reviewed-on: https://gerrit.libreoffice.org/11877

Change-Id: I2df0eeefbe27b6a267e960f9ffedab0d4774c8a8
Reviewed-on: https://gerrit.libreoffice.org/13041
Reviewed-by: Seyeong Kim seyeong@canonical.com
Reviewed-by: Björn Michaelsen bjoern.michael...@canonical.com
Tested-by: Björn Michaelsen bjoern.michael...@canonical.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index d2b7799..8f8a93c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -24,6 +24,7 @@
 #include global.hxx
 #include address.hxx
 #include rangenam.hxx
+#include rangelst.hxx
 #include types.hxx
 #include mtvelements.hxx
 #include formula/types.hxx
@@ -262,7 +263,7 @@ public:
 ScAttrIterator* CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) const;
 
 void UpdateSelectionFunction(
-const ScMarkData rMark, ScFunctionData rData, ScFlatBoolRowSegments 
rHiddenRows );
+const ScRangeList rRanges, ScFunctionData rData, 
ScFlatBoolRowSegments rHiddenRows );
 
 void CopyToColumn(
 sc::CopyToDocContext rCxt, SCROW nRow1, SCROW nRow2, sal_uInt16 
nFlags, bool bMarked,
diff --git a/sc/inc/columnspanset.hxx b/sc/inc/columnspanset.hxx
index 7c7fdf5..f397c3e 100644
--- a/sc/inc/columnspanset.hxx
+++ b/sc/inc/columnspanset.hxx
@@ -20,6 +20,7 @@ class ScDocument;
 class ScColumn;
 class ScMarkData;
 class ScRange;
+class ScRangeList;
 
 namespace sc {
 
@@ -132,6 +133,8 @@ public:
  */
 void scan(const ScMarkData rMark, SCTAB nTab, SCCOL nCol);
 
+void scan(const ScRangeList rRanges, SCTAB nTab, SCCOL nCol);
+
 void set(SCROW nRow1, SCROW nRow2, bool bVal);
 
 void getRows(std::vectorSCROW rRows) const;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c19be82..08a00c0 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -3072,10 +3072,10 @@ public:
 
 //  multiple selections:
 void ScColumn::UpdateSelectionFunction(
-const ScMarkData rMark, ScFunctionData rData, ScFlatBoolRowSegments 
rHiddenRows )
+const ScRangeList rRanges, ScFunctionData rData, ScFlatBoolRowSegments 
rHiddenRows )
 {
 sc::SingleColumnSpanSet aSpanSet;
-aSpanSet.scan(rMark, nTab, nCol); // mark all selected rows.
+aSpanSet.scan(rRanges, nTab, nCol); // mark all selected rows.
 
 // Exclude all hidden rows.
 ScFlatBoolRowSegments::RangeData aRange;
diff --git a/sc/source/core/data/columnspanset.cxx 
b/sc/source/core/data/columnspanset.cxx
index e431361..faf99ad 100644
--- a/sc/source/core/data/columnspanset.cxx
+++ b/sc/source/core/data/columnspanset.cxx
@@ -278,9 +278,17 @@ void SingleColumnSpanSet::scan(const ScMarkData rMark, 
SCTAB nTab, SCCOL nCol)
 return;
 
 ScRangeList aRanges = rMark.GetMarkedRanges();
-for (size_t i = 0, n = aRanges.size(); i  n; ++i)
+scan(aRanges, nTab, nCol);
+}
+
+void SingleColumnSpanSet::scan(const ScRangeList rRanges, SCTAB nTab, SCCOL 
nCol)
+{
+for (size_t i = 0, n = rRanges.size(); i  n; ++i)
 {
-const ScRange* p = aRanges[i];
+const ScRange* p = rRanges[i];
+if (nTab  p-aStart.Tab() || p-aEnd.Tab()  nTab)
+continue;
+
 if (nCol  p-aStart.Col() || p-aEnd.Col()  nCol)
 // This column is not in this range. Skip it.
 continue;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9b4fd02..8f81660 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -50,6 +50,7 @@
 #include refupdatecontext.hxx
 #include scopetools.hxx
 #include tabprotection.hxx
+#include columnspanset.hxx
 #include rowheightcontext.hxx
 #include refhint.hxx
 
@@ -1887,10 +1888,17 @@ bool ScTable::HasAttrib( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2, sal
 
 bool ScTable::HasAttribSelection( const ScMarkData rMark, sal_uInt16 nMask ) 
const
 {
-

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

2014-11-14 Thread Eike Rathke
 sc/inc/chartlis.hxx  |6 ++
 sc/source/core/tool/chartlis.cxx |   21 +
 2 files changed, 27 insertions(+)

New commits:
commit 547d613e0868726e602ccb00fca0e7518a6c4bee
Author: Eike Rathke er...@redhat.com
Date:   Sat Nov 15 02:00:16 2014 +0100

fdo#73695 prevent use of invalidated iterator due to re-entrance

... through the UNO backdoor..
While charts are updated there can be chart data listeners in BASIC that
in turn modify things such that charts are inserted/removed from the
listener chain, invalidating the iterator. If that happens break and
bail out instead of crashing. Not ideal, but..

Change-Id: Iefb33d3a96d79caed0ee4e19b73e8f811ef3d937
(cherry picked from commit ef2ed50231fd946c1f374ffbce28ebb98eda56c5)
Reviewed-on: https://gerrit.libreoffice.org/12434
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 24c1bcd..7feebf3 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -141,6 +141,12 @@ public:
 typedef boost::unordered_setOUString, OUStringHash StringSetType;
 private:
 ListenersType maListeners;
+enum UpdateStatus
+{
+SC_CLCUPDATE_NONE,
+SC_CLCUPDATE_RUNNING,
+SC_CLCUPDATE_MODIFIED
+} meModifiedDuringUpdate;
 ::std::listRangeListenerItem maHiddenListeners;
 StringSetType maNonOleObjectNames;
 
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx
index 4a96cf6..87cdb6ef 100644
--- a/sc/source/core/tool/chartlis.cxx
+++ b/sc/source/core/tool/chartlis.cxx
@@ -421,6 +421,7 @@ 
ScChartListenerCollection::RangeListenerItem::RangeListenerItem(const ScRange r
 }
 
 ScChartListenerCollection::ScChartListenerCollection( ScDocument* pDocP ) :
+meModifiedDuringUpdate( SC_CLCUPDATE_NONE ),
 pDoc( pDocP )
 {
 aTimer.SetTimeoutHdl( LINK( this, ScChartListenerCollection, TimerHdl ) );
@@ -428,6 +429,7 @@ ScChartListenerCollection::ScChartListenerCollection( 
ScDocument* pDocP ) :
 
 ScChartListenerCollection::ScChartListenerCollection(
 const ScChartListenerCollection rColl ) :
+meModifiedDuringUpdate( SC_CLCUPDATE_NONE ),
 pDoc( rColl.pDoc )
 {
 aTimer.SetTimeoutHdl( LINK( this, ScChartListenerCollection, TimerHdl ) );
@@ -451,12 +453,16 @@ void ScChartListenerCollection::StartAllListeners()
 
 void ScChartListenerCollection::insert(ScChartListener* pListener)
 {
+if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
+meModifiedDuringUpdate =  SC_CLCUPDATE_MODIFIED;
 OUString aName = pListener-GetName();
 maListeners.insert(aName, pListener);
 }
 
 void ScChartListenerCollection::removeByName(const OUString rName)
 {
+if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
+meModifiedDuringUpdate =  SC_CLCUPDATE_MODIFIED;
 maListeners.erase(rName);
 }
 
@@ -544,6 +550,9 @@ public:
 
 void ScChartListenerCollection::FreeUnused()
 {
+if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
+meModifiedDuringUpdate =  SC_CLCUPDATE_MODIFIED;
+
 ListenersType aUsed, aUnused;
 
 // First, filter each listener into 'used' and 'unused' categories.
@@ -575,6 +584,9 @@ void ScChartListenerCollection::FreeUnused()
 void ScChartListenerCollection::FreeUno( const uno::Reference 
chart::XChartDataChangeEventListener  rListener,
  const uno::Reference 
chart::XChartData  rSource )
 {
+if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING)
+meModifiedDuringUpdate =  SC_CLCUPDATE_MODIFIED;
+
 std::vectorScChartListener* aUsed, aUnused;
 
 // First, filter each listener into 'used' and 'unused' categories.
@@ -619,6 +631,11 @@ IMPL_LINK_NOARG(ScChartListenerCollection, TimerHdl)
 
 void ScChartListenerCollection::UpdateDirtyCharts()
 {
+// During ScChartListener::Update() the most nasty things can happen due to
+// UNO listeners, e.g. reentrant calls via BASIC to insert() and FreeUno()
+// and similar that modify maListeners and invalidate iterators.
+meModifiedDuringUpdate = SC_CLCUPDATE_RUNNING;
+
 ListenersType::iterator it = maListeners.begin(), itEnd = 
maListeners.end();
 for (; it != itEnd; ++it)
 {
@@ -626,9 +643,13 @@ void ScChartListenerCollection::UpdateDirtyCharts()
 if (p-IsDirty())
 p-Update();
 
+if (meModifiedDuringUpdate == SC_CLCUPDATE_MODIFIED)
+break;  // iterator is invalid
+
 if (aTimer.IsActive()  !pDoc-IsImportingXML())
 break;  // one interfered
 }
+meModifiedDuringUpdate = SC_CLCUPDATE_NONE;
 }
 
 void ScChartListenerCollection::SetDirty()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-09-03 Thread Eike Rathke
 sc/inc/compiler.hxx  |7 
 sc/source/core/tool/compiler.cxx |   90 ++-
 sc/source/core/tool/token.cxx|7 
 sc/source/filter/excel/excdoc.cxx|1 
 sc/source/filter/excel/ooxml-export-TODO.txt |2 
 sc/source/filter/excel/xecontent.cxx |2 
 sc/source/filter/excel/xelink.cxx|  313 +--
 sc/source/filter/inc/xecontent.hxx   |7 
 sc/source/filter/inc/xelink.hxx  |3 
 9 files changed, 387 insertions(+), 45 deletions(-)

New commits:
commit d3483180e684ab8272b30676a395a53c9c7c6ad2
Author: Eike Rathke er...@redhat.com
Date:   Tue Aug 5 22:51:01 2014 +0200

write OOXML externalReferences, externalLinks, fdo#45286

This for the first time writes external references (hopefully) correctly
and adds the necessary relationship streams and the externalLink streams
with sheetData. At least Excel 2013 loaded the result without
complaining, so do we.

(cherry picked from commit 8c23a767d926d8d08213f5e2f8e81775c653cbd7)

Conflicts:
sc/source/filter/excel/xelink.cxx

do not write empty externalReferences element, fdo#45286 follow-up

OOXML validation spewed
- (xl/workbook.xml:2 col:700) cvc-complex-type.2.4.b: The content of
  element ´externalReferences´ is not complete. One of
  
´{http://schemas.openxmlformats.org/spreadsheetml/2006/main:externalReference}´
  is expected.

(cherry picked from commit 8c51532289db36337c4984baec1bf5a7ca9e40af)

really do not write empty externalReferences element, fdo#45286 follow-up

Xti records exist also for internal sheet references in BIFF. It is not
enough to check for their presence, at least one EXC_SBTYPE_EXTERN must
be present as SUPBOOK.

(cherry picked from commit e04a4d2d2c18134556bb4e001d497ca7d66c6828)

Change-Id: I3d615490a60c5420ae13c0bfc6297642d86a07b9
Reviewed-on: https://gerrit.libreoffice.org/10872
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 6100835..18d788a 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -256,15 +256,16 @@ public:
 const ::com::sun::star::uno::Sequence
 com::sun::star::sheet::ExternalLinkInfo* pExternalLinks ) 
const = 0;
 
-virtual OUString makeExternalNameStr( const OUString rFile, const 
OUString rName ) const = 0;
+virtual OUString makeExternalNameStr( sal_uInt16 nFileId, const 
OUString rFile,
+const OUString rName ) const = 0;
 
 virtual void makeExternalRefStr(
-OUStringBuffer rBuffer, const ScAddress rPos, const OUString 
rFileName,
+OUStringBuffer rBuffer, const ScAddress rPos, sal_uInt16 
nFileId, const OUString rFileName,
 const OUString rTabName, const ScSingleRefData rRef ) const = 0;
 
 virtual void makeExternalRefStr(
 OUStringBuffer rBuffer, const ScAddress rPos,
-const OUString rFileName, const std::vectorOUString rTabNames,
+sal_uInt16 nFileId, const OUString rFileName, const 
std::vectorOUString rTabNames,
 const OUString rTabName, const ScComplexRefData rRef ) const = 0;
 
 enum SpecialSymbolType
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 8031f8e..bfd8802 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -823,7 +823,8 @@ struct ConventionOOO_A1 : public Convention_A1
 return lcl_parseExternalName(rSymbol, rFile, rName, '#', pDoc, 
pExternalLinks);
 }
 
-virtual OUString makeExternalNameStr( const OUString rFile, const 
OUString rName ) const SAL_OVERRIDE
+virtual OUString makeExternalNameStr( sal_uInt16 /*nFileId*/, const 
OUString rFile,
+const OUString rName ) const SAL_OVERRIDE
 {
 return lcl_makeExternalNameStr( rFile, rName, '#', false);
 }
@@ -874,7 +875,7 @@ struct ConventionOOO_A1 : public Convention_A1
 }
 
 virtual void makeExternalRefStr(
-OUStringBuffer rBuffer, const ScAddress rPos, const OUString 
rFileName,
+OUStringBuffer rBuffer, const ScAddress rPos, sal_uInt16 
/*nFileId*/, const OUString rFileName,
 const OUString rTabName, const ScSingleRefData rRef ) const 
SAL_OVERRIDE
 {
 makeExternalRefStrImpl(rBuffer, rPos, rFileName, rTabName, rRef, 
false);
@@ -921,7 +922,7 @@ struct ConventionOOO_A1 : public Convention_A1
 }
 
 virtual void makeExternalRefStr(
-OUStringBuffer rBuffer, const ScAddress rPos, const OUString 
rFileName,
+OUStringBuffer rBuffer, const ScAddress rPos, sal_uInt16 
/*nFileId*/, const OUString rFileName,
 const std::vectorOUString rTabNames, const OUString rTabName,
 const 

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

2014-08-22 Thread Eike Rathke
 sc/inc/types.hxx |8 
 sc/source/core/data/bcaslot.cxx  |   36 ++--
 sc/source/core/data/documen7.cxx |2 -
 sc/source/core/data/table3.cxx   |   67 +--
 sc/source/core/inc/bcaslot.hxx   |6 ++-
 sc/source/core/tool/token.cxx|2 +
 6 files changed, 111 insertions(+), 10 deletions(-)

New commits:
commit b07951a867e66c8b8523505de9ad6c13e9b55fc7
Author: Eike Rathke er...@redhat.com
Date:   Thu Aug 14 23:36:47 2014 +0200

correct references after sort, fdo#79441

5c6ee09126631342939ae8766fe36083d8c011e3 introduced a different
algorithm for reference handling during sort. Unfortunately that clashed
with the SC_CLONECELL_ADJUST3DREL introduced a little earlier resulting
in relative 3D references effectively being adjusted twice.

Furthermore, in-sort-range range references to one row (or column) were
not adapted to the move at all if the formula within the range listened
only to ranges and not a single cell. Added collecting and adjusting
area listeners for this.

Last but not least, external (relative) references need to be treated
the same as internal 3D references, making them point to the same
location after the sort.

(cherry picked from commit 69adec3ec051ff94f600ab899506ca9d645a8b56)

Conflicts:
sc/inc/types.hxx
sc/source/core/data/bcaslot.cxx

Plus necessary parts of 27182231acd3a0c9898a8dba78b76dc8a827b4c0 related
to bcaslot changes.

Change-Id: I492768b525f95f1c43d1c6e7a63a36cce093fa5a
Reviewed-on: https://gerrit.libreoffice.org/10929
Reviewed-by: Kohei Yoshida libreoff...@kohei.us
Tested-by: Kohei Yoshida libreoff...@kohei.us

diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx
index 37784dc..d40b2a5 100644
--- a/sc/inc/types.hxx
+++ b/sc/inc/types.hxx
@@ -100,6 +100,14 @@ struct RangeMatrix
 
 typedef boost::unordered_mapSCCOLROW,SCCOLROW ColRowReorderMapType;
 
+enum AreaOverlapType
+{
+AreaInside,
+AreaPartialOverlap,
+OneRowInsideArea,
+OneColumnInsideArea
+};
+
 }
 
 #endif
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 2dfc9a7..1eff597 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -446,7 +446,8 @@ void ScBroadcastAreaSlot::EraseArea( 
ScBroadcastAreas::iterator rIter )
 }
 }
 
-void ScBroadcastAreaSlot::GetAllListeners( const ScRange rRange, 
std::vectorsc::AreaListener rListeners )
+void ScBroadcastAreaSlot::GetAllListeners(
+const ScRange rRange, std::vectorsc::AreaListener rListeners, 
sc::AreaOverlapType eType )
 {
 for (ScBroadcastAreas::const_iterator aIter( aBroadcastAreaTbl.begin()),
 aIterEnd( aBroadcastAreaTbl.end()); aIter != aIterEnd; ++aIter )
@@ -456,8 +457,32 @@ void ScBroadcastAreaSlot::GetAllListeners( const ScRange 
rRange, std::vectorsc
 
 ScBroadcastArea* pArea = (*aIter).mpArea;
 const ScRange rAreaRange = pArea-GetRange();
-if (!rRange.In(rAreaRange))
-continue;
+
+switch (eType)
+{
+case sc::AreaInside:
+if (!rRange.In(rAreaRange))
+// The range needs to be fully inside specified range.
+continue;
+break;
+case sc::AreaPartialOverlap:
+if (!rRange.Intersects(rAreaRange) || rRange.In(rAreaRange))
+// The range needs to be only partially overlapping.
+continue;
+break;
+case sc::OneRowInsideArea:
+if (rAreaRange.aStart.Row() != rAreaRange.aEnd.Row() || 
!rRange.In(rAreaRange))
+// The range needs to be one single row and fully inside
+// specified range.
+continue;
+break;
+case sc::OneColumnInsideArea:
+if (rAreaRange.aStart.Col() != rAreaRange.aEnd.Col() || 
!rRange.In(rAreaRange))
+// The range needs to be one single column and fully inside
+// specified range.
+continue;
+break;
+}
 
 SvtBroadcaster::ListenersType rLst = 
pArea-GetBroadcaster().GetAllListeners();
 SvtBroadcaster::ListenersType::iterator itLst = rLst.begin(), itLstEnd 
= rLst.end();
@@ -1000,7 +1025,8 @@ void ScBroadcastAreaSlotMachine::FinallyEraseAreas( 
ScBroadcastAreaSlot* pSlot )
 maAreasToBeErased.swap( aCopy);
 }
 
-std::vectorsc::AreaListener ScBroadcastAreaSlotMachine::GetAllListeners( 
const ScRange rRange )
+std::vectorsc::AreaListener ScBroadcastAreaSlotMachine::GetAllListeners(
+const ScRange rRange, sc::AreaOverlapType eType )
 {
 std::vectorsc::AreaListener aRet;
 
@@ -1017,7 +1043,7 @@ std::vectorsc::AreaListener 
ScBroadcastAreaSlotMachine::GetAllListeners( const
 while ( nOff = nEnd )
 {
  

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

2014-07-30 Thread Kohei Yoshida
 sc/inc/column.hxx|1 
 sc/inc/table.hxx |5 
 sc/source/core/data/column.cxx   |   27 --
 sc/source/core/data/column4.cxx  |3 ++
 sc/source/core/data/documen7.cxx |   40 +--
 sc/source/core/data/table2.cxx   |7 --
 sc/source/core/data/table7.cxx   |   10 +
 7 files changed, 52 insertions(+), 41 deletions(-)

New commits:
commit ef32f401f27c394617df55114e912ffab3e6307a
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Wed Jul 30 11:02:31 2014 -0400

fdo#80501: Ensure that we notify each listener only once.

Change-Id: If2ce4643ff58c7c2ba326d749698dd5196a108dc
(cherry picked from commit b2ee0235e88dc4da715b5766295ed88f27974fbd)
Reviewed-on: https://gerrit.libreoffice.org/10645
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 09b1588..d2b7799 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -484,7 +484,6 @@ public:
 voidStartNeededListeners(); // only for cells where 
NeedsListening()==true
 voidSetDirtyIfPostponed();
 void BroadcastRecalcOnRefMove();
-void BroadcastRefMoved( const sc::RefMovedHint rHint );
 void TransferListeners( ScColumn rDestCol, SCROW nRow1, SCROW nRow2, 
SCROW nRowDelta );
 void CollectListeners( std::vectorSvtListener* rListeners, SCROW nRow1, 
SCROW nRow2 );
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e6289ec..537846d 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -923,10 +923,7 @@ public:
  */
 void BroadcastRecalcOnRefMove();
 
-/**
- * Broadcast all listeners of specified range that the range have moved.
- */
-void BroadcastRefMoved( const sc::RefMovedHint rHint );
+void CollectListeners( std::vectorSvtListener* rListeners, SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
 
 void TransferListeners(
 ScTable rDestTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3e4c4ae..1676e1b 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -3108,33 +3108,6 @@ void ScColumn::BroadcastRecalcOnRefMove()
 
 namespace {
 
-class BroadcastRefMovedHandler
-{
-const sc::RefMovedHint mrHint;
-public:
-BroadcastRefMovedHandler( const sc::RefMovedHint rHint ) : mrHint(rHint) 
{}
-
-void operator() ( size_t, SvtBroadcaster* p )
-{
-p-Broadcast(mrHint);
-}
-};
-
-}
-
-void ScColumn::BroadcastRefMoved( const sc::RefMovedHint rHint )
-{
-const ScRange rRange = rHint.getRange();
-SCROW nRow1 = rRange.aStart.Row();
-SCROW nRow2 = rRange.aEnd.Row();
-
-// Notify all listeners within specified rows.
-BroadcastRefMovedHandler aFunc(rHint);
-sc::ProcessBroadcaster(maBroadcasters.begin(), maBroadcasters, nRow1, 
nRow2, aFunc);
-}
-
-namespace {
-
 class TransferListenersHandler
 {
 public:
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 131f8cc..3f26db1 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -950,6 +950,9 @@ public:
 
 void ScColumn::CollectListeners( std::vectorSvtListener* rListeners, SCROW 
nRow1, SCROW nRow2 )
 {
+if (nRow2  nRow1 || !ValidRow(nRow1) || !ValidRow(nRow2))
+return;
+
 ListenerCollector aFunc(rListeners);
 sc::ProcessBroadcaster(maBroadcasters.begin(), maBroadcasters, nRow1, 
nRow2, aFunc);
 }
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index a4897d7..ec34b44 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -128,6 +128,22 @@ void ScDocument::BroadcastCells( const ScRange rRange, 
sal_uLong nHint )
 BroadcastUno(SfxSimpleHint(SC_HINT_DATACHANGED));
 }
 
+namespace {
+
+class RefMovedNotifier : std::unary_functionSvtListener*, void
+{
+const sc::RefMovedHint mrHint;
+public:
+RefMovedNotifier( const sc::RefMovedHint rHint ) : mrHint(rHint) {}
+
+void operator() ( SvtListener* p )
+{
+p-Notify(mrHint);
+}
+};
+
+}
+
 void ScDocument::BroadcastRefMoved( const sc::RefMovedHint rHint )
 {
 if (!pBASM)
@@ -148,6 +164,28 @@ void ScDocument::BroadcastRefMoved( const 
sc::RefMovedHint rHint )
 }
 }
 
+// Collect all listeners listening into the range.
+std::vectorSvtListener* aListeners;
+for (SCTAB nTab = rSrcRange.aStart.Tab(); nTab = rSrcRange.aEnd.Tab(); 
++nTab)
+{
+ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+continue;
+
+pTab-CollectListeners(
+aListeners,
+rSrcRange.aStart.Col(), rSrcRange.aStart.Row(),
+rSrcRange.aEnd.Col(), rSrcRange.aEnd.Row());
+}
+
+// Remove any duplicate listener entries.  We must ensure 

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

2014-07-29 Thread Kohei Yoshida
 sc/inc/column.hxx   |6 ++--
 sc/inc/document.hxx |8 +
 sc/inc/formulacell.hxx  |1 
 sc/inc/table.hxx|6 ++--
 sc/source/core/data/column2.cxx |   22 ---
 sc/source/core/data/column4.cxx |   43 +-
 sc/source/core/data/documen4.cxx|   11 ---
 sc/source/core/data/document10.cxx  |   17 ++--
 sc/source/core/data/formulacell.cxx |   51 
 sc/source/core/data/table4.cxx  |6 
 sc/source/core/data/table7.cxx  |   11 ++-
 sc/source/ui/docshell/dbdocfun.cxx  |   12 
 sc/source/ui/docshell/docfunc.cxx   |4 +-
 sc/source/ui/docshell/docsh5.cxx|4 +-
 sc/source/ui/undo/undocell.cxx  |2 -
 sc/source/ui/undo/undodat.cxx   |8 ++---
 sc/source/ui/undo/undorangename.cxx |2 -
 sc/source/ui/unoobj/nameuno.cxx |2 -
 sc/source/ui/view/dbfunc.cxx|4 +-
 sc/source/ui/view/viewfunc.cxx  |2 -
 20 files changed, 84 insertions(+), 138 deletions(-)

New commits:
commit 217d0ed1cdb492def7220859ecb4931d90d8022c
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jul 28 21:34:40 2014 -0400

fdo#79578: Properly update formulas upon change in db collection.

Update it to handle formula groups correctly.

(cherry picked from commit 300845922eec7a28bc1da337acd21f138685d759)

Conflicts:
sc/source/ui/docshell/dbdocfun.cxx
sc/source/ui/docshell/docfunc.cxx
sc/source/ui/undo/undocell.cxx
sc/source/ui/undo/undodat.cxx
sc/source/ui/unoobj/nameuno.cxx
sc/source/ui/view/viewfunc.cxx

Change-Id: I009a7fcf3d3fb17ef6951c50534ca6bc1fffc259
Reviewed-on: https://gerrit.libreoffice.org/10604
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9bb6bd6..09b1588 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -381,9 +381,12 @@ public:
 void PreprocessRangeNameUpdate(
 sc::EndListeningContext rEndListenCxt, sc::CompileFormulaContext 
rCompileCxt );
 
-void PostprocessRangeNameUpdate(
+void CompileHybridFormula(
 sc::StartListeningContext rStartListenCxt, sc::CompileFormulaContext 
rCompileCxt );
 
+void PreprocessDBDataUpdate(
+sc::EndListeningContext rEndListenCxt, sc::CompileFormulaContext 
rCompileCxt );
+
 const SfxPoolItem*  GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
 const ScPatternAttr*GetPattern( SCROW nRow ) const;
 const ScPatternAttr*GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow 
) const;
@@ -486,7 +489,6 @@ public:
 void CollectListeners( std::vectorSvtListener* rListeners, SCROW nRow1, 
SCROW nRow2 );
 
 void CompileDBFormula( sc::CompileFormulaContext rCxt );
-void CompileDBFormula( sc::CompileFormulaContext rCxt, bool 
bCreateFormulaString );
 void CompileColRowNameFormula( sc::CompileFormulaContext rCxt );
 
 sal_Int32   GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, 
rtl_TextEncoding eCharSet ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index bfeefc3..c8ca888 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -521,11 +521,8 @@ public:
  * Call this immediately before updating all named ranges.
  */
 SC_DLLPUBLIC void PreprocessRangeNameUpdate();
-
-/**
- * Call this immediately after all named ranges have been updated.
- */
-SC_DLLPUBLIC void PostprocessRangeNameUpdate();
+SC_DLLPUBLIC void PreprocessDBDataUpdate();
+SC_DLLPUBLIC void CompileHybridFormula();
 
 /**
  * Insert a new named expression to the global scope.
@@ -1981,7 +1978,6 @@ public:
 voidStartTrackTimer();
 
 voidCompileDBFormula();
-voidCompileDBFormula( bool bCreateFormulaString );
 voidCompileColRowNameFormula();
 
 /** Maximum string length of a column, e.g. for dBase export.
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 959779a..70072e5 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -309,7 +309,6 @@ public:
 boolIsRunning() const;
 voidSetRunning( bool bVal );
 void CompileDBFormula( sc::CompileFormulaContext rCxt );
-void CompileDBFormula( sc::CompileFormulaContext rCxt, bool 
bCreateFormulaString );
 void CompileColRowNameFormula( sc::CompileFormulaContext rCxt );
 ScFormulaCell*  GetPrevious() const;
 ScFormulaCell*  GetNext() const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c5b58b5..e6289ec 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -860,9 +860,12 @@ public:
 void PreprocessRangeNameUpdate(
 sc::EndListeningContext rEndListenCxt, sc::CompileFormulaContext 
rCompileCxt );
 
-void PostprocessRangeNameUpdate(
+void 

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

2014-07-28 Thread Kohei Yoshida
 sc/inc/table.hxx   |1 +
 sc/source/core/data/table3.cxx |8 
 sc/source/core/data/table7.cxx |8 
 3 files changed, 17 insertions(+)

New commits:
commit 0cb7d753b6b51411ab8dd72eab79f855a1d21c4d
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Sun Jul 27 14:35:37 2014 -0400

fdo#81617: Split formula groups at sort range boundaries.

Otherwise, partially sorting a range may crash, or at best incorrectly
update formula references.

Change-Id: Iefcb86d205d83ccc5b684048bfd9aadabf6e13eb
(cherry picked from commit a3fc7f20089062afa4f778e70ba8be84032a30a7)
Reviewed-on: https://gerrit.libreoffice.org/10581
Reviewed-by: Eike Rathke er...@redhat.com
Tested-by: Eike Rathke er...@redhat.com

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index c4ad09e..c5b58b5 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -884,6 +884,7 @@ public:
 formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, 
SCCOL nCol2, SCROW nRow2 );
 formula::VectorRefArray FetchVectorRefArray( SCCOL nCol, SCROW nRow1, 
SCROW nRow2 );
 
+void SplitFormulaGroups( SCCOL nCol, std::vectorSCROW rRows );
 void UnshareFormulaCells( SCCOL nCol, std::vectorSCROW rRows );
 void RegroupFormulaCells( SCCOL nCol );
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index ecfd850..91d7290 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -756,6 +756,14 @@ void ScTable::SortReorderByRow(
 ScSortInfoArray::RowsType* pRows = pArray-GetDataRows();
 assert(pRows); // In sort-by-row mode we must have data rows already 
populated.
 
+// Split formula groups at the sort range boundaries (if applicable).
+std::vectorSCROW aRowBounds;
+aRowBounds.reserve(2);
+aRowBounds.push_back(nRow1);
+aRowBounds.push_back(nRow2+1);
+for (SCCOL nCol = nCol1; nCol = nCol2; ++nCol)
+SplitFormulaGroups(nCol, aRowBounds);
+
 // Cells in the data rows only reference values in the document. Make
 // a copy before updating the document.
 
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index f39e529..6ff53de 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -118,6 +118,14 @@ bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW 
nRow2 ) const
 return nRow2 = aData.mnRow2;
 }
 
+void ScTable::SplitFormulaGroups( SCCOL nCol, std::vectorSCROW rRows )
+{
+if (!ValidCol(nCol))
+return;
+
+sc::SharedFormulaUtil::splitFormulaCellGroups(aCol[nCol].maCells, rRows);
+}
+
 void ScTable::UnshareFormulaCells( SCCOL nCol, std::vectorSCROW rRows )
 {
 if (!ValidCol(nCol))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-07-15 Thread Kohei Yoshida
 sc/inc/chgtrack.hxx  |   26 +--
 sc/source/core/tool/chgtrack.cxx |   46 ---
 sc/source/filter/inc/XclExpChangeTrack.hxx   |5 +-
 sc/source/filter/inc/XclImpChangeTrack.hxx   |2 -
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |   17 -
 sc/source/filter/xcl97/XclImpChangeTrack.cxx |   11 +++---
 6 files changed, 69 insertions(+), 38 deletions(-)

New commits:
commit cd278ead4d8865bc886f6641012f10d459601e71
Author: Kohei Yoshida kohei.yosh...@collabora.com
Date:   Mon Jul 14 15:24:19 2014 -0400

Preserve the end of list flag for xls round-tripping.

This end of list flag determines whether the row insertion was an
automatic insertion at the bottom.  Calc doesn't use this at the moment
but Excel uses it to differentiate a normal row insertion from an
automatic one.

Change-Id: I6b28669d816c54d1dc1e4c106918ba688415788d
(cherry picked from commit adf0d7b1fb8eed88f4fcd6d31662ae6f59d00812)
Reviewed-on: https://gerrit.libreoffice.org/10311
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 2b1e387..6c43942 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -423,7 +423,9 @@ class ScChangeActionIns : public ScChangeAction
 {
 friend class ScChangeTrack;
 
-ScChangeActionIns( const ScRange rRange );
+bool mbEndOfList; /// whether or not a row was auto-inserted at the bottom.
+
+ScChangeActionIns( const ScRange rRange, bool bEndOfList = false );
 virtual ~ScChangeActionIns();
 
 virtual voidAddContent( ScChangeActionContent* ) 
SAL_OVERRIDE {}
@@ -434,17 +436,21 @@ class ScChangeActionIns : public ScChangeAction
 virtual const ScChangeTrack*GetChangeTrack() const SAL_OVERRIDE { 
return 0; }
 
 public:
-ScChangeActionIns(const sal_uLong nActionNumber,
-const ScChangeActionState eState,
-const sal_uLong nRejectingNumber,
-const ScBigRange aBigRange,
-const OUString aUser,
-const DateTime aDateTime,
-const OUString sComment,
-const ScChangeActionType eType); // only to use in the XML import
+ScChangeActionIns(
+const sal_uLong nActionNumber,
+const ScChangeActionState eState,
+const sal_uLong nRejectingNumber,
+const ScBigRange aBigRange,
+const OUString aUser,
+const DateTime aDateTime,
+const OUString sComment,
+const ScChangeActionType eType,
+bool bEndOfList = false );
 
 virtual void GetDescription(
 OUString rStr, ScDocument* pDoc, bool bSplitRange = false, bool 
bWarning = true) const SAL_OVERRIDE;
+
+SC_DLLPUBLIC bool IsEndOfList() const;
 };
 
 //  ScChangeActionDel
@@ -1144,7 +1150,7 @@ public:
 // Only use the following two if there is no different solution! (Assign
 // string for NewValue or creation of a formula respectively)
 
-SC_DLLPUBLIC void AppendInsert( const ScRange );
+SC_DLLPUBLIC void AppendInsert( const ScRange rRange, bool bEndOfList = 
false );
 
 // pRefDoc may be NULL = no lookup of contents
 // = no generation of deleted contents
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index a9ccee7..56866e2 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -661,8 +661,9 @@ void ScChangeAction::AddDependent( sal_uLong nActionNumber,
 }
 
 //  ScChangeActionIns
-ScChangeActionIns::ScChangeActionIns( const ScRange rRange )
-: ScChangeAction( SC_CAT_NONE, rRange )
+ScChangeActionIns::ScChangeActionIns( const ScRange rRange, bool bEndOfList ) 
:
+ScChangeAction(SC_CAT_NONE, rRange),
+mbEndOfList(bEndOfList)
 {
 if ( rRange.aStart.Col() == 0  rRange.aEnd.Col() == MAXCOL )
 {
@@ -693,8 +694,10 @@ ScChangeActionIns::ScChangeActionIns(
 const sal_uLong nActionNumber, const ScChangeActionState eStateP,
 const sal_uLong nRejectingNumber, const ScBigRange aBigRangeP,
 const OUString aUserP, const DateTime aDateTimeP,
-const OUString sComment, const ScChangeActionType eTypeP) :
-ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, 
eStateP, aDateTimeP, aUserP, sComment)
+const OUString sComment, const ScChangeActionType eTypeP,
+bool bEndOfList ) :
+ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, 
eStateP, aDateTimeP, aUserP, sComment),
+mbEndOfList(bEndOfList)
 {
 }
 
@@ -737,6 +740,11 @@ void ScChangeActionIns::GetDescription(
 }
 }
 
+bool ScChangeActionIns::IsEndOfList() const
+{
+return mbEndOfList;
+}
+
 bool ScChangeActionIns::Reject( ScDocument* pDoc )
 {
 if ( !aBigRange.IsValid( pDoc ) )
@@ -2827,9 +2835,9 

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

2014-07-14 Thread Eike Rathke
 sc/inc/formulacell.hxx  |2 +-
 sc/source/core/data/formulacell.cxx |4 ++--
 sc/source/core/data/table3.cxx  |3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit caf35a3ab2fa19134a900dcfd2dcc86936e435a5
Author: Eike Rathke er...@redhat.com
Date:   Fri Jul 11 18:35:39 2014 +0200

resolved fdo#79441 keep 3D references intact during sort

Change-Id: I9e96d8e7cb99a3c280dd24495eefb9efd6d10888
(cherry picked from commit e463de2a56453a0d2cb0b5b58e96f7639f37cdd1)
Reviewed-on: https://gerrit.libreoffice.org/10238
Reviewed-by: Kohei Yoshida libreoff...@kohei.us
Tested-by: Kohei Yoshida libreoff...@kohei.us

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 11c5cb1..49b20b1 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -160,7 +160,7 @@ public:
 virtual ~ScFormulaCell();
 
 ScFormulaCell* Clone() const;
-ScFormulaCell* Clone( const ScAddress rPos ) const;
+ScFormulaCell* Clone( const ScAddress rPos, int nCloneFlags ) const;
 
 ScFormulaCell( ScDocument* pDoc, const ScAddress rPos );
 
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index af6aed4..2ff6079 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -841,9 +841,9 @@ ScFormulaCell* ScFormulaCell::Clone() const
 return new ScFormulaCell(*this, *pDocument, aPos);
 }
 
-ScFormulaCell* ScFormulaCell::Clone( const ScAddress rPos ) const
+ScFormulaCell* ScFormulaCell::Clone( const ScAddress rPos, int nCloneFlags ) 
const
 {
-return new ScFormulaCell(*this, *pDocument, rPos);
+return new ScFormulaCell(*this, *pDocument, rPos, nCloneFlags);
 }
 
 size_t ScFormulaCell::GetHash() const
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index b544711..1b2f86c 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -683,7 +683,8 @@ void ScTable::SortReorderByRow( ScSortInfoArray* pArray, 
ScProgress* pProgress )
 {
 assert(rCell.mpAttr);
 size_t n = rCellStore.size();
-sc::CellStoreType::iterator itBlk = 
rCellStore.push_back(rCell.maCell.mpFormula-Clone(aCellPos));
+sc::CellStoreType::iterator itBlk = rCellStore.push_back( 
rCell.maCell.mpFormula-Clone(
+aCellPos, SC_CLONECELL_DEFAULT | 
SC_CLONECELL_ADJUST3DREL));
 
 // Join the formula cells as we fill the container.
 size_t nOffset = n - itBlk-position;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-26 Thread Eike Rathke
 sc/inc/attarray.hxx |   21 ++
 sc/inc/column.hxx   |2 -
 sc/source/core/data/column2.cxx |   45 +---
 sc/source/core/data/table1.cxx  |4 +--
 4 files changed, 62 insertions(+), 10 deletions(-)

New commits:
commit 1baac7f17b024b15d79bbb9e89e68b2863c150e9
Author: Eike Rathke er...@redhat.com
Date:   Tue May 27 01:34:37 2014 +0200

resolved fdo#79228 resync ScPatternAttr if changed in GetNeededSize()

Change-Id: Ida47df6223a20939ad5971dc00b8f3462a92dd3e
(cherry picked from commit a1dedadbf0d87a1db24e9b336257678e059882f0)

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 08e3c5a..9b6464b 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -206,6 +206,7 @@ class ScAttrIterator
 public:
 inline  ScAttrIterator( const ScAttrArray* pNewArray, SCROW 
nStart, SCROW nEnd );
 inline const ScPatternAttr* Next( SCROW rTop, SCROW rBottom );
+inline const ScPatternAttr* Resync( SCROW nRow, SCROW rTop, SCROW 
rBottom );
 SCROW   GetNextRow() const { return nRow; }
 };
 
@@ -236,6 +237,26 @@ inline const ScPatternAttr* ScAttrIterator::Next( SCROW 
rTop, SCROW rBottom )
 return pRet;
 }
 
+inline const ScPatternAttr* ScAttrIterator::Resync( SCROW nRowP, SCROW rTop, 
SCROW rBottom )
+{
+nRow = nRowP;
+// Chances are high that the pattern changed on nRowP introduced a span
+// starting right there. Assume that Next() was called so nPos already
+// advanced. Another high chance is that the change extended a previous or
+// next pattern. In all these cases we don't need to search.
+if (3 = nPos  nPos = pArray-nCount  pArray-pData[nPos-3].nRow  
nRowP 
+nRowP = pArray-pData[nPos-2].nRow)
+nPos -= 2;
+else if (2 = nPos  nPos = pArray-nCount  pArray-pData[nPos-2].nRow 
 nRowP 
+nRowP = pArray-pData[nPos-1].nRow)
+--nPos;
+else if (pArray-nCount  0  nRowP = pArray-pData[0].nRow)
+nPos = 0;
+else
+pArray-Search( nRowP, nPos );
+return Next( rTop, rBottom);
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 4212056..547fd14 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -445,7 +445,7 @@ public:
 long GetNeededSize(
 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
 const Fraction rZoomX, const Fraction rZoomY,
-bool bWidth, const ScNeededSizeOptions rOptions) const;
+bool bWidth, const ScNeededSizeOptions rOptions, const 
ScPatternAttr** pPatternChange ) const;
 
 sal_uInt16 GetOptimalColWidth(
 OutputDevice* pDev, double nPPTX, double nPPTY,
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 7e5a4a6..763e658 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -86,7 +86,8 @@ inline bool IsAmbiguousScript( sal_uInt8 nScript )
 long ScColumn::GetNeededSize(
 SCROW nRow, OutputDevice* pDev, double nPPTX, double nPPTY,
 const Fraction rZoomX, const Fraction rZoomY,
-bool bWidth, const ScNeededSizeOptions rOptions ) const
+bool bWidth, const ScNeededSizeOptions rOptions,
+const ScPatternAttr** ppPatternChange ) const
 {
 std::pairsc::CellStoreType::const_iterator,size_t aPos = 
maCells.position(nRow);
 sc::CellStoreType::const_iterator it = aPos.first;
@@ -148,9 +149,32 @@ long ScColumn::GetNeededSize(
 SvNumberFormatter* pFormatter = pDocument-GetFormatTable();
 sal_uLong nFormat = pPattern-GetNumberFormat( pFormatter, pCondSet );
 // #i111387# disable automatic line breaks only for General number format
-if (bBreak  aCell.hasNumeric()  ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET 
) == 0 )
+if (bBreak  ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
 {
-bBreak = false;
+// If a formula cell needs to be interpreted during aCell.hasNumeric()
+// to determine the type, the pattern may get invalidated because the
+// result may set a number format. In which case there's also the
+// General format not set anymore..
+bool bMayInvalidatePattern = (aCell.meType == CELLTYPE_FORMULA);
+const ScPatternAttr* pOldPattern = pPattern;
+bool bNumeric = aCell.hasNumeric();
+if (bMayInvalidatePattern)
+{
+pPattern = pAttrArray-GetPattern( nRow );
+if (ppPatternChange)
+*ppPatternChange = pPattern;// XXX caller may have to 
check for change!
+}
+if (bNumeric)
+{
+if (!bMayInvalidatePattern || pPattern == pOldPattern)
+bBreak = false;
+else
+{
+nFormat = pPattern-GetNumberFormat( pFormatter, pCondSet );
+if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+bBreak = false;
+}
+}