[Libreoffice-commits] core.git: Branch 'feature/orcus-update' - 2 commits - sc/Library_scfilt.mk sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Mon Apr 8 18:45:26 PDT 2013


 sc/Library_scfilt.mk                    |    1 
 sc/source/filter/inc/orcusinterface.hxx |   18 ++++++++++++++++
 sc/source/filter/orcus/interface.cxx    |   25 +++++++++++++++++++++++
 sc/source/filter/orcus/xmlcontext.cxx   |   34 +++++++++++++++++++++++++++-----
 4 files changed, 73 insertions(+), 5 deletions(-)

New commits:
commit ff0ea0d36f3183a99936c347a96eb691fcace0cb
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Apr 8 21:41:51 2013 -0400

    Use ucb to load bytes from file URL.
    
    With this, we get file system abstraction for free.
    
    Change-Id: Iec988712599f506444cf9c7e3ebbd59d38f083ee

diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index a0e407b..5c8c8ef 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_Library_use_libraries,scfilt,\
 	svxcore \
 	tk \
 	tl \
+	ucbhelper \
 	utl \
 	vcl \
 	i18nlangtag \
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index 0d7e05f..ab21844 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -14,6 +14,7 @@
 
 #include "svtools/treelistbox.hxx"
 #include "svtools/treelistentry.hxx"
+#include "ucbhelper/content.hxx"
 
 #include <orcus/spreadsheet/import_interface.hpp>
 #include <orcus/xml_structure_tree.hpp>
@@ -21,7 +22,14 @@
 #include <orcus/orcus_xml.hpp>
 #include <orcus/global.hpp>
 
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+
 #include <string>
+#include <sstream>
+
+#define BUFFER_SIZE 4096
+
+using namespace com::sun::star;
 
 namespace {
 
@@ -143,6 +151,26 @@ public:
     }
 };
 
+void loadContentFromURL(const OUString& rURL, std::string& rStrm)
+{
+    ucbhelper::Content aContent(
+        rURL, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext());
+    uno::Reference<io::XInputStream> xStrm = aContent.openStream();
+
+    std::ostringstream aStrmBuf;
+    uno::Sequence<sal_Int8> aBytes;
+    size_t nBytesRead = 0;
+    do
+    {
+        nBytesRead = xStrm->readBytes(aBytes, BUFFER_SIZE);
+        const sal_Int8* p = aBytes.getConstArray();
+        aStrmBuf << std::string(p, p + nBytesRead);
+    }
+    while (nBytesRead == BUFFER_SIZE);
+
+    rStrm = aStrmBuf.str();
+}
+
 }
 
 ScOrcusXMLContextImpl::ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& rPath) :
@@ -154,12 +182,8 @@ bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM
 {
     rParam.maUserDataStore.clear();
 
-    OString aSysPath = ScOrcusFiltersImpl::toSystemPath(maPath);
-    const char* path = aSysPath.getStr();
-
-    // TODO: Use our own stream loading call instead of one from orcus.
     std::string aStrm;
-//  orcus::load_file_content(path, aStrm);
+    loadContentFromURL(maPath, aStrm);
 
     if (aStrm.empty())
         return false;
commit eea1c8e67053fa8620e69572365d1648841e5fdd
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Apr 8 14:58:39 2013 -0400

    Get it to build with the latest orcus. It may not be fully functional.
    
    Change-Id: Ife3c14a446273654d720eb38349cc42d1ed76893

diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index 2f8380c..4bc9b40 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -71,17 +71,31 @@ public:
     // Orcus import interface
     virtual void set_auto(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n);
     virtual void set_format(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t xf_index);
+
     virtual void set_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n);
     virtual void set_formula_result(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n);
+
     virtual void set_shared_formula(
         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
         const char* p_formula, size_t n_formula);
+
     virtual void set_shared_formula(
         orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
         const char* p_formula, size_t n_formula, const char* p_range, size_t n_range);
+
     virtual void set_shared_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex);
+
+    virtual void set_array_formula(
+        orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
+        const char* p, size_t n, orcus::spreadsheet::row_t array_rows, orcus::spreadsheet::col_t array_cols);
+
+    virtual void set_array_formula(
+        orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
+        const char* p, size_t n, const char* p_range, size_t n_range);
+
     virtual void set_string(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex);
     virtual void set_value(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, double value);
+    virtual void set_bool(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, bool value);
 
     SCTAB getIndex() const { return mnTab; }
 };
@@ -119,6 +133,10 @@ public:
     virtual void set_cell_locked(bool b);
     virtual size_t commit_cell_protection();
 
+    // number format
+    virtual void set_number_format(const char* s, size_t n);
+    virtual size_t commit_number_format();
+
     // cell style xf
 
     virtual void set_cell_style_xf_count(size_t n);
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 2aed628..25d9b5d 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -185,6 +185,18 @@ void ScOrcusSheet::set_shared_formula(row_t row, col_t col, size_t sindex)
     mrDoc.SetFormula(ScAddress(col,row,mnTab), aArr);
 }
 
+void ScOrcusSheet::set_array_formula(
+    row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/,
+    const char* /*p*/, size_t /*n*/, row_t /*array_rows*/, col_t /*array_cols*/)
+{
+}
+
+void ScOrcusSheet::set_array_formula(
+    row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/,
+    const char* /*p*/, size_t /*n*/, const char* /*p_range*/, size_t /*n_range*/)
+{
+}
+
 void ScOrcusSheet::set_string(row_t row, col_t col, size_t sindex)
 {
     // Calc does not yet support shared strings so we have to
@@ -201,6 +213,11 @@ void ScOrcusSheet::set_value(row_t row, col_t col, double value)
     mrDoc.SetValue( col, row, mnTab, value );
 }
 
+void ScOrcusSheet::set_bool(row_t row, col_t col, bool value)
+{
+    mrDoc.SetValue(col, row, mnTab, value ? 1.0 : 0.0);
+}
+
 size_t ScOrcusSharedStrings::append(const char* s, size_t n)
 {
     OUString aNewString(s, n, RTL_TEXTENCODING_UTF8);
@@ -334,6 +351,14 @@ size_t ScOrcusStyles::commit_cell_protection()
     return 0;
 }
 
+void ScOrcusStyles::set_number_format(const char* /*s*/, size_t /*n*/)
+{
+}
+
+size_t ScOrcusStyles::commit_number_format()
+{
+    return 0;
+}
 
 // cell style xf
 
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index edfd0b6..0d7e05f 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -159,7 +159,7 @@ bool ScOrcusXMLContextImpl::loadXMLStructure(SvTreeListBox& rTreeCtrl, ScOrcusXM
 
     // TODO: Use our own stream loading call instead of one from orcus.
     std::string aStrm;
-    orcus::load_file_content(path, aStrm);
+//  orcus::load_file_content(path, aStrm);
 
     if (aStrm.empty())
         return false;


More information about the Libreoffice-commits mailing list