[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf2' - 5 commits - sc/inc sc/qa sc/source
Daniel Bankston
dbank at kemper.freedesktop.org
Fri Jul 6 20:33:55 PDT 2012
sc/inc/cell.hxx | 1
sc/inc/document.hxx | 6 +--
sc/qa/unit/data/contentCSV/hard-recalc.csv | 1
sc/qa/unit/data/ods/hard-recalc.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 47 +++++++++++++++++++++++++++++
sc/source/core/data/bcaslot.cxx | 4 --
sc/source/core/data/documen2.cxx | 2 -
sc/source/core/data/documen7.cxx | 8 ++--
sc/source/filter/xml/xmlcelli.cxx | 12 ++++++-
sc/source/ui/docshell/docsh.cxx | 6 +--
sc/source/ui/docshell/docsh4.cxx | 2 -
11 files changed, 73 insertions(+), 16 deletions(-)
New commits:
commit c4bd67a09aff578be00e85c90cc056023387ca26
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jul 6 22:30:54 2012 -0500
Use text:p value if cached formula result is Err:### or #N/A
This should be removed once we have export working correctly for
function errors.
Change-Id: Ibdd20478b458dd7849544ec90f32d754e3a71755
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 708e227..6f21e8b 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -187,6 +187,11 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
{
::sax::Converter::convertDouble(fValue, sValue);
bIsEmpty = false;
+
+ //if office:value="0", treat like text in case the formula
+ //result is "Err:###" or "#N/A" until we confirm otherwise
+ if(fValue == 0.0)
+ bFormulaTextResult = true;
}
}
break;
@@ -1001,6 +1006,11 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
+ //if this is an "Err:###" or "#N/A" then use text:p value
+ if( bFormulaTextResult && pOUTextContent &&
+ (pOUTextContent->match("Err:") || pOUTextContent->match("#N/A")) )
+ pOUTextValue.reset(*pOUTextContent);
+
ScBaseCell* pNewCell = NULL;
if ( !aText.isEmpty() )
commit ca44cfe77d871ce5a240a56aeba54c50c9b59c83
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jul 6 20:59:34 2012 -0500
Set proper number format for formula cell
Set proper number format for formula cell so that cached
formula results are displayed properly.
Example: so =NOT(1) will properly display as FALSE instead of as 0.
Change-Id: Ifa4e3e83bc81779e34be385508da23a3b66c0a8c
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 9499084..a029e45 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -450,6 +450,7 @@ 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 SetFormatType( short nFType ) { nFormatType = nFType; }
sal_uLong GetFormatIndex() const { return nFormatIndex; }
void GetFormatInfo( short& nType, sal_uLong& nIndex ) const
{ nType = nFormatType; nIndex = nFormatIndex; }
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 86c7034..708e227 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -254,7 +254,6 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
{
if (nCellType == util::NumberFormat::TEXT)
bFormulaTextResult = true;
- nCellType = util::NumberFormat::UNDEFINED;
}
rXMLImport.GetStylesImportHelper()->SetAttributes(pStyleName, pCurrencySymbol, nCellType);
}
@@ -1023,6 +1022,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
pFCell->SetHybridString( *pOUTextValue );
else
pFCell->SetHybridDouble( fValue );
+ pFCell->SetFormatType( nCellType );
pFCell->ResetDirty();
}
else if ( aText[0] == '\'' && aText.getLength() > 1 )
commit 3d03a74079c4850b5ba3183d976fe49fd7bd6fb4
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jul 6 20:55:47 2012 -0500
Add test for import of cached formula results (without hard-recalc)
Change-Id: I7e73465d152332661f48e4dcd9ae28135821df68
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 948074b..ce0133f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -102,6 +102,7 @@ public:
void testRangeNameXLSX();
void testHardRecalcODS();
void testFunctionsODS();
+ void testCachedFormulaResultsODS();
void testDatabaseRangesODS();
void testDatabaseRangesXLS();
void testDatabaseRangesXLSX();
@@ -134,6 +135,7 @@ public:
CPPUNIT_TEST(testRangeNameXLSX);
CPPUNIT_TEST(testHardRecalcODS);
CPPUNIT_TEST(testFunctionsODS);
+ CPPUNIT_TEST(testCachedFormulaResultsODS);
CPPUNIT_TEST(testDatabaseRangesODS);
CPPUNIT_TEST(testDatabaseRangesXLS);
CPPUNIT_TEST(testDatabaseRangesXLSX);
@@ -349,6 +351,31 @@ void ScFiltersTest::testFunctionsODS()
xDocSh->DoClose();
}
+void ScFiltersTest::testCachedFormulaResultsODS()
+{
+ const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("functions."));
+ ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
+
+ CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ rtl::OUString aCSVFileName;
+
+ //test cached formula results of logical functions
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("logical-functions.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 0);
+ //test cached formula results of spreadsheet functions
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spreadsheet-functions.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 1);
+ //test cached formula results of mathematical functions
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mathematical-functions.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 2, PureString);
+ //test cached formula results of informations functions
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("information-functions.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 3);
+
+ xDocSh->DoClose();
+}
+
namespace {
void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat)
commit c90d5afea3e1ffeff1dd10a871871d5d5c039c28
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jul 6 02:22:12 2012 -0500
Add test for hard recalc
Change-Id: I0fdbac47d6049d4a8b0b100eb1ce0fdab3eed262
diff --git a/sc/qa/unit/data/contentCSV/hard-recalc.csv b/sc/qa/unit/data/contentCSV/hard-recalc.csv
new file mode 100644
index 0000000..5d7a586
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/hard-recalc.csv
@@ -0,0 +1 @@
+2+2=,4
diff --git a/sc/qa/unit/data/ods/hard-recalc.ods b/sc/qa/unit/data/ods/hard-recalc.ods
new file mode 100644
index 0000000..970ba2c
Binary files /dev/null and b/sc/qa/unit/data/ods/hard-recalc.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 987c6e0..948074b 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -100,6 +100,7 @@ public:
//ods, xls, xlsx filter tests
void testRangeNameXLS();
void testRangeNameXLSX();
+ void testHardRecalcODS();
void testFunctionsODS();
void testDatabaseRangesODS();
void testDatabaseRangesXLS();
@@ -131,6 +132,7 @@ public:
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testRangeNameXLS);
CPPUNIT_TEST(testRangeNameXLSX);
+ CPPUNIT_TEST(testHardRecalcODS);
CPPUNIT_TEST(testFunctionsODS);
CPPUNIT_TEST(testDatabaseRangesODS);
CPPUNIT_TEST(testDatabaseRangesXLS);
@@ -303,6 +305,24 @@ void ScFiltersTest::testRangeNameXLSX()
xDocSh->DoClose();
}
+void ScFiltersTest::testHardRecalcODS()
+{
+ const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("hard-recalc."));
+ ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
+ xDocSh->DoHardRecalc(true);
+
+ CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
+ ScDocument* pDoc = xDocSh->GetDocument();
+ rtl::OUString aCSVFileName;
+
+ //test hard recalc: document has an incorrect cached formula result
+ //hard recalc should have updated to the correct result
+ createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("hard-recalc.")), aCSVFileName);
+ testFile(aCSVFileName, pDoc, 0);
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testFunctionsODS()
{
const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("functions."));
commit 38128c677f5dcdcc4554db12456a287c0886bff6
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date: Fri Jul 6 02:04:28 2012 -0500
Use bool instead of sal_uInt16 for HardCalcState
Change-Id: Ia855780c28dc05e1606e8118fabd2a86bfcc5fa2
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index b4df35b..9a0c167 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -345,7 +345,7 @@ private:
sal_uInt16 nSrcVer; // file version (load/save)
SCROW nSrcMaxRow; // number of lines to load/save
sal_uInt16 nFormulaTrackCount;
- sal_uInt16 nHardRecalcState; // 0: soft, 1: hard-warn, 2: hard
+ bool bHardRecalcState; // false: soft, true: hard
SCTAB nVisibleTab; // for OLE etc.
ScLkUpdMode eLinkMode;
@@ -1672,8 +1672,8 @@ public:
sal_uInt16 GetFormulaTrackCount() const { return nFormulaTrackCount; }
bool IsInFormulaTree( ScFormulaCell* pCell ) const;
bool IsInFormulaTrack( ScFormulaCell* pCell ) const;
- sal_uInt16 GetHardRecalcState() { return nHardRecalcState; }
- void SetHardRecalcState( sal_uInt16 nVal ) { nHardRecalcState = nVal; }
+ bool GetHardRecalcState() { return bHardRecalcState; }
+ void SetHardRecalcState( bool bVal ) { bHardRecalcState = bVal; }
void StartAllListeners();
const ScFormulaCell* GetFormulaTree() const { return pFormulaTree; }
bool HasForcedFormulas() const { return bHasForcedFormulas; }
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 2d99ff4..b30a21e 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -151,8 +151,6 @@ bool ScBroadcastAreaSlot::CheckHardRecalcStateCondition() const
{ // this is more hypothetical now, check existed for old SV_PTRARR_SORT
if ( !pDoc->GetHardRecalcState() )
{
- pDoc->SetHardRecalcState( 1 );
-
SfxObjectShell* pShell = pDoc->GetDocumentShell();
OSL_ENSURE( pShell, "Missing DocShell :-/" );
@@ -160,7 +158,7 @@ bool ScBroadcastAreaSlot::CheckHardRecalcStateCondition() const
pShell->SetError( SCWARN_CORE_HARD_RECALC, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
pDoc->SetAutoCalc( false );
- pDoc->SetHardRecalcState( 2 );
+ pDoc->SetHardRecalcState( true );
}
return true;
}
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 2419859..6b3aa3c 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -173,7 +173,7 @@ ScDocument::ScDocument( ScDocumentMode eMode,
nSrcVer( SC_CURRENT_VERSION ),
nSrcMaxRow( MAXROW ),
nFormulaTrackCount(0),
- nHardRecalcState(0),
+ bHardRecalcState(false),
nVisibleTab( 0 ),
eLinkMode(LM_UNKNOWN),
bAutoCalc( eMode == SCDOCMODE_DOCUMENT ),
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 9e92150..7fe018a 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -87,7 +87,7 @@ void ScDocument::Broadcast( const ScHint& rHint )
{
if ( !pBASM )
return ; // Clipboard or Undo
- if ( !nHardRecalcState )
+ if ( !bHardRecalcState )
{
ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast
bool bIsBroadcasted = false;
@@ -130,7 +130,7 @@ void ScDocument::AreaBroadcast( const ScHint& rHint )
{
if ( !pBASM )
return ; // Clipboard or Undo
- if ( !nHardRecalcState )
+ if ( !bHardRecalcState )
{
ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast
if ( pBASM->AreaBroadcast( rHint ) )
@@ -153,7 +153,7 @@ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHin
{
if ( !pBASM )
return ; // Clipboard or Undo
- if ( !nHardRecalcState )
+ if ( !bHardRecalcState )
{
ScBulkBroadcast aBulkBroadcast( pBASM); // scoped bulk broadcast
if ( pBASM->AreaBroadcastInRange( rRange, rHint ) )
@@ -295,7 +295,7 @@ void ScDocument::CalcFormulaTree( bool bOnlyForced, bool bNoProgress )
//! _nicht_ SetAutoCalc( true ) weil das evtl. CalcFormulaTree( true )
//! aufruft, wenn vorher disabled war und bHasForcedFormulas gesetzt ist
bAutoCalc = true;
- if ( nHardRecalcState )
+ if ( bHardRecalcState )
CalcAll();
else
{
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index d6b77de..113582a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -386,12 +386,12 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
if (pModificator)
{
- sal_uInt16 nRecalcState = aDocument.GetHardRecalcState();
+ bool bRecalcState = aDocument.GetHardRecalcState();
//temporarily set hard-recalc to prevent calling ScFormulaCell::Notify()
//which will set the cells dirty.
- aDocument.SetHardRecalcState(2);
+ aDocument.SetHardRecalcState(true);
delete pModificator;
- aDocument.SetHardRecalcState(nRecalcState);
+ aDocument.SetHardRecalcState(bRecalcState);
pModificator = NULL;
}
else
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 1f1211e..0f54ef9 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1799,7 +1799,7 @@ void ScDocShell::GetState( SfxItemSet &rSet )
switch (nWhich)
{
case FID_AUTO_CALC:
- if ( (sal_Bool) aDocument.GetHardRecalcState() )
+ if ( aDocument.GetHardRecalcState() )
rSet.DisableItem( nWhich );
else
rSet.Put( SfxBoolItem( nWhich, aDocument.GetAutoCalc() ) );
More information about the Libreoffice-commits
mailing list