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

2017-04-06 Thread Kohei Yoshida
 sc/inc/refdata.hxx   |2 ++
 sc/source/core/tool/interpr4.cxx |   19 +--
 sc/source/core/tool/interpr6.cxx |6 ++
 sc/source/core/tool/refdata.cxx  |5 +
 sc/source/core/tool/token.cxx|   19 +++
 5 files changed, 49 insertions(+), 2 deletions(-)

New commits:
commit 2d9de590d9ebd8740fc0f6d94f5ee98b22377877
Author: Kohei Yoshida 
Date:   Wed Mar 22 21:21:31 2017 -0400

tdf#105908: restore previously deleted range references upon undo.

Reviewed-on: https://gerrit.libreoffice.org/35607
Tested-by: Jenkins 
Reviewed-by: Kohei Yoshida 
(cherry picked from commit 749405af4fc38e0c16dc7e860d23a13dfceb4e40)

 Conflicts:
sc/source/core/tool/interpr6.cxx

Change-Id: If1932a5eb10da4c50fbcc3329af75f2e7a0a5137
Reviewed-on: https://gerrit.libreoffice.org/35673
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 5f3e7626940a..098f24de28fd 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -190,6 +190,8 @@ struct ScComplexRefData
 @return TRUE if changed. */
 bool IncEndRowSticky( SCROW nDelta, const ScAddress& rPos );
 
+bool IsDeleted() const;
+
 #if DEBUG_FORMULA_COMPILER
 void Dump( int nIndent = 0 ) const;
 #endif
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 24a3d53dc093..fe3469c8f403 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -950,10 +950,17 @@ void ScInterpreter::PopSingleRef( ScAddress& rAdr )
 break;
 case svSingleRef:
 {
+const ScSingleRefData* pRefData = p->GetSingleRef();
+if (pRefData->IsDeleted())
+{
+SetError( errNoRef);
+break;
+}
+
 SCCOL nCol;
 SCROW nRow;
 SCTAB nTab;
-SingleRefToVars( *p->GetSingleRef(), nCol, nRow, nTab);
+SingleRefToVars( *pRefData, nCol, nRow, nTab);
 rAdr.Set( nCol, nRow, nTab );
 if (!pDok->m_TableOpList.empty())
 ReplaceCell( rAdr );
@@ -1075,9 +1082,17 @@ void ScInterpreter::PopDoubleRef( ScRange & rRange, 
short & rParam, size_t & rRe
 nGlobalError = pToken->GetError();
 break;
 case svDoubleRef:
+{
 --sp;
-DoubleRefToRange( *pToken->GetDoubleRef(), rRange);
+const ScComplexRefData* pRefData = pToken->GetDoubleRef();
+if (pRefData->IsDeleted())
+{
+SetError( errNoRef);
+break;
+}
+DoubleRefToRange( *pRefData, rRange);
 break;
+}
 case svRefList:
 {
 const ScRefList* pList = pToken->GetRefList();
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 78d6f47c2589..d385e77e1fda 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -613,6 +613,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
 case svSingleRef :
 {
 PopSingleRef( aAdr );
+if (nGlobalError == errNoRef)
+return 0.0;
+
 if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ||
  ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) )
 {
@@ -676,6 +679,9 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, 
bool bTextAsZero )
 case svRefList :
 {
 PopDoubleRef( aRange, nParamCount, nRefInList);
+if (nGlobalError == errNoRef)
+return 0.0;
+
 if ( nGlobalError && ( eFunc == ifCOUNT2 || eFunc == ifCOUNT ||
  ( mnSubTotalFlags & SUBTOTAL_IGN_ERR_VAL ) ) )
 {
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index d97289345ae5..5d7d0f320f68 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -553,6 +553,11 @@ bool ScComplexRefData::IncEndRowSticky( SCROW nDelta, 
const ScAddress& rPos )
 return true;
 }
 
+bool ScComplexRefData::IsDeleted() const
+{
+return Ref1.IsDeleted() || Ref2.IsDeleted();
+}
+
 #if DEBUG_FORMULA_COMPILER
 void ScComplexRefData::Dump( int nIndent ) const
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 2eb0fa6da110..e7714801dac0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2668,6 +2668,12 @@ 

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

2017-01-11 Thread Eike Rathke
 sc/inc/formulacell.hxx  |9 +++-
 sc/source/core/data/column.cxx  |2 -
 sc/source/core/data/formulacell.cxx |   40 
 sc/source/core/tool/refdata.cxx |4 +++
 4 files changed, 45 insertions(+), 10 deletions(-)

New commits:
commit 33c1491acb3fd6b87ac16d80ed728f423762e867
Author: Eike Rathke 
Date:   Mon Jan 9 19:47:06 2017 +0100

Resolves: tdf#104711 adjust range reference constructed of named anchors

A constructed range reference of named anchors (i.e. extended during
expression compilation) forms a range listened at that needs to be
adjusted if the cell is shifted and one or both anchor parts are
individually named relative references.

Currently the resulting range (ScComplexRefData aka DoubleRef) does not
know to distinguish between whether its anchors are the result of a
literal range in a named expression or the result of individually named
anchors, so such RelName DoubleRef needs to be adjusted unconditionally
when shifting or moving the formula cell.

Change-Id: I75e2cc79ac60116671acce7641567337d5f5f7ed
(cherry picked from commit 439b2a134218b93e6ca9fa23005b89c19498f586)
Reviewed-on: https://gerrit.libreoffice.org/32924
Tested-by: Jenkins 
Reviewed-by: Christian Lohmaier 

diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index faebe08..c31c1a1 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -241,7 +241,14 @@ public:
It is similar to HasOneReference(), but more general.
  */
 bool HasRefListExpressibleAsOneReference(ScRange& rRange) const;
-boolHasRelNameReference() const;
+
+enum class RelNameRef
+{
+NONE,   ///< no relative reference from named expression
+SINGLE, ///< only single cell relative reference
+DOUBLE  ///< at least one range relative reference from named 
expression
+};
+RelNameRef  HasRelNameReference() const;
 
 bool UpdateReference(
 const sc::RefUpdateContext& rCxt, ScDocument* pUndoDoc = nullptr, 
const ScAddress* pUndoCellPos = nullptr );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index ed04ccd..b707963 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2825,7 +2825,7 @@ struct SetDirtyIfPostponedHandler
 {
 void operator() (size_t /*nRow*/, ScFormulaCell* pCell)
 {
-if (pCell->IsPostponedDirty() || pCell->HasRelNameReference())
+if (pCell->IsPostponedDirty() || (pCell->HasRelNameReference() != 
ScFormulaCell::RelNameRef::NONE))
 pCell->SetDirty();
 }
 };
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 64a0bb4..a9cfdec 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2842,18 +2842,34 @@ 
ScFormulaCell::HasRefListExpressibleAsOneReference(ScRange& rRange) const
 return false;
 }
 
-bool ScFormulaCell::HasRelNameReference() const
+ScFormulaCell::RelNameRef ScFormulaCell::HasRelNameReference() const
 {
+RelNameRef eRelNameRef = RelNameRef::NONE;
 pCode->Reset();
 formula::FormulaToken* t;
 while ( ( t = pCode->GetNextReferenceRPN() ) != nullptr )
 {
-if ( t->GetSingleRef()->IsRelName() ||
-(t->GetType() == formula::svDoubleRef &&
-t->GetDoubleRef()->Ref2.IsRelName()) )
-return true;
+switch (t->GetType())
+{
+case formula::svSingleRef:
+if (t->GetSingleRef()->IsRelName() && eRelNameRef == 
RelNameRef::NONE)
+eRelNameRef = RelNameRef::SINGLE;
+break;
+case formula::svDoubleRef:
+if (t->GetDoubleRef()->Ref1.IsRelName() || 
t->GetDoubleRef()->Ref2.IsRelName())
+// May originate from individual cell names, in which case
+// it needs recompilation.
+return RelNameRef::DOUBLE;
+/* TODO: have an extra flag at ScComplexRefData if range was
+ * extended? or too cumbersome? might narrow recompilation to
+ * only needed cases.
+ * */
+break;
+default:
+;   // nothing
+}
 }
-return false;
+return eRelNameRef;
 }
 
 bool ScFormulaCell::UpdatePosOnShift( const sc::RefUpdateContext& rCxt )
@@ -3058,7 +3074,13 @@ bool ScFormulaCell::UpdateReferenceOnShift(
 bInDeleteUndo = (pChangeTrack && pChangeTrack->IsInDeleteUndo());
 
 // RelNameRefs are always moved
-bool bHasRelName = HasRelNameReference();
+bool bHasRelName = false;
+if (!bRecompile)
+{
+RelNameRef eRelNameRef = HasRelNameReference();
+bHasRelName = (eRelNameRef != 

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

2016-12-02 Thread Bartosz Kosiorek
 sc/inc/address.hxx  |   26 --
 sc/source/core/tool/address.cxx |   10 +-
 sc/source/filter/excel/xestream.cxx |6 --
 sc/source/filter/excel/xetable.cxx  |5 -
 sc/source/filter/inc/xestream.hxx   |2 +-
 5 files changed, 38 insertions(+), 11 deletions(-)

New commits:
commit 3cd0184306825c52da237815a8e782ce4c80253a
Author: Bartosz Kosiorek 
Date:   Fri Nov 18 12:36:21 2016 +0100

OOXML: Write dimension range in full address notation

In every sheet.xml there is information about dimensions, like:
. During export by LibreOffice to .xlsx,
when row or column has maximum value, the dimension was
truncated. For example given "A1:AMJ177" it's saves .
It was caused problems with Office 2007 import.
This patch is fixing that by always using full address notation
for dimension range,  and allow open documents exported by LO
properly by MS Office.

Change-Id: Idda1455d1f9db08ade0871110fe40be2667c176c
Reviewed-on: https://gerrit.libreoffice.org/30960
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 
(cherry picked from commit 71862564df1422f84340e421bbef9060c4e41a71)
Reviewed-on: https://gerrit.libreoffice.org/31526
Reviewed-by: Bartosz Kosiorek 
Reviewed-by: Justin Luth 
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index b2c41cc..52d6505 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -543,8 +543,30 @@ public:
 const 
css::uno::Sequence* pExternalLinks = nullptr,
 const OUString* pErrRef = nullptr );
 
-SC_DLLPUBLIC OUString Format(ScRefFlags nFlags = ScRefFlags::ZERO, const 
ScDocument* pDocument = nullptr,
- const ScAddress::Details& rDetails = 
ScAddress::detailsOOOa1) const;
+/** Returns string with formatted cell range from aStart to aEnd,
+according to provided address convention.
+@param nFlags
+Cell reference flags
+@param pDocument
+Pointer to document which is used for example to get tab names.
+@param rDetails
+Provide information about required address convention.
+Supported address conventions are:
+CONV_OOO  'doc'#sheet.A1:sheet2.B2
+CONV_XL_A1,   [doc]sheet:sheet2!A1:B2
+CONV_XL_OOX,  [#]sheet:sheet2!A1:B2
+CONV_XL_R1C1, [doc]sheet:sheet2!R1C1:R2C2
+@param bFullAddressNotation
+If TRUE, the full address notation will be used.
+For example in case all columns are used, "A1:AMJ177" is full 
address notation
+and "1:177" is shortened address notation.
+@returns
+String contains formatted cell range in address convention
+ */
+SC_DLLPUBLIC OUString Format( ScRefFlags nFlags = ScRefFlags::ZERO,
+  const ScDocument* pDocument = nullptr,
+  const ScAddress::Details& rDetails = 
ScAddress::detailsOOOa1,
+  bool bFullAddressNotation = false ) const;
 
 inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1,
  SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const;
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 134067c..62ad16e 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2166,7 +2166,7 @@ static inline bool lcl_RowAbsFlagDiffer(const ScRefFlags 
nFlags)
 }
 
 OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
-  const ScAddress::Details& rDetails ) const
+  const ScAddress::Details& rDetails, bool 
bFullAddressNotation ) const
 {
 if( !( nFlags & ScRefFlags::VALID ) )
 {
@@ -2201,14 +2201,14 @@ OUString ScRange::Format( ScRefFlags nFlags, const 
ScDocument* pDoc,
 case formula::FormulaGrammar::CONV_XL_A1:
 case formula::FormulaGrammar::CONV_XL_OOX:
 lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
-if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL )
+if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL && !bFullAddressNotation 
)
 {
 // Full col refs always require 2 rows (2:2)
 lcl_a1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) 
!= ScRefFlags::ZERO );
 r.append(":");
 lcl_a1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != 
ScRefFlags::ZERO );
 }
-else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW )
+else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW && 
!bFullAddressNotation )
 {
 // Full row refs always 

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

2016-11-29 Thread Eike Rathke
 sc/inc/table.hxx |4 +++-
 sc/source/core/data/documen2.cxx |8 +++-
 sc/source/core/data/table2.cxx   |   23 ---
 3 files changed, 26 insertions(+), 9 deletions(-)

New commits:
commit bea103fa2c331d776c39e126d0d086983d7ec28b
Author: Eike Rathke 
Date:   Sat Nov 26 11:23:24 2016 +0100

Resolves: tdf#103493 copying note captions needs a completed destination 
sheet

If a copied sheet's destination position is before its source position, the
source's ScColumn::nTab members still pointed to the original source 
position
when the captions were created, which led to the wrong drawing layer page 
being
used and at the end the drawing shapes not being correctly assigned.

Change-Id: I9c3cc97d8b4486756023b9ab02da28079a1d0627
(cherry picked from commit 0a2a7436b4041bb34b01a183b9264af8488d1af3)
Reviewed-on: https://gerrit.libreoffice.org/31229
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index be833da..4877f2b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -449,7 +449,9 @@ public:
 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab,
 const ScMarkData* pMarkData = nullptr, bool bAsLink = false, bool 
bColRowFlags = true,
-bool bGlobalNamesToLocal = false );
+bool bGlobalNamesToLocal = false, bool bCopyCaptions = true );
+
+void CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2, ScTable* pDestTab, bool bCloneCaption );
 
 void UndoToTable(
 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 9c30f0f..e5f4ffc 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -902,7 +902,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, 
const ScMarkData* pOnlyM
 sc::CopyToDocContext aCopyDocCxt(*this);
 maTabs[nOldPos]->CopyToTable(aCopyDocCxt, 0, 0, MAXCOL, MAXROW, 
InsertDeleteFlags::ALL,
 (pOnlyMarked != nullptr), maTabs[nNewPos], pOnlyMarked,
-false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal 
);
+false /*bAsLink*/, true /*bColRowFlags*/, bGlobalNamesToLocal, 
false /*bCopyCaptions*/ );
 maTabs[nNewPos]->SetTabBgColor(maTabs[nOldPos]->GetTabBgColor());
 
 SCTAB nDz = nNewPos - nOldPos;
@@ -940,6 +940,12 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, 
const ScMarkData* pOnlyM
 // Copy the RTL settings
 maTabs[nNewPos]->SetLayoutRTL(maTabs[nOldPos]->IsLayoutRTL());
 maTabs[nNewPos]->SetLoadingRTL(maTabs[nOldPos]->IsLoadingRTL());
+
+// Finally copy the note captions, which need
+// 1. the updated source ScColumn::nTab members if nNewPos <= nOldPos
+// 2. row heights and column widths of the destination
+// 3. RTL settings of the destination
+maTabs[nOldPos]->CopyCaptionsToTable( 0, 0, MAXCOL, MAXROW, 
maTabs[nNewPos], true /*bCloneCaption*/);
 }
 
 return bValid;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 923005a..5c26668 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1090,7 +1090,7 @@ void ScTable::StartListeningFormulaCells(
 void ScTable::CopyToTable(
 sc::CopyToDocContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2,
 InsertDeleteFlags nFlags, bool bMarked, ScTable* pDestTab, const 
ScMarkData* pMarkData,
-bool bAsLink, bool bColRowFlags, bool bGlobalNamesToLocal )
+bool bAsLink, bool bColRowFlags, bool bGlobalNamesToLocal, bool 
bCopyCaptions )
 {
 if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2))
 return;
@@ -1210,14 +1210,23 @@ void ScTable::CopyToTable(
 if(nFlags & InsertDeleteFlags::OUTLINE) // also only when bColRowFlags
 pDestTab->SetOutlineTable( pOutlineTable );
 
-if (nFlags & (InsertDeleteFlags::NOTE|InsertDeleteFlags::ADDNOTES))
+if (bCopyCaptions && (nFlags & (InsertDeleteFlags::NOTE | 
InsertDeleteFlags::ADDNOTES)))
 {
 bool bCloneCaption = (nFlags & InsertDeleteFlags::NOCAPTIONS) == 
InsertDeleteFlags::NONE;
-for (SCCOL i = nCol1; i <= nCol2; i++)
-{
-aCol[i].CopyCellNotesToDocument(nRow1, nRow2, pDestTab->aCol[i], 
bCloneCaption);
-pDestTab->aCol[i].UpdateNoteCaptions(nRow1, nRow2);
-}
+CopyCaptionsToTable( nCol1, nRow1, nCol2, nRow2, pDestTab, 
bCloneCaption);
+}
+}
+
+void ScTable::CopyCaptionsToTable( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2, ScTable* pDestTab,
+bool bCloneCaption )
+{
+if (!ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, 

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

2016-11-11 Thread Eike Rathke
 sc/inc/bulkdatahint.hxx   |2 +-
 sc/source/core/data/bcaslot.cxx   |   10 +-
 sc/source/core/data/documen2.cxx  |2 +-
 sc/source/core/data/documen7.cxx  |6 +++---
 sc/source/core/data/document.cxx  |8 
 sc/source/core/data/table2.cxx|6 +++---
 sc/source/core/inc/bcaslot.hxx|   11 +++
 sc/source/core/tool/bulkdatahint.cxx  |4 ++--
 sc/source/core/tool/grouparealistener.cxx |   21 +
 9 files changed, 35 insertions(+), 35 deletions(-)

New commits:
commit e64460d8d2e6deeb234d744f7618f11e70385e81
Author: Eike Rathke 
Date:   Mon Nov 7 23:49:46 2016 +0100

Resolves: tdf#103701 bulk-broadcast the correct hint ID for formula groups

BulkBroadcastGroupAreas() and BulkDataHint and thus
FormulaGroupAreaListener::Notify() omitted to transport the actual hint
and assumed SC_HINT_DATACHANGED, but SC_HINT_TABLEOPDIRTY needs to be
handled as well.

(cherry picked from commit 05d2a66955f8a6552a79696474386ca9f45f9ef2)

Backported.

 Conflicts:
sc/inc/bulkdatahint.hxx
sc/inc/document.hxx
sc/source/core/data/bcaslot.cxx
sc/source/core/data/documen7.cxx
sc/source/core/data/document.cxx
sc/source/core/inc/bcaslot.hxx
sc/source/core/tool/bulkdatahint.cxx
sc/source/core/tool/grouparealistener.cxx

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

diff --git a/sc/inc/bulkdatahint.hxx b/sc/inc/bulkdatahint.hxx
index 4b37584..c35e027 100644
--- a/sc/inc/bulkdatahint.hxx
+++ b/sc/inc/bulkdatahint.hxx
@@ -28,7 +28,7 @@ class BulkDataHint : public SfxSimpleHint
 BulkDataHint& operator= ( const BulkDataHint& ) = delete;
 
 public:
-BulkDataHint( ScDocument& rDoc, const ColumnSpanSet* pSpans );
+BulkDataHint( ScDocument& rDoc, const ColumnSpanSet* pSpans, sal_uInt32 
nHintId );
 virtual ~BulkDataHint();
 
 void setSpans( const ColumnSpanSet* pSpans );
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 8d5e1bb..c171b44 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -1091,14 +1091,14 @@ void ScBroadcastAreaSlotMachine::EnterBulkBroadcast()
 ++nInBulkBroadcast;
 }
 
-void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast()
+void ScBroadcastAreaSlotMachine::LeaveBulkBroadcast( sal_uInt32 nHintId )
 {
 if (nInBulkBroadcast > 0)
 {
 if (--nInBulkBroadcast == 0)
 {
 ScBroadcastAreasBulk().swap( aBulkBroadcastAreas);
-BulkBroadcastGroupAreas();
+BulkBroadcastGroupAreas( nHintId );
 }
 }
 }
@@ -1122,12 +1122,12 @@ void ScBroadcastAreaSlotMachine::InsertBulkGroupArea( 
ScBroadcastArea* pArea, co
 pSet->set(rRange, true);
 }
 
-void ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas()
+void ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas( sal_uInt32 nHintId )
 {
 if (m_BulkGroupAreas.empty())
 return;
 
-sc::BulkDataHint aHint(*pDoc, nullptr);
+sc::BulkDataHint aHint(*pDoc, nullptr, nHintId);
 
 bool bBroadcasted = false;
 BulkGroupAreasType::iterator it = m_BulkGroupAreas.begin(), itEnd = 
m_BulkGroupAreas.end();
@@ -1154,7 +1154,7 @@ void ScBroadcastAreaSlotMachine::BulkBroadcastGroupAreas()
 
 m_BulkGroupAreas.clear();
 if (bBroadcasted)
-pDoc->TrackFormulas();
+pDoc->TrackFormulas( nHintId );
 }
 
 size_t ScBroadcastAreaSlotMachine::RemoveBulkArea( const ScBroadcastArea* 
pArea )
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index dddcde6..9c30f0f 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1005,7 +1005,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, 
SCTAB nSrcPos,
 sc::CopyToDocContext aCxt(*this);
 nDestPos = std::min(nDestPos, (SCTAB)(GetTableCount() - 1));
 {   // scope for bulk broadcast
-ScBulkBroadcast aBulkBroadcast( pBASM);
+ScBulkBroadcast aBulkBroadcast( pBASM, SC_HINT_DATACHANGED);
 if (!bResultsOnly)
 {
 const bool bGlobalNamesToLocal = false;
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 6816010..70e7fba 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -62,7 +62,7 @@ void ScDocument::Broadcast( const ScHint& rHint )
 return ;// Clipboard or Undo
 if ( eHardRecalcState == HARDRECALCSTATE_OFF )
 {
-ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast
+ScBulkBroadcast aBulkBroadcast( 

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

2016-11-05 Thread Eike Rathke
 sc/inc/markdata.hxx  |   13 -
 sc/source/core/data/markdata.cxx |   25 +
 sc/source/core/data/table3.cxx   |2 +-
 sc/source/ui/view/tabcont.cxx|3 +++
 4 files changed, 37 insertions(+), 6 deletions(-)

New commits:
commit 0a296eee23380275ec7bad1dff8d81b75d98429f
Author: Eike Rathke 
Date:   Thu Nov 3 23:20:44 2016 +0100

Resolves: tdf#103684 calculate status bar functions across sheets

Also trigger recalculation when additional sheets are selected or 
deselected.

Change-Id: I259396a3e30c5653ac252b7bb2eb6a0a9405d6cc
(cherry picked from commit 8d777f85eaff6af8896942590316b7cd9f2c3e75)
Reviewed-on: https://gerrit.libreoffice.org/30546
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 60c04d0..d11173c 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -108,10 +108,21 @@ public:
 ScMarkArray GetMarkArray( SCCOL nCol ) const;
 
 boolIsCellMarked( SCCOL nCol, SCROW nRow, bool bNoSimple = false ) 
const;
-voidFillRangeListWithMarks( ScRangeList* pList, bool bClear ) 
const;
+
+/** Create a range list of marks.
+@param  nForTab
+If -1, use start-sheet-tab of the multi-area in ranges.
+If >= 0, use given sheet-tab in ranges.
+ */
+voidFillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB 
nForTab = -1 ) const;
 voidExtendRangeListTables( ScRangeList* pList ) const;
 
 ScRangeList GetMarkedRanges() const;
+/** Get marked ranges with sheet-tab set to nTab.
+Marks are stored for the currently active sheet respectively the
+multi-area start-sheet-tab, update ranges with the sheet for which this
+is called. */
+ScRangeList GetMarkedRangesForTab( SCTAB nTab ) const;
 
 voidMarkFromRangeList( const ScRangeList& rList, bool bReset );
 
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index defbef2..4907252 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -355,7 +355,7 @@ void ScMarkData::MarkFromRangeList( const ScRangeList& 
rList, bool bReset )
 }
 }
 
-void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear ) 
const
+void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear, 
SCTAB nForTab ) const
 {
 if (!pList)
 return;
@@ -367,7 +367,7 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* 
pList, bool bClear ) const
 
 if ( bMultiMarked )
 {
-SCTAB nTab = aMultiRange.aStart.Tab();
+SCTAB nTab = (nForTab < 0 ? aMultiRange.aStart.Tab() : nForTab);
 
 SCCOL nStartCol = aMultiRange.aStart.Col();
 SCCOL nEndCol = aMultiRange.aEnd.Col();
@@ -402,7 +402,17 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* 
pList, bool bClear ) const
 }
 
 if ( bMarked )
-pList->Append( aMarkRange );
+{
+if (nForTab < 0)
+pList->Append( aMarkRange );
+else
+{
+ScRange aRange( aMarkRange );
+aRange.aStart.SetTab( nForTab );
+aRange.aEnd.SetTab( nForTab );
+pList->Append( aRange );
+}
+}
 }
 
 void ScMarkData::ExtendRangeListTables( ScRangeList* pList ) const
@@ -427,7 +437,14 @@ void ScMarkData::ExtendRangeListTables( ScRangeList* pList 
) const
 ScRangeList ScMarkData::GetMarkedRanges() const
 {
 ScRangeList aRet;
-FillRangeListWithMarks(, false);
+FillRangeListWithMarks(, false, -1);
+return aRet;
+}
+
+ScRangeList ScMarkData::GetMarkedRangesForTab( SCTAB nTab ) const
+{
+ScRangeList aRet;
+FillRangeListWithMarks(, false, nTab);
 return aRet;
 }
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index d0f4e09..5bf37f7 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -3374,7 +3374,7 @@ sal_Int32 ScTable::GetMaxNumberStringLen(
 
 void ScTable::UpdateSelectionFunction( ScFunctionData& rData, const 
ScMarkData& rMark )
 {
-ScRangeList aRanges = rMark.GetMarkedRanges();
+ScRangeList aRanges = rMark.GetMarkedRangesForTab( nTab );
 for (SCCOL nCol = 0; nCol <= MAXCOL && !rData.bError; ++nCol)
 {
 if (pColFlags && ColHidden(nCol))
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 9322520..b9c837c 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -287,6 +287,9 @@ void ScTabControl::Select()
 rBind.Invalidate( FID_TABLE_HIDE );
 rBind.Invalidate( FID_TAB_SET_TAB_BG_COLOR );
 
+// Recalculate status bar functions.
+rBind.Invalidate( SID_TABLE_CELL );
+
 // SetReference onlw when the consolidate dialog is open
 // (for referenzes over multiple sheets)
 // for 

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

2016-11-03 Thread Eike Rathke
 sc/inc/markdata.hxx   |2 
 sc/source/core/data/markdata.cxx  |5 +
 sc/source/ui/docshell/docfunc.cxx |   54 ---
 sc/source/ui/inc/docfunc.hxx  |5 +
 sc/source/ui/inc/undoblk.hxx  |   10 ++-
 sc/source/ui/undo/undoblk.cxx |  105 +++---
 sc/source/ui/unoobj/cellsuno.cxx  |2 
 sc/source/ui/view/viewfun2.cxx|2 
 sc/source/ui/view/viewfun3.cxx|4 -
 9 files changed, 131 insertions(+), 58 deletions(-)

New commits:
commit cd998b587f9956c1f4292d4db3200cc6c9320001
Author: Eike Rathke 
Date:   Wed Oct 26 14:50:43 2016 +0200

Resolves: tdf#92117 create only one Undo for all UnmergeCells() calls

... during DeleteCells() and InsertCells(), instead of one Undo per
UnmergeCells() call. And actually create Undo only if bRecord requested.

(cherry picked from commit 647e860435c781fbb111ae59bc70dc8e6776fed5)

 Conflicts:
sc/source/ui/docshell/docfunc.cxx
sc/source/ui/inc/docfunc.hxx
sc/source/ui/inc/undoblk.hxx
sc/source/ui/undo/undoblk.cxx

init ScUndoRemoveMerge with range, tdf#92117 follow-up

So the original selection is restored after Undo.

(cherry picked from commit 0ebe9fab18e732468d2b9d53dddf9f266411a0e5)

e549a0b62da469ee38270ae089ea5abf9a6868e3

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

diff --git a/sc/inc/markdata.hxx b/sc/inc/markdata.hxx
index 0392971..60c04d0 100644
--- a/sc/inc/markdata.hxx
+++ b/sc/inc/markdata.hxx
@@ -143,10 +143,12 @@ public:
 // iterators for table access
 typedef std::set::iterator iterator;
 typedef std::set::const_iterator const_iterator;
+typedef std::set::const_reverse_iterator const_reverse_iterator;
 iterator begin();
 iterator end();
 const_iterator begin() const;
 const_iterator end() const;
+const_reverse_iterator rbegin() const;
 };
 
 #endif
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 9cb5329..defbef2 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -814,4 +814,9 @@ ScMarkData::const_iterator ScMarkData::end() const
 return maTabMarked.end();
 }
 
+ScMarkData::const_reverse_iterator ScMarkData::rbegin() const
+{
+return maTabMarked.rbegin();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 6fe32df..8aacaad 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1790,6 +1790,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 OUString aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTCELLS );
 if (bRecord)
 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+std::unique_ptr pUndoRemoveMerge;
 
 itr = aMark.begin();
 for (; itr != itrEnd && nTabCount; ++itr)
@@ -1897,12 +1898,19 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, 
const ScMarkData* pTabMark,
 
 if( !qIncreaseRange.empty() )
 {
+if (bRecord && !pUndoRemoveMerge)
+{
+ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO 
);
+pUndoDoc->InitUndo( , *aMark.begin(), 
*aMark.rbegin());
+pUndoRemoveMerge.reset( new ScUndoRemoveMerge( 
, rRange, pUndoDoc ));
+}
+
 for( ::std::vector::const_iterator iIter( 
qIncreaseRange.begin()); iIter != qIncreaseRange.end(); ++iIter )
 {
 ScRange aRange( *iIter );
 if( rDoc.HasAttrib( aRange, HASATTR_OVERLAPPED | 
HASATTR_MERGED ) )
 {
-UnmergeCells( aRange, true );
+UnmergeCells( aRange, bRecord, 
pUndoRemoveMerge.get() );
 }
 }
 }
@@ -1918,6 +1926,11 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, 
const ScMarkData* pTabMark,
 }
 }
 
+if (bRecord && pUndoRemoveMerge)
+{
+rDocShell.GetUndoManager()->AddUndoAction( pUndoRemoveMerge.release());
+}
+
 switch (eCmd)
 {
 case INS_CELLSDOWN:
@@ -2218,6 +2231,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const 
ScMarkData* pTabMark,
 OUString aUndo = ScGlobal::GetRscString( STR_UNDO_DELETECELLS );
 if (bRecord)
 rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+std::unique_ptr pUndoRemoveMerge;
 
 itr = aMark.begin();
 for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -2327,12 

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

2016-10-26 Thread Eike Rathke
 sc/inc/externalrefmgr.hxx|3 +++
 sc/source/filter/oox/formulabuffer.cxx   |4 
 sc/source/ui/docshell/externalrefmgr.cxx |   12 
 3 files changed, 19 insertions(+)

New commits:
commit ef4051a295b76a5398e6c4a64bc0f8e1322291c7
Author: Eike Rathke 
Date:   Tue Oct 25 19:41:30 2016 +0200

Resolves: tdf#79442 in OOXML import add external files to LinkManager

Now that we store formula results without recalculating, the implicit
logic that adds files of external references to the LinkManager is not
triggered, explicitly force it during import.

Change-Id: Id867d2fa2b39841fb4c8e90941814457c8db431d
(cherry picked from commit 8464ea6961b9cc54af9c11cce1b80ed7e0cc77e2)
Reviewed-on: https://gerrit.libreoffice.org/30277
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index b9d1394..9577f9a 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -724,6 +724,9 @@ public:
 
 void enableDocTimer( bool bEnable );
 
+/** Add all known external files to the LinkManager. */
+void addFilesToLinkManager();
+
 private:
 ScExternalRefManager(const ScExternalRefManager&) = delete;
 
diff --git a/sc/source/filter/oox/formulabuffer.cxx 
b/sc/source/filter/oox/formulabuffer.cxx
index 14e3f45..d7a574e 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -435,6 +435,10 @@ void FormulaBuffer::finalizeImport()
 }
 }
 
+// With formula results being set and not recalculated we need to
+// force-trigger adding all linked external files to the LinkManager.
+rDoc.getDoc().GetExternalRefManager()->addFilesToLinkManager();
+
 rDoc.getDoc().SetAutoNameCache(nullptr);
 
 xFormulaBar->setPosition( 1.0 );
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx 
b/sc/source/ui/docshell/externalrefmgr.cxx
index dac47e5..59863f6 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2645,6 +2645,18 @@ void 
ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
 maLinkedDocs.insert(LinkedDocMap::value_type(nFileId, true));
 }
 
+void ScExternalRefManager::addFilesToLinkManager()
+{
+if (maSrcFiles.empty())
+return;
+
+SAL_WARN_IF( maSrcFiles.size() >= SAL_MAX_UINT16,
+"sc.ui", "ScExternalRefManager::addFilesToLinkManager: files 
overflow");
+const sal_uInt16 nSize = static_cast( std::max( 
maSrcFiles.size(), SAL_MAX_UINT16));
+for (sal_uInt16 nFileId = 0; nFileId < nSize; ++nFileId)
+maybeLinkExternalFile( nFileId);
+}
+
 void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const 
OUString& rOwnDocName)
 {
 if (maRelativeName.isEmpty())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-10-04 Thread Markus Mohrhard
 sc/inc/rangelst.hxx  |2 +-
 sc/source/core/tool/rangelst.cxx |   22 +++---
 2 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 685071d10a4cbe556b0c83342b18aeb97dc878fd
Author: Markus Mohrhard 
Date:   Sat Oct 1 01:31:09 2016 +0200

tdf#101910, mark ScRangeList updated when DeleteArea was used

Change-Id: I98390b28c5a1bbbd391ff054b2f574951c7c00c4
Reviewed-on: https://gerrit.libreoffice.org/29422
Reviewed-by: Markus Mohrhard 
Tested-by: Jenkins 
(cherry picked from commit 5f658dc87794036182aa1f8586d82c5ee997cd8b)
Reviewed-on: https://gerrit.libreoffice.org/29424
Reviewed-by: Eike Rathke 

diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 2641483..996124f 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -62,7 +62,7 @@ public:
 /** For now this method assumes that nTab1 == nTab2
  * The algorithm will be much more complicated if nTab1 != nTab2
  */
-voidDeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL 
nCol2,
+boolDeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL 
nCol2,
 SCROW nRow2, SCTAB nTab2 );
 
 const ScRange*  Find( const ScAddress& ) const;
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index daa2ffe..a59c483 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -398,11 +398,11 @@ bool ScRangeList::UpdateReference(
 {
 if(nDx < 0)
 {
-DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow2, nTab2);
+bChanged = DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow2, 
nTab2);
 }
 if(nDy < 0)
 {
-DeleteArea(nCol1, nRow1+nDy, nTab1, nCol2, nRow1-1, nTab2);
+bChanged = DeleteArea(nCol1, nRow1+nDy, nTab1, nCol2, nRow1-1, 
nTab2);
 }
 SAL_WARN_IF(nDx < 0 && nDy < 0, "sc", "nDx and nDy are negative, 
check why");
 }
@@ -940,9 +940,10 @@ bool handleFourRanges( const ScRange& rDelRange, ScRange* 
p, std::vector= p.aEnd.X()
 // && ( r.aStart.Y() <= p.aStart.Y() || r.aEnd.Y() >= r.aEnd.Y() )
 if(handleOneRange( aRange, *itr ))
+{
+bChanged = true;
 continue;
+}
 
 // getting two ranges
 // r.aStart.X()
 else if(handleTwoRanges( aRange, *itr, aNewRanges ))
+{
+bChanged = true;
 continue;
+}
 
 // getting 3 ranges
 // r.aStart.X() > p.aStart.X() && r.aEnd.X() >= p.aEnd.X()
@@ -989,16 +997,24 @@ void ScRangeList::DeleteArea( SCCOL nCol1, SCROW nRow1, 
SCTAB nTab1,
 // r.aStart.X() <= p.aStart.X() && r.aEnd.X() < p.aEnd.X()
 // && r.aStart.Y() > p.aStart.Y() && r.aEnd.Y() < p.aEnd.Y()
 else if(handleThreeRanges( aRange, *itr, aNewRanges ))
+{
+bChanged = true;
 continue;
+}
 
 // getting 4 ranges
 // r.aStart.X() > p.aStart.X() && r.aEnd().X() < p.aEnd.X()
 // && r.aStart.Y() > p.aStart.Y() && r.aEnd().Y() < p.aEnd.Y()
 else if(handleFourRanges( aRange, *itr, aNewRanges ))
+{
+bChanged = true;
 continue;
+}
 }
 for(vector::iterator itr = aNewRanges.begin(); itr != 
aNewRanges.end(); ++itr)
 Join( *itr);
+
+return bChanged;
 }
 
 const ScRange* ScRangeList::Find( const ScAddress& rAdr ) 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-2' - sc/inc sc/source

2016-08-23 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |   10 ++-
 sc/source/core/tool/scmatrix.cxx |   82 +--
 sc/source/ui/docshell/externalrefmgr.cxx |6 +-
 3 files changed, 80 insertions(+), 18 deletions(-)

New commits:
commit aee6678b0fcc28ce0accd1429b525af95346a6b2
Author: Eike Rathke 
Date:   Tue Aug 23 00:28:33 2016 +0200

Resolves: tdf#101137 handle empty elements in matrix concatenation

Change-Id: I2de90e1cdfc4f215f6d7c644e0ab74372a4c2639
(cherry picked from commit 31d39c24e1ff2d3602e0212cd8de88da6d38)
Reviewed-on: https://gerrit.libreoffice.org/28335
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index a5c810f..62cddee 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -127,6 +127,7 @@ public:
 typedef std::function DoubleOpFunction;
 typedef std::function BoolOpFunction;
 typedef std::function 
StringOpFunction;
+typedef std::function EmptyOpFunction;
 
 /**
  * When adding all numerical matrix elements for a scalar result such as
@@ -407,7 +408,8 @@ public:
 virtual std::vector Collect(bool bTextAsZero, 
const std::vector& aOp) = 0;
 
 virtual void ExecuteOperation(const std::pair& rStartPos, 
const std::pair& rEndPos,
-DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc) const = 0;
+DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc,
+EmptyOpFunction aEmptyFunc) const = 0;
 
 virtual void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& 
xMat1, const ScMatrixRef& xMat2,
 SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool) = 0;
@@ -620,7 +622,8 @@ public:
 virtual std::vector Collect(bool bTextAsZero, 
const std::vector& aOp) override;
 
 virtual void ExecuteOperation(const std::pair& rStartPos, 
const std::pair& rEndPos,
-DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc) const override;
+DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc,
+EmptyOpFunction aEmptyFunc) const override;
 ScFullMatrix& operator+= ( const ScFullMatrix& r );
 
 virtual void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& 
xMat1, const ScMatrixRef& xMat2,
@@ -835,7 +838,8 @@ public:
 virtual std::vector Collect(bool bTextAsZero, 
const std::vector& aOp) override;
 
 virtual void ExecuteOperation(const std::pair& rStartPos, 
const std::pair& rEndPos,
-DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc) const override;
+DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, 
StringOpFunction aStringFunc,
+EmptyOpFunction aEmptyFunc) const override;
 
 ScVectorRefMatrix& operator+=(const ScVectorRefMatrix& r);
 
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9dfc2e5..0974143 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -317,7 +317,8 @@ public:
 
 void ExecuteOperation(const std::pair& rStartPos,
 const std::pair& rEndPos, const 
ScFullMatrix::DoubleOpFunction& aDoubleFunc,
-const ScFullMatrix::BoolOpFunction& aBoolFunc, const 
ScFullMatrix::StringOpFunction& aStringFunc) const;
+const ScFullMatrix::BoolOpFunction& aBoolFunc, const 
ScFullMatrix::StringOpFunction& aStringFunc,
+const ScFullMatrix::EmptyOpFunction& aEmptyFunc) const;
 
 template
 std::vector ApplyCollectOperation(bool 
bTextAsZero, const std::vector& aOp);
@@ -2254,13 +2255,15 @@ public:
 WalkElementBlockOperation(size_t nRowSize, size_t /*nColSize*/,
 ScFullMatrix::DoubleOpFunction aDoubleFunc,
 ScFullMatrix::BoolOpFunction aBoolFunc,
-ScFullMatrix::StringOpFunction aStringFunc):
+ScFullMatrix::StringOpFunction aStringFunc,
+ScFullMatrix::EmptyOpFunction aEmptyFunc):
 mnRowSize(nRowSize),
 mnRowPos(0),
 mnColPos(0),
 maDoubleFunc(aDoubleFunc),
 maBoolFunc(aBoolFunc),
-maStringFunc(aStringFunc)
+maStringFunc(aStringFunc),
+maEmptyFunc(aEmptyFunc)
 {
 }
 
@@ -2328,8 +2331,32 @@ public:
 }
 }
 break;
-case mdds::mtm::element_integer:
 case mdds::mtm::element_empty:
+{
+for (size_t i=0; i < 

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

2016-07-27 Thread Caolán McNamara
 sc/inc/postit.hxx  |2 ++
 sc/source/core/data/postit.cxx |9 +
 sc/source/core/data/table6.cxx |   23 +++
 3 files changed, 30 insertions(+), 4 deletions(-)

New commits:
commit a2890a3fcdfcbf2447871ebc23db47864dd5b215
Author: Caolán McNamara 
Date:   Wed Jul 27 11:32:49 2016 +0100

Resolves: tdf#65334 cannot search in cell notes

regression since...

commit c06dbbe7594c2a0b5a5b19f8e183d9c421e6e094
Author: Markus Mohrhard 
Date:   Thu Feb 23 23:36:49 2012 +0100

remove mpNote from ScBaseCell

and requires restoring some code subsequently removed in

commit a1a1131c16227327d17bcf5ad2a5209ddc0f01a1
Date:   Sun Mar 4 15:27:27 2012 +0800

Remove unused code

Change-Id: If931c3162cacaeb126e730e3e79c1c47be4ce434
(cherry picked from commit 7c84a219e3cc8d623826343f547ba8adacca6d56)
Reviewed-on: https://gerrit.libreoffice.org/27577
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
Tested-by: Jenkins 

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 8a7dec8..fb962442 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -118,6 +118,8 @@ public:
 
 /** Returns the caption text of this note. */
 OUString GetText() const;
+/** Returns true, if the caption text of this note contains line breaks. */
+boolHasMultiLineText() const;
 /** Changes the caption text of this note. All text formatting will be 
lost. */
 voidSetText( const ScAddress& rPos, const OUString& rText 
);
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 8eb8331..64f47a5 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -562,6 +562,15 @@ OUString ScPostIt::GetText() const
 return OUString();
 }
 
+bool ScPostIt::HasMultiLineText() const
+{
+if( const EditTextObject* pEditObj = GetEditTextObject() )
+return pEditObj->GetParagraphCount() > 1;
+if( maNoteData.mxInitData.get() )
+return maNoteData.mxInitData->maSimpleText.indexOf( '\n' ) >= 0;
+return false;
+}
+
 void ScPostIt::SetText( const ScAddress& rPos, const OUString& rText )
 {
 CreateCaptionFromInitData( rPos );
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 2c63ed4..b5a4499 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -73,6 +73,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, SCROW nRo
 return false;
 
 bool bMultiLine = false;
+ScPostIt* pNote = nullptr;
 CellType eCellType = aCell.meType;
 switch (rSearchItem.GetCellType())
 {
@@ -89,8 +90,8 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, SCROW nRo
 else
 aCol[nCol].GetString( nRow, aString );
 }
+break;
 }
-break;
 case SvxSearchCellType::VALUE:
 if ( eCellType == CELLTYPE_EDIT )
 bMultiLine = lcl_GetTextWithBreaks(*aCell.mpEditText, 
pDocument, aString);
@@ -103,7 +104,15 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, SCROW nRo
 }
 break;
 case SvxSearchCellType::NOTE:
-break; // don't search this case here
+{
+pNote = aCol[nCol].GetCellNote(nRow);
+if (pNote)
+{
+aString = pNote->GetText();
+bMultiLine = pNote->HasMultiLineText();
+}
+break;
+}
 default:
 break;
 }
@@ -212,8 +221,14 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, SCROW nRo
 }
 }
 while (bRepeat);
-
-if ( cMatrixFlag != MM_NONE )
+if (rSearchItem.GetCellType() == SvxSearchCellType::NOTE)
+{
+// NB: rich text format is lost.
+// This is also true of Cells.
+if (pNote)
+pNote->SetText( ScAddress( nCol, nRow, nTab ), aString );
+}
+else if ( cMatrixFlag != MM_NONE )
 {   // don't split Matrix
 if ( aString.getLength() > 2 )
 {   // remove {} here so that "{=" can be replaced by "{=..."
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-06-15 Thread Eike Rathke
 sc/inc/scmatrix.hxx  |6 +
 sc/source/core/tool/scmatrix.cxx |   45 ++-
 2 files changed, 41 insertions(+), 10 deletions(-)

New commits:
commit 56c916992276baf374664d0bfca4181919b849f5
Author: Eike Rathke 
Date:   Wed Jun 15 16:28:44 2016 +0200

introduce ScMatrix::GetDoubleWithStringConversion() preparing for tdf#100409

... as GetDouble() returns 0.0 for any string and we don't want to
change that, most relevant places already check for numeric/text
beforehand.

Change-Id: Ifbc04e892f6f504040026042faa38674ced880fb
(cherry picked from commit 481b8589d135baced12469bec4ee734b23faac21)
Reviewed-on: https://gerrit.libreoffice.org/26333
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index aacb9ce..a5c810f 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -306,6 +306,8 @@ public:
 virtual double GetDouble( SCSIZE nC, SCSIZE nR) const = 0;
 /// @return 0.0 if empty or empty path, else value or DoubleError.
 virtual double GetDouble( SCSIZE nIndex) const = 0;
+/// @return value or DoubleError or string converted to value.
+virtual double GetDoubleWithStringConversion( SCSIZE nC, SCSIZE nR ) const 
= 0;
 
 /// @return empty string if empty or empty path, else string content.
 virtual svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const = 0;
@@ -517,6 +519,8 @@ public:
 virtual double GetDouble( SCSIZE nC, SCSIZE nR) const override;
 /// @return 0.0 if empty or empty path, else value or DoubleError.
 virtual double GetDouble( SCSIZE nIndex) const override;
+/// @return value or DoubleError or string converted to value.
+virtual double GetDoubleWithStringConversion( SCSIZE nC, SCSIZE nR ) const 
override;
 
 /// @return empty string if empty or empty path, else string content.
 virtual svl::SharedString GetString( SCSIZE nC, SCSIZE nR) const override;
@@ -731,6 +735,8 @@ public:
 virtual double GetDouble(SCSIZE nC, SCSIZE nR) const override;
 /// @return 0.0 if empty or empty path, else value or DoubleError.
 virtual double GetDouble(SCSIZE nIndex) const override;
+/// @return value or DoubleError or string converted to value.
+virtual double GetDoubleWithStringConversion( SCSIZE nC, SCSIZE nR ) const 
override;
 
 /// @return empty string if empty or empty path, else string content.
 virtual svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const override;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 4aa0993..4a3aaf2 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -69,6 +69,20 @@ typedef mdds::multi_type_matrix MatrixImplType;
 
 namespace {
 
+double convertStringToValue( ScInterpreter* pErrorInterpreter, const OUString& 
rStr )
+{
+if (pErrorInterpreter)
+{
+sal_uInt16 nError = 0;
+short nCurFmtType = 0;
+double fValue = pErrorInterpreter->ConvertStringToValue( rStr, nError, 
nCurFmtType);
+if (nError)
+return formula::CreateDoubleError( nError);
+return fValue;
+}
+return formula::CreateDoubleError( formula::errNoValue);
+}
+
 struct ElemEqualZero : public unary_function
 {
 double operator() (double val) const
@@ -244,6 +258,7 @@ public:
 sal_uInt16 GetError( SCSIZE nC, SCSIZE nR) const;
 double GetDouble(SCSIZE nC, SCSIZE nR) const;
 double GetDouble( SCSIZE nIndex) const;
+double GetDoubleWithStringConversion(SCSIZE nC, SCSIZE nR) const;
 svl::SharedString GetString(SCSIZE nC, SCSIZE nR) const;
 svl::SharedString GetString( SCSIZE nIndex) const;
 svl::SharedString GetString( SvNumberFormatter& rFormatter, SCSIZE nC, 
SCSIZE nR) const;
@@ -560,6 +575,14 @@ double ScMatrixImpl::GetDouble( SCSIZE nIndex) const
 return GetDouble(nC, nR);
 }
 
+double ScMatrixImpl::GetDoubleWithStringConversion(SCSIZE nC, SCSIZE nR) const
+{
+ScMatrixValue aMatVal = Get(nC, nR);
+if (aMatVal.nType == SC_MATVAL_STRING)
+return convertStringToValue( pErrorInterpreter, 
aMatVal.aStr.getString());
+return aMatVal.fVal;
+}
+
 svl::SharedString ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const
 {
 if (ValidColRowOrReplicated( nC, nR ))
@@ -2734,6 +2757,11 @@ double ScFullMatrix::GetDouble( SCSIZE nIndex) const
 return pImpl->GetDouble(nIndex);
 }
 
+double ScFullMatrix::GetDoubleWithStringConversion(SCSIZE nC, SCSIZE nR) const
+{
+return pImpl->GetDoubleWithStringConversion(nC, nR);
+}
+
 svl::SharedString ScFullMatrix::GetString(SCSIZE nC, SCSIZE nR) const
 {
 return pImpl->GetString(nC, nR);
@@ -3034,16 +3062,7 @@ public:
 
 double operator()(const svl::SharedString& rStr) const
 {
-if (mpErrorInterpreter)
-{
-sal_uInt16 nError = 0;
-short 

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

2016-06-10 Thread Noel Grandin
 sc/inc/orcusxml.hxx   |5 +++--
 sc/source/filter/orcus/xmlcontext.cxx |   27 ++-
 2 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit 895468d7388ee17ba33804f19bad52933312ae5d
Author: Noel Grandin 
Date:   Thu Jun 9 14:46:17 2016 +0200

tdf#100257 - Data : XML Source does not work

Revert "sc: boost::ptr_vector->std::vector"
This reverts commit 280553e30f4ddc932838f98a9efaac03a988a0df.

Reviewed-on: https://gerrit.libreoffice.org/26106
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 
(cherry picked from commit d6a6f587a852ba5c993c658b6b6432a65207f5b7)

sc: eeek, a boost::ptr_vector! take it off! take it off!
(cherry picked from commit 741077bf1cdb0c9240ee3e90f07a42bef5bb7a8f)

Change-Id: Ia50c9cf7902e2e830c6e7f7a13c8f04341556e6c
Reviewed-on: https://gerrit.libreoffice.org/26150
Reviewed-by: Noel Grandin 
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sc/inc/orcusxml.hxx b/sc/inc/orcusxml.hxx
index e16029c..9d803ef 100644
--- a/sc/inc/orcusxml.hxx
+++ b/sc/inc/orcusxml.hxx
@@ -15,6 +15,7 @@
 #include 
 
 #include 
+#include 
 
 class SvTreeListEntry;
 
@@ -37,7 +38,7 @@ struct ScOrcusXMLTreeParam
 SC_DLLPUBLIC EntryData(EntryType eType);
 };
 
-typedef std::vector EntryDataVec;
+typedef std::vector UserDataStoreType;
 
 Image maImgElementDefault;
 Image maImgElementRepeat;
@@ -47,7 +48,7 @@ struct ScOrcusXMLTreeParam
  * Store all custom data instances since the tree control doesn't manage
  * the life cycle of user datas.
  */
-EntryDataVec maUserDataStore;
+UserDataStoreType m_UserDataStore;
 
 static SC_DLLPUBLIC EntryData* getUserData(SvTreeListEntry& rEntry);
 static SC_DLLPUBLIC const EntryData* getUserData(const SvTreeListEntry& 
rEntry);
diff --git a/sc/source/filter/orcus/xmlcontext.cxx 
b/sc/source/filter/orcus/xmlcontext.cxx
index 0839720..6064565 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -34,11 +35,18 @@ using namespace com::sun::star;
 namespace {
 
 ScOrcusXMLTreeParam::EntryData& setUserDataToEntry(
-SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::EntryDataVec& rStore, 
ScOrcusXMLTreeParam::EntryType eType)
+SvTreeListEntry& rEntry, ScOrcusXMLTreeParam::UserDataStoreType& rStore, 
ScOrcusXMLTreeParam::EntryType eType)
 {
-rStore.push_back(ScOrcusXMLTreeParam::EntryData(eType));
-rEntry.SetUserData(());
-return rStore.back();
+rStore.push_back(o3tl::make_unique(eType));
+rEntry.SetUserData(rStore.back().get());
+return *rStore.back();
+}
+
+void setEntityNameToUserData(
+ScOrcusXMLTreeParam::EntryData& rEntryData,
+const orcus::xml_structure_tree::entity_name& entity, const 
orcus::xml_structure_tree::walker& walker)
+{
+rEntryData.mnNamespaceID = walker.get_xmlns_index(entity.ns);
 }
 
 OUString toString(const orcus::xml_structure_tree::entity_name& entity, const 
orcus::xml_structure_tree::walker& walker)
@@ -66,9 +74,10 @@ void populateTree(
 return;
 
 ScOrcusXMLTreeParam::EntryData& rEntryData = setUserDataToEntry(
-*pEntry, rParam.maUserDataStore,
+*pEntry, rParam.m_UserDataStore,
 bRepeat ? ScOrcusXMLTreeParam::ElementRepeat : 
ScOrcusXMLTreeParam::ElementDefault);
-rEntryData.mnNamespaceID = rWalker.get_xmlns_index(rElemName.ns);
+
+setEntityNameToUserData(rEntryData, rElemName, rWalker);
 
 if (bRepeat)
 {
@@ -95,8 +104,8 @@ void populateTree(
 continue;
 
 ScOrcusXMLTreeParam::EntryData& rAttrData =
-setUserDataToEntry(*pAttr, rParam.maUserDataStore, 
ScOrcusXMLTreeParam::Attribute);
-rAttrData.mnNamespaceID = rWalker.get_xmlns_index(rAttrName.ns);
+setUserDataToEntry(*pAttr, rParam.m_UserDataStore, 
ScOrcusXMLTreeParam::Attribute);
+setEntityNameToUserData(rAttrData, rAttrName, rWalker);
 
 rTreeCtrl.SetExpandedEntryBmp(pAttr, rParam.maImgAttribute);
 rTreeCtrl.SetCollapsedEntryBmp(pAttr, rParam.maImgAttribute);
@@ -172,7 +181,7 @@ ScOrcusXMLContextImpl::~ScOrcusXMLContextImpl() {}
 
 void ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, 
ScOrcusXMLTreeParam& rParam)
 {
-rParam.maUserDataStore.clear();
+rParam.m_UserDataStore.clear();
 
 std::string aStrm;
 loadContentFromURL(maPath, aStrm);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-06-03 Thread Caolán McNamara
 sc/inc/document.hxx |4 ++--
 sc/source/core/data/column2.cxx |2 +-
 sc/source/core/data/document.cxx|4 ++--
 sc/source/core/data/grouptokenconverter.cxx |   18 ++
 sc/source/core/inc/grouptokenconverter.hxx  |1 +
 5 files changed, 24 insertions(+), 5 deletions(-)

New commits:
commit 57f8094fd312114d670ac4cdbdfd18b80b2c67e5
Author: Caolán McNamara 
Date:   Thu Jun 2 11:18:02 2016 +0100

Resolves: tdf#98880 ensure backing context of DoubleVectorRefToken...

exists for the lifetime of the ScGroupTokenConverter

otherwise in tdf#98880 ScDocument::InterpretDirtyCells releases
that backing storage that the DoubleVectorRefToken relies on, and
the ScVectorRefMatrix relies on that, so...

when sc/source/core/tool/interpr4.cxx calls ::IsString on the 
ScVectorRefMatrix
which calls ensureFullMatrix. That makes use of rArray.mpStringArray where
rArray's mpStringArray is set to that rArray by
FormulaGroupContext::ensureStrArray and the storage of mpStringArray 
belongs to
the FormulaGroupContext, but that context was reset and destroyed up the 
stack
in ScDocument::InterpretDirtyCells so the data is now invalid

We could turn the unique_ptr into a shared_ptr and have the 
ScGroupTokenConverter
take a ref to the currently active FormulaGroupContext to ensure any 
generated
DoubleVectorRefToken/SingleVectorRefToken point to valid data during the
lifetime of the ScGroupTokenConverter

Change-Id: Id457934cdff18570961cb261cf5c46b6ef8ea083
Reviewed-on: https://gerrit.libreoffice.org/25815
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
(cherry picked from commit dc78e5c6f5f55b0289012f4c4e6013d2935b1cc6)
Reviewed-on: https://gerrit.libreoffice.org/25866
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5696f26..b17296e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -299,7 +299,7 @@ private:
 rtl::Reference xPoolHelper;
 
 std::shared_ptr mpCellStringPool;
-std::unique_ptr mpFormulaGroupCxt;
+std::shared_ptr mpFormulaGroupCxt;
 mutable std::unique_ptr mpDocLinkMgr;
 
 ScCalcConfigmaCalcConfig;
@@ -1050,7 +1050,7 @@ public:
 
 svl::SharedString GetSharedString( const ScAddress& rPos ) const;
 
-sc::FormulaGroupContext& GetFormulaGroupContext();
+std::shared_ptr& GetFormulaGroupContext();
 
 SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, 
OUString& rString );
 sal_uInt16 GetStringForFormula( const ScAddress& rPos, OUString& rString );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 19a7aed..a32b2f7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2560,7 +2560,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( 
SCROW nRow1, SCROW nRow2
 return formula::VectorRefArray(formula::VectorRefArray::Invalid);
 
 // See if the requested range is already cached.
-sc::FormulaGroupContext& rCxt = pDocument->GetFormulaGroupContext();
+sc::FormulaGroupContext& rCxt = *(pDocument->GetFormulaGroupContext());
 sc::FormulaGroupContext::ColArray* pColArray = 
rCxt.getCachedColArray(nTab, nCol, nRow2+1);
 if (pColArray)
 {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f5ad18c..1ae8454 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3443,12 +3443,12 @@ svl::SharedString ScDocument::GetSharedString( const 
ScAddress& rPos ) const
 return maTabs[rPos.Tab()]->GetSharedString(rPos.Col(), rPos.Row());
 }
 
-sc::FormulaGroupContext& ScDocument::GetFormulaGroupContext()
+std::shared_ptr& ScDocument::GetFormulaGroupContext()
 {
 if (!mpFormulaGroupCxt)
 mpFormulaGroupCxt.reset(new sc::FormulaGroupContext);
 
-return *mpFormulaGroupCxt;
+return mpFormulaGroupCxt;
 }
 
 void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& 
rString )
diff --git a/sc/source/core/data/grouptokenconverter.cxx 
b/sc/source/core/data/grouptokenconverter.cxx
index da3964c..22b89a6 100644
--- a/sc/source/core/data/grouptokenconverter.cxx
+++ b/sc/source/core/data/grouptokenconverter.cxx
@@ -135,6 +135,15 @@ bool ScGroupTokenConverter::convert(ScTokenArray& rCode)
 
 formula::SingleVectorRefToken aTok(aArray, nLen, nTrimLen);
 mrGroupTokens.AddToken(aTok);
+
+if (nTrimLen && !mxFormulaGroupContext)
+{
+//tdf#98880 if the SingleVectorRefToken relies on the
+//underlying storage provided by the Document
+   

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

2016-05-30 Thread Eike Rathke
 sc/inc/document.hxx|2 +-
 sc/source/core/data/document.cxx   |2 +-
 sc/source/core/data/document10.cxx |7 +++
 3 files changed, 5 insertions(+), 6 deletions(-)

New commits:
commit dd38581b787f357ee88da7dfabeb596a894b5afe
Author: Eike Rathke 
Date:   Mon May 30 20:04:25 2016 +0200

actually multiple destination sheets are handled, tdf#97158 follow-up

... so ScMarkData doesn't need to be passed. Which it wasn't anyway
because the destination sheet span is part of CopyFromClipContext.

Change-Id: I0addd370d96ab78b22ed957081a1212fc70419a1
(cherry picked from commit 9d07f557572bdeaeda8e923525c8895d79fc0d22)
Reviewed-on: https://gerrit.libreoffice.org/25685
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 01eadaf..5696f26 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1419,7 +1419,7 @@ public:
 sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, 
sc::ColumnSpanSet& rBroadcastSpans );
 
 bool CopyOneCellFromClip(
-sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
+sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 );
 void CopyBlockFromClip(
 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
 const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 224908d..f5ad18c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2806,7 +2806,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, 
const ScMarkData& rMar
 else
 DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag, false, 
);
 
-if (CopyOneCellFromClip(aCxt, rMark, nCol1, nRow1, nCol2, nRow2))
+if (CopyOneCellFromClip(aCxt, nCol1, nRow1, nCol2, nRow2))
 continue;
 
 SCCOL nC1 = nCol1;
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index e99d0b4..6363265 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -65,7 +65,7 @@ void ScDocument::DeleteBeforeCopyFromClip(
 }
 
 bool ScDocument::CopyOneCellFromClip(
-sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW nRow2 )
+sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 )
 {
 ScDocument* pClipDoc = rCxt.getClipDoc();
 if (pClipDoc->GetClipParam().mbCutMode)
@@ -82,9 +82,8 @@ bool ScDocument::CopyOneCellFromClip(
 if (nDestColSize < nSrcColSize)
 return false;
 
-if (rCxt.getClipDoc()->maTabs.size() > 1 || rMark.GetSelectCount() > 1)
-// Copying from multiple source sheets or to multiple destination
-// sheets is not handled here.
+if (rCxt.getClipDoc()->maTabs.size() > 1)
+// Copying from multiple source sheets is not handled here.
 return false;
 
 ScAddress aSrcPos = aClipRange.aStart;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2016-05-30 Thread Eike Rathke
 sc/inc/document.hxx|2 +-
 sc/source/core/data/document.cxx   |2 +-
 sc/source/core/data/document10.cxx |7 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 800920a7b0600b1677d231c514345fe9f6687d82
Author: Eike Rathke 
Date:   Mon May 30 18:30:48 2016 +0200

Resolves: tdf#97158 CopyOneCellFromClip() does not handle multiple sheets

... so check that and bail out to let the remainder of CopyFromClip()
handle it.

Change-Id: I9d139de905fd108ae41fed79a38860058525272c
(cherry picked from commit dc9eac5a5f4f247ba5efb67931ffde61f2c8d5b6)
Reviewed-on: https://gerrit.libreoffice.org/25678
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5696f26..01eadaf 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1419,7 +1419,7 @@ public:
 sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, 
sc::ColumnSpanSet& rBroadcastSpans );
 
 bool CopyOneCellFromClip(
-sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 );
+sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, SCCOL nCol1, 
SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
 void CopyBlockFromClip(
 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2,
 const ScMarkData& rMark, SCsCOL nDx, SCsROW nDy );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index f5ad18c..224908d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2806,7 +2806,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, 
const ScMarkData& rMar
 else
 DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag, false, 
);
 
-if (CopyOneCellFromClip(aCxt, nCol1, nRow1, nCol2, nRow2))
+if (CopyOneCellFromClip(aCxt, rMark, nCol1, nRow1, nCol2, nRow2))
 continue;
 
 SCCOL nC1 = nCol1;
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 59aff13..e99d0b4 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -65,7 +65,7 @@ void ScDocument::DeleteBeforeCopyFromClip(
 }
 
 bool ScDocument::CopyOneCellFromClip(
-sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 )
+sc::CopyFromClipContext& rCxt, const ScMarkData& rMark, SCCOL nCol1, SCROW 
nRow1, SCCOL nCol2, SCROW nRow2 )
 {
 ScDocument* pClipDoc = rCxt.getClipDoc();
 if (pClipDoc->GetClipParam().mbCutMode)
@@ -82,6 +82,11 @@ bool ScDocument::CopyOneCellFromClip(
 if (nDestColSize < nSrcColSize)
 return false;
 
+if (rCxt.getClipDoc()->maTabs.size() > 1 || rMark.GetSelectCount() > 1)
+// Copying from multiple source sheets or to multiple destination
+// sheets is not handled here.
+return false;
+
 ScAddress aSrcPos = aClipRange.aStart;
 
 for (SCCOL nCol = aClipRange.aStart.Col(); nCol <= aClipRange.aEnd.Col(); 
++nCol)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits