[Libreoffice-commits] .: sc/inc sc/source

Muthu Subramanian sumuthu at kemper.freedesktop.org
Wed Jun 29 00:13:48 PDT 2011


 sc/inc/cell.hxx                  |    1 +
 sc/inc/cellsuno.hxx              |    4 ++++
 sc/source/core/data/cell.cxx     |    7 ++++++-
 sc/source/ui/docshell/docsh4.cxx |    2 +-
 sc/source/ui/unoobj/cellsuno.cxx |   25 +++++++++++++++++++++++++
 sc/source/ui/unoobj/docuno.cxx   |   11 ++++++++---
 6 files changed, 45 insertions(+), 5 deletions(-)

New commits:
commit c93c3b0073d3ce86234031b47fb2aad9f72d7665
Author: Muthu Subramanian <sumuthu at novell.com>
Date:   Wed Jun 29 12:59:27 2011 +0530

    Improved xlsx formula import.
    
    Now uses the values present in the import document
    rather than calculating the formula. This speeds up
    document loading.
    TODO: Extend this to string results as well.

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 55a72b0..4c92203 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -404,6 +404,7 @@ public:
     void			SetTableOpDirty();
     sal_Bool			IsDirtyOrInTableOpDirty() const;
     sal_Bool			GetDirty() const { return bDirty; }
+    void                ResetDirty() { bDirty = false; }
     sal_Bool            NeedsListening() const { return bNeedListening; }
     void            SetNeedsListening( sal_Bool bVar ) { bNeedListening = bVar; }
     void			Compile(const String& rFormula,
diff --git a/sc/inc/cellsuno.hxx b/sc/inc/cellsuno.hxx
index c90b306..379d087 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -929,6 +929,10 @@ public:
     virtual ::rtl::OUString SAL_CALL getFormula() throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setFormula( const ::rtl::OUString& aFormula )
                                 throw(::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL	setFormulaResult( const double nValue )
+                                throw(::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL	setFormulaString( const ::rtl::OUString& aFormula )
+                                throw(::com::sun::star::uno::RuntimeException);
     virtual double SAL_CALL getValue() throw(::com::sun::star::uno::RuntimeException);
     virtual void SAL_CALL	setValue( double nValue ) throw(::com::sun::star::uno::RuntimeException);
     virtual ::com::sun::star::table::CellContentType SAL_CALL getType()
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 5374f94..b3c7373 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1400,7 +1400,12 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
             pCode->SetCodeError( errNoCode );
             // This is worth an assertion; if encountered in daily work
             // documents we might need another solution. Or just confirm correctness.
-            OSL_FAIL( "ScFormulaCell::Interpret: no UPN, no error, no token, but string" );
+            OSL_FAIL( "ScFormulaCell::Interpret: no UPN, no error, no token, but string -> Try compiling it." );
+            // Force Compilation
+            String aFormula = aResult.GetHybridFormula();
+            aResult.SetHybridFormula( String() );
+            Compile( aFormula );
+            InterpretTail( eTailParam );
             return;
         }
         CompileTokenArray();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 0660421..e4c86c5 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1240,7 +1240,7 @@ void ScDocShell::DoRecalc( sal_Bool bApi )
     if (!bDone)							// sonst Dokument neu berechnen
     {
         WaitObject aWaitObj( GetActiveDialogParent() );
-        aDocument.CalcFormulaTree();
+        aDocument.CalcFormulaTree( sal_True );
         if ( pSh )
             pSh->UpdateCharts(sal_True);
 
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 2027960..67622b2 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6512,6 +6512,31 @@ void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException)
     SetValue_Impl(nValue);
 }
 
+void SAL_CALL ScCellObj::setFormulaString( const rtl::OUString& aFormula) throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    ScDocShell *pDocSh = GetDocShell();
+    if( pDocSh )
+    {
+        ScDocFunc aFunc( *pDocSh );
+        ScFormulaCell* pCell = new ScFormulaCell( pDocSh->GetDocument(), aCellPos );
+        pCell->SetHybridFormula( aFormula, formula::FormulaGrammar::GRAM_NATIVE );
+        aFunc.PutCell( aCellPos, pCell, sal_True );
+    }
+}
+void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeException)
+{
+    SolarMutexGuard aGuard;
+    ScDocShell* pDocSh = GetDocShell();
+    if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA )
+    {
+        ScFormulaCell* pCell = (ScFormulaCell *)pDocSh->GetDocument()->GetCell( aCellPos );
+        pCell->SetHybridDouble( nValue );
+        pCell->ResetDirty();
+        pCell->ResetChanged();
+    }
+}
+
 table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 0c15e65..b597aaf 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1602,11 +1602,18 @@ void SAL_CALL ScModelObj::setPropertyValue(
         ScDocument* pDoc = pDocShell->GetDocument();
         const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
         ScDocOptions aNewOpt = rOldOpt;
+        //  Don't recalculate while loading XML, when the formula text is stored
+        //  Recalculation after loading is handled separately.
+        bool bHardRecalc = !pDoc->IsImportingXML();
 
         sal_Bool bOpt = ScDocOptionsHelper::setPropertyValue( aNewOpt, *aPropSet.getPropertyMap(), aPropertyName, aValue );
         if (bOpt)
         {
             // done...
+            if ( aString.EqualsAscii( SC_UNO_IGNORECASE ) ||
+                 aString.EqualsAscii( SC_UNONAME_REGEXP ) ||
+                 aString.EqualsAscii( SC_UNO_LOOKUPLABELS ) )
+                bHardRecalc = false;
         }
         else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) )
         {
@@ -1713,10 +1720,8 @@ void SAL_CALL ScModelObj::setPropertyValue(
         if ( aNewOpt != rOldOpt )
         {
             pDoc->SetDocOptions( aNewOpt );
-            //  Don't recalculate while loading XML, when the formula text is stored.
-            //  Recalculation after loading is handled separately.
             //! Recalc only for options that need it?
-            if ( !pDoc->IsImportingXML() )
+            if ( bHardRecalc )
                 pDocShell->DoHardRecalc( sal_True );
             pDocShell->SetDocumentModified();
         }


More information about the Libreoffice-commits mailing list