summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-05-24 22:41:44 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-06-02 03:25:49 +0200
commit57efd69c22e2c6f5cb4d057345644b6e07a62d48 (patch)
tree768a5ed0f68f5c3a7fe2a0efe5aecca1e666953d
parentfda007e69f16aaebe81ee7b9ac8ea4742801bb85 (diff)
remove inherited number formats, related fdo#60215
Change-Id: I23d5e1b3baeb1499ada1fba1665027bdbe3fbb87
-rw-r--r--sc/inc/formulacell.hxx2
-rw-r--r--sc/source/core/data/column.cxx9
-rw-r--r--sc/source/core/data/column2.cxx9
-rw-r--r--sc/source/core/data/column3.cxx13
-rw-r--r--sc/source/core/data/formulacell.cxx24
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx2
6 files changed, 48 insertions, 11 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 7b3302f97de3..1954b749ee47 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -90,6 +90,7 @@ private:
bool bInChangeTrack : 1; // Cell is in ChangeTrack
bool bTableOpDirty : 1; // Dirty flag for TableOp
bool bNeedListening : 1; // Listeners need to be re-established after UpdateReference
+ bool mbNeedsNumberFormat : 1; // set the calculated number format as hard number format
enum ScInterpretTailParameter
{
@@ -152,6 +153,7 @@ public:
void ResetDirty() { bDirty = false; }
bool NeedsListening() const { return bNeedListening; }
void SetNeedsListening( bool bVar ) { bNeedListening = bVar; }
+ void SetNeedNumberFormat( bool bVal ) { mbNeedsNumberFormat = bVal; }
void Compile(const OUString& rFormula,
bool bNoListening = false,
const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index a8f8cbb5550b..878255296911 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2235,7 +2235,14 @@ void ScColumn::CompileXML( ScProgress& rProgress )
if ( pCell->GetCellType() == CELLTYPE_FORMULA )
{
SCROW nRow = maItems[i].nRow;
- static_cast<ScFormulaCell*>(pCell)->CompileXML( rProgress );
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ sal_uInt32 nCellFormat = GetNumberFormat( nRow );
+ if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
+ pFCell->SetNeedNumberFormat(false);
+ else
+ pFCell->SetDirty(true);
+
+ pFCell->CompileXML( rProgress );
if ( nRow != maItems[i].nRow )
Search( nRow, i ); // Listener deleted/inserted?
}
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index fbd0c0a26eb0..cc814fd06e9c 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1477,6 +1477,15 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r
void ScColumn::SetCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScBaseCell* pNewCell )
{
+ if(pNewCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pNewCell);
+ sal_uInt32 nCellFormat = GetNumberFormat( nRow );
+ if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+ pFCell->SetNeedNumberFormat(true);
+
+ }
+
bool bIsAppended = false;
if ( !maItems.empty() )
{
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 60eb8e3e4340..59a51907be05 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1448,13 +1448,22 @@ void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const S
void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram )
{
ScAddress aPos(nCol, nRow, nTab);
- Insert(nRow, new ScFormulaCell(pDocument, aPos, &rArray, eGram));
+ ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, &rArray, eGram);
+ sal_uInt32 nCellFormat = GetNumberFormat( nRow );
+ if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
+ pCell->SetNeedNumberFormat(true);
+ Insert(nRow, pCell);
}
void ScColumn::SetFormula( SCROW nRow, const OUString& rFormula, formula::FormulaGrammar::Grammar eGram )
{
ScAddress aPos(nCol, nRow, nTab);
- Insert(nRow, new ScFormulaCell(pDocument, aPos, rFormula, eGram));
+ ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, rFormula, eGram);
+
+ sal_uInt32 nCellFormat = GetNumberFormat( nRow );
+ if( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
+ pCell->SetNeedNumberFormat(true);
+ Insert(nRow, pCell);
}
void ScColumn::SetFormulaCell( SCROW nRow, ScFormulaCell* pCell )
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 98df69afe19a..7108597f5f4c 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -414,6 +414,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
bInChangeTrack( false ),
bTableOpDirty( false ),
bNeedListening( false ),
+ mbNeedsNumberFormat( false ),
aPos( rPos )
{
Compile( rFormula, true, eGrammar ); // bNoListening, Insert does that
@@ -448,6 +449,7 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
bInChangeTrack( false ),
bTableOpDirty( false ),
bNeedListening( false ),
+ mbNeedsNumberFormat( false ),
aPos( rPos )
{
// UPN-Array generation
@@ -494,6 +496,7 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
bInChangeTrack( false ),
bTableOpDirty( false ),
bNeedListening( false ),
+ mbNeedsNumberFormat( false ),
aPos( rPos )
{
pCode = rCell.pCode->Clone();
@@ -1292,16 +1295,21 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
if ( aResult.GetCellResultType() != svUnknown )
bContentChanged = true;
}
- // Different number format?
- if( nFormatType != p->GetRetFormatType() )
- {
- nFormatType = p->GetRetFormatType();
- bChanged = true;
- }
- if( nFormatIndex != p->GetRetFormatIndex() )
+
+ if( mbNeedsNumberFormat )
{
- nFormatIndex = p->GetRetFormatIndex();
+ sal_uInt16 nFormatType = p->GetRetFormatType();
+ sal_Int32 nFormatIndex = p->GetRetFormatIndex();
+
+ if((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+ nFormatIndex = ScGlobal::GetStandardFormat(*pDocument->GetFormatTable(),
+ nFormatIndex, nFormatType);
+
+ // set number format explicitly
+ pDocument->SetNumberFormat( aPos, nFormatIndex );
+
bChanged = true;
+ mbNeedsNumberFormat = false;
}
// In case of changes just obtain the result, no temporary and
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index b1f83dc9c920..1e838a0f350c 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1116,6 +1116,7 @@ void ScXMLTableRowCellContext::PutValueCell( const ScAddress& rCurrentPos )
{
ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCurrentPos);
SetFormulaCell(pFCell);
+ pFCell->SetNeedNumberFormat( true );
}
}
else //regular value cell
@@ -1347,6 +1348,7 @@ void ScXMLTableRowCellContext::PutFormulaCell( const ScAddress& rCellPos )
ScFormulaCell* pNewCell = new ScFormulaCell(pDoc, rCellPos, pCode.get(), eGrammar, MM_NONE);
SetFormulaCell(pNewCell);
pDoc->SetFormulaCell(rCellPos, pNewCell);
+ pNewCell->SetNeedNumberFormat( true );
}
else if ( aText[0] == '\'' && aText.getLength() > 1 )
{