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

Muthu Subramanian sumuthu at kemper.freedesktop.org
Fri Jul 1 02:54:50 PDT 2011


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

New commits:
commit f55943b2236eb44fba810aaeed2c3f6e6dbef6c9
Author: Muthu Subramanian <sumuthu at novell.com>
Date:   Fri Jul 1 15:38:44 2011 +0530

    XLSX formula import improvement. Recommit.

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..9c86c4c 100644
--- a/sc/inc/cellsuno.hxx
+++ b/sc/inc/cellsuno.hxx
@@ -73,6 +73,7 @@
 #include <com/sun/star/util/XSortable.hpp>
 #include <com/sun/star/util/XImportable.hpp>
 #include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XCell2.hpp>
 #include <com/sun/star/table/BorderLine.hpp>
 #include <com/sun/star/table/TableBorder.hpp>
 #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
@@ -817,7 +818,7 @@ public:
 class SC_DLLPUBLIC ScCellObj : public ScCellRangeObj,
                   public com::sun::star::text::XText,
                   public com::sun::star::container::XEnumerationAccess,
-                  public com::sun::star::table::XCell,
+                  public com::sun::star::table::XCell2,
                   public com::sun::star::sheet::XFormulaTokens,
                   public com::sun::star::sheet::XCellAddressable,
                   public com::sun::star::sheet::XSheetAnnotationAnchor,
@@ -929,6 +930,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..c921da5 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6088,6 +6088,7 @@ void ScCellObj::RefChanged()
 uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
 {
     SC_QUERYINTERFACE( table::XCell )
+    SC_QUERYINTERFACE( table::XCell2 )
     SC_QUERYINTERFACE( sheet::XFormulaTokens )
     SC_QUERYINTERFACE( sheet::XCellAddressable )
     SC_QUERYINTERFACE( text::XText )
@@ -6121,7 +6122,7 @@ uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeExcept
         long nParentLen = aParentTypes.getLength();
         const uno::Type* pParentPtr = aParentTypes.getConstArray();
 
-        aTypes.realloc( nParentLen + 8 );
+        aTypes.realloc( nParentLen + 9 );
         uno::Type* pPtr = aTypes.getArray();
         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<table::XCell>*)0);
         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XCellAddressable>*)0);
@@ -6131,6 +6132,7 @@ uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeExcept
         pPtr[nParentLen + 5] = getCppuType((const uno::Reference<text::XTextFieldsSupplier>*)0);
         pPtr[nParentLen + 6] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
         pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XFormulaTokens>*)0);
+        pPtr[nParentLen + 8] = getCppuType((const uno::Reference<table::XCell2>*)0);
 
         for (long i=0; i<nParentLen; i++)
             pPtr[i] = pParentPtr[i];				// parent types first
@@ -6512,6 +6514,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