switch to new mdds and libixion

f41
David Tardon 9 years ago
parent 33a1b8b97d
commit 00858046cd

@ -0,0 +1,395 @@
From 1f12d182ca0fa4f3f0fd017cce551d8fdc30a1a2 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@gmail.com>
Date: Sat, 20 Jun 2015 14:46:56 -0400
Subject: [PATCH] Remove use of boost in orcus-spreadsheet-model.
---
src/spreadsheet/document.cpp | 100 +++++++++++++++++++++++--------------------
src/spreadsheet/sheet.cpp | 18 ++++----
src/spreadsheet/table.cpp | 6 ++-
3 files changed, 68 insertions(+), 56 deletions(-)
diff --git a/src/spreadsheet/document.cpp b/src/spreadsheet/document.cpp
index c33a30e..02850ce 100644
--- a/src/spreadsheet/document.cpp
+++ b/src/spreadsheet/document.cpp
@@ -16,6 +16,7 @@
#include "orcus/pstring.hpp"
#include "orcus/types.hpp"
#include "orcus/string_pool.hpp"
+#include "orcus/global.hpp"
#include <ixion/formula.hpp>
#include <ixion/formula_result.hpp>
@@ -26,9 +27,7 @@
#include <iostream>
#include <fstream>
-#include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/ptr_container/ptr_map.hpp>
-#include <boost/scoped_ptr.hpp>
+#include <map>
using namespace std;
@@ -41,47 +40,50 @@ namespace {
* Use the printer function object to print sheet content with for_each
* function.
*/
-struct sheet_item : private boost::noncopyable
+struct sheet_item
{
+ sheet_item(const sheet_item&) = delete;
+ sheet_item& operator=(const sheet_item&) = delete;
+
pstring name;
sheet data;
sheet_item(document& doc, const pstring& _name, sheet_t sheet_index, row_t row_size, col_t col_size);
- class flat_printer : public ::std::unary_function<sheet_item, void>
+ class flat_printer : public ::std::unary_function<std::unique_ptr<sheet_item>, void>
{
const std::string& m_outdir;
public:
flat_printer(const std::string& outdir);
- void operator() (const sheet_item& item) const;
+ void operator() (const std::unique_ptr<sheet_item>& item) const;
};
- class check_printer : public std::unary_function<sheet_item, void>
+ class check_printer : public std::unary_function<std::unique_ptr<sheet_item>, void>
{
std::ostream& m_os;
public:
check_printer(std::ostream& os);
- void operator() (const sheet_item& item) const;
+ void operator() (const std::unique_ptr<sheet_item>& item) const;
};
- struct html_printer : public ::std::unary_function<sheet_item, void>
+ struct html_printer : public ::std::unary_function<std::unique_ptr<sheet_item>, void>
{
html_printer(const ::std::string& filepath);
- void operator() (const sheet_item& item) const;
+ void operator() (const std::unique_ptr<sheet_item>& item) const;
private:
const ::std::string& m_filepath;
};
};
-typedef boost::ptr_map<pstring, table_t> table_store_type;
+typedef std::map<pstring, std::unique_ptr<table_t>> table_store_type;
sheet_item::sheet_item(document& doc, const pstring& _name, sheet_t sheet_index, row_t row_size, col_t col_size) :
name(_name), data(doc, sheet_index, row_size, col_size) {}
sheet_item::flat_printer::flat_printer(const string& outdir) : m_outdir(outdir) {}
-void sheet_item::flat_printer::operator() (const sheet_item& item) const
+void sheet_item::flat_printer::operator() (const std::unique_ptr<sheet_item>& item) const
{
- string this_file = m_outdir + '/' + item.name.str() + ".txt";
+ string this_file = m_outdir + '/' + item->name.str() + ".txt";
ofstream file(this_file.c_str());
if (!file)
@@ -91,35 +93,35 @@ void sheet_item::flat_printer::operator() (const sheet_item& item) const
}
file << "---" << endl;
- file << "Sheet name: " << item.name << endl;
- item.data.dump_flat(file);
+ file << "Sheet name: " << item->name << endl;
+ item->data.dump_flat(file);
}
sheet_item::check_printer::check_printer(std::ostream& os) : m_os(os) {}
-void sheet_item::check_printer::operator() (const sheet_item& item) const
+void sheet_item::check_printer::operator() (const std::unique_ptr<sheet_item>& item) const
{
- item.data.dump_check(m_os, item.name);
+ item->data.dump_check(m_os, item->name);
}
sheet_item::html_printer::html_printer(const string& filepath) :
m_filepath(filepath) {}
-void sheet_item::html_printer::operator() (const sheet_item& item) const
+void sheet_item::html_printer::operator() (const std::unique_ptr<sheet_item>& item) const
{
// file path is expected to be a directory.
- string this_file = m_filepath + '/' + item.name.str() + ".html";
- item.data.dump_html(this_file);
+ string this_file = m_filepath + '/' + item->name.str() + ".html";
+ item->data.dump_html(this_file);
}
-class find_sheet_by_name : std::unary_function<sheet_item , bool>
+class find_sheet_by_name : std::unary_function<std::unique_ptr<sheet_item> , bool>
{
const pstring& m_name;
public:
find_sheet_by_name(const pstring& name) : m_name(name) {}
- bool operator() (const sheet_item & v) const
+ bool operator() (const std::unique_ptr<sheet_item>& v) const
{
- return v.name == m_name;
+ return v->name == m_name;
}
};
@@ -208,10 +210,10 @@ class table_handler : public ixion::iface::table_handler
const table_t* find_table(const ixion::abs_address_t& pos) const
{
- table_store_type::const_iterator it = m_tables.begin(), it_end = m_tables.end();
+ auto it = m_tables.begin(), it_end = m_tables.end();
for (; it != it_end; ++it)
{
- const table_t* p = it->second;
+ const table_t* p = it->second.get();
if (p->range.contains(pos))
return p;
}
@@ -310,31 +312,36 @@ public:
// no table name given.
return ixion::abs_range_t(ixion::abs_range_t::invalid);
- table_store_type::const_iterator it = m_tables.find(tab_name);
+ auto it = m_tables.find(tab_name);
if (it == m_tables.end())
// no table by this name found.
return ixion::abs_range_t(ixion::abs_range_t::invalid);
- const table_t* tab = it->second;
+ const table_t* tab = it->second.get();
return get_range_from_table(*tab, column_first, column_last, areas);
}
};
+typedef std::vector<std::unique_ptr<sheet_item>> sheet_items_type;
+
}
struct document_impl
{
+ document_impl(const document_impl&) = delete;
+ document_impl& operator=(const document_impl&) = delete;
+
document& m_doc;
string_pool m_string_pool;
ixion::model_context m_context;
date_time_t m_origin_date;
- boost::ptr_vector<sheet_item> m_sheets;
+ sheet_items_type m_sheets;
import_styles* mp_styles;
import_shared_strings* mp_strings;
ixion::dirty_formula_cells_t m_dirty_cells;
- boost::scoped_ptr<ixion::formula_name_resolver> mp_name_resolver;
+ std::unique_ptr<ixion::formula_name_resolver> mp_name_resolver;
formula_grammar_t m_grammar;
table_store_type m_tables;
@@ -407,22 +414,23 @@ void document::insert_table(table_t* p)
return;
pstring name = p->name;
- mp_impl->m_tables.insert(name, p);
+ mp_impl->m_tables.insert(
+ table_store_type::value_type(name, std::unique_ptr<table_t>(p)));
}
const table_t* document::get_table(const pstring& name) const
{
- table_store_type::const_iterator it = mp_impl->m_tables.find(name);
- return it == mp_impl->m_tables.end() ? NULL : it->second;
+ auto it = mp_impl->m_tables.find(name);
+ return it == mp_impl->m_tables.end() ? NULL : it->second.get();
}
namespace {
-struct sheet_finalizer : unary_function<sheet_item, void>
+struct sheet_finalizer : std::unary_function<std::unique_ptr<sheet_item>, void>
{
- void operator() (sheet_item& sh)
+ void operator() (std::unique_ptr<sheet_item>& sh)
{
- sh.data.finalize();
+ sh->data.finalize();
}
};
@@ -440,24 +448,24 @@ sheet* document::append_sheet(const pstring& sheet_name, row_t row_size, col_t c
sheet_t sheet_index = static_cast<sheet_t>(mp_impl->m_sheets.size());
mp_impl->m_sheets.push_back(
- new sheet_item(
+ make_unique<sheet_item>(
*this, sheet_name_safe, sheet_index, row_size, col_size));
mp_impl->m_context.append_sheet(
sheet_name_safe.get(), sheet_name_safe.size(), row_size, col_size);
- return &mp_impl->m_sheets.back().data;
+ return &mp_impl->m_sheets.back()->data;
}
sheet* document::get_sheet(const pstring& sheet_name)
{
- boost::ptr_vector<sheet_item>::iterator it =
- std::find_if(mp_impl->m_sheets.begin(), mp_impl->m_sheets.end(), find_sheet_by_name(sheet_name));
+ auto it = std::find_if(
+ mp_impl->m_sheets.begin(), mp_impl->m_sheets.end(), find_sheet_by_name(sheet_name));
if (it == mp_impl->m_sheets.end())
return NULL;
- return &it->data;
+ return &(*it)->data;
}
sheet* document::get_sheet(sheet_t sheet_pos)
@@ -465,7 +473,7 @@ sheet* document::get_sheet(sheet_t sheet_pos)
if (static_cast<size_t>(sheet_pos) >= mp_impl->m_sheets.size())
return NULL;
- return &mp_impl->m_sheets[sheet_pos].data;
+ return &mp_impl->m_sheets[sheet_pos]->data;
}
const sheet* document::get_sheet(sheet_t sheet_pos) const
@@ -473,7 +481,7 @@ const sheet* document::get_sheet(sheet_t sheet_pos) const
if (static_cast<size_t>(sheet_pos) >= mp_impl->m_sheets.size())
return NULL;
- return &mp_impl->m_sheets[sheet_pos].data;
+ return &mp_impl->m_sheets[sheet_pos]->data;
}
void document::calc_formulas()
@@ -516,13 +524,13 @@ void document::dump_html(const string& outdir) const
sheet_t document::get_sheet_index(const pstring& name) const
{
- boost::ptr_vector<sheet_item>::const_iterator it =
- std::find_if(mp_impl->m_sheets.begin(), mp_impl->m_sheets.end(), find_sheet_by_name(name));
+ auto it = std::find_if(
+ mp_impl->m_sheets.begin(), mp_impl->m_sheets.end(), find_sheet_by_name(name));
if (it == mp_impl->m_sheets.end())
return ixion::invalid_sheet;
- boost::ptr_vector<sheet_item>::const_iterator it_beg = mp_impl->m_sheets.begin();
+ auto it_beg = mp_impl->m_sheets.begin();
size_t pos = std::distance(it_beg, it);
return static_cast<sheet_t>(pos);
}
@@ -536,7 +544,7 @@ pstring document::get_sheet_name(sheet_t sheet_pos) const
if (pos >= mp_impl->m_sheets.size())
return pstring();
- return mp_impl->m_sheets[pos].name;
+ return mp_impl->m_sheets[pos]->name;
}
size_t document::sheet_size() const
diff --git a/src/spreadsheet/sheet.cpp b/src/spreadsheet/sheet.cpp
index 8e9db3b..a9d423f 100644
--- a/src/spreadsheet/sheet.cpp
+++ b/src/spreadsheet/sheet.cpp
@@ -30,6 +30,7 @@
#include <cassert>
#include <memory>
#include <cstdlib>
+#include <unordered_map>
#include <mdds/flat_segment_tree.hpp>
#include <mdds/multi_type_matrix.hpp>
@@ -43,9 +44,6 @@
#include <ixion/model_context.hpp>
#include <ixion/address.hpp>
-#include <boost/unordered_map.hpp>
-#include <boost/noncopyable.hpp>
-
#define ORCUS_DEBUG_SHEET 0
using namespace std;
@@ -64,15 +62,15 @@ struct merge_size
};
// Merged cell data stored in sheet.
-typedef boost::unordered_map<row_t, merge_size> merge_size_type;
-typedef boost::unordered_map<col_t, merge_size_type*> col_merge_size_type;
+typedef std::unordered_map<row_t, merge_size> merge_size_type;
+typedef std::unordered_map<col_t, merge_size_type*> col_merge_size_type;
// Overlapped cells per row, used when rendering sheet content.
typedef mdds::flat_segment_tree<col_t, bool> overlapped_col_index_type;
-typedef boost::unordered_map<row_t, overlapped_col_index_type*> overlapped_cells_type;
+typedef std::unordered_map<row_t, overlapped_col_index_type*> overlapped_cells_type;
typedef mdds::flat_segment_tree<row_t, size_t> segment_row_index_type;
-typedef boost::unordered_map<col_t, segment_row_index_type*> cell_format_type;
+typedef std::unordered_map<col_t, segment_row_index_type*> cell_format_type;
// Widths and heights are stored in twips.
typedef mdds::flat_segment_tree<col_t, col_width_t> col_widths_store_type;
@@ -156,7 +154,7 @@ public:
}
-struct sheet_impl : boost::noncopyable
+struct sheet_impl
{
document& m_doc;
sheet_properties m_sheet_props; /// sheet properties import interface.
@@ -184,6 +182,10 @@ struct sheet_impl : boost::noncopyable
col_t m_col_size;
const sheet_t m_sheet; /// sheet ID
+ sheet_impl() = delete;
+ sheet_impl(const sheet_impl&) = delete;
+ sheet_impl& operator=(const sheet_impl&) = delete;
+
sheet_impl(document& doc, sheet& sh, sheet_t sheet_index, row_t row_size, col_t col_size) :
m_doc(doc),
m_sheet_props(doc, sh), m_data_table(sh),
diff --git a/src/spreadsheet/table.cpp b/src/spreadsheet/table.cpp
index 9abc978..9dc7564 100644
--- a/src/spreadsheet/table.cpp
+++ b/src/spreadsheet/table.cpp
@@ -15,7 +15,6 @@
#include "orcus/spreadsheet/auto_filter.hpp"
#include <ixion/formula_name_resolver.hpp>
-#include <boost/noncopyable.hpp>
namespace orcus { namespace spreadsheet {
@@ -84,7 +83,7 @@ public:
}
-struct table_impl : boost::noncopyable
+struct table_impl
{
document& m_doc;
sheet& m_sheet;
@@ -94,6 +93,9 @@ struct table_impl : boost::noncopyable
std::unique_ptr<table_t> mp_data;
table_column_t m_column;
+ table_impl(const table_impl&) = delete;
+ table_impl& operator=(const table_impl&) = delete;
+
table_impl(document& doc, sheet& sh) :
m_doc(doc), m_sheet(sh), m_auto_filter(doc) {}
};
--
2.5.0

@ -0,0 +1,159 @@
From 67494ab53550b483beb25c1aab4c714dcebd42f3 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@gmail.com>
Date: Wed, 1 Jul 2015 19:33:34 -0400
Subject: [PATCH] master now requires ixion master branch build.
Mostly the new C++11 stuff.
---
configure.ac | 2 +-
src/spreadsheet/document.cpp | 14 +++++++-------
src/spreadsheet/sheet.cpp | 24 ++++++++++++------------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/spreadsheet/document.cpp b/src/spreadsheet/document.cpp
index 02850ce..b5e1dc0 100644
--- a/src/spreadsheet/document.cpp
+++ b/src/spreadsheet/document.cpp
@@ -351,7 +351,7 @@ struct document_impl
m_doc(doc),
mp_styles(new import_styles(m_string_pool)),
mp_strings(new import_shared_strings(m_string_pool, m_context, *mp_styles)),
- mp_name_resolver(ixion::formula_name_resolver::get(ixion::formula_name_resolver_excel_a1, &m_context)),
+ mp_name_resolver(ixion::formula_name_resolver::get(ixion::formula_name_resolver_t::excel_a1, &m_context)),
m_grammar(formula_grammar_xlsx_2007),
m_table_handler(m_context, m_tables)
{
@@ -569,20 +569,20 @@ void document::set_formula_grammar(formula_grammar_t grammar)
{
case formula_grammar_xlsx_2007:
case formula_grammar_xlsx_2010:
- mp_impl->mp_name_resolver.reset(
+ mp_impl->mp_name_resolver =
ixion::formula_name_resolver::get(
- ixion::formula_name_resolver_excel_a1, &mp_impl->m_context));
+ ixion::formula_name_resolver_t::excel_a1, &mp_impl->m_context);
break;
case formula_grammar_ods:
- mp_impl->mp_name_resolver.reset(
+ mp_impl->mp_name_resolver =
ixion::formula_name_resolver::get(
- ixion::formula_name_resolver_odff, &mp_impl->m_context));
+ ixion::formula_name_resolver_t::odff, &mp_impl->m_context);
break;
case formula_grammar_gnumeric:
// TODO : Use Excel A1 name resolver for now.
- mp_impl->mp_name_resolver.reset(
+ mp_impl->mp_name_resolver =
ixion::formula_name_resolver::get(
- ixion::formula_name_resolver_excel_a1, &mp_impl->m_context));
+ ixion::formula_name_resolver_t::excel_a1, &mp_impl->m_context);
break;
default:
mp_impl->mp_name_resolver.reset();
diff --git a/src/spreadsheet/sheet.cpp b/src/spreadsheet/sheet.cpp
index a9d423f..6485334 100644
--- a/src/spreadsheet/sheet.cpp
+++ b/src/spreadsheet/sheet.cpp
@@ -501,7 +501,7 @@ void sheet::write_string(ostream& os, row_t row, col_t col) const
ixion::abs_address_t pos(mp_impl->m_sheet, row, col);
switch (cxt.get_celltype(pos))
{
- case ixion::celltype_string:
+ case ixion::celltype_t::string:
{
size_t str_id = cxt.get_string_identifier(pos);
const string* p = cxt.get_string(str_id);
@@ -509,7 +509,7 @@ void sheet::write_string(ostream& os, row_t row, col_t col) const
os << *p;
}
break;
- case ixion::celltype_numeric:
+ case ixion::celltype_t::numeric:
os << cxt.get_numeric_value(pos);
break;
default:
@@ -668,7 +668,7 @@ void sheet::dump_flat(std::ostream& os) const
ixion::abs_address_t pos(mp_impl->m_sheet,row,col);
switch (cxt.get_celltype(pos))
{
- case ixion::celltype_string:
+ case ixion::celltype_t::string:
{
size_t sindex = cxt.get_string_identifier(pos);
const string* p = cxt.get_string(sindex);
@@ -676,14 +676,14 @@ void sheet::dump_flat(std::ostream& os) const
mx.set(row, col, *p);
}
break;
- case ixion::celltype_numeric:
+ case ixion::celltype_t::numeric:
{
ostringstream os2;
os2 << cxt.get_numeric_value(pos) << " [v]";
mx.set(row, col, os2.str());
}
break;
- case ixion::celltype_formula:
+ case ixion::celltype_t::formula:
{
// print the formula and the formula result.
const ixion::formula_cell* cell = cxt.get_formula_cell(pos);
@@ -829,7 +829,7 @@ void sheet::dump_check(ostream& os, const pstring& sheet_name) const
ixion::abs_address_t pos(mp_impl->m_sheet, row, col);
switch (cxt.get_celltype(pos))
{
- case ixion::celltype_string:
+ case ixion::celltype_t::string:
{
write_cell_position(os, sheet_name, row, col);
size_t sindex = cxt.get_string_identifier(pos);
@@ -838,13 +838,13 @@ void sheet::dump_check(ostream& os, const pstring& sheet_name) const
os << "string:\"" << escape_chars(*p) << '"' << endl;
}
break;
- case ixion::celltype_numeric:
+ case ixion::celltype_t::numeric:
{
write_cell_position(os, sheet_name, row, col);
os << "numeric:" << cxt.get_numeric_value(pos) << endl;
}
break;
- case ixion::celltype_formula:
+ case ixion::celltype_t::formula:
{
write_cell_position(os, sheet_name, row, col);
os << "formula";
@@ -1373,7 +1373,7 @@ void sheet::dump_html(const string& filepath) const
}
ixion::celltype_t ct = cxt.get_celltype(pos);
- if (ct == ixion::celltype_empty)
+ if (ct == ixion::celltype_t::empty)
{
html_elem::attrs_type attrs;
build_html_elem_attributes(attrs, style, p_merge_size);
@@ -1390,7 +1390,7 @@ void sheet::dump_html(const string& filepath) const
ostringstream os;
switch (ct)
{
- case ixion::celltype_string:
+ case ixion::celltype_t::string:
{
size_t sindex = cxt.get_string_identifier(pos);
const string* p = cxt.get_string(sindex);
@@ -1402,10 +1402,10 @@ void sheet::dump_html(const string& filepath) const
os << *p;
}
break;
- case ixion::celltype_numeric:
+ case ixion::celltype_t::numeric:
os << cxt.get_numeric_value(pos);
break;
- case ixion::celltype_formula:
+ case ixion::celltype_t::formula:
{
// print the formula and the formula result.
const ixion::formula_cell* cell = cxt.get_formula_cell(pos);
--
2.5.0

@ -5,7 +5,7 @@
Name: liborcus Name: liborcus
Version: 0.9.2 Version: 0.9.2
Release: 3%{?dist} Release: 4%{?dist}
Summary: Standalone file import filter library for spreadsheet documents Summary: Standalone file import filter library for spreadsheet documents
License: MPLv2.0 License: MPLv2.0
@ -15,11 +15,24 @@ Source: http://kohei.us/files/orcus/src/%{name}-%{version}.tar.xz
BuildRequires: boost-devel BuildRequires: boost-devel
%if %{with convtools} %if %{with convtools}
BuildRequires: help2man BuildRequires: help2man
%if 0%{?fedora} >= 24
BuildRequires: pkgconfig(libixion-0.11)
%else
BuildRequires: pkgconfig(libixion-0.10) BuildRequires: pkgconfig(libixion-0.10)
%endif %endif
%endif
%if 0%{?fedora} >= 24
BuildRequires: pkgconfig(mdds-1.0)
%else
BuildRequires: pkgconfig(mdds) >= 0.12.0 BuildRequires: pkgconfig(mdds) >= 0.12.0
%endif
BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(zlib)
%if 0%{?fedora} >= 24
Patch0: 0001-master-now-requires-ixion-master-branch-build.patch
Patch1: 0001-Remove-use-of-boost-in-orcus-spreadsheet-model.patch
%endif
%description %description
%{name} is a standalone file import filter library for spreadsheet %{name} is a standalone file import filter library for spreadsheet
documents. Currently under development are ODS, XLSX and CSV import documents. Currently under development are ODS, XLSX and CSV import
@ -59,6 +72,15 @@ and text.
%endif %endif
%build %build
%if 0%{?fedora} >= 24
%if %{with convtools}
export LIBIXION_CFLAGS=`pkg-config --cflags libixion-0.11`
export LIBIXION_LIBS=`pkg-config --libs libixion-0.11`
%endif
export MDDS_CFLAGS=`pkg-config --cflags mdds-1.0`
export MDDS_LIBS=' '
%endif
%configure --disable-debug --disable-silent-rules --disable-static \ %configure --disable-debug --disable-silent-rules --disable-static \
--disable-werror --with-pic %{?condopts} --disable-werror --with-pic %{?condopts}
sed -i \ sed -i \
@ -143,6 +165,9 @@ make check %{?_smp_mflags}
%endif %endif
%changelog %changelog
* Sun Feb 14 2016 David Tardon <dtardon@redhat.com> - 0.9.2-4
- switch to new mdds and libixion
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-3 * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

Loading…
Cancel
Save