diff options
-rw-r--r-- | sc/inc/cell.hxx | 1 | ||||
-rw-r--r-- | sc/inc/cellsuno.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/cell.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh4.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 25 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 11 |
6 files changed, 45 insertions, 5 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index e24154516d4d..fcd83da9ddd6 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 b1f703f39b9f..342da6fcf0b7 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 d744c16758f9..89f4cdbb761e 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 9a99fdc6ff41..7e9fb513807b 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 be0ce4b4c456..3b70066ced57 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 898b48e0d58e..d77bb37a56c3 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(); } |