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

2016-03-09 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |2 +-
 sc/source/core/tool/interpr6.cxx |4 ++--
 sc/source/core/tool/scmatrix.cxx |   28 ++--
 3 files changed, 25 insertions(+), 9 deletions(-)

New commits:
commit 84f8fa501ac772b40639d7b6e95ebeb752b01bf5
Author: Eike Rathke 
Date:   Wed Mar 2 22:48:01 2016 +0100

Resolves: tdf#98297 exclude error values from COUNT in array/matrix

Backport of b2f5336b08b5f638f890a626eb2aeefaf499a79b

Change-Id: I04ef53b8880243b3548e1b7fd926690dcb4a2137
Reviewed-on: https://gerrit.libreoffice.org/22846
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 5a5ff95..a4b38df 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -372,7 +372,7 @@ public:
 IterateResult Sum(bool bTextAsZero) const;
 IterateResult SumSquare(bool bTextAsZero) const;
 IterateResult Product(bool bTextAsZero) const;
-size_t Count(bool bCountStrings) const;
+size_t Count(bool bCountStrings, bool bCountErrors) const;
 size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) 
const;
 size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, 
size_t nCol2) const;
 
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index e02abbc..6d5e624 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -376,10 +376,10 @@ void IterateMatrix(
 }
 break;
 case ifCOUNT:
-rCount += pMat->Count(bTextAsZero);
+rCount += pMat->Count(bTextAsZero, false);  // do not count error 
values
 break;
 case ifCOUNT2:
-rCount += pMat->Count(true);
+rCount += pMat->Count(true, true);  // do count error 
values
 break;
 case ifPRODUCT:
 {
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 328a4ba..55ed380 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -284,7 +284,7 @@ public:
 ScMatrix::IterateResult Sum(bool bTextAsZero) const;
 ScMatrix::IterateResult SumSquare(bool bTextAsZero) const;
 ScMatrix::IterateResult Product(bool bTextAsZero) const;
-size_t Count(bool bCountStrings) const;
+size_t Count(bool bCountStrings, bool bCountErrors) const;
 size_t MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) 
const;
 size_t MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, 
size_t nCol2) const;
 
@@ -1105,8 +1105,10 @@ class CountElements : 
std::unary_functionProduct(bTextAsZero);
 }
 
-size_t ScMatrix::Count(bool bCountStrings) const
+size_t ScMatrix::Count(bool bCountStrings, bool bCountErrors) const
 {
-return pImpl->Count(bCountStrings);
+return pImpl->Count(bCountStrings, bCountErrors);
 }
 
 size_t ScMatrix::MatchDoubleInColumns(double fValue, size_t nCol1, size_t 
nCol2) const
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-03-09 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |6 
 sc/source/core/tool/scmatrix.cxx |   43 +++-
 sc/source/filter/oox/workbookhelper.cxx  |2 
 sc/source/ui/docshell/externalrefmgr.cxx |  330 +--
 4 files changed, 268 insertions(+), 113 deletions(-)

New commits:
commit 23510e0c61dc92eed37129070d2a2b349b43d686
Author: Eike Rathke 
Date:   Mon Mar 7 13:20:54 2016 +0100

Resolves: tdf#98389 check memory requirement of matrix

Attachment 123203 of tdf#98389 has external references of the form
[1]Data!$1:$1048576
which effectively address the entire cell range of sheet Data and
allocating a matrix for a billion cells attempted to allocate 8GB+xGB of
memory which the system said no-no ...

Some brave soul along the road once decided that a check on the number
of elements wasn't needed anymore and dared to remove it during
refactoring.. This change reintroduces the check and adds it also to
other places that try to instanciate or resize a matrix.

When allocation of a matrix for an external range reference fails it is
checked whether the request is for such nasty entire rows or entire
columns ranges and if so tries to shrink the range to the actual data
area used, which at least in this case helps and works.

Additionally it fixes a long standing bug in the cached area to array
mapping which caused the cache to not be hit but instead the matrix was
aquired over and over again for the same range, causing a serious
performance bottle neck specifically for VLOOKUP and related functions
where the same external range is used in a lot of cells.

(cherry picked from commit 9e60bbdb3aa5f80ca80c9c4fdf7accd12c4a5d1c)

Change in convertToTokenArray() backported to older code flow.

disable means Enable(false), not true.. tdf#98389 related

EnableAdjustHeight(true) lead to the side effect that when clearing the
range of a pivot table during import, formulas in the same rows were
recalculated with then empty data. Through xSheetOp->clearContents() in
PivotTable::finalizeImport() of
sc/source/filter/oox/pivottablebuffer.cxx

In the case of the bugdoc attached to tdf#98389 that lead to all
VLOOKUP() calls resulting in #N/A errors because an empty string was
looked up.

(cherry picked from commit 088ba465d6bb0931c7034d564a3077e21078cb13)

e629ce871d255cc871671165c4da974f21041cec

Backported to ScMatrix implementation of 5-0.

setCellRangeData: check matrix size before operating, tdf#98389 follow-up

Now that we can have the one element error matrix we can't blindly call
ExecuteOperation() on it that would access elements out of bounds.

(cherry picked from commit 9cae3a88587deaf22ee83b2e36487013a1220a3b)

Backported to older code flow.

b6e5525f685c9324235f128a943dd716ea7a3fca

Change-Id: I35f67b48e665bf1cc8d672325c32b889f2e05c57
Reviewed-on: https://gerrit.libreoffice.org/23003
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index f1fbe8e..5a5ff95 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -160,6 +160,12 @@ public:
 #endif
 }
 
+/** Checks nC or nR for zero and uses GetElementsMax() whether a matrix of
+the size of nC*nR could be allocated. A zero size (both nC and nR zero)
+matrix is allowed for later resize.
+ */
+bool static IsSizeAllocatable( SCSIZE nC, SCSIZE nR );
+
 /// Value or boolean.
 inline static bool IsValueType( ScMatValType nType )
 {
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index c5c42f3..328a4ba 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2157,25 +2157,52 @@ void ScMatrix::DecRef() const
 delete this;
 }
 
-ScMatrix::ScMatrix( SCSIZE nC, SCSIZE nR) :
-pImpl(new ScMatrixImpl(nC, nR)), nRefCnt(0)
+bool ScMatrix::IsSizeAllocatable( SCSIZE nC, SCSIZE nR )
 {
 SAL_WARN_IF( !nC, "sc", "ScMatrix with 0 columns!");
 SAL_WARN_IF( !nR, "sc", "ScMatrix with 0 rows!");
+// 0-size matrix is valid, it could be resized later.
+if ((nC && !nR) || (!nC && nR))
+{
+SAL_WARN( "sc", "ScMatrix one-dimensional zero: " << nC << " columns * 
" << nR << " rows");
+return false;
+}
+if (nC && nR && (nC > (ScMatrix::GetElementsMax() / nR)))
+{
+SAL_WARN( "sc", "ScMatrix overflow: " << nC << " columns * " << nR << 
" rows");
+return false;
+}
+return true;
+}
+
+ScMatrix::ScMatrix( SCSIZE nC, SCSIZE nR) :
+pImpl(nullptr), nRefCnt(0)
+{
+if (ScMatrix::IsSizeAllocatable( nC, nR))
+pImpl = new ScMatrixImpl( nC, nR);
+else
+// Invalid 

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

2015-10-22 Thread Eike Rathke
 sc/inc/global.hxx|  112 +++
 sc/source/core/data/global2.cxx  |  266 +
 sc/source/core/inc/interpre.hxx  |5 
 sc/source/core/tool/interpr4.cxx |  276 +--
 sc/source/core/tool/interpr5.cxx |   26 +++
 sc/source/core/tool/scmatrix.cxx |   41 +++--
 6 files changed, 444 insertions(+), 282 deletions(-)

New commits:
commit 0c8d1c04a30ea5df783f758cf6744b2918643c0d
Author: Eike Rathke 
Date:   Fri Oct 2 23:36:25 2015 +0200

Resolves: tdf#91453 use configuration of text to number conversion

... also in arithmetic matrix operations.

(combination of 4 commits):

move ConvertStringToValue() implementation from ScInterpreter to ScGlobal

In preparation of matrix calculations to use string conversion
configuration and UI markers for cells containing strings that could be
numeric values.

Change-Id: Ifa9e45853dded249fa741c050ae1f106365f99ea
(cherry picked from commit 329496c1f75f97d2e6119ceb214a2ea1fbadb17a)

add half decoupled ScInterpreter::ConvertStringToValue()

... for back calls of ScMatrix in preparation of tdf#91453

Change-Id: Ife94d1675c1bc7c5611586e3f352ff69264469d7
(cherry picked from commit 6516d5e299bdf0e7aa03d1004763f6d10db48546)

Resolves: tdf#91453 use configuration of text to number conversion

... also in arithmetic matrix operations.

Change-Id: Ia00054d0af383e225d9d40b59da2dc28a817b65a
(cherry picked from commit 466a20ef07f36d50a73a18ab119b3cc18b4babf4)

Resolves: tdf#91453 use configuration of text to number conversion

... also in arithmetic matrix operations if both operands are matrix.

Change-Id: I84609656b166b4e059d9496a5ed732a96e731164
(cherry picked from commit 778d03b59c62d21fd171b81c9fab3ba8496e319d)
Reviewed-on: https://gerrit.libreoffice.org/19172
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 
Tested-by: Markus Mohrhard 

diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index 397808e..e84410d 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -34,6 +34,7 @@ class ImageList;
 class Bitmap;
 class SfxItemSet;
 class Color;
+struct ScCalcConfig;
 enum class SvtScriptType;
 
 #define SC_COLLATOR_IGNORES ( \
@@ -720,6 +721,117 @@ SC_DLLPUBLICstatic const sal_Unicode* FindUnquoted( 
const sal_Unicode* pStri
 SC_DLLPUBLIC static OUStringReplaceOrAppend( const OUString& rString,
  const OUString& 
rPlaceholder,
  const OUString& 
rReplacement );
+
+
+/** Convert string content to numeric value.
+
+In any case, if rError is set 0.0 is returned.
+
+If nStringNoValueError is errCellNoValue, that is unconditionally
+assigned to rError and 0.0 is returned. The caller is expected to
+handle this situation. Used by the interpreter.
+
+Usually errNoValue is passed as nStringNoValueError.
+
+Otherwise, depending on the string conversion configuration different
+approaches are taken:
+
+
+For ScCalcConfig::StringConversion::ILLEGAL
+The error value passed in nStringNoValueError is assigned to rError
+(and 0.0 returned).
+
+
+For ScCalcConfig::StringConversion::ZERO
+A zero value is returned and no error assigned.
+
+
+For ScCalcConfig::StringConversion::LOCALE
+
+If the string is empty or consists only of spaces, if "treat empty
+string as zero" is set 0.0 is returned, else nStringNoValueError
+assigned to rError (and 0.0 returned).
+
+Else a non-empty string is passed to the number formatter's scanner to
+be parsed locale dependent. If that does not detect a numeric value
+nStringNoValueError is assigned to rError (and 0.0 returned).
+
+If no number formatter was passed, the conversion falls back to
+UNAMBIGUOUS.
+
+
+For ScCalcConfig::StringConversion::UNAMBIGUOUS
+
+If the string is empty or consists only of spaces, if "treat empty
+string as zero" is set 0.0 is returned, else nStringNoValueError
+assigned to rError (and 0.0 returned).
+
+If the string is not empty the following conversion rules are applied:
+
+Converted are only integer numbers including exponent, and ISO 8601 
dates
+and times in their extended formats with separators. Anything else,
+especially fractional numeric values with decimal separators or dates 
other
+than ISO 8601 would be locale dependent and is a no-no. Leading and
+trailing blanks are ignored.
+
+The following ISO 8601 formats are converted:
+
+CCYY-MM-DD
+CCYY-MM-DDThh:mm
+CCYY-MM-DDThh:mm:ss
+

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

2015-10-05 Thread Julien Nabet
 sc/inc/autoform.hxx  |6 +-
 sc/source/core/tool/autoform.cxx |   10 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 457a9f405f3778547cc2fcafff445d89e87c7db6
Author: Julien Nabet 
Date:   Tue Sep 15 21:41:48 2015 +0200

tdf#94173: Calc doesn't save your own created autoformat presets

Auformat list (maData) is defined as "MapType" which itself is defined like 
this:
boost::ptr_map
so default sorting is ascii

2 consequences:
1) Default didn't appear first
2) When adding a new autoformat entry when it was new first one of the list
wasn't saved because of iterator was incremented first before looping
See https://bugs.documentfoundation.org/show_bug.cgi?id=94173#c5
There were some other weird behaviors too according to comments of the 
bugtracker

Regression from 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=72c1b6141d590fb4479925ed8bc88b79357c2bfc

Solution:
Add a Compare so Default entry is always first one so the first time 
incremented iterator is ok and
new entry (even if new first one in list) is saved

Thank you Markus for the idea! (I was lost in Compare syntax)

Reviewed-on: https://gerrit.libreoffice.org/18598
Tested-by: Jenkins 
Reviewed-by: Julien Nabet 
(cherry picked from commit 652158c3f2c9cd0d6f71ecd14bf5d5cc02a71b50)

use collator for UI visible sorting, tdf#94173 follow-up

(cherry picked from commit a71febc99d2cfc2fe51dec8c0bca5d84d8577168)

b9f7ebb087c1ce5008f43b2df3f1fadc41066ed1

Change-Id: I9ba0cdc63c66b747db102bb661cd09fbfe5996ae
Reviewed-on: https://gerrit.libreoffice.org/19029
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index 938ef5e..a083116 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -307,9 +307,13 @@ public:
 boolSave( SvStream& rStream, sal_uInt16 
fileVersion );
 };
 
+struct DefaultFirstEntry {
+bool operator() (const OUString& left, const OUString& right) const;
+};
+
 class SC_DLLPUBLIC ScAutoFormat
 {
-typedef boost::ptr_map MapType;
+typedef boost::ptr_map 
MapType;
 MapType maData;
 bool mbSaveLater;
 ScAfVersions m_aVersions;
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 522e955..795eb19 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -896,6 +896,16 @@ ScAutoFormat::ScAutoFormat() :
 insert(pData);
 }
 
+bool DefaultFirstEntry::operator() (const OUString& left, const OUString& 
right) const
+{
+OUString aStrStandard(ScGlobal::GetRscString(STR_STYLENAME_STANDARD));
+if ( ScGlobal::GetpTransliteration()->isEqual( left, aStrStandard ) )
+return true;
+if ( ScGlobal::GetpTransliteration()->isEqual( right, aStrStandard ) )
+return false;
+return ScGlobal::GetCollator()->compareString( left, right) < 0;
+}
+
 ScAutoFormat::ScAutoFormat(const ScAutoFormat& r) :
 maData(r.maData),
 mbSaveLater(false) {}
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-09-17 Thread Eike Rathke
 sc/inc/sharedformula.hxx  |3 ++-
 sc/source/core/data/column.cxx|8 
 sc/source/core/data/column3.cxx   |8 
 sc/source/core/tool/sharedformula.cxx |   15 +++
 4 files changed, 21 insertions(+), 13 deletions(-)

New commits:
commit d1d44378374f63f7b187e5e359ab0ab7f7b4d7fb
Author: Eike Rathke 
Date:   Wed Sep 16 12:38:06 2015 +0200

Resolves: tdf#94249 do not remove broadcasters while iterators are in use

EndListeningContext holds BroadcasterStoreType iterators in its
ColumnBlockPositionSet and collects broadcasters to purge them at the
end. Removing broadcasters from ScColumn::maBroadcasters in between
invalidates the iterators. Hence calling the "normal" EndListening()
that removes a broadcaster when all listeners are gone while an
EndListeningContext is in use is bad.

Change-Id: Ibdd88469e91e6173ceff1f391c23ef7cb7c6f596
(cherry picked from commit e4a8ae0bf54476e9a0c9e1f5348c05f3cd838899)
Reviewed-on: https://gerrit.libreoffice.org/18615
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index e4b25bb..33a2d48 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -64,8 +64,9 @@ public:
  * specified position is not a formula cell.
  *
  * @param aPos position of cell to examine.
+ * @param pCxt context to be used, if any, may be nullptr.
  */
-static void splitFormulaCellGroup(const CellStoreType::position_type& 
aPos);
+static void splitFormulaCellGroup(const CellStoreType::position_type& 
aPos, sc::EndListeningContext* pCxt);
 
 /**
  * Split existing shared formula ranges at specified row positions.
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 9accde9..910981a 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1908,15 +1908,15 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, 
ScColumn& rCol)
 
 // Split the formula grouping at the top and bottom boundaries.
 sc::CellStoreType::position_type aPos = maCells.position(nStartRow);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr);
 aPos = maCells.position(aPos.first, nEndRow+1);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr);
 
 // Do the same with the destination column.
 aPos = rCol.maCells.position(nStartRow);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr);
 aPos = rCol.maCells.position(aPos.first, nEndRow+1);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr);
 
 // Move the broadcasters to the destination column.
 maBroadcasters.transfer(nStartRow, nEndRow, rCol.maBroadcasters, 
nStartRow);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 757c3e3..c0376ea 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -327,13 +327,13 @@ void ScColumn::DetachFormulaCells(
 const sc::CellStoreType::position_type& aPos, size_t nLength )
 {
 // Split formula grouping at the top and bottom boundaries.
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, nullptr);
 size_t nRow = aPos.first->position + aPos.second;
 size_t nNextTopRow = nRow + nLength; // start row of next formula group.
 if (ValidRow(nNextTopRow))
 {
 sc::CellStoreType::position_type aPos2 = maCells.position(aPos.first, 
nNextTopRow);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos2);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos2, nullptr);
 }
 
 if (pDocument->IsClipOrUndo())
@@ -368,11 +368,11 @@ void ScColumn::DetachFormulaCells( 
sc::EndListeningContext& rCxt, SCROW nRow1, S
 sc::CellStoreType::iterator it = aPos.first;
 
 // Split formula grouping at the top and bottom boundaries.
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, );
 if (ValidRow(nRow2+1))
 {
 aPos = maCells.position(it, nRow2+1);
-sc::SharedFormulaUtil::splitFormulaCellGroup(aPos);
+sc::SharedFormulaUtil::splitFormulaCellGroup(aPos, );
 }
 
 if (pDocument->IsClipOrUndo())
diff --git a/sc/source/core/tool/sharedformula.cxx 
b/sc/source/core/tool/sharedformula.cxx
index a3fd1ae..8e84ac0 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -16,7 +16,7 @@
 
 namespace sc {
 
-void SharedFormulaUtil::splitFormulaCellGroup(const 

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

2015-09-11 Thread Eike Rathke
 sc/inc/column.hxx   |2 +-
 sc/inc/global.hxx   |3 ++-
 sc/source/core/data/column2.cxx |   21 -
 sc/source/core/data/column3.cxx |5 -
 sc/source/core/data/column4.cxx |2 +-
 sc/source/ui/undo/undoblk.cxx   |9 -
 6 files changed, 36 insertions(+), 6 deletions(-)

New commits:
commit fa26aa0bdb0c93c2a3e5d0bfc879e9185a6e910e
Author: Eike Rathke 
Date:   Thu Sep 10 15:52:21 2015 +0200

Resolves: tdf#92995 do not delete caption objects that are held by Undo

Drag Undo is a special case of ownership..

Change-Id: I2fe7769c4d84efe09d432335d5d8e72d506bf7a1
(cherry picked from commit 44f34c1163882c2e3086282374fee9cd55ee211f)
Reviewed-on: https://gerrit.libreoffice.org/18470
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9d96793..fd27c10 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -583,7 +583,7 @@ public:
 ScPostIt* GetCellNote( SCROW nRow );
 const ScPostIt* GetCellNote( SCROW nRow ) const;
 const ScPostIt* GetCellNote( sc::ColumnBlockConstPosition& rBlockPos, 
SCROW nRow ) const;
-void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, 
SCROW nRow2 );
+void DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW nRow1, 
SCROW nRow2, bool bForgetCaptionOwnership );
 bool HasCellNotes() const;
 void SetCellNote( SCROW nRow, ScPostIt* pNote);
 bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index b95faf5..397808e 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -197,10 +197,11 @@ const InsertDeleteFlags IDF_OUTLINE   = 
InsertDeleteFlags::fromInt(0x0800);   //
 const InsertDeleteFlags IDF_NOCAPTIONS  = InsertDeleteFlags::fromInt(0x0200);  
 /// Internal use only (undo etc.): do not copy/delete caption objects of cell 
notes.
 const InsertDeleteFlags IDF_ADDNOTES= InsertDeleteFlags::fromInt(0x0400);  
 /// Internal use only (copy from clip): do not delete existing cell contents 
when pasting notes.
 const InsertDeleteFlags IDF_SPECIAL_BOOLEAN  = 
InsertDeleteFlags::fromInt(0x1000);
+const InsertDeleteFlags IDF_FORGETCAPTIONS = 
InsertDeleteFlags::fromInt(0x2000); /// Internal use only (d undo): do not 
delete caption objects of cell notes.
 const InsertDeleteFlags IDF_ATTRIB = IDF_HARDATTR | IDF_STYLES;
 const InsertDeleteFlags IDF_CONTENTS   = IDF_VALUE | IDF_DATETIME | IDF_STRING 
| IDF_NOTE | IDF_FORMULA | IDF_OUTLINE;
 const InsertDeleteFlags IDF_ALL= IDF_CONTENTS | IDF_ATTRIB | 
IDF_OBJECTS;
-const InsertDeleteFlags IDF_ALL_USED_BITS = IDF_ALL | IDF_EDITATTR | 
IDF_NOCAPTIONS | IDF_ADDNOTES | IDF_SPECIAL_BOOLEAN;
+const InsertDeleteFlags IDF_ALL_USED_BITS = IDF_ALL | IDF_EDITATTR | 
IDF_NOCAPTIONS | IDF_ADDNOTES | IDF_SPECIAL_BOOLEAN | IDF_FORGETCAPTIONS;
 
 inline InsertDeleteFlags operator~ (const InsertDeleteFlags& rhs)
 {
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index bb6a37d..8929ecd 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1816,8 +1816,27 @@ void ScColumn::SetCellNote(SCROW nRow, ScPostIt* pNote)
 maCellNotes.set(nRow, pNote);
 }
 
-void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW 
nRow1, SCROW nRow2 )
+namespace {
+class ForgetCellNoteCaptionsHandler
+{
+
+public:
+ForgetCellNoteCaptionsHandler() {}
+
+void operator() ( size_t /*nRow*/, ScPostIt* p )
+{
+p->ForgetCaption();
+}
+};
+}
+
+void ScColumn::DeleteCellNotes( sc::ColumnBlockPosition& rBlockPos, SCROW 
nRow1, SCROW nRow2, bool bForgetCaptionOwnership )
 {
+if (bForgetCaptionOwnership)
+{
+ForgetCellNoteCaptionsHandler aFunc;
+sc::ParseNote(maCellNotes.begin(), maCellNotes, nRow1, nRow2, aFunc);
+}
 rBlockPos.miCellNotePos =
 maCellNotes.set_empty(rBlockPos.miCellNotePos, nRow1, nRow2);
 }
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 40ec240..757c3e3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -684,7 +684,10 @@ void ScColumn::DeleteArea(
 }
 
 if (nDelFlag & IDF_NOTE)
-DeleteCellNotes(aBlockPos, nStartRow, nEndRow);
+{
+bool bForgetCaptionOwnership = ((nDelFlag & IDF_FORGETCAPTIONS) != 
IDF_NONE);
+DeleteCellNotes(aBlockPos, nStartRow, nEndRow, 
bForgetCaptionOwnership);
+}
 
 if ( nDelFlag & IDF_EDITATTR )
 {
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 46b59c0..ac09eac 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -114,7 +114,7 @@ void ScColumn::DeleteBeforeCopyFromClip(
 }
 
 if (nDelFlag & IDF_NOTE)
-

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

2015-08-07 Thread Eike Rathke
 sc/inc/compare.hxx   |8 ++--
 sc/source/core/inc/interpre.hxx  |2 +-
 sc/source/core/tool/compare.cxx  |   22 --
 sc/source/core/tool/interpr1.cxx |   20 ++--
 sc/source/core/tool/scmatrix.cxx |2 +-
 5 files changed, 34 insertions(+), 20 deletions(-)

New commits:
commit 34bdbdee3baebf5f008f2ad6762f455db7752e48
Author: Eike Rathke er...@redhat.com
Date:   Mon Jul 20 19:13:06 2015 +0200

Resolves: tdf#58838 do not use collation for Equal/NotEqual operators

Unicode collation ignores control characters and other specific
characters, see
http://www.unicode.org/charts/collation/chart_Ignored.html
and thus is not suitable to be used for Equal/NotEqual operators.

Change-Id: Ib84713e1da59d92e07bc974d93b6def8217bb067
(cherry picked from commit 1e5e7b9323c3321a380edf86097ccc2e3f0a7a7a)
Reviewed-on: https://gerrit.libreoffice.org/17240
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/compare.hxx b/sc/inc/compare.hxx
index 69080a5..e04b5db 100644
--- a/sc/inc/compare.hxx
+++ b/sc/inc/compare.hxx
@@ -61,9 +61,13 @@ private:
 };
 
 /** @param pOptions
-NULL means case sensitivity document option is to be used!
+Used for comparing two strings, if given.
+NULL means that for comparing two strings ScQueryOp rComp.meOp is
+tested for SC_EQUAL and SC_NOT_EQUAL, else pOptions-aQueryEntry.eOp
+Case sensitivity document option is always to be passed in
+rComp.mbIgnoreCase.
  */
-double CompareFunc( const Compare::Cell rCell1, const Compare::Cell rCell2, 
bool bIgnoreCase, CompareOptions* pOptions = NULL );
+double CompareFunc( const Compare rComp, CompareOptions* pOptions = NULL );
 double CompareFunc( const Compare::Cell rCell1, double fCell2, 
CompareOptions* pOptions = NULL );
 double CompareFunc( double fCell1, double fCell2 );
 
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index aea7c5f..f804052 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -407,7 +407,7 @@ void ScChooseJump();
 // Returns true if last jump was executed and result matrix pushed.
 bool JumpMatrix( short nStackLevel );
 
-double Compare();
+double Compare( ScQueryOp eOp );
 /** @param pOptions
 NULL means case sensitivity document option is to be used!
  */
diff --git a/sc/source/core/tool/compare.cxx b/sc/source/core/tool/compare.cxx
index 6395f2f..b883605 100644
--- a/sc/source/core/tool/compare.cxx
+++ b/sc/source/core/tool/compare.cxx
@@ -43,8 +43,11 @@ CompareOptions::CompareOptions( ScDocument* pDoc, const 
ScQueryEntry rEntry, bo
 // struct if needed.
 }
 
-double CompareFunc( const Compare::Cell rCell1, const Compare::Cell rCell2, 
bool bIgnoreCase, CompareOptions* pOptions )
+double CompareFunc( const Compare rComp, CompareOptions* pOptions )
 {
+const Compare::Cell rCell1 = rComp.maCells[0];
+const Compare::Cell rCell2 = rComp.maCells[1];
+
 // Keep DoubleError if encountered
 // #i40539# if bEmpty is set, bVal/nVal are uninitialized
 if (!rCell1.mbEmpty  rCell1.mbValue  
!rtl::math::isFinite(rCell1.mfValue))
@@ -134,7 +137,7 @@ double CompareFunc( const Compare::Cell rCell1, const 
Compare::Cell rCell2, bo
 sal_Int32 nStart = 0;
 sal_Int32 nStop  = rCell1.maStr.getLength();
 bool bMatch = rEntry.GetSearchTextPtr(
-!bIgnoreCase)-SearchForward(
+!rComp.mbIgnoreCase)-SearchForward(
 rCell1.maStr.getString(), nStart, nStop);
 if (bMatch  pOptions-bMatchWholeCell  (nStart != 0 || 
nStop != rCell1.maStr.getLength()))
 bMatch = false; // RegEx must match entire string.
@@ -143,12 +146,12 @@ double CompareFunc( const Compare::Cell rCell1, const 
Compare::Cell rCell2, bo
 else if (rEntry.eOp == SC_EQUAL || rEntry.eOp == SC_NOT_EQUAL)
 {
 ::utl::TransliterationWrapper* pTransliteration =
-(bIgnoreCase ? ScGlobal::GetpTransliteration() :
+(rComp.mbIgnoreCase ? ScGlobal::GetpTransliteration() :
  ScGlobal::GetCaseTransliteration());
 bool bMatch = false;
 if (pOptions-bMatchWholeCell)
 {
-if (bIgnoreCase)
+if (rComp.mbIgnoreCase)
 bMatch = rCell1.maStr.getDataIgnoreCase() == 
rCell2.maStr.getDataIgnoreCase();
 else
 bMatch = rCell1.maStr.getData() == 
rCell2.maStr.getData();
@@ -165,14 +168,21 @@ double CompareFunc( const Compare::Cell rCell1, const 
Compare::Cell rCell2, bo
 }
 fRes = (bMatch ? 0 : 1);
 }
-else if (bIgnoreCase)
+  

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

2015-08-07 Thread Eike Rathke
 sc/inc/globstr.hrc|4 +++-
 sc/source/ui/namedlg/namemgrtable.cxx |2 +-
 sc/source/ui/src/globstr.src  |6 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 29be11a5d5d9e3e72816ebf6b204099ff8d86058
Author: Eike Rathke er...@redhat.com
Date:   Mon Jul 13 19:07:02 2015 +0200

Resolves: tdf#92709 conditional formats are applied to ranges, not 
expressions

Hence we need a separate string as header in the dialog. Unfortunately I
did not see this when applying 0cf38e7d0c5d2b67dca828aae1797bff58b6c5fe

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

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 07896d4..6ca1fd7 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -700,7 +700,9 @@
 
 #define STR_TABLE_COUNT 535
 
-#define SC_GLOBSTR_STR_COUNT536 /** the count of permanently 
resident strings */
+#define STR_HEADER_RANGE_OR_EXPR536
+
+#define SC_GLOBSTR_STR_COUNT537 /** the count of permanently 
resident strings */
 
 #endif
 
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx 
b/sc/source/ui/namedlg/namemgrtable.cxx
index e226e89..89749c6 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -45,7 +45,7 @@ ScRangeManagerTable::ScRangeManagerTable( 
SvSimpleTableContainer rParent, boost
 SetTabs( aStaticTabs[0], MAP_PIXEL );
 
 OUString aNameStr(ScGlobal::GetRscString(STR_HEADER_NAME));
-OUString aRangeStr(ScGlobal::GetRscString(STR_HEADER_RANGE));
+OUString aRangeStr(ScGlobal::GetRscString(STR_HEADER_RANGE_OR_EXPR));
 OUString aScopeStr(ScGlobal::GetRscString(STR_HEADER_SCOPE));
 
 HeaderBar rHeaderBar = GetTheHeaderBar();
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 0ce65a8..8ebb2c6 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1772,7 +1772,7 @@ Resource RID_GLOBSTR
 {
 Text [en-US] = Name;
 };
-String STR_HEADER_RANGE
+String STR_HEADER_RANGE_OR_EXPR
 {
 Text [en-US] = Range or formula expression;
 };
@@ -1804,6 +1804,10 @@ Resource RID_GLOBSTR
 {
 Text [ en-US ] = This Document is referenced by another document and 
not yet saved. Closing it without saving will result in data loss.;
 };
+String STR_HEADER_RANGE
+{
+Text [en-US] = Range;
+};
 String STR_HEADER_COND
 {
 Text [ en-US ] = First Condition;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-07-19 Thread Eike Rathke
 sc/inc/dbdata.hxx  |5 +
 sc/source/core/tool/dbdata.cxx |   21 +
 sc/source/ui/docshell/dbdocfun.cxx |3 +++
 3 files changed, 29 insertions(+)

New commits:
commit e6241675a74e305b1af1049374be648ec63c37d8
Author: Eike Rathke er...@redhat.com
Date:   Thu Jul 16 17:52:29 2015 +0200

Resolves: tdf#88402 remember sort has headers at anonymous database ranges

Change-Id: I4a126f40589fd401f3a63f74be5e86e3df947ef6
(cherry picked from commit 33255f974fc712b9e9e2965a350c65a2195a7ae6)
Reviewed-on: https://gerrit.libreoffice.org/17136
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index 4965e94..fdcf678 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -128,6 +128,10 @@ public:
 voidGetSortParam(ScSortParam rSortParam) const;
 voidSetSortParam(const ScSortParam rSortParam);
 
+/** Remember some more settings of ScSortParam, only to be called at
+anonymous DB ranges as it at least overwrites bHasHeader. */
+voidUpdateFromSortParam( const ScSortParam rSortParam );
+
 SC_DLLPUBLIC void   GetQueryParam(ScQueryParam rQueryParam) const;
 SC_DLLPUBLIC void   SetQueryParam(const ScQueryParam rQueryParam);
 SC_DLLPUBLIC bool   GetAdvancedQuerySource(ScRange rSource) const;
@@ -228,6 +232,7 @@ public:
 ScDBData* getByRange(const ScRange rRange);
 void insert(ScDBData* p);
 bool empty() const;
+bool has( const ScDBData* p ) const;
 bool operator== (const AnonDBs r) const;
 };
 
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index e51da5d..e91f2b1 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -346,6 +346,11 @@ void ScDBData::SetSortParam( const ScSortParam rSortParam 
)
 bByRow = rSortParam.bByRow;
 }
 
+void ScDBData::UpdateFromSortParam( const ScSortParam rSortParam )
+{
+bHasHeader = rSortParam.bHasHeader;
+}
+
 void ScDBData::GetQueryParam( ScQueryParam rQueryParam ) const
 {
 rQueryParam = *mpQueryParam;
@@ -744,6 +749,17 @@ public:
 }
 };
 
+class FindByPointer : public unary_functionScDBData, bool
+{
+const ScDBData* mpDBData;
+public:
+FindByPointer(const ScDBData* pDBData) : mpDBData(pDBData) {}
+bool operator() (const ScDBData r) const
+{
+return r == mpDBData;
+}
+};
+
 }
 
 ScDBCollection::NamedDBs::NamedDBs(ScDBCollection rParent, ScDocument rDoc) :
@@ -894,6 +910,11 @@ bool ScDBCollection::AnonDBs::empty() const
 return maDBs.empty();
 }
 
+bool ScDBCollection::AnonDBs::has( const ScDBData* p ) const
+{
+return find_if( maDBs.begin(), maDBs.end(), FindByPointer(p)) != 
maDBs.end();
+}
+
 bool ScDBCollection::AnonDBs::operator== (const AnonDBs r) const
 {
 return maDBs == r.maDBs;
diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index 567e100..ff748c4 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -574,6 +574,9 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam 
rSortParam,
 }
 
 pDBData-SetSortParam(rSortParam);
+// Remember additional settings on anonymous database ranges.
+if (pDBData == rDoc.GetAnonymousDBData( nTab) || 
rDoc.GetDBCollection()-getAnonDBs().has( pDBData))
+pDBData-UpdateFromSortParam( rSortParam);
 
 if (nStartRow = aLocalParam.nRow2)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-07-09 Thread Eike Rathke
 sc/inc/conditio.hxx  |1 +
 sc/source/core/data/conditio.cxx |5 +
 sc/source/core/data/documen7.cxx |5 -
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 1f3ec2e3cb52c0e10c36ac0b113c37462147f3b1
Author: Eike Rathke er...@redhat.com
Date:   Thu Jul 9 21:05:20 2015 +0200

execute the terrible bottle neck loop only if there are conditional formats

Change-Id: Ic8bd65a728289c9fa1a0721b0ecbd9b4a48672ca
(cherry picked from commit 2aefb89b299e7ebdca5bb35aa4e9059e59805715)
Reviewed-on: https://gerrit.libreoffice.org/16902
Reviewed-by: Markus Mohrhard markus.mohrh...@googlemail.com
Tested-by: Markus Mohrhard markus.mohrh...@googlemail.com

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index fc039c0..4a813c9 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -495,6 +495,7 @@ public:
 const_iterator end() const;
 
 size_t size() const;
+bool empty() const;
 
 void erase(sal_uLong nIndex);
 
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 3036999..d4408d9 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2321,6 +2321,11 @@ size_t ScConditionalFormatList::size() const
 return maConditionalFormats.size();
 }
 
+bool ScConditionalFormatList::empty() const
+{
+return maConditionalFormats.empty();
+}
+
 void ScConditionalFormatList::erase( sal_uLong nIndex )
 {
 for( iterator itr = begin(); itr != end(); ++itr )
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index b67cce9..795e93c 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -141,8 +141,11 @@ void ScDocument::BroadcastCells( const ScRange rRange, 
sal_uLong nHint, bool bB
 continue;
 
 ScConditionalFormatList* pCondFormList = GetCondFormList(nTab);
-if (pCondFormList)
+if (pCondFormList  !pCondFormList-empty())
 {
+/* TODO: looping over all possible cells is a terrible bottle neck,
+ * for each cell looping over all conditional formats even worse,
+ * this certainly needs a better method. */
 ScAddress aAddress( 0, 0, nTab);
 for (SCROW nRow = nRow1; nRow = nRow2; ++nRow)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-07-08 Thread Eike Rathke
 sc/inc/refdata.hxx  |9 +++
 sc/inc/tokenarray.hxx   |6 ++
 sc/source/core/data/formulacell.cxx |3 +
 sc/source/core/tool/interpr4.cxx|1 
 sc/source/core/tool/refdata.cxx |   92 
 sc/source/core/tool/token.cxx   |   28 ++
 6 files changed, 139 insertions(+)

New commits:
commit 21d5e7bbb5ba986a3fd2b4194f83c18003fc3bac
Author: Eike Rathke er...@redhat.com
Date:   Tue Jul 7 01:45:41 2015 +0200

always justify a referenced range in order, tdf#92468

(cherry picked from commit d24c6a0280b0287ee6c23ca89068323c6b7c3dd7)

(re-)introduce ScComplexRefData::PutInOrder(), tdf#92468

(cherry picked from commit ad3d2b6c2e88d191d76f90eb5be927f7ca76c670)

introduce ScTokenArray::AdjustReferenceOnCopy(), tdf#92468

(cherry picked from commit 369ee0b1faf79f1bd23c75ee04dd0dcc5bf283af)

call ScTokenArray::AdjustReferenceOnCopy() in ScFormulaCell clone, tdf#92468

(cherry picked from commit 3ddaeaab37d585971e376de6ad7b0f06f55f2e1a)

f551e02a77a416b95f74266de896391d1d72eb3c
0a7ac0d9d10e96223cd5f095a771aa6f9d271417
0dc0c3528b35bc6ea2525bafb94d72ee65e4791a

Change-Id: Id69c58800d28f1733777f7931a20d8ee7bdf034f
Reviewed-on: https://gerrit.libreoffice.org/16815
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index c49682f..b96acb7 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -104,6 +104,9 @@ public:
 SCCOL Col() const;
 SCTAB Tab() const;
 
+/** Adjust ordering (front-top-left/rear-bottom-right) to a new position. 
*/
+static void PutInOrder( ScSingleRefData rRef1, ScSingleRefData rRef2, 
const ScAddress rPos );
+
 bool operator==( const ScSingleRefData ) const;
 bool operator!=( const ScSingleRefData ) const;
 
@@ -161,8 +164,14 @@ struct ScComplexRefData
 }
 
 SC_DLLPUBLIC ScRange toAbs( const ScAddress rPos ) const;
+
+/** Set a new range, assuming that the ordering of the range matches the
+ordering of the reference data flags already set. */
 void SetRange( const ScRange rRange, const ScAddress rPos );
 
+/** Adjust ordering (front-top-left/rear-bottom-right) to a new position. 
*/
+void PutInOrder( const ScAddress rPos );
+
 inline bool operator==( const ScComplexRefData r ) const
 { return Ref1 == r.Ref1  Ref2 == r.Ref2; }
 /** Enlarge range if reference passed is not within existing range.
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 0d3fa02..8ed8697 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -217,6 +217,12 @@ public:
 void AdjustReferenceOnMovedOriginIfOtherSheet( const ScAddress rOldPos, 
const ScAddress rNewPos );
 
 /**
+ * Adjust internal range references on base position change to justify /
+ * put in order the relative references.
+ */
+void AdjustReferenceOnCopy( 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/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 24f365a..eb2b374 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -850,6 +850,9 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell rCell, 
ScDocument rDoc, cons
 pCode-AdjustAbsoluteRefs( rCell.pDocument, rCell.aPos, aPos, false, 
bCopyBetweenDocs );
 }
 
+if (!pDocument-IsClipOrUndo())
+pCode-AdjustReferenceOnCopy( aPos);
+
 if ( nCloneFlags  SC_CLONECELL_ADJUST3DREL )
 pCode-ReadjustRelative3DReferences( rCell.aPos, aPos );
 
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 18dee8e..9d4821c 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1309,6 +1309,7 @@ void ScInterpreter::DoubleRefToRange( const 
ScComplexRefData  rCRef,
 rRange.aStart.Set( nCol, nRow, nTab );
 SingleRefToVars( rCRef.Ref2, nCol, nRow, nTab);
 rRange.aEnd.Set( nCol, nRow, nTab );
+rRange.Justify();
 if (! pDok-aTableOpList.empty()  !bDontCheckForTableOp )
 {
 if ( IsTableOpInRange( rRange ) )
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 97d419c..4a814db 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -239,6 +239,93 @@ SCTAB ScSingleRefData::Tab() const
 return mnTab;
 }
 
+// static
+void ScSingleRefData::PutInOrder( ScSingleRefData rRef1, ScSingleRefData 
rRef2, const ScAddress rPos )
+{
+sal_uInt8 nRelState1 = rRef1.Flags.bRelName ?
+((rRef1.Flags.bTabRel ? 4 

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

2015-06-26 Thread Jan Holesovsky
 sc/inc/document.hxx  |3 +++
 sc/source/core/data/documen2.cxx |   15 +++
 sc/source/ui/unoobj/docuno.cxx   |2 +-
 sc/source/ui/view/gridwin4.cxx   |2 +-
 4 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit 44a534ab8706f78dd812a4cf68123963a52035af
Author: Jan Holesovsky ke...@collabora.com
Date:   Mon Jun 22 15:47:44 2015 +0200

sc tiled rendering: Set some minimal size of the document.

Let's default to 12x36 cells.

Change-Id: Ic39739ec036a6e5867d31b7e05b6da12ce2e46d2
Reviewed-on: https://gerrit.libreoffice.org/16413
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Miklos Vajna vmik...@collabora.co.uk

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7ea90f1..69e6f5b 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1157,6 +1157,9 @@ public:
 SCROW rEndRow, bool bNotes = true ) 
const;
 voidInvalidateTableArea();
 
+/// Return the number of colums / rows that should be visible for the 
tiled rendering.
+SC_DLLPUBLIC bool   GetTiledRenderingArea(SCTAB nTab, SCCOL 
rEndCol, SCROW rEndRow) const;
+
 SC_DLLPUBLIC bool   GetDataStart( SCTAB nTab, SCCOL rStartCol, 
SCROW rStartRow ) const;
 
 /**
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index eeec6ef..8d3e4e3 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -706,6 +706,21 @@ bool ScDocument::GetDataStart( SCTAB nTab, SCCOL 
rStartCol, SCROW rStartRow )
 return false;
 }
 
+bool ScDocument::GetTiledRenderingArea(SCTAB nTab, SCCOL rEndCol, SCROW 
rEndRow) const
+{
+if (!GetPrintArea(nTab, rEndCol, rEndRow, false))
+return false;
+
+// we need some reasonable minimal document size
+if (rEndCol  12)
+rEndCol = 12;
+
+if (rEndRow  36)
+rEndRow = 36;
+
+return true;
+}
+
 bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
 {
 if (nOldPos == nNewPos)
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index a195b8a..5375176 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -523,7 +523,7 @@ Size ScModelObj::getDocumentSize()
 SCROW nEndRow = 0;
 const ScDocument rDoc = pDocShell-GetDocument();
 
-if (!rDoc.GetPrintArea( nTab, nEndCol, nEndRow, false ))
+if (!rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow))
 return aSize;
 
 // convert to twips
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 3919ca5..ceaf3d8 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -971,7 +971,7 @@ void ScGridWindow::PaintTile( VirtualDevice rDevice,
 SCROW nStartRow = 0, nEndRow = 0;
 
 // size of the document including drawings, charts, etc.
-pDoc-GetPrintArea(nTab, nEndCol, nEndRow, false);
+pDoc-GetTiledRenderingArea(nTab, nEndCol, nEndRow);
 
 double fPPTX = pViewData-GetPPTX();
 double fPPTY = pViewData-GetPPTY();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-06-26 Thread Eike Rathke
 sc/inc/refdata.hxx   |   14 ++
 sc/source/core/tool/compiler.cxx |8 
 2 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit e8f83d8fca7cd24375a1b9ec5e4c8a25972276c7
Author: Eike Rathke er...@redhat.com
Date:   Fri Jun 26 20:05:54 2015 +0200

use ScComplexRefData::IsEntireCol() and IsEntireRow()

Change-Id: I4287019f5492825f6d295c4e364405f0d7329eb7
(cherry picked from commit dcbceb945b7a282c1a1309cf07e62ecc925e98f6)

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index e0d9b80..c49682f 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -146,6 +146,20 @@ struct ScComplexRefData
 tab if one sheet, or =0 if more than one sheets. */
 bool ValidExternal() const;
 
+/** Whether this references entire columns, A:A */
+inline bool IsEntireCol() const
+{
+// Both row anchors must be absolute.
+return Ref1.Row() == 0  Ref2.Row() == MAXROW  !Ref1.IsRowRel()  
!Ref2.IsRowRel();
+}
+
+/** Whether this references entire rows, 1:1 */
+inline bool IsEntireRow() const
+{
+// Both column anchors must be absolute.
+return Ref1.Col() == 0  Ref2.Col() == MAXCOL  !Ref1.IsColRel()  
!Ref2.IsColRel();
+}
+
 SC_DLLPUBLIC ScRange toAbs( const ScAddress rPos ) const;
 void SetRange( const ScRange rRange, const ScAddress rPos );
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index ad5b0ec..22272fb 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -830,12 +830,12 @@ struct ConventionOOO_A1 : public Convention_A1
 !ValidCol(rAbs2.Col()) || rRef.Ref2.IsColDeleted() || 
!ValidRow(rAbs2.Row()) || rRef.Ref2.IsRowDeleted())
 return SINGLETON_NONE;
 
-// A:A or $A:$A or A:$A or $A:A, both row anchors must be absolute.
-if (rAbs1.Row() == 0  rAbs2.Row() == MAXROW  !rRef.Ref1.IsRowRel() 
 !rRef.Ref2.IsRowRel())
+// A:A or $A:$A or A:$A or $A:A
+if (rRef.IsEntireCol())
 return SINGLETON_COL;
 
-// 1:1 or $1:$1 or 1:$1 or $1:1, both column anchors must be absolute.
-if (rAbs1.Col() == 0  rAbs2.Col() == MAXCOL  !rRef.Ref1.IsColRel() 
 !rRef.Ref2.IsColRel())
+// 1:1 or $1:$1 or 1:$1 or $1:1
+if (rRef.IsEntireRow())
 return SINGLETON_ROW;
 
 return SINGLETON_NONE;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-06-23 Thread Henry Castro
 sc/inc/docuno.hxx  |3 +
 sc/source/ui/unoobj/docuno.cxx |   82 +
 2 files changed, 85 insertions(+)

New commits:
commit bf373a5da2aa6621f0afe0b0d2c38d71dfb6ffe3
Author: Henry Castro hcas...@collabora.com
Date:   Mon Jun 22 23:16:39 2015 -0400

sc: add ScModelObj::getTextSelection().

Calc copy part of copypaste

Change-Id: Id9d2d05b491849fa30b3c91c6b22abe60355e876

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index e11b960..a7e9af5 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -403,6 +403,9 @@ public:
 /// @see vcl::ITiledRenderable::setTextSelection().
 virtual void setTextSelection(int nType, int nX, int nY) SAL_OVERRIDE;
 
+/// @see vcl::ITiledRenderable::getTextSelection().
+virtual OString getTextSelection(const char* pMimeType, OString 
rUsedMimeType) SAL_OVERRIDE;
+
 /// @see vcl::ITiledRenderable::setGraphicSelection().
 virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 36de586..a195b8a 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -37,6 +37,7 @@
 #include unotools/moduleoptions.hxx
 #include sfx2/printer.hxx
 #include sfx2/bindings.hxx
+#include sfx2/dispatch.hxx
 #include vcl/pdfextoutdevdata.hxx
 #include vcl/waitobj.hxx
 #include unotools/charclass.hxx
@@ -107,6 +108,10 @@
 #include unonames.hxx
 #include ViewSettingsSequenceDefines.hxx
 #include viewuno.hxx
+#include editsh.hxx
+#include drawsh.hxx
+#include drtxtob.hxx
+#include transobj.hxx
 
 #include sc.hrc
 
@@ -679,6 +684,83 @@ void ScModelObj::setTextSelection(int nType, int nX, int 
nY)
 }
 }
 
+OString ScModelObj::getTextSelection(const char* pMimeType, OString 
rUsedMimeType)
+{
+SolarMutexGuard aGuard;
+
+ScEditShell* pShell;
+ScDrawShell* pDrawShell;
+ScDrawTextObjectBar* pTextShell;
+TransferableDataHelper aDataHelper;
+ScViewData* pViewData = ScDocShell::GetViewData();
+uno::Referencedatatransfer::XTransferable xTransferable;
+
+if (( pShell = PTR_CAST( ScEditShell, 
pViewData-GetViewShell()-GetViewFrame()-GetDispatcher()-GetShell(0) )))
+xTransferable = pShell-GetEditView()-GetTransferable();
+else if (( pTextShell = PTR_CAST( ScDrawTextObjectBar, 
pViewData-GetViewShell()-GetViewFrame()-GetDispatcher()-GetShell(0) )))
+{
+ScDrawView* pView = pViewData-GetScDrawView();
+OutlinerView* pOutView = pView-GetTextEditOutlinerView();
+if (pOutView)
+xTransferable = pOutView-GetEditView().GetTransferable();
+}
+else if (( pDrawShell = PTR_CAST( ScDrawShell, 
pViewData-GetViewShell()-GetViewFrame()-GetDispatcher()-GetShell(0) )))
+xTransferable = pDrawShell-GetDrawView()-CopyToTransferable();
+else
+{
+ScTransferObj* pObj = pViewData-GetViewShell()-CopyToTransferable();
+xTransferable.set( pObj );
+}
+
+if (!xTransferable.is())
+xTransferable.set( aDataHelper.GetTransferable() );
+
+// Take care of UTF-8 text here.
+OString aMimeType(pMimeType);
+bool bConvert = false;
+sal_Int32 nIndex = 0;
+if (aMimeType.getToken(0, ';', nIndex) == text/plain)
+{
+if (aMimeType.getToken(0, ';', nIndex) == charset=utf-8)
+{
+aMimeType = text/plain;charset=utf-16;
+bConvert = true;
+}
+}
+
+datatransfer::DataFlavor aFlavor;
+aFlavor.MimeType = OUString::fromUtf8(aMimeType.getStr());
+if (aMimeType == text/plain;charset=utf-16)
+aFlavor.DataType = cppu::UnoTypeOUString::get();
+else
+aFlavor.DataType = cppu::UnoType uno::Sequencesal_Int8 ::get();
+
+if (!xTransferable-isDataFlavorSupported(aFlavor))
+return OString();
+
+uno::Any aAny(xTransferable-getTransferData(aFlavor));
+
+OString aRet;
+if (aFlavor.DataType == cppu::UnoTypeOUString::get())
+{
+OUString aString;
+aAny = aString;
+if (bConvert)
+aRet = OUStringToOString(aString, RTL_TEXTENCODING_UTF8);
+else
+aRet = OString(reinterpret_castconst sal_Char 
*(aString.getStr()), aString.getLength() * sizeof(sal_Unicode));
+}
+else
+{
+uno::Sequencesal_Int8 aSequence;
+aAny = aSequence;
+aRet = OString(reinterpret_castsal_Char*(aSequence.getArray()), 
aSequence.getLength());
+}
+
+rUsedMimeType = pMimeType;
+return aRet;
+}
+
 void ScModelObj::setGraphicSelection(int nType, int nX, int nY)
 {
 SolarMutexGuard aGuard;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-06-22 Thread Eike Rathke
 sc/inc/tokenarray.hxx|4 
 sc/source/core/tool/compiler.cxx |   13 +
 sc/source/core/tool/token.cxx|9 +++--
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit b076c015083caaee79a43dc87e6cbf017e27ceae
Author: Eike Rathke er...@redhat.com
Date:   Mon Jun 22 15:03:33 2015 +0200

TableRef: inherit RelName in generated reference if named expression

Change-Id: I67621e59c6e20e7f3b5101772b5d274d8c745ce9
(cherry picked from commit d0255f30e34442a70665a91fa7e4b6c92f3dab1b)

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 0d3fa02..b36936a 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -52,6 +52,7 @@ class SC_DLLPUBLIC ScTokenArray : public 
formula::FormulaTokenArray
 
 size_t mnHashValue;
 ScFormulaVectorState meVectorState;
+bool mbFromRangeName;
 
 public:
 ScTokenArray();
@@ -69,6 +70,9 @@ public:
 
 ScFormulaVectorState GetVectorState() const { return meVectorState;}
 
+void SetFromRangeName( bool b ) { mbFromRangeName = b; }
+bool IsFromRangeName() const { return mbFromRangeName; }
+
 /**
  * If the array contains at least one relative row reference or named
  * expression, it's variant. Otherwise invariant.
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 5f46dde..6585e40 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4301,6 +4301,7 @@ bool ScCompiler::HandleRange()
 pNew-Reset();
 }
 pNew = pRangeData-GetCode()-Clone();
+pNew-SetFromRangeName( true );
 PushTokenArray( pNew, true );
 if( pRangeData-HasReferences() )
 {
@@ -5086,6 +5087,8 @@ bool ScCompiler::HandleTableRef()
 bool bColumnRange = false;
 bool bCol1Rel = false;
 bool bCol2Rel = false;
+bool bCol1RelName = false;
+bool bCol2RelName = false;
 int nLevel = 0;
 if (bForwardToClose  GetTokenIfOpCode( ocTableRefOpen))
 {
@@ -5136,6 +5139,7 @@ bool ScCompiler::HandleTableRef()
 {
 bColumnRange = true;
 bCol1Rel = p-GetSingleRef()-IsColRel();
+bCol1RelName = p-GetSingleRef()-IsRelName();
 eState = sLast;
 }
 else
@@ -5184,6 +5188,7 @@ bool ScCompiler::HandleTableRef()
 aColRange.aEnd = 
mpToken-GetSingleRef()-toAbs( aPos);
 aColRange.Justify();
 bCol2Rel = 
mpToken-GetSingleRef()-IsColRel();
+bCol2RelName = 
mpToken-GetSingleRef()-IsRelName();
 }
 }
 }
@@ -5209,7 +5214,10 @@ bool ScCompiler::HandleTableRef()
 if (eItem == ScTableRefToken::THIS_ROW)
 {
 aRefData.SetRowRel( true);
+if (!bCol1RelName)
+bCol1RelName = 
static_castScTokenArray*(pArr)-IsFromRangeName();
 }
+aRefData.SetRelName( bCol1RelName);
 aRefData.SetFlag3D( true);
 if (nError)
 {
@@ -5229,11 +5237,16 @@ bool ScCompiler::HandleTableRef()
 aRefData.InitFlags();
 aRefData.Ref1.SetColRel( bCol1Rel);
 aRefData.Ref2.SetColRel( bCol2Rel);
+bool bRelName = bCol1RelName || bCol2RelName;
 if (eItem == ScTableRefToken::THIS_ROW)
 {
 aRefData.Ref1.SetRowRel( true);
 aRefData.Ref2.SetRowRel( true);
+if (!bRelName)
+bRelName = 
static_castScTokenArray*(pArr)-IsFromRangeName();
 }
+aRefData.Ref1.SetRelName( bRelName);
+aRefData.Ref2.SetRelName( bRelName);
 aRefData.Ref1.SetFlag3D( true);
 if (nError)
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index fdc602a..05e5b67 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1743,14 +1743,16 @@ bool ScTokenArray::IsValidReference( ScRange rRange, 
const ScAddress rPos ) co
 ScTokenArray::ScTokenArray() :
 FormulaTokenArray(),
 mnHashValue(0),
-meVectorState(FormulaVectorEnabled)
+meVectorState(FormulaVectorEnabled),
+mbFromRangeName(false)
 {
 }
 
 ScTokenArray::ScTokenArray( const ScTokenArray rArr ) :
 FormulaTokenArray(rArr),
 mnHashValue(rArr.mnHashValue),
-meVectorState(rArr.meVectorState)
+

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

2015-06-21 Thread Eike Rathke
 sc/inc/token.hxx |2 
 sc/source/core/tool/compiler.cxx |   37 ++-
 sc/source/core/tool/token.cxx|  435 ---
 3 files changed, 261 insertions(+), 213 deletions(-)

New commits:
commit 187914c75f4fe49bb1204363aac9876b03d88389
Author: Eike Rathke er...@redhat.com
Date:   Sun Jun 21 20:11:08 2015 +0200

TableRef: make ThisRow work in named expressions

... including reference update as named expressions don't hold RPN.

Change-Id: Ieea19e24f1dcf71d489ff0249bc7d3644e4f0d2b
(cherry picked from commit 37464e3fdaea201900408f7c2395f9bec6184f72)

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 63584c7..3e4f7f8 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -237,7 +237,7 @@ public:
 ItemGetItem() const;
 voidAddItem( Item );
 voidSetAreaRefRPN( formula::FormulaToken* pToken );
-const formula::FormulaToken*GetAreaRefRPN() const;
+formula::FormulaToken*  GetAreaRefRPN() const;
 
 private:
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 64a7d61..5f46dde 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5073,7 +5073,12 @@ bool ScCompiler::HandleTableRef()
 aRange.aEnd.SetRow( aPos.Row());
 }
 else
-nError = errNoRef;
+{
+nError = errNoValue;
+// For *some* relative row reference in named
+// expressions' thisrow special handling below.
+aRange.aEnd.SetRow( aRange.aStart.Row());
+}
 bForwardToClose = true;
 }
 break;
@@ -5154,8 +5159,10 @@ bool ScCompiler::HandleTableRef()
 } while (eState != sStop);
 }
 ScTokenArray* pNew = new ScTokenArray();
-if (!nError)
+if (!nError || nError == errNoValue)
 {
+// The errNoValue case generates a thisrow reference that can be
+// used to save named expressions in A1 syntax notation.
 if (bColumnRange)
 {
 // Limit range to specified columns.
@@ -5204,8 +5211,17 @@ bool ScCompiler::HandleTableRef()
 aRefData.SetRowRel( true);
 }
 aRefData.SetFlag3D( true);
-aRefData.SetAddress( aRange.aStart, aPos);
-pTR-SetAreaRefRPN( pNew-AddSingleReference( aRefData ));
+if (nError)
+{
+aRefData.SetAddress( aRange.aStart, aRange.aStart);
+pTR-SetAreaRefRPN( new ScSingleRefToken( aRefData));  
 // set reference at TableRef
+pNew-Add( new FormulaErrorToken( nError));
 // set error in RPN
+}
+else
+{
+aRefData.SetAddress( aRange.aStart, aPos);
+pTR-SetAreaRefRPN( pNew-AddSingleReference( 
aRefData));
+}
 }
 else
 {
@@ -5219,8 +5235,17 @@ bool ScCompiler::HandleTableRef()
 aRefData.Ref2.SetRowRel( true);
 }
 aRefData.Ref1.SetFlag3D( true);
-aRefData.SetRange( aRange, aPos);
-pTR-SetAreaRefRPN( pNew-AddDoubleReference( aRefData ));
+if (nError)
+{
+aRefData.SetRange( aRange, aRange.aStart);
+pTR-SetAreaRefRPN( new ScDoubleRefToken( aRefData));  
 // set reference at TableRef
+pNew-Add( new FormulaErrorToken( nError));
 // set error in RPN
+}
+else
+{
+aRefData.SetRange( aRange, aPos);
+pTR-SetAreaRefRPN( pNew-AddDoubleReference( 
aRefData));
+}
 }
 }
 else
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 8be2390..fdc602a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -164,6 +164,30 @@ namespace
 
 return false;
 }
+
+FormulaToken* getHandledToken( size_t i, FormulaToken* const * pp )
+{
+if (skipToken( i, pp))
+return nullptr;
+
+FormulaToken* p = *pp;
+if (p-GetOpCode() == ocTableRef)
+{
+// Return the inner reference token if it is not in RPN.
+ScTableRefToken* pTR = dynamic_castScTableRefToken*(p);
+if (!pTR)
+

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

2015-06-16 Thread Eike Rathke
 sc/inc/token.hxx  |6 ++
 sc/source/core/tool/token.cxx |   19 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit ab6be8b2b01f9657f105d5ec9b027c9fa99d4325
Author: Eike Rathke er...@redhat.com
Date:   Wed Jun 17 00:04:30 2015 +0200

Resolves: tdf#86305 clone upper left of matrix result if double token

Change-Id: I541577e0b99b0144a755e5755adc890c0ca8d204
(cherry picked from commit ffc1ffed11dc63a69fc2db04f12b3ea266b580fe)

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 4662074..63584c7 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -381,6 +381,12 @@ public:
 /** Reset matrix and upper left, keep matrix
 formula dimension. */
 void ResetResult();
+
+private:
+
+/** xUpperLeft is modifiable through SetUpperLeftDouble(), so clone it
+whenever an svDouble token is assigned to. */
+void CloneUpperLeftIfNecessary();
 };
 
 class SC_DLLPUBLIC ScHybridCellToken : public formula::FormulaToken
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f9e0cc0..00f1d45 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1022,7 +1022,10 @@ void ScMatrixCellResultToken::Assign( const 
ScMatrixCellResultToken  r )
 
 ScMatrixFormulaCellToken::ScMatrixFormulaCellToken(
 SCCOL nC, SCROW nR, const ScConstMatrixRef pMat, formula::FormulaToken* 
pUL ) :
-ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC) {}
+ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC)
+{
+CloneUpperLeftIfNecessary();
+}
 
 ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
 ScMatrixCellResultToken(NULL, NULL), nRows(nR), nCols(nC) {}
@@ -1030,10 +1033,7 @@ ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( 
SCCOL nC, SCROW nR ) :
 ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( const 
ScMatrixFormulaCellToken r ) :
 ScMatrixCellResultToken(r), nRows(r.nRows), nCols(r.nCols)
 {
-// xUpperLeft is modifiable through
-// SetUpperLeftDouble(), so clone it.
-if (xUpperLeft)
-xUpperLeft = xUpperLeft-Clone();
+CloneUpperLeftIfNecessary();
 }
 
 ScMatrixFormulaCellToken::~ScMatrixFormulaCellToken() {}
@@ -1045,9 +1045,17 @@ bool ScMatrixFormulaCellToken::operator==( const 
FormulaToken r ) const
 nCols == p-nCols  nRows == p-nRows;
 }
 
+void ScMatrixFormulaCellToken::CloneUpperLeftIfNecessary()
+{
+if (xUpperLeft  xUpperLeft-GetType() == svDouble)
+xUpperLeft = xUpperLeft-Clone();
+}
+
 void ScMatrixFormulaCellToken::Assign( const ScMatrixCellResultToken  r )
 {
 ScMatrixCellResultToken::Assign( r);
+
+CloneUpperLeftIfNecessary();
 }
 
 void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken r )
@@ -1069,6 +1077,7 @@ void ScMatrixFormulaCellToken::Assign( const 
formula::FormulaToken r )
 {
 xUpperLeft = r;
 xMatrix = NULL;
+CloneUpperLeftIfNecessary();
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2015-06-11 Thread Mike Kaganski
 sc/inc/externalrefmgr.hxx|7 ++
 sc/inc/formulacell.hxx   |3 ++
 sc/source/core/data/formulacell.cxx  |   18 +++
 sc/source/ui/docshell/externalrefmgr.cxx |   35 ++-
 4 files changed, 57 insertions(+), 6 deletions(-)

New commits:
commit bc00e475d45c0e0cf44dc46c67308c152a2b3f70
Author: Mike Kaganski mikekagan...@hotmail.com
Date:   Thu Jun 4 06:47:38 2015 +1000

tdf#89972: also copy external reference status

fixes regression from commit 4467c67dc8bf17c67c70985c0d0ea64636884f9f,
where the new optimized code path failed to properly register
ScFormulaCell with ScExternalRefManager.
Introduces a new public method in ScExternalRefManager: insertRefCellAsTmpl
that registers a formula cell to listen to the same external references
as template cell
Introduces new property to ScFormulaCell: mbIsExtRef
that indicates that some external references are referenced by this cell

Change-Id: Iee07d7b51949fd31953b5fa662a213052eb85181
Reviewed-on: https://gerrit.libreoffice.org/16066
Reviewed-by: Michael Meeks michael.me...@collabora.com
Tested-by: Michael Meeks michael.me...@collabora.com
(cherry picked from commit 17282387d650e843e0f5a28611d91597ccd09970)
Reviewed-on: https://gerrit.libreoffice.org/16219
Tested-by: Jenkins c...@libreoffice.org

diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 9af6eef..1105136 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -701,6 +701,12 @@ public:
 bool containsUnsavedReferences() const { return 
!maUnsavedDocShells.empty(); }
 
 void insertRefCell(sal_uInt16 nFileId, const ScAddress rCell);
+/**
+ * Add a cell to reference the same files as the template cell.
+ */
+void insertRefCellFromTemplate( ScFormulaCell* pTemplateCell, 
ScFormulaCell* pCell );
+
+bool hasCellExternalReference(const ScAddress rCell);
 
 void enableDocTimer( bool bEnable );
 
@@ -790,6 +796,7 @@ private:
  */
 void transformUnsavedRefToSavedRef( SfxObjectShell* pShell );
 
+void insertRefCell(RefCellMap::iterator itr, ScFormulaCell* pCell);
 private:
 ScDocument* mpDoc;
 
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 8e84e00..66f4c9b 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -143,6 +143,7 @@ private:
 boolbNeedListening : 1; // Listeners need to be re-established 
after UpdateReference
 boolmbNeedsNumberFormat : 1; // set the calculated number 
format as hard number format
 boolmbPostponedDirty : 1;   // if cell needs to be set dirty 
later
+boolmbIsExtRef   : 1; // has references in 
ScExternalRefManager; never cleared after set
 
 enum ScInterpretTailParameter
 {
@@ -426,6 +427,8 @@ public:
 void SyncSharedCode();
 
 bool IsPostponedDirty() const { return mbPostponedDirty;}
+
+void SetIsExtRef() { mbIsExtRef = true; }
 };
 
 #endif
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 85b0f83..4af29d6 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -608,6 +608,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const 
ScAddress rPos ) :
 bNeedListening(false),
 mbNeedsNumberFormat(false),
 mbPostponedDirty(false),
+mbIsExtRef(false),
 aPos(rPos)
 {
 SAL_INFO( sc.core.formulacell, ScFormulaCell ctor this   this);
@@ -638,7 +639,8 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const 
ScAddress rPos,
 bNeedListening( false ),
 mbNeedsNumberFormat( false ),
 mbPostponedDirty(false),
-aPos( rPos )
+mbIsExtRef(false),
+aPos(rPos)
 {
 SAL_INFO( sc.core.formulacell, ScFormulaCell ctor this   this);
 
@@ -672,7 +674,8 @@ ScFormulaCell::ScFormulaCell(
 bNeedListening( false ),
 mbNeedsNumberFormat( false ),
 mbPostponedDirty(false),
-aPos( rPos )
+mbIsExtRef(false),
+aPos(rPos)
 {
 SAL_INFO( sc.core.formulacell, ScFormulaCell ctor this   this);
 assert(pArray); // Never pass a NULL pointer here.
@@ -721,7 +724,8 @@ ScFormulaCell::ScFormulaCell(
 bNeedListening( false ),
 mbNeedsNumberFormat( false ),
 mbPostponedDirty(false),
-aPos( rPos )
+mbIsExtRef(false),
+aPos(rPos)
 {
 SAL_INFO( sc.core.formulacell, ScFormulaCell ctor this   this);
 
@@ -770,7 +774,8 @@ ScFormulaCell::ScFormulaCell(
 bNeedListening( false ),
 mbNeedsNumberFormat( false ),
 mbPostponedDirty(false),
-aPos( rPos )
+mbIsExtRef(false),
+aPos(rPos)
 {
 SAL_INFO( sc.core.formulacell, ScFormulaCell ctor this   this);
 
@@ -801,7 +806,8 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell rCell, 
ScDocument rDoc, cons
 bNeedListening( false ),
 mbNeedsNumberFormat( false ),
 mbPostponedDirty(false),
-