summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@novell.com>2011-07-01 15:38:44 +0530
committerMuthu Subramanian <sumuthu@novell.com>2011-07-01 15:42:12 +0530
commit2fb377c19f8ae38e7ec649af1343bbd64b70a16b (patch)
tree0e765efe5ae4a78805102fe339690411b6bfaf37 /sc
parent9291672fd750be475dd39131cc297e7dae10c1ab (diff)
XLSX formula import improvement. Recommit.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/cell.hxx1
-rw-r--r--sc/inc/cellsuno.hxx7
-rw-r--r--sc/source/core/data/cell.cxx7
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx29
-rw-r--r--sc/source/ui/unoobj/docuno.cxx11
6 files changed, 50 insertions, 7 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..92d2bc53b033 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 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..9107e1d2a226 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 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();
}