2016-09-18 23:32:59 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-12-14 15:58:15 +08:00
|
|
|
#include <detail/default_case.hpp>
|
2016-11-10 08:52:18 +08:00
|
|
|
#include <detail/include_libstudxml.hpp>
|
2016-09-18 23:32:59 +08:00
|
|
|
#include <xlnt/packaging/relationship.hpp>
|
|
|
|
#include <xlnt/styles/border.hpp>
|
|
|
|
#include <xlnt/styles/font.hpp>
|
|
|
|
#include <xlnt/styles/fill.hpp>
|
|
|
|
#include <xlnt/styles/horizontal_alignment.hpp>
|
|
|
|
#include <xlnt/styles/vertical_alignment.hpp>
|
|
|
|
#include <xlnt/utils/exceptions.hpp>
|
2016-12-02 21:37:50 +08:00
|
|
|
#include <xlnt/worksheet/pane.hpp>
|
2016-09-18 23:32:59 +08:00
|
|
|
|
|
|
|
namespace xlnt {
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the string representation of the underline style.
|
|
|
|
/// </summary>
|
|
|
|
std::string to_string(font::underline_style underline_style);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the string representation of the relationship type.
|
|
|
|
/// </summary>
|
2016-12-02 21:37:50 +08:00
|
|
|
std::string to_string(relationship_type t);
|
2016-09-18 23:32:59 +08:00
|
|
|
|
|
|
|
std::string to_string(pattern_fill_type fill_type);
|
|
|
|
|
|
|
|
std::string to_string(gradient_fill_type fill_type);
|
|
|
|
|
|
|
|
std::string to_string(border_style border_style);
|
|
|
|
|
|
|
|
std::string to_string(vertical_alignment vertical_alignment);
|
|
|
|
|
|
|
|
std::string to_string(horizontal_alignment horizontal_alignment);
|
|
|
|
|
|
|
|
std::string to_string(border_side side);
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
} // namespace xlnt
|
|
|
|
|
|
|
|
namespace xml {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::font::underline_style>
|
|
|
|
{
|
|
|
|
static xlnt::font::underline_style parse(std::string underline_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::font;
|
|
|
|
|
|
|
|
static auto *underline_styles = new std::vector<font::underline_style>
|
|
|
|
{
|
|
|
|
font::underline_style::double_,
|
|
|
|
font::underline_style::double_accounting,
|
|
|
|
font::underline_style::single,
|
|
|
|
font::underline_style::single_accounting,
|
|
|
|
font::underline_style::none
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto underline_style : *underline_styles)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(underline_style) == underline_string)
|
|
|
|
{
|
|
|
|
return underline_style;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(font::underline_style::none);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize(xlnt::font::underline_style underline_style, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(underline_style);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::font::underline_style>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::relationship_type>
|
|
|
|
{
|
|
|
|
static xlnt::relationship_type parse(std::string relationship_type_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::relationship_type;
|
|
|
|
|
|
|
|
static auto *relationship_types = new std::vector<relationship_type>
|
|
|
|
{
|
2016-12-11 02:22:26 +08:00
|
|
|
// Package parts
|
|
|
|
relationship_type::core_properties,
|
|
|
|
relationship_type::extended_properties,
|
|
|
|
relationship_type::custom_properties,
|
|
|
|
relationship_type::office_document,
|
|
|
|
relationship_type::thumbnail,
|
|
|
|
relationship_type::printer_settings,
|
|
|
|
|
|
|
|
// SpreadsheetML parts
|
2016-09-18 23:32:59 +08:00
|
|
|
relationship_type::calculation_chain,
|
|
|
|
relationship_type::chartsheet,
|
|
|
|
relationship_type::comments,
|
|
|
|
relationship_type::connections,
|
|
|
|
relationship_type::custom_property,
|
|
|
|
relationship_type::custom_xml_mappings,
|
|
|
|
relationship_type::dialogsheet,
|
|
|
|
relationship_type::drawings,
|
|
|
|
relationship_type::external_workbook_references,
|
|
|
|
relationship_type::metadata,
|
|
|
|
relationship_type::pivot_table,
|
|
|
|
relationship_type::pivot_table_cache_definition,
|
|
|
|
relationship_type::pivot_table_cache_records,
|
|
|
|
relationship_type::query_table,
|
|
|
|
relationship_type::shared_string_table,
|
|
|
|
relationship_type::shared_workbook_revision_headers,
|
2016-12-11 02:22:26 +08:00
|
|
|
relationship_type::shared_workbook,
|
|
|
|
relationship_type::theme,
|
|
|
|
relationship_type::revision_log,
|
2016-09-18 23:32:59 +08:00
|
|
|
relationship_type::shared_workbook_user_data,
|
|
|
|
relationship_type::single_cell_table_definitions,
|
2016-11-20 05:42:16 +08:00
|
|
|
relationship_type::stylesheet,
|
2016-09-18 23:32:59 +08:00
|
|
|
relationship_type::table_definition,
|
2016-10-29 22:23:04 +08:00
|
|
|
relationship_type::vml_drawing,
|
2016-09-18 23:32:59 +08:00
|
|
|
relationship_type::volatile_dependencies,
|
2016-12-11 02:22:26 +08:00
|
|
|
relationship_type::worksheet,
|
|
|
|
|
|
|
|
// Worksheet parts
|
|
|
|
relationship_type::hyperlink,
|
|
|
|
relationship_type::image
|
2016-09-18 23:32:59 +08:00
|
|
|
};
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
// Core properties relationships can have two different type strings
|
|
|
|
if (relationship_type_string
|
|
|
|
== "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties")
|
|
|
|
{
|
|
|
|
return relationship_type::core_properties;
|
|
|
|
}
|
|
|
|
|
2016-09-18 23:32:59 +08:00
|
|
|
for (auto type : *relationship_types)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(type) == relationship_type_string)
|
|
|
|
{
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(relationship_type::unknown);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize(xlnt::relationship_type type, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(type);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::relationship_type>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::pattern_fill_type>
|
|
|
|
{
|
|
|
|
static xlnt::pattern_fill_type parse(std::string fill_type_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::pattern_fill_type;
|
|
|
|
|
|
|
|
static auto *fill_types = new std::vector<pattern_fill_type>
|
|
|
|
{
|
|
|
|
pattern_fill_type::darkdown,
|
|
|
|
pattern_fill_type::darkgray,
|
|
|
|
pattern_fill_type::darkgrid,
|
|
|
|
pattern_fill_type::darkhorizontal,
|
|
|
|
pattern_fill_type::darktrellis,
|
|
|
|
pattern_fill_type::darkup,
|
|
|
|
pattern_fill_type::darkvertical,
|
|
|
|
pattern_fill_type::gray0625,
|
|
|
|
pattern_fill_type::gray125,
|
|
|
|
pattern_fill_type::lightdown,
|
|
|
|
pattern_fill_type::lightgray,
|
|
|
|
pattern_fill_type::lightgrid,
|
|
|
|
pattern_fill_type::lighthorizontal,
|
|
|
|
pattern_fill_type::lighttrellis,
|
|
|
|
pattern_fill_type::lightup,
|
|
|
|
pattern_fill_type::lightvertical,
|
|
|
|
pattern_fill_type::mediumgray,
|
|
|
|
pattern_fill_type::none,
|
|
|
|
pattern_fill_type::solid
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto fill_type : *fill_types)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(fill_type) == fill_type_string)
|
|
|
|
{
|
|
|
|
return fill_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(pattern_fill_type::none);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize(xlnt::pattern_fill_type fill_type, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(fill_type);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::fill_type>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::gradient_fill_type>
|
|
|
|
{
|
|
|
|
static xlnt::gradient_fill_type parse(std::string fill_type_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::gradient_fill_type;
|
|
|
|
|
|
|
|
static auto *gradient_fill_types = new std::vector<gradient_fill_type>
|
|
|
|
{
|
|
|
|
gradient_fill_type::linear,
|
|
|
|
gradient_fill_type::path
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto fill_type : *gradient_fill_types)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(fill_type) == fill_type_string)
|
|
|
|
{
|
|
|
|
return fill_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(gradient_fill_type::linear);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize(xlnt::gradient_fill_type fill_type, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(fill_type);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::gradient_fill_type>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::border_style>
|
|
|
|
{
|
|
|
|
static xlnt::border_style parse(std::string style_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::border_style;
|
|
|
|
|
|
|
|
static auto *border_styles = new std::vector<border_style>
|
|
|
|
{
|
|
|
|
border_style::dashdot,
|
|
|
|
border_style::dashdotdot,
|
|
|
|
border_style::dashed,
|
|
|
|
border_style::dotted,
|
|
|
|
border_style::double_,
|
|
|
|
border_style::hair,
|
|
|
|
border_style::medium,
|
|
|
|
border_style::mediumdashdot,
|
|
|
|
border_style::mediumdashdotdot,
|
|
|
|
border_style::mediumdashed,
|
|
|
|
border_style::none,
|
|
|
|
border_style::slantdashdot,
|
|
|
|
border_style::thick,
|
|
|
|
border_style::thin
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto style : *border_styles)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(style) == style_string)
|
|
|
|
{
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(border_style::none);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string
|
|
|
|
serialize (xlnt::border_style style, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(style);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::border_style>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::vertical_alignment>
|
|
|
|
{
|
|
|
|
static xlnt::vertical_alignment parse(std::string alignment_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::vertical_alignment;
|
|
|
|
|
|
|
|
static auto *vertical_alignments = new std::vector<vertical_alignment>
|
|
|
|
{
|
2016-12-11 02:22:26 +08:00
|
|
|
vertical_alignment::top,
|
2016-09-18 23:32:59 +08:00
|
|
|
vertical_alignment::center,
|
2016-12-11 02:22:26 +08:00
|
|
|
vertical_alignment::bottom,
|
2016-09-18 23:32:59 +08:00
|
|
|
vertical_alignment::justify,
|
2016-12-11 02:22:26 +08:00
|
|
|
vertical_alignment::distributed
|
2016-09-18 23:32:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
for (auto alignment : *vertical_alignments)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(alignment) == alignment_string)
|
|
|
|
{
|
|
|
|
return alignment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(vertical_alignment::none);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize (xlnt::vertical_alignment alignment, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(alignment);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::vertical_alignment>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::horizontal_alignment>
|
|
|
|
{
|
|
|
|
static xlnt::horizontal_alignment parse(std::string alignment_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::horizontal_alignment;
|
|
|
|
|
|
|
|
static auto *horizontal_alignments = new std::vector<horizontal_alignment>
|
|
|
|
{
|
|
|
|
horizontal_alignment::general,
|
|
|
|
horizontal_alignment::left,
|
2016-12-11 02:22:26 +08:00
|
|
|
horizontal_alignment::center,
|
2016-09-18 23:32:59 +08:00
|
|
|
horizontal_alignment::right,
|
2016-12-11 02:22:26 +08:00
|
|
|
horizontal_alignment::fill,
|
|
|
|
horizontal_alignment::justify,
|
|
|
|
horizontal_alignment::center_continuous,
|
|
|
|
horizontal_alignment::distributed
|
2016-09-18 23:32:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
for (auto alignment : *horizontal_alignments)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(alignment) == alignment_string)
|
|
|
|
{
|
|
|
|
return alignment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
default_case(horizontal_alignment::none);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string serialize(xlnt::horizontal_alignment alignment, const serializer &)
|
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(alignment);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::horizontal_alignment>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::border_side>
|
|
|
|
{
|
|
|
|
static xlnt::border_side parse(std::string side_string, const parser &)
|
|
|
|
{
|
|
|
|
using xlnt::border_side;
|
|
|
|
|
|
|
|
static auto *border_sides = new std::vector<border_side>
|
|
|
|
{
|
|
|
|
border_side::top,
|
|
|
|
border_side::bottom,
|
|
|
|
border_side::start,
|
|
|
|
border_side::end,
|
|
|
|
border_side::vertical,
|
|
|
|
border_side::horizontal,
|
|
|
|
border_side::diagonal
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto side : *border_sides)
|
|
|
|
{
|
|
|
|
if (xlnt::detail::to_string(side) == side_string)
|
|
|
|
{
|
|
|
|
return side;
|
|
|
|
}
|
|
|
|
}
|
2016-12-11 02:22:26 +08:00
|
|
|
|
|
|
|
default_case(xlnt::border_side::top);
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
static std::string serialize(xlnt::border_side side, const serializer &)
|
2016-09-18 23:32:59 +08:00
|
|
|
{
|
|
|
|
return xlnt::detail::to_string(side);
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::border_side>
|
|
|
|
|
2016-11-30 08:05:47 +08:00
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::target_mode>
|
|
|
|
{
|
|
|
|
static xlnt::target_mode parse(std::string mode_string, const parser &)
|
|
|
|
{
|
|
|
|
return mode_string == "Internal" ? xlnt::target_mode::internal : xlnt::target_mode::external;
|
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
static std::string serialize(xlnt::target_mode mode, const serializer &)
|
2016-11-30 08:05:47 +08:00
|
|
|
{
|
|
|
|
return mode == xlnt::target_mode::internal ? "Internal" : "External";
|
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::target_mode>
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::pane_state>
|
|
|
|
{
|
|
|
|
static xlnt::pane_state parse(std::string string, const parser &)
|
|
|
|
{
|
|
|
|
if (string == "frozen") return xlnt::pane_state::frozen;
|
|
|
|
else if (string == "frozenSplit") return xlnt::pane_state::frozen_split;
|
|
|
|
else if (string == "split") return xlnt::pane_state::split;
|
2016-12-11 02:22:26 +08:00
|
|
|
|
|
|
|
default_case(xlnt::pane_state::frozen);
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
static std::string serialize(xlnt::pane_state state, const serializer &)
|
2016-12-02 21:37:50 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case xlnt::pane_state::frozen: return "frozen";
|
|
|
|
case xlnt::pane_state::frozen_split: return "frozenSplit";
|
|
|
|
case xlnt::pane_state::split: return "split";
|
|
|
|
}
|
2016-12-11 02:22:26 +08:00
|
|
|
|
|
|
|
default_case("frozen");
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::pane_state>
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct value_traits<xlnt::pane_corner>
|
|
|
|
{
|
|
|
|
static xlnt::pane_corner parse(std::string string, const parser &)
|
|
|
|
{
|
|
|
|
if (string == "bottomLeft") return xlnt::pane_corner::bottom_left;
|
|
|
|
else if (string == "bottomRight") return xlnt::pane_corner::bottom_right;
|
|
|
|
else if (string == "topLeft") return xlnt::pane_corner::top_left;
|
|
|
|
else if (string == "topRight") return xlnt::pane_corner::top_right;
|
2016-12-11 02:22:26 +08:00
|
|
|
|
|
|
|
default_case(xlnt::pane_corner::top_left);
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
|
2016-12-11 02:22:26 +08:00
|
|
|
static std::string serialize(xlnt::pane_corner corner, const serializer &)
|
2016-12-02 21:37:50 +08:00
|
|
|
{
|
|
|
|
switch (corner)
|
|
|
|
{
|
|
|
|
case xlnt::pane_corner::bottom_left: return "bottomLeft";
|
|
|
|
case xlnt::pane_corner::bottom_right: return "bottomRight";
|
|
|
|
case xlnt::pane_corner::top_left: return "topLeft";
|
|
|
|
case xlnt::pane_corner::top_right: return "topRight";
|
|
|
|
}
|
2016-12-11 02:22:26 +08:00
|
|
|
|
|
|
|
default_case("topLeft");
|
2016-12-02 21:37:50 +08:00
|
|
|
}
|
|
|
|
}; // struct value_traits<xlnt::pane_corner>
|
|
|
|
|
2016-09-18 23:32:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|