summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@novell.com>2011-07-01 15:38:09 +0530
committerMuthu Subramanian <sumuthu@novell.com>2011-07-01 15:43:03 +0530
commit063ea6bd2703a55f9ca136d3c7ec63df818147e7 (patch)
treef1fd5c11f62460ed35e732299159ff988af5f109
parent34f6f96ecbc08632da82bc29e7f609b75af51e52 (diff)
XLSX formula import improvement. Recommit.
-rw-r--r--oox/inc/oox/xls/worksheethelper.hxx8
-rw-r--r--oox/source/xls/sheetdatacontext.cxx15
-rw-r--r--oox/source/xls/workbookfragment.cxx7
-rw-r--r--oox/source/xls/worksheethelper.cxx14
4 files changed, 40 insertions, 4 deletions
diff --git a/oox/inc/oox/xls/worksheethelper.hxx b/oox/inc/oox/xls/worksheethelper.hxx
index e31c8f69711b..c824c4eb922b 100644
--- a/oox/inc/oox/xls/worksheethelper.hxx
+++ b/oox/inc/oox/xls/worksheethelper.hxx
@@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star {
namespace sheet { class XSheetCellRanges; }
namespace sheet { class XSpreadsheet; }
namespace table { class XCell; }
+ namespace table { class XCell2; }
namespace table { class XCellRange; }
namespace table { class XTableColumns; }
namespace table { class XTableRows; }
@@ -323,6 +324,13 @@ public:
void putValue(
const ::com::sun::star::table::CellAddress& rAddress,
double fValue ) const;
+ void putFormulaResult(
+ const ::com::sun::star::table::CellAddress& rAddress,
+ double fValue ) const;
+ void putFormulaString(
+ const ::com::sun::star::table::CellAddress& rAddress,
+ const ::rtl::OUString& rText ) const;
+
/** Inserts a string cell directly into the Calc sheet. */
void putString(
const ::com::sun::star::table::CellAddress& rAddress,
diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx
index 569126e0ebad..36011518cb92 100644
--- a/oox/source/xls/sheetdatacontext.cxx
+++ b/oox/source/xls/sheetdatacontext.cxx
@@ -163,8 +163,8 @@ void SheetDataContext::onCharacters( const OUString& rChars )
maCellValue = rChars;
break;
case XLS_TOKEN( f ):
- if( maFmlaData.mnFormulaType != XML_TOKEN_INVALID )
- maTokens = mrFormulaParser.importFormula( maCellData.maCellAddr, rChars );
+ maCellValue = rChars;
+ mrSheetData.putFormulaString( maCellData.maCellAddr, maCellValue );
break;
}
}
@@ -177,8 +177,8 @@ void SheetDataContext::onEndElement()
if( mbHasFormula ) switch( maFmlaData.mnFormulaType )
{
case XML_normal:
- mrSheetData.setFormulaCell( maCellData, maTokens );
- break;
+ //mrSheetData.setFormulaCell( maCellData, maTokens );
+ break;
case XML_shared:
if( maFmlaData.mnSharedId >= 0 )
{
@@ -240,6 +240,13 @@ void SheetDataContext::onEndElement()
mrSheetData.setBlankCell( maCellData );
}
}
+ else if( maCellValue.getLength() > 0 ) switch( maCellData.mnCellType )
+ {
+ case XML_n:
+ /* Set the pre-loaded value */
+ mrSheetData.putFormulaResult( maCellData.maCellAddr, maCellValue.toDouble() );
+ break;
+ }
}
}
diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx
index 96fd34f0c100..9d22f5fdf937 100644
--- a/oox/source/xls/workbookfragment.cxx
+++ b/oox/source/xls/workbookfragment.cxx
@@ -29,6 +29,7 @@
#include "oox/xls/workbookfragment.hxx"
#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/sheet/XCalculatable.hpp>
#include "oox/core/filterbase.hxx"
#include "oox/drawingml/themefragmenthandler.hxx"
#include "oox/helper/attributelist.hxx"
@@ -59,6 +60,7 @@ namespace xls {
using namespace ::com::sun::star::io;
using namespace ::com::sun::star::table;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sheet;
using namespace ::oox::core;
using ::oox::drawingml::ThemeFragmentHandler;
@@ -313,6 +315,11 @@ void WorkbookFragment::finalizeImport()
// final conversions, e.g. calculation settings and view settings
finalizeWorkbookImport();
+
+ // Recalculate (only changed ones)
+ Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY );
+ if( xCalculatable.is() )
+ xCalculatable->calculate();
}
// private --------------------------------------------------------------------
diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx
index 068c89cde2d9..a74e24f3343b 100644
--- a/oox/source/xls/worksheethelper.cxx
+++ b/oox/source/xls/worksheethelper.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/sheet/XSheetOutline.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XCell2.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/text/XText.hpp>
#include <rtl/ustrbuf.hxx>
@@ -1654,6 +1655,19 @@ void WorksheetHelper::putValue( const CellAddress& rAddress, double fValue ) con
if( xCell.is() ) xCell->setValue( fValue );
}
+void WorksheetHelper::putFormulaResult( const CellAddress& rAddress, double fValue ) const
+{
+ Reference< XCell2 > xCell( getCell( rAddress ), UNO_QUERY );
+ OSL_ENSURE( xCell.is(), "WorksheetHelper::putFormulaResult - missing cell interface" );
+ if( xCell.is() ) xCell->setFormulaResult( fValue );
+}
+
+void WorksheetHelper::putFormulaString( const CellAddress& rAddress, const OUString& rFormula ) const
+{
+ Reference< XCell2 > xCell( getCell( rAddress ), UNO_QUERY );
+ if( xCell.is() ) xCell->setFormulaString( rFormula );
+}
+
void WorksheetHelper::putString( const CellAddress& rAddress, const OUString& rText ) const
{
Reference< XText > xText( getCell( rAddress ), UNO_QUERY );