[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf2' - sc/source

Daniel Bankston dbank at kemper.freedesktop.org
Sat Jul 7 05:16:13 PDT 2012


 sc/source/filter/xml/xmlcelli.cxx |   12 ++++++++++--
 sc/source/ui/docshell/docsh.cxx   |    5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 7dd4d50687d7c94673e6d9f62b54054b1b817027
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Sat Jul 7 07:15:21 2012 -0500

    Use indexOf instead of match
    
    Change-Id: I2743929c3ba06ce1345d7217d9297515d2b5b2e4

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 6f21e8b..212f03e 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -996,6 +996,15 @@ void ScXMLTableRowCellContext::AddNonFormulaCells( const ScAddress& rCellPos )
     }
 }
 
+namespace{
+
+bool isErrOrNA(const rtl::OUString& rStr)
+{
+    return (rStr.indexOf("Err:")  > -1) || (rStr.indexOf("#N/A") > -1);
+}
+
+}
+
 void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPos )
 {
     ScDocument* pDoc = rXMLImport.GetDocument();
@@ -1007,8 +1016,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
     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")) )
+    if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
         pOUTextValue.reset(*pOUTextContent);
 
     ScBaseCell* pNewCell = NULL;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 113582a..6c3bb24 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -450,10 +450,13 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
     if ( nError )
         pLoadMedium->SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
 
+    //if the document was not generated by LibreOffice, do hard recalc in case some other document
+    //generator saved cached formula results that differ from LibreOffice's calculated results or
+    //did not use cached formula results.
     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
     uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
     rtl::OUString sGenerator(xDocProps->getGenerator());
-    if(!sGenerator.match(SC_LIBO_PROD_NAME))
+    if(sGenerator.indexOf(SC_LIBO_PROD_NAME) == -1)
         DoHardRecalc(false);
 
     aDocument.SetXMLFromWrapper( false );


More information about the Libreoffice-commits mailing list