summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-08-06 00:15:10 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-12 19:46:24 -0400
commit417d1c2b13cbd70300d2921b5667dfadc7e25895 (patch)
tree84ff1312837d2ce818c48dd4d868a89ce8b36e49 /sc/source/core/data
parent71c3df6576038df6d519982e7d2367e803574368 (diff)
Map shared formula from xls to formula groups, and share the tokens as well.
No more mapping to range names. Change-Id: Ic43b6ef35a91fe4d6fff748ebc22969ba4e036db
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/column3.cxx25
-rw-r--r--sc/source/core/data/documen2.cxx8
-rw-r--r--sc/source/core/data/formulacell.cxx12
-rw-r--r--sc/source/core/data/table2.cxx8
4 files changed, 45 insertions, 8 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 4474aecebd39..461193c77267 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -381,16 +381,17 @@ sc::CellStoreType::iterator ScColumn::GetPositionToInsert( const sc::CellStoreTy
}
void ScColumn::ActivateNewFormulaCell(
- const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell )
+ const sc::CellStoreType::iterator& itPos, SCROW nRow, ScFormulaCell& rCell, bool bJoin )
{
- ActivateNewFormulaCell(maCells.position(itPos, nRow), rCell);
+ ActivateNewFormulaCell(maCells.position(itPos, nRow), rCell, bJoin);
}
void ScColumn::ActivateNewFormulaCell(
- const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell )
+ const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell, bool bJoin )
{
- // See if this new formula cell can join an existing shared formula group.
- JoinNewFormulaCell(aPos, rCell);
+ if (bJoin)
+ // See if this new formula cell can join an existing shared formula group.
+ JoinNewFormulaCell(aPos, rCell);
// When we insert from the Clipboard we still have wrong (old) References!
// First they are rewired in CopyBlockFromClip via UpdateReference and the
@@ -1729,6 +1730,20 @@ ScFormulaCell* ScColumn::SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCR
return pCell;
}
+bool ScColumn::SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell )
+{
+ sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
+ sal_uInt32 nCellFormat = GetNumberFormat(nRow);
+ if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+ pCell->SetNeedNumberFormat(true);
+ it = maCells.set(it, nRow, pCell);
+ maCellTextAttrs.set(nRow, sc::CellTextAttr());
+ CellStorageModified();
+
+ ActivateNewFormulaCell(it, nRow, *pCell, false);
+ return true;
+}
+
namespace {
class FilterEntriesHandler
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 7a9e9d6106ae..720b504b6e61 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1075,6 +1075,14 @@ ScFormulaCell* ScDocument::SetFormulaCell( const ScAddress& rPos, ScFormulaCell*
return maTabs[rPos.Tab()]->SetFormulaCell(rPos.Col(), rPos.Row(), pCell);
}
+bool ScDocument::SetGroupFormulaCell( const ScAddress& rPos, ScFormulaCell* pCell )
+{
+ if (!TableExists(rPos.Tab()))
+ return false;
+
+ return maTabs[rPos.Tab()]->SetGroupFormulaCell(rPos.Col(), rPos.Row(), pCell);
+}
+
void ScDocument::SetConsolidateDlgData( const ScConsolidateParam* pData )
{
delete pConsolidateDlgData;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index cdedb660bc9f..b9db55ab74ee 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -397,6 +397,14 @@ ScFormulaCellGroup::~ScFormulaCellGroup()
delete mpCode;
}
+void ScFormulaCellGroup::setCode( const ScTokenArray& rCode )
+{
+ delete mpCode;
+ mpCode = rCode.Clone();
+ mbInvariant = mpCode->IsInvariant();
+ mpCode->GenHash();
+}
+
// ============================================================================
ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
@@ -522,8 +530,6 @@ ScFormulaCell::ScFormulaCell(
if (bSubTotal)
pDocument->AddSubTotalCell(this);
-
- pCode->GenHash();
}
ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, const ScAddress& rPos, int nCloneFlags ) :
@@ -3358,7 +3364,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
// Re-build formulae groups if necessary - ideally this is done at
// import / insert / delete etc. and is integral to the data structures
- pDocument->RebuildFormulaGroups();
+// pDocument->RebuildFormulaGroups();
if (!mxGroup || !pCode)
return false;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 278096ebf259..537f85654082 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1453,6 +1453,14 @@ ScFormulaCell* ScTable::SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* p
return aCol[nCol].SetFormulaCell(nRow, pCell);
}
+bool ScTable::SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell )
+{
+ if (!ValidColRow(nCol, nRow))
+ return false;
+
+ return aCol[nCol].SetGroupFormulaCell(nRow, pCell);
+}
+
void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )
{
if (ValidColRow(nCol, nRow))