Kaydet (Commit) 57efd69c authored tarafından Markus Mohrhard's avatar Markus Mohrhard

remove inherited number formats, related fdo#60215

Change-Id: I23d5e1b3baeb1499ada1fba1665027bdbe3fbb87
üst fda007e6
......@@ -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 );
......
......@@ -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?
}
......
......@@ -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() )
{
......
......@@ -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 )
......
......@@ -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
......
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment