[Libreoffice-commits] core.git: Branch 'feature/orcus-continuous-integration' - 3 commits - sc/source
Markus Mohrhard
markus.mohrhard at collabora.co.uk
Sun Aug 17 17:14:40 PDT 2014
sc/source/filter/inc/orcusinterface.hxx | 38 ++++++++++
sc/source/filter/inc/worksheethelper.hxx | 2
sc/source/filter/oox/worksheetfragment.cxx | 18 ++++
sc/source/filter/oox/worksheethelper.cxx | 4 -
sc/source/filter/orcus/interface.cxx | 105 +++++++++++++++++++++++++++++
5 files changed, 163 insertions(+), 4 deletions(-)
New commits:
commit a644ea69d4baac7d3582dd50db5363dc047df298
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Aug 18 02:01:58 2014 +0200
use orcus for table import
This is a proof of concept and shows that it is possible to partially
replace the OOXML import with orcus.
Change-Id: I610cec4ba4ec6f966848397ec9f0c465520a3c65
diff --git a/sc/source/filter/oox/worksheetfragment.cxx b/sc/source/filter/oox/worksheetfragment.cxx
index f93d56ee..7fd5e76 100644
--- a/sc/source/filter/oox/worksheetfragment.cxx
+++ b/sc/source/filter/oox/worksheetfragment.cxx
@@ -44,11 +44,15 @@
#include "workbooksettings.hxx"
#include "worksheetsettings.hxx"
+#include "orcusinterface.hxx"
+#include <orcus/orcus_import_xlsx.hpp>
+
namespace oox {
namespace xls {
using namespace ::com::sun::star::table;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
using namespace ::oox::core;
namespace {
@@ -195,7 +199,19 @@ WorksheetFragment::WorksheetFragment( const WorksheetHelper& rHelper, const OUSt
// import data tables related to this worksheet
RelationsRef xTableRels = getRelations().getRelationsFromTypeFromOfficeDoc( "table" );
for( Relations::const_iterator aIt = xTableRels->begin(), aEnd = xTableRels->end(); aIt != aEnd; ++aIt )
- importOoxFragment( new TableFragment( *this, getFragmentPathFromRelation( aIt->second ) ) );
+ {
+ OUString aFragmentPath = getFragmentPathFromRelation( aIt->second );
+ uno::Reference<io::XInputStream> xStream = rHelper.getBaseFilter().openInputStream(aFragmentPath);
+ uno::Sequence<sal_Int8> aData(8000);
+ sal_Int32 nRead = 0;
+ OStringBuffer aString;
+ do {
+ nRead = xStream->readBytes(aData, 8000);
+ aString.append(OString((char*) aData.getConstArray(), nRead));
+ } while(nRead == 8000);
+ ScOrcusTable aTable(getSheetIndex());
+ orcus::import_xlsx::read_table(aString.getStr(), aString.getLength(), &aTable);
+ }
// import comments related to this worksheet
OUString aCommentsFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
commit 55ea8f5da96ad9765002ace388312620b3af1b2f
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Aug 18 01:36:43 2014 +0200
make these types future proof
Our core already supports more than 32k sheets and we should not use
sal_Int16 anymore for sheets.
Change-Id: Ifeb321cba044b255ef2e7d34da0908c27877d6ae
diff --git a/sc/source/filter/inc/worksheethelper.hxx b/sc/source/filter/inc/worksheethelper.hxx
index 37179bb..ab12261 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -191,7 +191,7 @@ public:
/** Returns the type of this sheet. */
WorksheetType getSheetType() const;
/** Returns the index of the current sheet. */
- sal_Int16 getSheetIndex() const;
+ sal_Int32 getSheetIndex() const;
/** Returns the XSpreadsheet interface of the current sheet. */
const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >&
getSheet() const;
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index 4417bbe..4c02759 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -217,7 +217,7 @@ public:
/** Returns the type of this sheet. */
inline WorksheetType getSheetType() const { return meSheetType; }
/** Returns the index of the current sheet. */
- inline sal_Int16 getSheetIndex() const { return maUsedArea.Sheet; }
+ inline sal_Int32 getSheetIndex() const { return maUsedArea.Sheet; }
/** Returns the XSpreadsheet interface of the current sheet. */
inline const Reference< XSpreadsheet >& getSheet() const { return mxSheet; }
@@ -1380,7 +1380,7 @@ WorksheetType WorksheetHelper::getSheetType() const
return mrSheetGlob.getSheetType();
}
-sal_Int16 WorksheetHelper::getSheetIndex() const
+sal_Int32 WorksheetHelper::getSheetIndex() const
{
return mrSheetGlob.getSheetIndex();
}
commit dab14c9e3b2387dce32a4b12fbc3ab27f8bc2595
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date: Mon Aug 18 00:16:03 2014 +0200
implement orcus::spreadsheet::iface::import_table interface
Just some stubs to check that it is working.
Change-Id: I24e61cd24030ca5adeb07222fd63464d836ecb3d
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index 49d435b..8c089bb 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -278,5 +278,43 @@ public:
void setStatusIndicator(const com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator>& rIndicator);
};
+class ScOrcusTable : public orcus::spreadsheet::iface::import_table
+{
+private:
+ SCTAB mnTab;
+
+public:
+ ScOrcusTable(SCTAB nTab);
+ virtual ~ScOrcusTable();
+
+ virtual orcus::spreadsheet::iface::import_auto_filter* get_auto_filter() SAL_OVERRIDE;
+
+ virtual void set_identifier(size_t id) SAL_OVERRIDE;
+
+ virtual void set_range(const char* p_ref, size_t n_ref) SAL_OVERRIDE;
+
+ virtual void set_totals_row_count(size_t row_count) SAL_OVERRIDE;
+
+ virtual void set_name(const char* p, size_t n) SAL_OVERRIDE;
+
+ virtual void set_display_name(const char* p, size_t n) SAL_OVERRIDE;
+
+ virtual void set_column_count(size_t n) SAL_OVERRIDE;
+
+ virtual void set_column_identifier(size_t id) SAL_OVERRIDE;
+ virtual void set_column_name(const char* p, size_t n) SAL_OVERRIDE;
+ virtual void set_column_totals_row_label(const char* p, size_t n) SAL_OVERRIDE;
+ virtual void set_column_totals_row_function(orcus::spreadsheet::totals_row_function_t func) SAL_OVERRIDE;
+ virtual void commit_column() SAL_OVERRIDE;
+
+ virtual void set_style_name(const char* p, size_t n) SAL_OVERRIDE;
+ virtual void set_style_show_first_column(bool b) SAL_OVERRIDE;
+ virtual void set_style_show_last_column(bool b) SAL_OVERRIDE;
+ virtual void set_style_show_row_stripes(bool b) SAL_OVERRIDE;
+ virtual void set_style_show_column_stripes(bool b) SAL_OVERRIDE;
+
+ virtual void commit() SAL_OVERRIDE;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 31bbff1..f475327 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -698,4 +698,109 @@ void ScOrcusAutoFilter::commit()
{
}
+ScOrcusTable::ScOrcusTable(SCTAB nTab):
+ mnTab(nTab)
+{
+}
+
+ScOrcusTable::~ScOrcusTable()
+{
+}
+
+os::iface::import_auto_filter* ScOrcusTable::get_auto_filter()
+{
+ return NULL;
+}
+
+void ScOrcusTable::set_identifier(size_t id)
+{
+ SAL_INFO("sc.orcus.table", "set_identifier :" << id);
+}
+
+void ScOrcusTable::set_range(const char* p_ref, size_t n_ref)
+{
+ OUString aRange(p_ref, n_ref, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_range: " << aRange);
+}
+
+void ScOrcusTable::set_totals_row_count(size_t row_count)
+{
+ SAL_INFO("sc.orcus.table", "set_totals_row_count: " << row_count);
+}
+
+void ScOrcusTable::set_name(const char* p, size_t n)
+{
+ OUString aName(p, n, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_name: " << aName);
+}
+
+void ScOrcusTable::set_display_name(const char* p, size_t n)
+{
+ OUString aName(p, n, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_display_name: " << aName);
+}
+
+void ScOrcusTable::set_column_count(size_t n)
+{
+ SAL_INFO("sc.orcus.table", "set_column_count: " << n);
+}
+
+void ScOrcusTable::set_column_identifier(size_t id)
+{
+ SAL_INFO("sc.orcus.table", "set_column_identifier: " << id);
+}
+
+void ScOrcusTable::set_column_name(const char* p, size_t n)
+{
+ OUString aName(p, n, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_column_name: " << aName);
+}
+
+void ScOrcusTable::set_column_totals_row_label(const char* p, size_t n)
+{
+ OUString aLabel(p, n, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_column_totals_row_label: " << aLabel);
+}
+
+void ScOrcusTable::set_column_totals_row_function(os::totals_row_function_t )
+{
+ SAL_INFO("sc.orcus.table", "set_column_totals_row_function");
+}
+
+void ScOrcusTable::commit_column()
+{
+ SAL_INFO("sc.orcus.table", "commit_column");
+}
+
+void ScOrcusTable::set_style_name(const char* p, size_t n)
+{
+ OUString aName(p, n, RTL_TEXTENCODING_UTF8);
+ SAL_INFO("sc.orcus.table", "set_style_name: " << aName);
+}
+
+void ScOrcusTable::set_style_show_first_column(bool b)
+{
+ SAL_INFO("sc.orcus.table", "set_style_show_first_column: " << b);
+}
+
+void ScOrcusTable::set_style_show_last_column(bool b)
+{
+ SAL_INFO("sc.orcus.table", "set_style_show_last_column: " << b);
+}
+
+void ScOrcusTable::set_style_show_row_stripes(bool b)
+{
+ SAL_INFO("sc.orcus.table", "set_style_show_row_stripes: " << b);
+}
+
+void ScOrcusTable::set_style_show_column_stripes(bool b)
+{
+ SAL_INFO("sc.orcus.table", "set_style_show_column_stripes: " << b);
+}
+
+void ScOrcusTable::commit()
+{
+ SAL_INFO("sc.orcus.table", "commit");
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list