[Libreoffice-commits] core.git: Branch 'private/kohei/excel-2003-xml-orcus-filter' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Dec 12 02:57:18 UTC 2017


 sc/source/filter/inc/orcusinterface.hxx |   13 +++++++++++++
 sc/source/filter/orcus/interface.cxx    |   26 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

New commits:
commit cd710d7645d3dfc7b796c961cf3067aed8cc3f99
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Dec 11 21:53:55 2017 -0500

    Pick up global named expressions.
    
    Formulas with named expressions don't work yet since they get
    imported before the named expressions do.  We need to insert formula
    cells after the named expressions.
    
    Change-Id: Id2d7c59194ce7c07a3580cc8d9afd9fdda660b24

diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index b869e0bc43a4..64c3383708f2 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -76,6 +76,17 @@ public:
     orcus::spreadsheet::range_t resolve_range(const char* p, size_t n);
 };
 
+class ScOrcusNamedExpression : public orcus::spreadsheet::iface::import_named_expression
+{
+    ScDocumentImport& mrDoc;
+    const ScOrcusGlobalSettings& mrGlobalSettings;
+
+public:
+    ScOrcusNamedExpression( ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS );
+
+    virtual void define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp) override;
+};
+
 class ScOrcusSharedStrings : public orcus::spreadsheet::iface::import_shared_strings
 {
     ScOrcusFactory& mrFactory;
@@ -518,6 +529,7 @@ class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory
     ScOrcusGlobalSettings maGlobalSettings;
     ScOrcusRefResolver maRefResolver;
     ScOrcusSharedStrings maSharedStrings;
+    ScOrcusNamedExpression maNamedExpressions;
     std::vector< std::unique_ptr<ScOrcusSheet> > maSheets;
     ScOrcusStyles maStyles;
 
@@ -534,6 +546,7 @@ public:
     virtual orcus::spreadsheet::iface::import_sheet* get_sheet(orcus::spreadsheet::sheet_t sheet_index) override;
     virtual orcus::spreadsheet::iface::import_global_settings* get_global_settings() override;
     virtual orcus::spreadsheet::iface::import_shared_strings* get_shared_strings() override;
+    virtual orcus::spreadsheet::iface::import_named_expression* get_named_expression() override;
     virtual orcus::spreadsheet::iface::import_styles* get_styles() override;
     virtual void finalize() override;
 
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 87ac4f89d0e8..f57ca97eae65 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -151,6 +151,26 @@ os::range_t ScOrcusRefResolver::resolve_range(const char* p, size_t n)
     return ret;
 }
 
+ScOrcusNamedExpression::ScOrcusNamedExpression(
+    ScDocumentImport& rDoc, const ScOrcusGlobalSettings& rGS ) :
+    mrDoc(rDoc), mrGlobalSettings(rGS) {}
+
+void ScOrcusNamedExpression::define_name(const char* p_name, size_t n_name, const char* p_exp, size_t n_exp)
+{
+    OUString aName(p_name, n_name, RTL_TEXTENCODING_UTF8);
+    OUString aExpr(p_exp, n_exp, RTL_TEXTENCODING_UTF8);
+
+    ScRangeName* pNames = mrDoc.getDoc().GetRangeName();
+    if (!pNames)
+        return;
+
+    ScRangeData* pRange = new ScRangeData(
+        &mrDoc.getDoc(), aName, aExpr, ScAddress(), ScRangeData::Type::Name,
+        mrGlobalSettings.getCalcGrammar());
+
+    pNames->insert(pRange, false);
+}
+
 ScOrcusFactory::StringCellCache::StringCellCache(const ScAddress& rPos, size_t nIndex) :
     maPos(rPos), mnIndex(nIndex) {}
 
@@ -159,6 +179,7 @@ ScOrcusFactory::ScOrcusFactory(ScDocument& rDoc) :
     maGlobalSettings(maDoc),
     maRefResolver(maDoc, maGlobalSettings),
     maSharedStrings(*this),
+    maNamedExpressions(maDoc, maGlobalSettings),
     maStyles(rDoc),
     mnProgress(0) {}
 
@@ -242,6 +263,11 @@ orcus::spreadsheet::iface::import_shared_strings* ScOrcusFactory::get_shared_str
     return &maSharedStrings;
 }
 
+orcus::spreadsheet::iface::import_named_expression* ScOrcusFactory::get_named_expression()
+{
+    return &maNamedExpressions;
+}
+
 orcus::spreadsheet::iface::import_styles* ScOrcusFactory::get_styles()
 {
     return &maStyles;


More information about the Libreoffice-commits mailing list