[Libreoffice-commits] core.git: 25 commits - sc/inc sc/Library_sc.mk sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sat Jun 1 18:31:15 PDT 2013
sc/Library_sc.mk | 1
sc/inc/document.hxx | 8
sc/inc/formulacell.hxx | 15 -
sc/inc/formularesult.hxx | 2
sc/inc/simpleformulacalc.hxx | 54 ++++
sc/qa/unit/helper/csv_handler.hxx | 4
sc/qa/unit/ucalc.cxx | 344 +++++++++++++++++-------------
sc/source/core/data/column.cxx | 20 +
sc/source/core/data/column2.cxx | 23 +-
sc/source/core/data/column3.cxx | 18 +
sc/source/core/data/dociter.cxx | 25 --
sc/source/core/data/document.cxx | 7
sc/source/core/data/formulacell.cxx | 59 +----
sc/source/core/data/simpleformulacalc.cxx | 100 ++++++++
sc/source/core/tool/cellform.cxx | 9
sc/source/core/tool/interpr2.cxx | 4
sc/source/core/tool/interpr4.cxx | 24 +-
sc/source/core/tool/interpr5.cxx | 4
sc/source/filter/excel/xestream.cxx | 28 +-
sc/source/filter/excel/xetable.cxx | 70 +-----
sc/source/filter/html/htmlexp.cxx | 3
sc/source/filter/inc/xetable.hxx | 3
sc/source/filter/xml/xmlcelli.cxx | 2
sc/source/filter/xml/xmlexprt.cxx | 29 --
sc/source/ui/app/inputhdl.cxx | 122 ++++------
sc/source/ui/app/transobj.cxx | 12 -
sc/source/ui/docshell/docsh8.cxx | 6
sc/source/ui/formdlg/formula.cxx | 21 -
sc/source/ui/unoobj/chart2uno.cxx | 12 -
sc/source/ui/unoobj/funcuno.cxx | 24 --
sc/source/ui/view/output2.cxx | 20 -
sc/source/ui/view/tabvwsha.cxx | 7
32 files changed, 562 insertions(+), 518 deletions(-)
New commits:
commit 998326779db3ef3c8915745069bc88ab99fe0c89
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jun 2 03:27:26 2013 +0200
fix warnings after merge
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 1f93b5e..b572cb9 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -155,7 +155,7 @@ public:
const Size& GetTextSize() const { return aTextSize; }
long GetOriginalWidth() const { return nOriginalWidth; }
- sal_uLong GetResultValueFormat( const ScRefCellValue& rCell ) const;
+ sal_uLong GetResultValueFormat() const;
sal_uLong GetValueFormat() const { return nValueFormat; }
sal_Bool GetLineBreak() const { return bLineBreak; }
@@ -598,7 +598,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScRefCellValue& rCell, long nWidth
return;
}
- sal_uLong nFormat = GetResultValueFormat(rCell);
+ sal_uLong nFormat = GetResultValueFormat();
if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
{
// Not 'General' number format. Set hash text and bail out.
@@ -784,7 +784,7 @@ sal_Bool ScDrawStringsVars::HasEditCharacters() const
return aString.SearchChar( pChars ) != STRING_NOTFOUND;
}
-sal_uLong ScDrawStringsVars::GetResultValueFormat( const ScRefCellValue& rCell ) const
+sal_uLong ScDrawStringsVars::GetResultValueFormat() const
{
// Get the effective number format, including formula result types.
// This assumes that a formula cell has already been calculated.
commit 3b6734d1986b832858a58b89a84095593d94e495
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jun 2 03:20:55 2013 +0200
after rebase we have two SetCell methods
Change-Id: Ib10e3084a4881bbafdd4c5b51d64fcf65d5d7da3
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 4df926e..b987a31 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1519,6 +1519,15 @@ void ScColumn::SetCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScBaseCe
void ScColumn::SetCell( 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() )
{
commit 879edb243ec69421088d7a45fcd0eb5a61aeb22f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun May 26 23:26:46 2013 +0200
temporary ugly hack for ordering problem
Currently we have a problem with the ordering of the calls when we come
to old cells that had inherited formats. They may not yet contain a
number format when we get the number format.
Change-Id: I0ddcdd10ff6ff0a43dbfecaf191e5903d3c0f9ce
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 59a5190..f36dbd0 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1705,6 +1705,11 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const
{
ScRefCellValue aCell;
aCell.assign(*maItems[nIndex].pCell);
+
+ // ugly hack for ordering problem with GetNumberFormat and missing inherited formats
+ if(aCell.meType == CELLTYPE_FORMULA)
+ aCell.mpFormula->MaybeInterpret();
+
sal_uLong nFormat = GetNumberFormat( nRow );
ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()));
}
commit 40bcd06d32112e713013d679b8ac43992ee36d12
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat May 25 16:04:39 2013 +0200
use the correct order of arguments for expected and actual in calc tests
Change-Id: I40fc9b46d35e7046ef51c6ea92f9a1595f6d74a1
diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx
index a591cf8..aa98257 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -123,7 +123,7 @@ public:
std::cout << "result: " << (int)(aCSVString == aString) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString, aCSVString);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aCSVString, aString);
}
else
{
@@ -151,7 +151,7 @@ public:
std::cout << "result: " << (int)(aCSVString == aString) << std::endl;
#endif //DEBUG_CSV_HANDLER
- CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aString, aCSVString);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, aCSVString, aString).getStr(), aCSVString, aString);
}
else
{
commit e18f5306714e6ca4103dd236bcf3187d492cbb91
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat May 25 15:12:24 2013 +0200
all formula cells have now an explicit number format
Remove ScFormulaCell::GetStandardFormat
Change-Id: I0b19f572cfcf5c08c81009b0f10e7cc44a1aa2f4
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index c407ae70..c6d3aa7 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -243,10 +243,6 @@ public:
void SetInChangeTrack( bool bVal ) { bInChangeTrack = bVal; }
bool IsInChangeTrack() const { return bInChangeTrack; }
- // standard format for type and format
- // for format "Standard" possibly the format used in the formula cell
- sal_uLong GetStandardFormat( SvNumberFormatter& rFormatter, sal_uLong nFormat ) const;
-
// For import filters!
void AddRecalcMode( formula::ScRecalcMode );
/** For import only: set a double result. */
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index d3d1b38..b75bdcc 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1495,16 +1495,6 @@ void ScFormulaCell::GetMatColsRows( SCCOL & nCols, SCROW & nRows ) const
}
-sal_uLong ScFormulaCell::GetStandardFormat( SvNumberFormatter& rFormatter, sal_uLong nFormat ) const
-{
- //! not ScFormulaCell::IsValue(), that could reinterpret the formula again.
- if ( aResult.IsValue() )
- return ScGlobal::GetStandardFormat( aResult.GetDouble(), rFormatter, nFormat, nFormatType );
- else
- return ScGlobal::GetStandardFormat( rFormatter, nFormat, nFormatType );
-}
-
-
void ScFormulaCell::Notify( SvtBroadcaster&, const SfxHint& rHint)
{
if ( !pDocument->IsInDtorClear() && !pDocument->GetHardRecalcState() )
@@ -1652,10 +1642,7 @@ void ScFormulaCell::GetURLResult( OUString& rURL, OUString& rCellText )
sal_uLong nCellFormat = pDocument->GetNumberFormat( aPos );
SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
- if ( (nCellFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nCellFormat = GetStandardFormat( *pFormatter,nCellFormat );
-
- sal_uLong nURLFormat = ScGlobal::GetStandardFormat( *pFormatter,nCellFormat, NUMBERFORMAT_NUMBER);
+ sal_uLong nURLFormat = ScGlobal::GetStandardFormat( *pFormatter, nCellFormat, NUMBERFORMAT_NUMBER);
if ( IsValue() )
{
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 6846874..a33405f 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -101,11 +101,6 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString
{
sal_uInt16 nErrCode = pFCell->GetErrCode();
- // get the number format only after interpretation (GetErrCode):
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = pFCell->GetStandardFormat( rFormatter,
- nFormat );
-
if (nErrCode != 0)
rString = ScGlobal::GetErrorString(nErrCode);
else if ( pFCell->IsEmptyDisplayedAsString() )
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index a4cbb40..2b72e89 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2929,33 +2929,14 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
bool bIsStandard;
OUString sCurrency;
GetNumberFormatAttributesExportHelper()->GetCellType(aCell.nNumberFormat, sCurrency, bIsStandard);
- if (bIsStandard)
+ if (pDoc)
{
- if (pDoc)
+ GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
+ aCell.nNumberFormat, pDoc->GetValue( aCellPos ));
+ if( getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
{
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
- pDoc->GetValue( aCellPos ));
- if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
- {
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- pFormulaCell->GetStandardFormat(*pDoc->GetFormatTable(), 0),
- pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT, false);
- }
- }
- }
- else
- {
- if (pDoc)
- {
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, pDoc->GetValue( aCellPos ));
- if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
- {
- GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
- aCell.nNumberFormat, pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT, false );
-
- }
+ aCell.nNumberFormat, pDoc->GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT, false );
}
}
}
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index a68adf3..a2fcc11 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -831,18 +831,6 @@ void ScTransferObj::StripRefs( ScDocument* pDoc,
pDestDoc->SetString(aPos, aStr);
}
}
-
- // number formats
-
- sal_uLong nOldFormat = ((const SfxUInt32Item*)
- pDestDoc->GetAttr(nCol,nRow,nDestTab, ATTR_VALUE_FORMAT))->GetValue();
- if ( (nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- {
- sal_uLong nNewFormat = pFCell->GetStandardFormat( *pFormatter,
- nOldFormat );
- pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
- SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) );
- }
}
}
}
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index 22fbf0e..7c57ee9 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -173,30 +173,6 @@ static sal_Bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange,
pClipDoc->ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nSrcTab, aPattern );
}
- // If the range contains formula cells with default number format,
- // apply a number format for the formula result
- ScCellIterator aIter( pClipDoc, rSrcRange );
- for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
- {
- if (aIter.getType() != CELLTYPE_FORMULA)
- continue;
-
- ScAddress aCellPos = aIter.GetPos();
- sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos);
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- {
- ScFormulaCell* pFCell = aIter.getFormulaCell();
- sal_uInt16 nErrCode = pFCell->GetErrCode();
- if ( nErrCode == 0 && pFCell->IsValue() )
- {
- sal_uInt32 nNewFormat = pFCell->GetStandardFormat( *pClipDoc->GetFormatTable(), nFormat );
- if ( nNewFormat != nFormat )
- pClipDoc->ApplyAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(),
- SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
- }
- }
- }
-
ScMarkData aDestMark;
aDestMark.SelectOneTable( nDestTab );
aDestMark.SetMarkArea( aNewRange );
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 1cc39fd..4e2d645 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -112,13 +112,6 @@ sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
{
// Zahlformat aus Attributen oder Formel
pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
- if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- {
- ScRefCellValue aCell;
- aCell.assign(*pDoc, aCursor);
- if (aCell.meType == CELLTYPE_FORMULA)
- nNumFmt = aCell.mpFormula->GetStandardFormat(*pFormatter, nNumFmt);
- }
}
String aValStr;
commit 81e4e89b28f28a4780948769a86e2c486d797e59
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat May 25 14:45:53 2013 +0200
let us use clean test environments
The additional typing and the duplicated code benefit cleaner test
execution. Test failures might be hidden by a dirty test environment or
random test failures might be produced by it.
Change-Id: I97283009b65facbaad82e41ae6f1258430684438
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d2c042f..de15b2d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -111,7 +111,17 @@ public:
void testRangeList();
void testInput();
void testFormulaHashAndTag();
- void testCellFunctions();
+ void testFuncSUM();
+ void testFuncPRODUCT();
+ void testFuncN();
+ void testFuncCOUNTIF();
+ void testFuncNUMBERVALUE();
+ void testFuncVLOOKUP();
+ void testFuncMATCH();
+ void testFuncCELL();
+ void testFuncDATEDIF();
+ void testFuncINDIRECT();
+ void testFuncIFERROR();
void testCopyToDocument();
/**
* Make sure the SHEETS function gets properly updated during sheet
@@ -281,7 +291,17 @@ public:
CPPUNIT_TEST(testRangeList);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testFormulaHashAndTag);
- CPPUNIT_TEST(testCellFunctions);
+ CPPUNIT_TEST(testFuncSUM);
+ CPPUNIT_TEST(testFuncPRODUCT);
+ CPPUNIT_TEST(testFuncN);
+ CPPUNIT_TEST(testFuncCOUNTIF);
+ CPPUNIT_TEST(testFuncNUMBERVALUE);
+ CPPUNIT_TEST(testFuncVLOOKUP);
+ CPPUNIT_TEST(testFuncMATCH);
+ CPPUNIT_TEST(testFuncCELL);
+ CPPUNIT_TEST(testFuncDATEDIF);
+ CPPUNIT_TEST(testFuncINDIRECT);
+ CPPUNIT_TEST(testFuncIFERROR);
CPPUNIT_TEST(testCopyToDocument);
CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
@@ -839,90 +859,106 @@ void Test::testInput()
m_pDoc->DeleteTab(0);
}
-void testFuncSUM(ScDocument* pDoc)
+void Test::testFuncSUM()
{
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
double val = 1;
double result;
- pDoc->SetValue (0, 0, 0, val);
- pDoc->SetValue (0, 1, 0, val);
- pDoc->SetString (0, 2, 0, OUString("=SUM(A1:A2)"));
- pDoc->CalcAll();
- pDoc->GetValue (0, 2, 0, result);
+ m_pDoc->SetValue (0, 0, 0, val);
+ m_pDoc->SetValue (0, 1, 0, val);
+ m_pDoc->SetString (0, 2, 0, OUString("=SUM(A1:A2)"));
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue (0, 2, 0, result);
CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 2.0);
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncPRODUCT(ScDocument* pDoc)
+void Test::testFuncPRODUCT()
{
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
double val = 1;
double result;
- pDoc->SetValue(0, 0, 0, val);
+ m_pDoc->SetValue(0, 0, 0, val);
val = 2;
- pDoc->SetValue(0, 1, 0, val);
+ m_pDoc->SetValue(0, 1, 0, val);
val = 3;
- pDoc->SetValue(0, 2, 0, val);
- pDoc->SetString(0, 3, 0, OUString("=PRODUCT(A1:A3)"));
- pDoc->CalcAll();
- pDoc->GetValue(0, 3, 0, result);
+ m_pDoc->SetValue(0, 2, 0, val);
+ m_pDoc->SetString(0, 3, 0, OUString("=PRODUCT(A1:A3)"));
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue(0, 3, 0, result);
CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT failed", result == 6.0);
- pDoc->SetString(0, 4, 0, OUString("=PRODUCT({1;2;3})"));
- pDoc->CalcAll();
- pDoc->GetValue(0, 4, 0, result);
+ m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({1;2;3})"));
+ m_pDoc->CalcAll();
+ m_pDoc->GetValue(0, 4, 0, result);
CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", result == 6.0);
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncN(ScDocument* pDoc)
+void Test::testFuncN()
{
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
double result;
// Clear the area first.
- clearRange(pDoc, ScRange(0, 0, 0, 1, 20, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 1, 20, 0));
// Put values to reference.
double val = 0;
- pDoc->SetValue(0, 0, 0, val);
- pDoc->SetString(0, 2, 0, OUString("Text"));
+ m_pDoc->SetValue(0, 0, 0, val);
+ m_pDoc->SetString(0, 2, 0, OUString("Text"));
val = 1;
- pDoc->SetValue(0, 3, 0, val);
+ m_pDoc->SetValue(0, 3, 0, val);
val = -1;
- pDoc->SetValue(0, 4, 0, val);
+ m_pDoc->SetValue(0, 4, 0, val);
val = 12.3;
- pDoc->SetValue(0, 5, 0, val);
- pDoc->SetString(0, 6, 0, OUString("'12.3"));
+ m_pDoc->SetValue(0, 5, 0, val);
+ m_pDoc->SetString(0, 6, 0, OUString("'12.3"));
// Cell references
- pDoc->SetString(1, 0, 0, OUString("=N(A1)"));
- pDoc->SetString(1, 1, 0, OUString("=N(A2)"));
- pDoc->SetString(1, 2, 0, OUString("=N(A3)"));
- pDoc->SetString(1, 3, 0, OUString("=N(A4)"));
- pDoc->SetString(1, 4, 0, OUString("=N(A5)"));
- pDoc->SetString(1, 5, 0, OUString("=N(A6)"));
- pDoc->SetString(1, 6, 0, OUString("=N(A9)"));
+ m_pDoc->SetString(1, 0, 0, OUString("=N(A1)"));
+ m_pDoc->SetString(1, 1, 0, OUString("=N(A2)"));
+ m_pDoc->SetString(1, 2, 0, OUString("=N(A3)"));
+ m_pDoc->SetString(1, 3, 0, OUString("=N(A4)"));
+ m_pDoc->SetString(1, 4, 0, OUString("=N(A5)"));
+ m_pDoc->SetString(1, 5, 0, OUString("=N(A6)"));
+ m_pDoc->SetString(1, 6, 0, OUString("=N(A9)"));
// In-line values
- pDoc->SetString(1, 7, 0, OUString("=N(0)"));
- pDoc->SetString(1, 8, 0, OUString("=N(1)"));
- pDoc->SetString(1, 9, 0, OUString("=N(-1)"));
- pDoc->SetString(1, 10, 0, OUString("=N(123)"));
- pDoc->SetString(1, 11, 0, OUString("=N(\"\")"));
- pDoc->SetString(1, 12, 0, OUString("=N(\"12\")"));
- pDoc->SetString(1, 13, 0, OUString("=N(\"foo\")"));
+ m_pDoc->SetString(1, 7, 0, OUString("=N(0)"));
+ m_pDoc->SetString(1, 8, 0, OUString("=N(1)"));
+ m_pDoc->SetString(1, 9, 0, OUString("=N(-1)"));
+ m_pDoc->SetString(1, 10, 0, OUString("=N(123)"));
+ m_pDoc->SetString(1, 11, 0, OUString("=N(\"\")"));
+ m_pDoc->SetString(1, 12, 0, OUString("=N(\"12\")"));
+ m_pDoc->SetString(1, 13, 0, OUString("=N(\"foo\")"));
// Range references
- pDoc->SetString(2, 2, 0, OUString("=N(A1:A8)"));
- pDoc->SetString(2, 3, 0, OUString("=N(A1:A8)"));
- pDoc->SetString(2, 4, 0, OUString("=N(A1:A8)"));
- pDoc->SetString(2, 5, 0, OUString("=N(A1:A8)"));
+ m_pDoc->SetString(2, 2, 0, OUString("=N(A1:A8)"));
+ m_pDoc->SetString(2, 3, 0, OUString("=N(A1:A8)"));
+ m_pDoc->SetString(2, 4, 0, OUString("=N(A1:A8)"));
+ m_pDoc->SetString(2, 5, 0, OUString("=N(A1:A8)"));
// Calculate and check the results.
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
double checks1[] = {
0, 0, 0, 1, -1, 12.3, 0, // cell reference
0, 1, -1, 123, 0, 0, 0 // in-line values
};
for (size_t i = 0; i < SAL_N_ELEMENTS(checks1); ++i)
{
- pDoc->GetValue(1, i, 0, result);
+ m_pDoc->GetValue(1, i, 0, result);
bool bGood = result == checks1[i];
if (!bGood)
{
@@ -935,7 +971,7 @@ void testFuncN(ScDocument* pDoc)
};
for (size_t i = 0; i < SAL_N_ELEMENTS(checks2); ++i)
{
- pDoc->GetValue(1, i+2, 0, result);
+ m_pDoc->GetValue(1, i+2, 0, result);
bool bGood = result == checks2[i];
if (!bGood)
{
@@ -943,14 +979,20 @@ void testFuncN(ScDocument* pDoc)
CPPUNIT_ASSERT_MESSAGE("Unexpected result for N", false);
}
}
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncCOUNTIF(ScDocument* pDoc)
+void Test::testFuncCOUNTIF()
{
// COUNTIF (test case adopted from OOo i#36381)
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
// Empty A1:A39 first.
- clearRange(pDoc, ScRange(0, 0, 0, 0, 40, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 0, 40, 0));
// Raw data (rows 1 through 9)
const char* aData[] = {
@@ -967,9 +1009,9 @@ void testFuncCOUNTIF(ScDocument* pDoc)
SCROW nRows = SAL_N_ELEMENTS(aData);
for (SCROW i = 0; i < nRows; ++i)
- pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
+ m_pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
- printRange(pDoc, ScRange(0, 0, 0, 0, 8, 0), "data range for COUNTIF");
+ printRange(m_pDoc, ScRange(0, 0, 0, 0, 8, 0), "data range for COUNTIF");
// formulas and results
struct {
@@ -992,15 +1034,15 @@ void testFuncCOUNTIF(ScDocument* pDoc)
for (SCROW i = 0; i < nRows; ++i)
{
SCROW nRow = 20 + i;
- pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
+ m_pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
for (SCROW i = 0; i < nRows; ++i)
{
double result;
SCROW nRow = 20 + i;
- pDoc->GetValue(0, nRow, 0, result);
+ m_pDoc->GetValue(0, nRow, 0, result);
bool bGood = result == aChecks[i].fResult;
if (!bGood)
{
@@ -1013,22 +1055,28 @@ void testFuncCOUNTIF(ScDocument* pDoc)
// Don't count empty strings when searching for a number.
// Clear A1:A2.
- clearRange(pDoc, ScRange(0, 0, 0, 0, 1, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 0, 1, 0));
- pDoc->SetString(0, 0, 0, OUString("=\"\""));
- pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)"));
- pDoc->CalcAll();
+ m_pDoc->SetString(0, 0, 0, OUString("=\"\""));
+ m_pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)"));
+ m_pDoc->CalcAll();
- double result = pDoc->GetValue(0, 1, 0);
+ double result = m_pDoc->GetValue(0, 1, 0);
CPPUNIT_ASSERT_MESSAGE("We shouldn't count empty string as valid number.", result == 0.0);
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncIFERROR(ScDocument* pDoc)
+void Test::testFuncIFERROR()
{
// IFERROR/IFNA (fdo#56124)
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
// Empty A1:A39 first.
- clearRange(pDoc, ScRange(0, 0, 0, 0, 40, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 0, 40, 0));
// Raw data (rows 1 through 12)
const char* aData[] = {
@@ -1048,9 +1096,9 @@ void testFuncIFERROR(ScDocument* pDoc)
SCROW nRows = SAL_N_ELEMENTS(aData);
for (SCROW i = 0; i < nRows; ++i)
- pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
+ m_pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
- printRange(pDoc, ScRange(0, 0, 0, 0, nRows-1, 0), "data range for IFERROR/IFNA");
+ printRange(m_pDoc, ScRange(0, 0, 0, 0, nRows-1, 0), "data range for IFERROR/IFNA");
// formulas and results
struct {
@@ -1075,32 +1123,38 @@ void testFuncIFERROR(ScDocument* pDoc)
for (SCROW i = 0; i < nRows-2; ++i)
{
SCROW nRow = 20 + i;
- pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
+ m_pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
// Create a matrix range in last two rows of the range above, actual data
// of the placeholders.
ScMarkData aMark;
aMark.SelectOneTable(0);
- pDoc->InsertMatrixFormula(0, 20 + nRows-2, 0, 20 + nRows-1, aMark, "=IFERROR(3*A11:A12;1998)", NULL);
+ m_pDoc->InsertMatrixFormula(0, 20 + nRows-2, 0, 20 + nRows-1, aMark, "=IFERROR(3*A11:A12;1998)", NULL);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
for (SCROW i = 0; i < nRows; ++i)
{
SCROW nRow = 20 + i;
- OUString aResult = pDoc->GetString(0, nRow, 0);
+ OUString aResult = m_pDoc->GetString(0, nRow, 0);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
aChecks[i].pFormula, OUString::createFromAscii( aChecks[i].pResult), aResult);
}
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncNUMBERVALUE( ScDocument* pDoc )
+void Test::testFuncNUMBERVALUE()
{
// NUMBERVALUE fdo#57180
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
// Empty A1:A39 first.
- clearRange(pDoc, ScRange(0, 0, 0, 0, 40, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 0, 40, 0));
// Raw data (rows 1 through 6)
const char* aData[] = {
@@ -1114,9 +1168,9 @@ void testFuncNUMBERVALUE( ScDocument* pDoc )
SCROW nRows = SAL_N_ELEMENTS(aData);
for (SCROW i = 0; i < nRows; ++i)
- pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
+ m_pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i]));
- printRange(pDoc, ScRange(0, 0, 0, 0, nRows - 1, 0), "data range for NUMBERVALUE");
+ printRange(m_pDoc, ScRange(0, 0, 0, 0, nRows - 1, 0), "data range for NUMBERVALUE");
// formulas and results
struct {
@@ -1136,25 +1190,31 @@ void testFuncNUMBERVALUE( ScDocument* pDoc )
for (SCROW i = 0; i < nRows; ++i)
{
SCROW nRow = 20 + i;
- pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
+ m_pDoc->SetString(0, nRow, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
for (SCROW i = 0; i < nRows; ++i)
{
SCROW nRow = 20 + i;
- OUString aResult = pDoc->GetString(0, nRow, 0);
+ OUString aResult = m_pDoc->GetString(0, nRow, 0);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
aChecks[i].pFormula, OUString::createFromAscii( aChecks[i].pResult), aResult);
}
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncVLOOKUP(ScDocument* pDoc)
+void Test::testFuncVLOOKUP()
{
// VLOOKUP
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
// Clear A1:F40.
- clearRange(pDoc, ScRange(0, 0, 0, 5, 39, 0));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 5, 39, 0));
// Raw data
const char* aData[][2] = {
@@ -1178,11 +1238,11 @@ void testFuncVLOOKUP(ScDocument* pDoc)
// Insert raw data into A1:B14.
for (SCROW i = 0; aData[i][0]; ++i)
{
- pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i][0]));
- pDoc->SetString(1, i, 0, OUString::createFromAscii(aData[i][1]));
+ m_pDoc->SetString(0, i, 0, OUString::createFromAscii(aData[i][0]));
+ m_pDoc->SetString(1, i, 0, OUString::createFromAscii(aData[i][1]));
}
- printRange(pDoc, ScRange(0, 0, 0, 1, 13, 0), "raw data for VLOOKUP");
+ printRange(m_pDoc, ScRange(0, 0, 0, 1, 13, 0), "raw data for VLOOKUP");
// Formula data
struct {
@@ -1211,11 +1271,11 @@ void testFuncVLOOKUP(ScDocument* pDoc)
// Insert formula data into D1:E18.
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- pDoc->SetString(3, i, 0, OUString::createFromAscii(aChecks[i].pLookup));
- pDoc->SetString(4, i, 0, OUString::createFromAscii(aChecks[i].pFormula));
+ m_pDoc->SetString(3, i, 0, OUString::createFromAscii(aChecks[i].pLookup));
+ m_pDoc->SetString(4, i, 0, OUString::createFromAscii(aChecks[i].pFormula));
}
- pDoc->CalcAll();
- printRange(pDoc, ScRange(3, 0, 0, 4, 17, 0), "formula data for VLOOKUP");
+ m_pDoc->CalcAll();
+ printRange(m_pDoc, ScRange(3, 0, 0, 4, 17, 0), "formula data for VLOOKUP");
// Verify results.
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
@@ -1224,7 +1284,7 @@ void testFuncVLOOKUP(ScDocument* pDoc)
// Skip the header row.
continue;
- OUString aRes = pDoc->GetString(4, i, 0);
+ OUString aRes = m_pDoc->GetString(4, i, 0);
bool bGood = aRes.equalsAscii(aChecks[i].pRes);
if (!bGood)
{
@@ -1233,6 +1293,8 @@ void testFuncVLOOKUP(ScDocument* pDoc)
CPPUNIT_ASSERT_MESSAGE("Unexpected result for VLOOKUP", false);
}
}
+
+ m_pDoc->DeleteTab(0);
}
struct NumStrCheck {
@@ -1284,9 +1346,13 @@ void runTestMATCH(ScDocument* pDoc, const char* aData[_DataSize], StrStrCheck aC
}
}
-void testFuncMATCH(ScDocument* pDoc)
+void Test::testFuncMATCH()
{
- clearRange(pDoc, ScRange(0, 0, 0, 4, 40, 0));
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
+ clearRange(m_pDoc, ScRange(0, 0, 0, 4, 40, 0));
{
// Ascending in-exact match
@@ -1325,7 +1391,7 @@ void testFuncMATCH(ScDocument* pDoc)
{ "Charlie", "12" }
};
- runTestMATCH<SAL_N_ELEMENTS(aData),SAL_N_ELEMENTS(aChecks),1>(pDoc, aData, aChecks);
+ runTestMATCH<SAL_N_ELEMENTS(aData),SAL_N_ELEMENTS(aChecks),1>(m_pDoc, aData, aChecks);
}
{
@@ -1367,19 +1433,25 @@ void testFuncMATCH(ScDocument* pDoc)
{ "David", "#N/A" }
};
- runTestMATCH<SAL_N_ELEMENTS(aData),SAL_N_ELEMENTS(aChecks),-1>(pDoc, aData, aChecks);
+ runTestMATCH<SAL_N_ELEMENTS(aData),SAL_N_ELEMENTS(aChecks),-1>(m_pDoc, aData, aChecks);
}
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncCELL(ScDocument* pDoc)
+void Test::testFuncCELL()
{
- clearRange(pDoc, ScRange(0, 0, 0, 2, 20, 0)); // Clear A1:C21.
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
+ clearRange(m_pDoc, ScRange(0, 0, 0, 2, 20, 0)); // Clear A1:C21.
{
const char* pContent = "Some random text";
- pDoc->SetString(2, 9, 0, OUString::createFromAscii(pContent)); // Set this value to C10.
+ m_pDoc->SetString(2, 9, 0, OUString::createFromAscii(pContent)); // Set this value to C10.
double val = 1.2;
- pDoc->SetValue(2, 0, 0, val); // Set numeric value to C1;
+ m_pDoc->SetValue(2, 0, 0, val); // Set numeric value to C1;
// We don't test: FILENAME, FORMAT, WIDTH, PROTECT, PREFIX
StrStrCheck aChecks[] = {
@@ -1396,20 +1468,26 @@ void testFuncCELL(ScDocument* pDoc)
};
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
- pDoc->SetString(0, i, 0, OUString::createFromAscii(aChecks[i].pVal));
- pDoc->CalcAll();
+ m_pDoc->SetString(0, i, 0, OUString::createFromAscii(aChecks[i].pVal));
+ m_pDoc->CalcAll();
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- OUString aVal = pDoc->GetString(0, i, 0);
+ OUString aVal = m_pDoc->GetString(0, i, 0);
CPPUNIT_ASSERT_MESSAGE("Unexpected result for CELL", aVal.equalsAscii(aChecks[i].pRes));
}
}
+
+ m_pDoc->DeleteTab(0);
}
/** See also test case document fdo#44456 sheet cpearson */
-void testFuncDATEDIF( ScDocument* pDoc )
+void Test::testFuncDATEDIF()
{
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+
const char* aData[][5] = {
{ "2007-01-01", "2007-01-10", "d", "9", "=DATEDIF(A1;B1;C1)" } ,
{ "2007-01-01", "2007-01-31", "m", "0", "=DATEDIF(A2;B2;C2)" } ,
@@ -1428,44 +1506,49 @@ void testFuncDATEDIF( ScDocument* pDoc )
{ "2007-01-02", "2007-01-01", "md", "Err:502", "=DATEDIF(A15;B15;C15)" } // fail date1 > date2
};
- clearRange( pDoc, ScRange(0, 0, 0, 4, SAL_N_ELEMENTS(aData), 0));
+ clearRange( m_pDoc, ScRange(0, 0, 0, 4, SAL_N_ELEMENTS(aData), 0));
ScAddress aPos(0,0,0);
- ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+ ScRange aDataRange = insertRangeData( m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
for (size_t i = 0; i < SAL_N_ELEMENTS(aData); ++i)
{
- OUString aVal = pDoc->GetString( 4, i, 0);
+ OUString aVal = m_pDoc->GetString( 4, i, 0);
//std::cout << "row "<< i << ": " << OUStringToOString( aVal, RTL_TEXTENCODING_UTF8).getStr() << ", expected " << aData[i][3] << std::endl;
CPPUNIT_ASSERT_MESSAGE("Unexpected result for DATEDIF", aVal.equalsAscii( aData[i][3]));
}
+
+ m_pDoc->DeleteTab(0);
}
-void testFuncINDIRECT(ScDocument* pDoc)
+void Test::testFuncINDIRECT()
{
- clearRange(pDoc, ScRange(0, 0, 0, 0, 10, 0)); // Clear A1:A11
- OUString aTabName;
- bool bGood = pDoc->GetName(0, aTabName);
+ OUString aTabName("foo");
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
+ m_pDoc->InsertTab (0, aTabName));
+ clearRange(m_pDoc, ScRange(0, 0, 0, 0, 10, 0)); // Clear A1:A11
+
+ bool bGood = m_pDoc->GetName(0, aTabName);
CPPUNIT_ASSERT_MESSAGE("failed to get sheet name.", bGood);
OUString aTest = "Test", aRefErr = "#REF!";
- pDoc->SetString(0, 10, 0, aTest);
- CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", pDoc->GetString(0,10,0) == aTest);
+ m_pDoc->SetString(0, 10, 0, aTest);
+ CPPUNIT_ASSERT_MESSAGE("Unexpected cell value.", m_pDoc->GetString(0,10,0) == aTest);
OUString aPrefix = "=INDIRECT(\"";
OUString aFormula = aPrefix + aTabName + ".A11\")"; // Calc A1
- pDoc->SetString(0, 0, 0, aFormula);
+ m_pDoc->SetString(0, 0, 0, aFormula);
aFormula = aPrefix + aTabName + "!A11\")"; // Excel A1
- pDoc->SetString(0, 1, 0, aFormula);
+ m_pDoc->SetString(0, 1, 0, aFormula);
aFormula = aPrefix + aTabName + "!R11C1\")"; // Excel R1C1
- pDoc->SetString(0, 2, 0, aFormula);
+ m_pDoc->SetString(0, 2, 0, aFormula);
aFormula = aPrefix + aTabName + "!R11C1\";0)"; // Excel R1C1 (forced)
- pDoc->SetString(0, 3, 0, aFormula);
+ m_pDoc->SetString(0, 3, 0, aFormula);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
{
// Default is to use the current formula syntax, which is Calc A1.
const OUString* aChecks[] = {
@@ -1474,7 +1557,7 @@ void testFuncINDIRECT(ScDocument* pDoc)
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- OUString aVal = pDoc->GetString(0, i, 0);
+ OUString aVal = m_pDoc->GetString(0, i, 0);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong value!", *aChecks[i], aVal);
}
}
@@ -1482,7 +1565,7 @@ void testFuncINDIRECT(ScDocument* pDoc)
ScCalcConfig aConfig;
aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_OOO;
ScInterpreter::SetGlobalConfig(aConfig);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
{
// Explicit Calc A1 syntax
const OUString* aChecks[] = {
@@ -1491,14 +1574,14 @@ void testFuncINDIRECT(ScDocument* pDoc)
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- OUString aVal = pDoc->GetString(0, i, 0);
+ OUString aVal = m_pDoc->GetString(0, i, 0);
CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]);
}
}
aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_A1;
ScInterpreter::SetGlobalConfig(aConfig);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
{
// Excel A1 syntax
const OUString* aChecks[] = {
@@ -1507,14 +1590,14 @@ void testFuncINDIRECT(ScDocument* pDoc)
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- OUString aVal = pDoc->GetString(0, i, 0);
+ OUString aVal = m_pDoc->GetString(0, i, 0);
CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]);
}
}
aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_R1C1;
ScInterpreter::SetGlobalConfig(aConfig);
- pDoc->CalcAll();
+ m_pDoc->CalcAll();
{
// Excel R1C1 syntax
const OUString* aChecks[] = {
@@ -1523,10 +1606,12 @@ void testFuncINDIRECT(ScDocument* pDoc)
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
- OUString aVal = pDoc->GetString(0, i, 0);
+ OUString aVal = m_pDoc->GetString(0, i, 0);
CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]);
}
}
+
+ m_pDoc->DeleteTab(0);
}
void Test::testFormulaHashAndTag()
@@ -1620,27 +1705,6 @@ void Test::testFormulaHashAndTag()
m_pDoc->DeleteTab(0);
}
-void Test::testCellFunctions()
-{
- OUString aTabName("foo");
- CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
- m_pDoc->InsertTab (0, aTabName));
-
- testFuncSUM(m_pDoc);
- testFuncPRODUCT(m_pDoc);
- testFuncN(m_pDoc);
- testFuncCOUNTIF(m_pDoc);
- testFuncIFERROR(m_pDoc);
- testFuncNUMBERVALUE(m_pDoc);
- testFuncVLOOKUP(m_pDoc);
- testFuncMATCH(m_pDoc);
- testFuncCELL(m_pDoc);
- testFuncDATEDIF(m_pDoc);
- testFuncINDIRECT(m_pDoc);
-
- m_pDoc->DeleteTab(0);
-}
-
void Test::testCopyToDocument()
{
CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "src"));
commit 7e700674c88153ddfecbcb10e7078618a4d0f206
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat May 25 14:26:21 2013 +0200
accept this result as bug fixed
We still have the number format type in ScFormulaCell. Removing that one
from ScFormulaCell is more work and needs much more inspection than
removing the formula index. Additionally we should inspect all callers
of ScFormulaCell::GetStandardFormat as most of them are useless when we
know that a cell has a fixed number format.
Change-Id: I3ad55a0c072da0fc4046d6c7245ed734a1dcaabc
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 1954b74..c407ae70 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -77,10 +77,9 @@ private:
ScFormulaCell* pPreviousTrack;
ScFormulaCell* pNextTrack;
ScFormulaCellGroupRef xGroup; // re-factoring hack - group of formulae we're part of.
- sal_uLong nFormatIndex; // Number format set by calculation
- short nFormatType; // Number format type set by calculation
sal_uInt16 nSeenInIteration; // Iteration cycle in which the cell was last encountered
sal_uInt8 cMatrixFlag; // One of ScMatrixMode
+ short nFormatType;
bool bDirty : 1; // Must be (re)calculated
bool bChanged : 1; // Whether something changed regarding display/representation
bool bRunning : 1; // Already interpreting right now
@@ -154,6 +153,7 @@ public:
bool NeedsListening() const { return bNeedListening; }
void SetNeedsListening( bool bVar ) { bNeedListening = bVar; }
void SetNeedNumberFormat( bool bVal ) { mbNeedsNumberFormat = bVal; }
+ short GetFormatType() const { return nFormatType; }
void Compile(const OUString& rFormula,
bool bNoListening = false,
const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT );
@@ -215,7 +215,6 @@ public:
sal_uInt16 GetMatrixEdge( ScAddress& rOrgPos );
sal_uInt16 GetErrCode(); // interpret first if necessary
sal_uInt16 GetRawError(); // don't interpret, just return code or result error
- short GetFormatType() const { return nFormatType; }
sal_uInt8 GetMatrixFlag() const { return cMatrixFlag; }
ScTokenArray* GetCode() const { return pCode; }
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index cc814fd..4df926e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -160,10 +160,7 @@ long ScColumn::GetNeededSize(
// #i111387# disable automatic line breaks only for "General" number format
if (bBreak && aCell.hasNumeric() && ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
{
- // also take formula result type into account for number format
- if (aCell.meType != CELLTYPE_FORMULA ||
- (aCell.mpFormula->GetStandardFormat(*pFormatter, nFormat) % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
- bBreak = false;
+ bBreak = false;
}
// get other attributes from pattern and conditional formatting
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index d4a4846..d3d1b38 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -401,10 +401,9 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
pNext(0),
pPreviousTrack(0),
pNextTrack(0),
- nFormatIndex(0),
- nFormatType( NUMBERFORMAT_NUMBER ),
nSeenInIteration(0),
cMatrixFlag ( cMatInd ),
+ nFormatType ( NUMBERFORMAT_NUMBER ),
bDirty( true ), // -> Because of the use of the Auto Pilot Function was: cMatInd != 0
bChanged( false ),
bRunning( false ),
@@ -436,10 +435,9 @@ ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos,
pNext(0),
pPreviousTrack(0),
pNextTrack(0),
- nFormatIndex(0),
- nFormatType( NUMBERFORMAT_NUMBER ),
nSeenInIteration(0),
cMatrixFlag ( cInd ),
+ nFormatType ( NUMBERFORMAT_NUMBER ),
bDirty( NULL != pArr ), // -> Because of the use of the Auto Pilot Function was: cInd != 0
bChanged( false ),
bRunning( false ),
@@ -483,10 +481,9 @@ ScFormulaCell::ScFormulaCell( const ScFormulaCell& rCell, ScDocument& rDoc, cons
pNext(0),
pPreviousTrack(0),
pNextTrack(0),
- nFormatIndex( &rDoc == rCell.pDocument ? rCell.nFormatIndex : 0 ),
- nFormatType( rCell.nFormatType ),
nSeenInIteration(0),
cMatrixFlag ( rCell.cMatrixFlag ),
+ nFormatType( rCell.nFormatType ),
bDirty( rCell.bDirty ),
bChanged( rCell.bChanged ),
bRunning( false ),
@@ -770,7 +767,6 @@ void ScFormulaCell::CompileTokenArray( bool bNoListening )
if( !pCode->GetCodeError() )
{
nFormatType = aComp.GetNumFormatType();
- nFormatIndex = 0;
bChanged = true;
aResult.SetToken( NULL);
bCompile = false;
@@ -820,7 +816,6 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress )
if( !pCode->GetCodeError() )
{
nFormatType = aComp.GetNumFormatType();
- nFormatIndex = 0;
bChanged = true;
bCompile = false;
StartListeningTo( pDocument );
@@ -871,7 +866,6 @@ void ScFormulaCell::CalcAfterLoad()
aComp.SetGrammar(pDocument->GetGrammar());
bSubTotal = aComp.CompileTokenArray();
nFormatType = aComp.GetNumFormatType();
- nFormatIndex = 0;
bDirty = true;
bCompile = false;
bNewCompiled = true;
@@ -1298,7 +1292,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
if( mbNeedsNumberFormat )
{
- sal_uInt16 nFormatType = p->GetRetFormatType();
+ nFormatType = p->GetRetFormatType();
sal_Int32 nFormatIndex = p->GetRetFormatIndex();
// don't set text format as hard format
@@ -1378,11 +1372,6 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
&& nFormatType != NUMBERFORMAT_DATETIME )
{
sal_uLong nFormat = pDocument->GetNumberFormat( aPos );
- if ( nFormatIndex && (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = nFormatIndex;
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = ScGlobal::GetStandardFormat(
- *pDocument->GetFormatTable(), nFormat, nFormatType );
aResult.SetDouble( pDocument->RoundValueAsShown(
aResult.GetDouble(), nFormat));
}
@@ -1508,8 +1497,6 @@ void ScFormulaCell::GetMatColsRows( SCCOL & nCols, SCROW & nRows ) const
sal_uLong ScFormulaCell::GetStandardFormat( SvNumberFormatter& rFormatter, sal_uLong nFormat ) const
{
- if ( nFormatIndex && (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- return nFormatIndex;
//! not ScFormulaCell::IsValue(), that could reinterpret the formula again.
if ( aResult.IsValue() )
return ScGlobal::GetStandardFormat( aResult.GetDouble(), rFormatter, nFormat, nFormatType );
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index cb7ce81..6846874 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -203,10 +203,6 @@ OUString ScCellFormat::GetString(
{
sal_uInt16 nErrCode = pFCell->GetErrCode();
- // get the number format only after interpretation (GetErrCode):
- if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) nFormat = pFCell->GetStandardFormat(rFormatter,
- nFormat);
-
if (nErrCode != 0) aString = ScGlobal::GetErrorString(nErrCode);
else if (pFCell->IsEmptyDisplayedAsString()) aString = OUString();
else if (pFCell->IsValue())
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 7fd4ef7..1f789b9 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -170,8 +170,6 @@ sal_uLong ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, ScRefCellVa
else
nErr = 0;
nFormat = pDok->GetNumberFormat( rPos );
- if (rCell.meType == CELLTYPE_FORMULA && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0))
- nFormat = rCell.mpFormula->GetStandardFormat(*pFormatter, nFormat);
}
SetError(nErr);
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index c6363a4..832f59c 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -3257,17 +3257,7 @@ namespace {
sal_uLong getDisplayNumberFormat(ScDocument* pDoc, const ScAddress& rPos)
{
sal_uLong nFormat = pDoc->GetNumberFormat(rPos); // original format from cell.
- SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
- if (!pFormatter)
- return nFormat;
-
- ScRefCellValue aCell;
- aCell.assign(*pDoc, rPos);
- if (aCell.isEmpty() || aCell.meType != CELLTYPE_FORMULA || nFormat)
- return nFormat;
-
- // With formula cell, the format may be inferred from the formula result.
- return aCell.mpFormula->GetStandardFormat(*pFormatter, nFormat);
+ return nFormat;
}
}
commit c7e046e6420b410eb9a9382108df62b29bf128c6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 24 23:39:13 2013 +0200
CPPUNIT_ASSERT_EQUAL gives a more helpful error message
Change-Id: Ic7bc7d0298e6983e377b55f0362f34983de3df7a
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3f306d0..d2c042f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1475,7 +1475,7 @@ void testFuncINDIRECT(ScDocument* pDoc)
for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
{
OUString aVal = pDoc->GetString(0, i, 0);
- CPPUNIT_ASSERT_MESSAGE("Wrong value!", aVal == *aChecks[i]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong value!", *aChecks[i], aVal);
}
}
commit b61642bb3ca4cddd38b496816c0003420c352f77
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 24 23:38:08 2013 +0200
don't set hard format for text formats
Gets rid of some test failures that are the result of dirty test
environments.
Change-Id: I45ed4bbe46c8aa598e074c3eac7903811cbb2620
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 7108597..d4a4846 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1301,7 +1301,10 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
sal_uInt16 nFormatType = p->GetRetFormatType();
sal_Int32 nFormatIndex = p->GetRetFormatIndex();
- if((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+ // don't set text format as hard format
+ if(nFormatType == NUMBERFORMAT_TEXT)
+ nFormatIndex = 0;
+ else if((nFormatIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
nFormatIndex = ScGlobal::GetStandardFormat(*pDocument->GetFormatTable(),
nFormatIndex, nFormatType);
commit 57efd69c22e2c6f5cb4d057345644b6e07a62d48
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 24 22:41:44 2013 +0200
remove inherited number formats, related fdo#60215
Change-Id: I23d5e1b3baeb1499ada1fba1665027bdbe3fbb87
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 7b3302f..1954b74 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 a8f8cbb..8782552 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 fbd0c0a..cc814fd 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 60eb8e3..59a5190 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 98df69a..7108597 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 b1f83dc..1e838a0 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 )
{
commit fda007e69f16aaebe81ee7b9ac8ea4742801bb85
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 23 23:17:49 2013 +0200
use static_cast instead of c style cast
Change-Id: I9194d5fb9fc42247cf43bfcd0327472eeca7c297
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index dfbc21d..a8f8cbb 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2183,13 +2183,13 @@ void ScColumn::CalcAll()
ScBaseCell* pCell = maItems[i].pCell;
if (pCell->GetCellType() == CELLTYPE_FORMULA)
{
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
#if OSL_DEBUG_LEVEL > 1
// after F9 ctrl-F9: check the calculation for each FormulaTree
- ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
double nOldVal, nNewVal;
nOldVal = pFCell->GetValue();
#endif
- ((ScFormulaCell*)pCell)->Interpret();
+ pFCell->Interpret();
#if OSL_DEBUG_LEVEL > 1
if ( pFCell->GetCode()->IsRecalcModeNormal() )
nNewVal = pFCell->GetValue();
@@ -2214,9 +2214,10 @@ void ScColumn::CompileAll()
SCROW nRow = maItems[i].nRow;
// for unconditional compilation
// bCompile=true and pCode->nError=0
- ((ScFormulaCell*)pCell)->GetCode()->SetCodeError( 0 );
- ((ScFormulaCell*)pCell)->SetCompile( true );
- ((ScFormulaCell*)pCell)->CompileTokenArray();
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ pFCell->GetCode()->SetCodeError( 0 );
+ pFCell->SetCompile( true );
+ pFCell->CompileTokenArray();
if ( nRow != maItems[i].nRow )
Search( nRow, i ); // Listener deleted/inserted?
}
@@ -2234,7 +2235,7 @@ void ScColumn::CompileXML( ScProgress& rProgress )
if ( pCell->GetCellType() == CELLTYPE_FORMULA )
{
SCROW nRow = maItems[i].nRow;
- ((ScFormulaCell*)pCell)->CompileXML( rProgress );
+ static_cast<ScFormulaCell*>(pCell)->CompileXML( rProgress );
if ( nRow != maItems[i].nRow )
Search( nRow, i ); // Listener deleted/inserted?
}
commit abbe4414613ac26010cf378a6e52f4e6ce18f3c3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 21 20:26:04 2013 +0200
this method is unused now
We are down to two number format methods in ScFormulaCell now
Change-Id: If8bf13dfdd9803872bc1425909c31a5bb0ee1598
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 9dce5fa7..7b3302f 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -100,8 +100,6 @@ private:
void InterpretTail( ScInterpretTailParameter );
ScFormulaCell( const ScFormulaCell& );
- sal_uLong GetFormatIndex() const { return nFormatIndex; }
-
public:
enum CompareState { NotEqual = 0, EqualInvariant, EqualRelativeRef };
commit 914378d2a2987bcd437accafbe1df2250a2b2b0a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 21 20:25:21 2013 +0200
String to OUString
Change-Id: I4ca8254fea9e2ec78cb1d542cc8c0c2cd12e6e89
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 55c54c0..39f2e03 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -910,8 +910,8 @@ void XclExpFormulaCell::WriteContents( XclExpStream& rStrm )
case NUMBERFORMAT_TEXT:
{
- String aResult = mrScFmlaCell.GetString();
- if( aResult.Len() || (rStrm.GetRoot().GetBiff() <= EXC_BIFF5) )
+ OUString aResult = mrScFmlaCell.GetString();
+ if( !aResult.isEmpty() || (rStrm.GetRoot().GetBiff() <= EXC_BIFF5) )
{
rStrm << EXC_FORMULA_RES_STRING;
mxStringRec.reset( new XclExpStringRec( rStrm.GetRoot(), aResult ) );
commit 337066eb1fa395990b78d1032c399a4688d2a6f9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 7 03:05:07 2013 +0200
bail out early for error cells
Change-Id: Ice38b42cdd01b8dbb472752d2c8e1679181f8422
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 8945f16..55c54c0 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -887,20 +887,24 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
void XclExpFormulaCell::WriteContents( XclExpStream& rStrm )
{
+ sal_uInt16 nScErrCode = mrScFmlaCell.GetErrCode();
+ if( nScErrCode )
+ {
+ rStrm << EXC_FORMULA_RES_ERROR << sal_uInt8( 0 )
+ << XclTools::GetXclErrorCode( nScErrCode )
+ << sal_uInt8( 0 ) << sal_uInt16( 0 )
+ << sal_uInt16( 0xFFFF );
+
+ return;
+ }
+
// result of the formula
switch( mrScFmlaCell.GetFormatType() )
{
case NUMBERFORMAT_NUMBER:
{
// either value or error code
- sal_uInt16 nScErrCode = mrScFmlaCell.GetErrCode();
- if( nScErrCode )
- rStrm << EXC_FORMULA_RES_ERROR << sal_uInt8( 0 )
- << XclTools::GetXclErrorCode( nScErrCode )
- << sal_uInt8( 0 ) << sal_uInt16( 0 )
- << sal_uInt16( 0xFFFF );
- else
- rStrm << mrScFmlaCell.GetValue();
+ rStrm << mrScFmlaCell.GetValue();
}
break;
commit d6b10909221e15c3c33fb354e42a77b03657c51b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 7 02:10:12 2013 +0200
bail out for error cells early
Change-Id: I36581f3b735008dbba6eea5808da654eb8b279e3
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index eaeb357..de764b2 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -674,22 +674,22 @@ static const char* lcl_GetErrorString( sal_uInt16 nScErrCode )
void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsType, OUString& rsValue )
{
+ sal_uInt16 nScErrCode = rCell.GetErrCode();
+ if( nScErrCode )
+ {
+ rsType = "e";
+ rsValue = ToOUString( lcl_GetErrorString( nScErrCode ) );
+
+ return;
+ }
+
switch( rCell.GetFormatType() )
{
case NUMBERFORMAT_NUMBER:
{
// either value or error code
- sal_uInt16 nScErrCode = rCell.GetErrCode();
- if( nScErrCode )
- {
- rsType = "e";
- rsValue = ToOUString( lcl_GetErrorString( nScErrCode ) );
- }
- else
- {
- rsType = "n";
- rsValue = OUString::valueOf( rCell.GetValue() );
- }
+ rsType = "n";
+ rsValue = OUString::valueOf( rCell.GetValue() );
}
break;
commit 64223bda068cc6d82d3c5e359d465014568398bb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 7 02:00:25 2013 +0200
remove one more use of inherited number formats
Change-Id: If12ca06b45821efe9e52555095a45ae3ce2d377a
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 9c29380..8945f16 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -760,55 +760,13 @@ IMPL_FIXEDMEMPOOL_NEWDEL( XclExpFormulaCell )
XclExpFormulaCell::XclExpFormulaCell(
const XclExpRoot& rRoot, const XclAddress& rXclPos,
- const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
- const ScFormulaCell& rScFmlaCell,
+ sal_uInt32 nForcedXFId, const ScFormulaCell& rScFmlaCell,
XclExpArrayBuffer& rArrayBfr,
XclExpShrfmlaBuffer& rShrfmlaBfr,
XclExpTableopBuffer& rTableopBfr ) :
XclExpSingleCellBase( EXC_ID2_FORMULA, 0, rXclPos, nForcedXFId ),
mrScFmlaCell( const_cast< ScFormulaCell& >( rScFmlaCell ) )
{
- // *** Find result number format overwriting cell number format *** -------
-
- if( GetXFId() == EXC_XFID_NOTFOUND )
- {
- SvNumberFormatter& rFormatter = rRoot.GetFormatter();
- XclExpNumFmtBuffer& rNumFmtBfr = rRoot.GetNumFmtBuffer();
-
- // current cell number format
- sal_uLong nScNumFmt = pPattern ?
- GETITEMVALUE( pPattern->GetItemSet(), SfxUInt32Item, ATTR_VALUE_FORMAT, sal_uLong ) :
- rNumFmtBfr.GetStandardFormat();
-
- // alternative number format passed to XF buffer
- sal_uLong nAltScNumFmt = NUMBERFORMAT_ENTRY_NOT_FOUND;
- /* Xcl doesn't know Boolean number formats, we write
- "TRUE";"FALSE" (language dependent). Don't do it for automatic
- formula formats, because Excel gets them right. */
- /* #i8640# Don't set text format, if we have string results. */
- short nFormatType = mrScFmlaCell.GetFormatType();
- if( ((nScNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0) &&
- (nFormatType != NUMBERFORMAT_LOGICAL) &&
- (nFormatType != NUMBERFORMAT_TEXT) )
- nAltScNumFmt = mrScFmlaCell.GetStandardFormat( rFormatter, nScNumFmt );
- /* If cell number format is Boolean and automatic formula
- format is Boolean don't write that ugly special format. */
- else if( (nFormatType == NUMBERFORMAT_LOGICAL) &&
- (rFormatter.GetType( nScNumFmt ) == NUMBERFORMAT_LOGICAL) )
- nAltScNumFmt = rNumFmtBfr.GetStandardFormat();
-
- // #i41420# find script type according to result type (always latin for numeric results)
- sal_Int16 nScript = ApiScriptType::LATIN;
- bool bForceLineBreak = false;
- if( nFormatType == NUMBERFORMAT_TEXT )
- {
- String aResult = mrScFmlaCell.GetString();
- bForceLineBreak = mrScFmlaCell.IsMultilineResult();
- nScript = XclExpStringHelper::GetLeadingScriptType( rRoot, aResult );
- }
- SetXFId( rRoot.GetXFBuffer().InsertWithNumFmt( pPattern, nScript, nAltScNumFmt, bForceLineBreak ) );
- }
-
// *** Convert the formula token array *** --------------------------------
ScAddress aScPos( static_cast< SCCOL >( rXclPos.mnCol ), static_cast< SCROW >( rXclPos.mnRow ), rRoot.GetCurrScTab() );
@@ -2374,7 +2332,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) :
case CELLTYPE_FORMULA:
{
xCell.reset(new XclExpFormulaCell(
- GetRoot(), aXclPos, pPattern, nMergeBaseXFId,
+ GetRoot(), aXclPos, nMergeBaseXFId,
*rScCell.mpFormula, maArrayBfr, maShrfmlaBfr, maTableopBfr));
}
break;
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 655d6ea..b0253b3 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -451,8 +451,7 @@ class XclExpFormulaCell : public XclExpSingleCellBase
public:
explicit XclExpFormulaCell( const XclExpRoot& rRoot, const XclAddress& rXclPos,
- const ScPatternAttr* pPattern, sal_uInt32 nForcedXFId,
- const ScFormulaCell& rScFmlaCell,
+ sal_uInt32 nForcedXFId, const ScFormulaCell& rScFmlaCell,
XclExpArrayBuffer& rArrayBfr,
XclExpShrfmlaBuffer& rShrfmlaBfr,
XclExpTableopBuffer& rTableopBfr );
commit 1a663077de77bdbb7edfe2283d9e9bc93e90594f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue May 7 00:59:48 2013 +0200
initial work on removing some ScFormulaCell instances
These cells where using a ScFormulaCell to calculate the result of a
formula and get the number format. Use the new ScSimpleFormulaCalculator
which is a simplified version that has only a few limitations.
Change-Id: I71f01b8fa10506234627a6512cb434800dceca6a
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 373ba8a..9178c92 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -153,6 +153,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/postit \
sc/source/core/data/segmenttree \
sc/source/core/data/sheetevents \
+ sc/source/core/data/simpleformulacalc \
sc/source/core/data/sortparam \
sc/source/core/data/stlpool \
sc/source/core/data/stlsheet \
diff --git a/sc/inc/simpleformulacalc.hxx b/sc/inc/simpleformulacalc.hxx
new file mode 100644
index 0000000..43ff6ea
--- /dev/null
+++ b/sc/inc/simpleformulacalc.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_SIMPLE_FORMULA_CALC_HXX
+#define SC_SIMPLE_FORMULA_CALC_HXX
+
+#include <boost/scoped_ptr.hpp>
+#include <formula/grammar.hxx>
+
+#include "address.hxx"
+#include "formularesult.hxx"
+
+class ScDocument;
+class ScTokenArray;
+
+class ScSimpleFormulaCalculator
+{
+private:
+ short mnFormatType;
+ sal_uLong mnFormatIndex;
+
+ bool mbCalculated;
+ boost::scoped_ptr<ScTokenArray> mpCode;
+ ScAddress maAddr;
+ ScDocument* mpDoc;
+ ScFormulaResult maResult;
+
+public:
+ ScSimpleFormulaCalculator(ScDocument* pDoc, const ScAddress& rAddr,
+ const OUString& rFormula, formula::FormulaGrammar::Grammar eGram = formula::FormulaGrammar::GRAM_DEFAULT);
+ ~ScSimpleFormulaCalculator();
+
+ void Calculate();
+ bool IsValue();
+ sal_uInt16 GetErrCode();
+ double GetValue();
+ OUString GetString();
+ short GetFormatType() const { return mnFormatType; }
+ sal_uLong GetFormatIndex() const { return mnFormatIndex; }
+
+ bool HasColRowName();
+
+ ScTokenArray* GetCode();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/simpleformulacalc.cxx b/sc/source/core/data/simpleformulacalc.cxx
new file mode 100644
index 0000000..1b2cd35
--- /dev/null
+++ b/sc/source/core/data/simpleformulacalc.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "simpleformulacalc.hxx"
+#include "document.hxx"
+#include "tokenarray.hxx"
+#include "interpre.hxx"
+#include "compiler.hxx"
+
+
+ScSimpleFormulaCalculator::ScSimpleFormulaCalculator( ScDocument* pDoc, const ScAddress& rAddr,
+ const OUString& rFormula, formula::FormulaGrammar::Grammar eGram ):
+ mbCalculated(false),
+ maAddr(rAddr),
+ mpDoc(pDoc)
+{
+ // compile already here
+ ScCompiler aComp(pDoc, rAddr);
+ aComp.SetGrammar(eGram);
+ mpCode.reset(aComp.CompileString(rFormula));
+ if(!mpCode->GetCodeError() && mpCode->GetLen())
+ aComp.CompileTokenArray();
+}
+
+ScSimpleFormulaCalculator::~ScSimpleFormulaCalculator()
+{
+}
+
+void ScSimpleFormulaCalculator::Calculate()
+{
+ if(mbCalculated)
+ return;
+
+ mbCalculated = true;
+ ScInterpreter aInt(NULL, mpDoc, maAddr, *mpCode.get());
+ aInt.Interpret();
+
+ mnFormatType = aInt.GetRetFormatType();
+ mnFormatIndex = aInt.GetRetFormatIndex();
+ maResult.SetToken(aInt.GetResultToken().get());
+}
+
+bool ScSimpleFormulaCalculator::IsValue()
+{
+ Calculate();
+
+ return maResult.IsValue();
+}
+
+sal_uInt16 ScSimpleFormulaCalculator::GetErrCode()
+{
+ Calculate();
+
+ sal_uInt16 nErr = mpCode->GetCodeError();
+ if (nErr)
+ return nErr;
+ return maResult.GetResultError();
+}
+
+
+double ScSimpleFormulaCalculator::GetValue()
+{
+ Calculate();
+
+ if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == errDoubleRef) &&
+ !maResult.GetResultError())
+ return maResult.GetDouble();
+
+ return 0.0;
+}
+
+OUString ScSimpleFormulaCalculator::GetString()
+{
+ Calculate();
+
+ if ((!mpCode->GetCodeError() || mpCode->GetCodeError() == errDoubleRef) &&
+ !maResult.GetResultError())
+ return maResult.GetString();
+
+ return OUString();
+}
+
+bool ScSimpleFormulaCalculator::HasColRowName()
+{
+ mpCode->Reset();
+ return mpCode->GetNextColRowName() != NULL;
+}
+
+ScTokenArray* ScSimpleFormulaCalculator::GetCode()
+{
+ return mpCode.get();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index d98b044..7fd4ef7 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3724,8 +3724,14 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScTTT" );
- sal_uInt8 cMatFlag = pMyFormulaCell->GetMatrixFlag();
- bMatrixFormula = ( cMatFlag == MM_FORMULA || cMatFlag == MM_FAKE );
+ if(pMyFormulaCell)
+ {
+ sal_uInt8 cMatFlag = pMyFormulaCell->GetMatrixFlag();
+ bMatrixFormula = ( cMatFlag == MM_FORMULA || cMatFlag == MM_FAKE );
+ }
+ else
+ bMatrixFormula = false;
+
if (!bGlobalStackInUse)
{
bGlobalStackInUse = true;
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 90cba30..090d0cd 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -70,7 +70,7 @@
#include "userlist.hxx"
#include "rfindlst.hxx"
#include "inputopt.hxx"
-#include "formulacell.hxx" // fuer Formel-Preview
+#include "simpleformulacalc.hxx"
#include "compiler.hxx" // fuer Formel-Preview
#include "editable.hxx"
#include "funcdesc.hxx"
@@ -1307,48 +1307,48 @@ static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const
if(rFormula.isEmpty())
return String();
- boost::scoped_ptr<ScFormulaCell> pCell(new ScFormulaCell( pDoc, rPos, rFormula ));
+ boost::scoped_ptr<ScSimpleFormulaCalculator> pCalc( new ScSimpleFormulaCalculator( pDoc, rPos, rFormula ) );
// HACK! um bei ColRowNames kein #REF! zu bekommen,
// wenn ein Name eigentlich als Bereich in die Gesamt-Formel
// eingefuegt wird, bei der Einzeldarstellung aber als
// single-Zellbezug interpretiert wird
- bool bColRowName = pCell->HasColRowName();
+ bool bColRowName = pCalc->HasColRowName();
if ( bColRowName )
{
// ColRowName im RPN-Code?
- if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ if ( pCalc->GetCode()->GetCodeLen() <= 1 )
{ // ==1: einzelner ist als Parameter immer Bereich
// ==0: es waere vielleicht einer, wenn..
OUStringBuffer aBraced;
aBraced.append('(');
aBraced.append(rFormula);
aBraced.append(')');
- pCell.reset(new ScFormulaCell( pDoc, rPos, aBraced.makeStringAndClear() ));
+ pCalc.reset( new ScSimpleFormulaCalculator( pDoc, rPos, aBraced.makeStringAndClear() ) );
}
else
bColRowName = false;
}
- sal_uInt16 nErrCode = pCell->GetErrCode();
+ sal_uInt16 nErrCode = pCalc->GetErrCode();
if ( nErrCode != 0 )
return ScGlobal::GetErrorString(nErrCode);
SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
OUString aValue;
- if ( pCell->IsValue() )
+ if ( pCalc->IsValue() )
{
- double n = pCell->GetValue();
+ double n = pCalc->GetValue();
sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
- pCell->GetFormatType(), ScGlobal::eLnge );
+ pCalc->GetFormatType(), ScGlobal::eLnge );
aFormatter.GetInputLineString( n, nFormat, aValue );
//! display OutputString but insert InputLineString
}
else
{
- OUString aStr = pCell->GetString();
+ OUString aStr = pCalc->GetString();
sal_uLong nFormat = aFormatter.GetStandardFormat(
- pCell->GetFormatType(), ScGlobal::eLnge);
+ pCalc->GetFormatType(), ScGlobal::eLnge);
{
Color* pColor;
aFormatter.GetOutputString( aStr, nFormat,
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 6b04dc3..522a277 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -39,7 +39,7 @@
#include "scresid.hxx"
#include "reffact.hxx"
#include "document.hxx"
-#include "formulacell.hxx"
+#include "simpleformulacalc.hxx"
#include "scmod.hxx"
#include "inputhdl.hxx"
#include "tabvwsh.hxx"
@@ -184,8 +184,6 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
pData->SetMode( (sal_uInt16) eMode );
String rStrExp = GetMeText();
- pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
-
Update(rStrExp);
}
@@ -241,8 +239,6 @@ void ScFormulaDlg::fill()
SetMeText(rStrExp);
- pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
-
Update();
// Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde!
pScMod->SetRefInputHdl(NULL);
@@ -260,8 +256,6 @@ ScFormulaDlg::~ScFormulaDlg()
pScMod->SetRefInputHdl(NULL);
StoreFormEditData(pData);
} // if (pData) // wird nicht ueber Close zerstoert;
-
- delete pCell;
}
sal_Bool ScFormulaDlg::IsInputHdl(ScInputHandler* pHdl)
@@ -316,24 +310,24 @@ sal_Bool ScFormulaDlg::Close()
// --------------------------------------------------------------------------
bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult )
{
- boost::scoped_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
+ boost::scoped_ptr<ScSimpleFormulaCalculator> pFCell( new ScSimpleFormulaCalculator( pDoc, aCursorPos, rStrExp ) );
// HACK! um bei ColRowNames kein #REF! zu bekommen,
// wenn ein Name eigentlich als Bereich in die Gesamt-Formel
// eingefuegt wird, bei der Einzeldarstellung aber als
// single-Zellbezug interpretiert wird
- sal_Bool bColRowName = pCell->HasColRowName();
+ sal_Bool bColRowName = pFCell->HasColRowName();
if ( bColRowName )
{
// ColRowName im RPN-Code?
- if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ if ( pFCell->GetCode()->GetCodeLen() <= 1 )
{ // ==1: einzelner ist als Parameter immer Bereich
// ==0: es waere vielleicht einer, wenn..
OUStringBuffer aBraced;
aBraced.append('(');
aBraced.append(rStrExp);
aBraced.append(')');
- pFCell.reset( new ScFormulaCell( pDoc, aCursorPos, aBraced.makeStringAndClear() ) );
+ pFCell.reset( new ScSimpleFormulaCalculator( pDoc, aCursorPos, aBraced.makeStringAndClear() ) );
}
else
bColRowName = false;
@@ -371,11 +365,6 @@ bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult )
else
rStrResult += ScGlobal::GetErrorString(nErrCode);
- if(!isUserMatrix() && pFCell->GetMatrixFlag())
- {
- CheckMatrix();
- }
-
return true;
}
commit 58545dee13cd54ac7e2d7e776efdc46534086e11
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon May 6 22:53:25 2013 +0200
we don't need this include in the header file
Change-Id: Ic0dce5427c359a44c36a59acfce3427fc9815d97
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index 4e6fd39..b337d2f 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -23,8 +23,6 @@
#include "token.hxx"
#include "scdllapi.h"
-#include <sal/log.hxx>
-
/** Store a variable formula cell result, balancing between runtime performance
and memory consumption. */
class ScFormulaResult
commit e2d17fe71e322461004e9c2c52b91050a25584b6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 3 23:28:23 2013 +0200
a few more places without ScFormulaCell
Change-Id: I13ae80429e06fad5e28f1166a585656e8e4ec29f
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index f4afd4e..91397b4 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2274,8 +2274,8 @@ void ScInterpreter::ScDde()
// Nach dem Laden muss neu interpretiert werden (Verknuepfungen aufbauen)
- if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
- pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
+ if ( rArr.IsRecalcModeNormal() )
+ rArr.SetExclusiveRecalcModeOnLoad();
// solange der Link nicht ausgewertet ist, Idle abklemmen
// (um zirkulaere Referenzen zu vermeiden)
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 5b654b7..d98b044 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2647,8 +2647,8 @@ void ScInterpreter::ScExternal()
else
{
// nach dem Laden Asyncs wieder anwerfen
- if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
- pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
+ if ( rArr.IsRecalcModeNormal() )
+ rArr.SetExclusiveRecalcModeOnLoad();
// garantiert identischer Handle bei identischem Aufruf?!?
// sonst schei*e ...
double nErg = 0.0;
@@ -3019,9 +3019,9 @@ void ScInterpreter::ScExternal()
if ( aCall.HasVarRes() ) // handle async functions
{
- if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
+ if ( rArr.IsRecalcModeNormal() )
{
- pMyFormulaCell->GetCode()->SetExclusiveRecalcModeOnLoad();
+ rArr.SetExclusiveRecalcModeOnLoad();
}
uno::Reference<sheet::XVolatileResult> xRes = aCall.GetVarRes();
ScAddInListener* pLis = ScAddInListener::Get( xRes );
commit 267f7a630b33f02a8dfda55945ee10b2c5f615f9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 3 22:54:53 2013 +0200
preparations for inherited number format removal
Without inherited number format these calls are unnecessary.
Change-Id: I359cb217eb32d98df29bb6d2c0fbb14367e30425
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index d7d63f7..eb29dea 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -849,13 +849,7 @@ public:
SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScAddress& ) const;
void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat );
- /**
- * If no number format attribute is set and a formula cell pointer is
- * passed, the calculated number format of the formula cell is returned.
- * pCell may be NULL.
- */
- SC_DLLPUBLIC void GetNumberFormatInfo( short& nType, sal_uLong& nIndex,
- const ScAddress& rPos, const ScFormulaCell* pCell ) const;
+ void GetNumberFormatInfo( short& nType, sal_uLong& nIndex, const ScAddress& rPos ) const;
void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormula ) const;
const ScTokenArray* GetFormulaTokens( const ScAddress& rPos ) const;
SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const;
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 4ff97f3..9dce5fa7 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -216,8 +216,6 @@ public:
sal_uInt16 GetErrCode(); // interpret first if necessary
sal_uInt16 GetRawError(); // don't interpret, just return code or result error
short GetFormatType() const { return nFormatType; }
- void GetFormatInfo( short& nType, sal_uLong& nIndex ) const
- { nType = nFormatType; nIndex = nFormatIndex; }
sal_uInt8 GetMatrixFlag() const { return cMatrixFlag; }
ScTokenArray* GetCode() const { return pCode; }
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index b834a0c..8f6d1c2 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -415,27 +415,7 @@ void ScValueIterator::GetCurNumFmtInfo( short& nType, sal_uLong& nIndex )
{
const ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol];
nNumFmtIndex = pCol->GetNumberFormat( nRow );
- if ( (nNumFmtIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- {
- const ScBaseCell* pCell;
- SCSIZE nIdx = nColRow - 1;
- // Something might have rearranged; be on the safe side
- if ( nIdx < pCol->maItems.size() && pCol->maItems[nIdx].nRow == nRow )
- pCell = pCol->maItems[nIdx].pCell;
- else
- {
- if ( pCol->Search( nRow, nIdx ) )
- pCell = pCol->maItems[nIdx].pCell;
- else
- pCell = NULL;
- }
- if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
- ((const ScFormulaCell*)pCell)->GetFormatInfo( nNumFmtType, nNumFmtIndex );
- else
- nNumFmtType = pDoc->GetFormatTable()->GetType( nNumFmtIndex );
- }
- else
- nNumFmtType = pDoc->GetFormatTable()->GetType( nNumFmtIndex );
+ nNumFmtType = pDoc->GetFormatTable()->GetType( nNumFmtIndex );
bNumValid = true;
}
nType = nNumFmtType;
@@ -612,8 +592,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
rValue.mfValue = ((ScFormulaCell*)pCell)->GetValue();
rValue.mbIsNumber = true;
mpDoc->GetNumberFormatInfo( nNumFmtType,
- nNumFmtIndex, ScAddress(nCol, nRow, nTab),
- static_cast<ScFormulaCell*>(pCell));
+ nNumFmtIndex, ScAddress(nCol, nRow, nTab));
rValue.mnError = ((ScFormulaCell*)pCell)->GetErrCode();
return true; // Found it!
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9a9201c..e1997fe 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3321,16 +3321,13 @@ void ScDocument::SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberForma
}
void ScDocument::GetNumberFormatInfo( short& nType, sal_uLong& nIndex,
- const ScAddress& rPos, const ScFormulaCell* pCell ) const
+ const ScAddress& rPos ) const
{
SCTAB nTab = rPos.Tab();
if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
{
nIndex = maTabs[nTab]->GetNumberFormat( rPos );
- if ( (nIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && pCell)
- pCell->GetFormatInfo(nType, nIndex);
- else
- nType = GetFormatTable()->GetType( nIndex );
+ nType = GetFormatTable()->GetType( nIndex );
}
else
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index adbf268..5b654b7 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -464,7 +464,7 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue&
{
fValue = pFCell->GetValue();
pDok->GetNumberFormatInfo( nCurFmtType, nCurFmtIndex,
- rPos, pFCell );
+ rPos );
}
else
{
@@ -980,7 +980,7 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString,
{
bool bInherited = (aCell.meType == CELLTYPE_FORMULA);
if (pRetTypeExpr && pRetIndexExpr)
- pDok->GetNumberFormatInfo(*pRetTypeExpr, *pRetIndexExpr, rAddress, (bInherited ? aCell.mpFormula : NULL));
+ pDok->GetNumberFormatInfo(*pRetTypeExpr, *pRetIndexExpr, rAddress);
PushTempToken( new ScEmptyCellToken( bInherited, bDisplayEmptyAsString));
return;
}
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index fc904a4..df47cf0 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -3293,7 +3293,7 @@ void ScInterpreter::ScMatRef()
else
{
PushDouble(nMatVal.fVal); // handles DoubleError
- pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr, aCell.mpFormula);
+ pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr);
nFuncFmtType = nCurFmtType;
nFuncFmtIndex = nCurFmtIndex;
}
@@ -3312,7 +3312,7 @@ void ScInterpreter::ScMatRef()
OUString aVal = aCell.mpFormula->GetString();
PushString( aVal );
}
- pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr, aCell.mpFormula);
+ pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr);
nFuncFmtType = nCurFmtType;
nFuncFmtIndex = nCurFmtIndex;
}
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index af79ad7..603dfee 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1065,9 +1065,6 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
break;
case CELLTYPE_FORMULA:
fVal = aCell.mpFormula->GetValue();
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
- nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
- nFormat, aCell.mpFormula->GetFormatType() );
break;
default:
OSL_FAIL( "value data with unsupported cell type" );
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index e1f551b..90cba30 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1372,8 +1372,8 @@ void ScInputHandler::FormulaPreview()
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && pActiveViewSh )
{
- String aPart = pActiveView->GetSelected();
- if (!aPart.Len())
+ OUString aPart = pActiveView->GetSelected();
+ if (aPart.isEmpty())
aPart = pEngine->GetText(0);
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
aValue = lcl_Calculate( aPart, pDoc, aCursorPos );
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 120b386..2eb7b25 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -628,12 +628,6 @@ void lcl_GetColumnTypes(
{
sal_uInt32 nFormat;
pDoc->GetNumberFormat( nCol, nFirstDataRow, nTab, nFormat );
- if (aCell.meType == CELLTYPE_FORMULA && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0))
- {
- nFormat = ScGlobal::GetStandardFormat(
- aCell.mpFormula->GetValue(), *pNumFmt, nFormat,
- aCell.mpFormula->GetFormatType());
- }
switch ( pNumFmt->GetType( nFormat ) )
{
case NUMBERFORMAT_LOGICAL :
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 33432fa..1f93b5e 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -596,15 +596,6 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScRefCellValue& rCell, long nWidth
// If it's formula, the result must be a value.
if (!pFCell->IsValue())
return;
-
- if (pFCell->GetFormatType() != NUMBERFORMAT_NUMBER)
- {
- // Make sure the format type implicitly set by the interpreter is
- // of pure numeric type. We don't want to adjust date and time
- // values here.
- SetHashText();
- return;
- }
}
sal_uLong nFormat = GetResultValueFormat(rCell);
@@ -798,10 +789,7 @@ sal_uLong ScDrawStringsVars::GetResultValueFormat( const ScRefCellValue& rCell )
// Get the effective number format, including formula result types.
// This assumes that a formula cell has already been calculated.
- if ((nValueFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && rCell.meType == CELLTYPE_FORMULA)
- return rCell.mpFormula->GetStandardFormat(*pOutput->mpDoc->GetFormatTable(), nValueFormat);
- else
- return nValueFormat;
+ return nValueFormat;
}
//==================================================================
commit ddade7a4751b9b7f6459f48ffdf3dedf31d151f3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 3 22:25:58 2013 +0200
remove temporary String instances
Change-Id: I8afd7636fa0dcbf53402e8a4393868526e56892b
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 550753a..eaeb357 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -696,8 +696,7 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT
case NUMBERFORMAT_TEXT:
{
rsType = "str";
- String aResult = rCell.GetString();
- rsValue = ToOUString( aResult );
+ rsValue = rCell.GetString();
}
break;
@@ -711,8 +710,7 @@ void XclXmlUtils::GetFormulaTypeAndValue( ScFormulaCell& rCell, const char*& rsT
default:
{
rsType = "inlineStr";
- String aResult = rCell.GetString();
- rsValue = ToOUString( aResult );
+ rsValue = rCell.GetString();
}
break;
}
commit 7978c78606608622a5e064f4d95c88393bea426a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri May 3 03:53:44 2013 +0200
more String->OUString and early bail outs
Change-Id: Ia573f27962b5fbb48e543a2e2a802e85db36fafd
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 04a09ed..e1f551b 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1299,7 +1299,7 @@ void ScInputHandler::PasteFunctionData()
// Selektion berechnen und als Tip-Hilfe anzeigen
//
-static String lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const ScAddress &rPos )
+static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const ScAddress &rPos )
{
//! mit ScFormulaDlg::CalcValue zusammenfassen und ans Dokument verschieben !!!!
//! (Anfuehrungszeichen bei Strings werden nur hier eingefuegt)
@@ -1331,43 +1331,37 @@ static String lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const S
}
sal_uInt16 nErrCode = pCell->GetErrCode();
- if ( nErrCode == 0 )
+ if ( nErrCode != 0 )
+ return ScGlobal::GetErrorString(nErrCode);
+
+ SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
+ OUString aValue;
+ if ( pCell->IsValue() )
{
- SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
- Color* pColor;
- if ( pCell->IsValue() )
- {
- double n = pCell->GetValue();
- sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
- pCell->GetFormatType(), ScGlobal::eLnge );
- aFormatter.GetInputLineString( n, nFormat, aValue );
- //! display OutputString but insert InputLineString
- }
- else
+ double n = pCell->GetValue();
+ sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
+ pCell->GetFormatType(), ScGlobal::eLnge );
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list