summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2017-12-11 21:53:55 -0500
committerKohei Yoshida <libreoffice@kohei.us>2017-12-18 23:27:12 +0100
commita72f3d40def7878ae487c8c34cd84da7d90fc99a (patch)
tree30b8dbb2bee43baded37e4d5b6b3ed21d61d3d72
parente45e2c4897933f14c90a65fa74d0ad2a0b620ede (diff)
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 Reviewed-on: https://gerrit.libreoffice.org/46664 Reviewed-by: Kohei Yoshida <libreoffice@kohei.us> Tested-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r--sc/source/filter/inc/orcusinterface.hxx13
-rw-r--r--sc/source/filter/orcus/interface.cxx26
2 files changed, 39 insertions, 0 deletions
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index e502d49296b1..851271f9806a 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -75,6 +75,17 @@ public:
orcus::spreadsheet::range_t resolve_range(const char* p, size_t n) override;
};
+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;
@@ -517,6 +528,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;
@@ -533,6 +545,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 e8c216308941..c2fa116d0617 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -157,6 +157,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) {}
@@ -165,6 +185,7 @@ ScOrcusFactory::ScOrcusFactory(ScDocument& rDoc) :
maGlobalSettings(maDoc),
maRefResolver(maGlobalSettings),
maSharedStrings(*this),
+ maNamedExpressions(maDoc, maGlobalSettings),
maStyles(rDoc),
mnProgress(0) {}
@@ -248,6 +269,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;