mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Cleanup from review
This commit is contained in:
parent
0325c19488
commit
e0d62b0835
|
@ -170,7 +170,7 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the name of the font face.
|
/// Returns the name of the font face.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
std::string name() const;
|
const std::string& name() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if this font has a color applied.
|
/// Returns true if this font has a color applied.
|
||||||
|
@ -232,7 +232,7 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the scheme of this font.
|
/// Returns the scheme of this font.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
std::string scheme() const;
|
const std::string& scheme() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if left is exactly equal to right.
|
/// Returns true if left is exactly equal to right.
|
||||||
|
|
44
include/xlnt/utils/serialisation_utils.hpp
Normal file
44
include/xlnt/utils/serialisation_utils.hpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright (c) 2014-2018 Thomas Fussell
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE
|
||||||
|
//
|
||||||
|
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
// @author: see AUTHORS file
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <xlnt/xlnt_config.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace xlnt {
|
||||||
|
/// <summary>
|
||||||
|
/// Takes in any nuber and outputs a string form of that number which will
|
||||||
|
/// serialise and deserialise without loss of precision
|
||||||
|
/// </summary>
|
||||||
|
template <typename Number>
|
||||||
|
std::string serialize_number_to_string(Number num)
|
||||||
|
{
|
||||||
|
// more digits and excel won't match
|
||||||
|
constexpr int Excel_Digit_Precision = 15; //sf
|
||||||
|
std::stringstream ss;
|
||||||
|
ss.precision(Excel_Digit_Precision);
|
||||||
|
ss << num;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,29 +43,29 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// possible values for alignment property
|
/// possible values for alignment property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
enum class Alignment
|
enum class align
|
||||||
{
|
{
|
||||||
Center,
|
center,
|
||||||
Distributed,
|
distributed,
|
||||||
Left,
|
left,
|
||||||
No_Control
|
no_control
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// possible values for type property
|
/// possible values for type property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
enum class Type
|
enum class phonetic_type
|
||||||
{
|
{
|
||||||
Full_Width_Katakana,
|
full_width_katakana,
|
||||||
Half_Width_Katakana,
|
half_width_katakana,
|
||||||
Hiragana,
|
hiragana,
|
||||||
No_Conversion
|
no_conversion
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FontID represented by an unsigned 32-bit integer
|
/// FontID represented by an unsigned 32-bit integer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
using Font_ID = std::uint32_t;
|
using font_id_t = std::uint32_t;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default ctor for phonetic properties
|
/// Default ctor for phonetic properties
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FontID ctor for phonetic properties
|
/// FontID ctor for phonetic properties
|
||||||
/// </summary>
|
/// </summary>
|
||||||
explicit phonetic_pr(Font_ID font);
|
explicit phonetic_pr(font_id_t font);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// adds the xml serialised representation of this element to the stream
|
/// adds the xml serialised representation of this element to the stream
|
||||||
|
@ -85,12 +85,12 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get the font index
|
/// get the font index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Font_ID font_id() const;
|
font_id_t font_id() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// set the font index
|
/// set the font index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void font_id(Font_ID font);
|
void font_id(font_id_t font);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// is the phonetic type set
|
/// is the phonetic type set
|
||||||
|
@ -100,12 +100,12 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// returns the phonetic type
|
/// returns the phonetic type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Type type() const;
|
phonetic_type type() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// sets the phonetic type
|
/// sets the phonetic type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void type(Type type);
|
void type(phonetic_type type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// is the alignment set
|
/// is the alignment set
|
||||||
|
@ -115,51 +115,51 @@ public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// get the alignment
|
/// get the alignment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Alignment alignment() const;
|
align alignment() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// set the alignment
|
/// set the alignment
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void alignment(Alignment align);
|
void alignment(align align);
|
||||||
|
|
||||||
// serialisation
|
// serialisation
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// string form of the type enum
|
/// string form of the type enum
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const std::string &type_as_string(Type type);
|
static const std::string &type_as_string(phonetic_type type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// type enum from string
|
/// type enum from string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static Type type_from_string(const std::string &str);
|
static phonetic_type type_from_string(const std::string &str);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// string form of alignment enum
|
/// string form of alignment enum
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static const std::string &alignment_as_string(xlnt::phonetic_pr::Alignment type);
|
static const std::string &alignment_as_string(xlnt::phonetic_pr::align type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// alignment enum from string
|
/// alignment enum from string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static Alignment alignment_from_string(const std::string &str);
|
static align alignment_from_string(const std::string &str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// zero based index into style sheet font record.
|
/// zero based index into style sheet font record.
|
||||||
/// Default: 0
|
/// Default: 0
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Font_ID font_id_ = 0;
|
font_id_t font_id_ = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of characters to use.
|
/// Type of characters to use.
|
||||||
/// Default: full width katakana
|
/// Default: full width katakana
|
||||||
/// </summary>
|
/// </summary>
|
||||||
xlnt::optional<Type> type_;
|
xlnt::optional<phonetic_type> type_;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Alignment across the cell(s).
|
/// align across the cell(s).
|
||||||
/// Default: Left
|
/// Default: Left
|
||||||
/// </summary>
|
/// </summary>
|
||||||
xlnt::optional<Alignment> alignment_;
|
xlnt::optional<align> alignment_;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
|
||||||
struct print_options
|
struct XLNT_API print_options
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// if both grid_lines_set and this are true, grid lines are printed
|
/// if both grid_lines_set and this are true, grid lines are printed
|
||||||
|
|
|
@ -31,42 +31,42 @@
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
|
||||||
struct sheet_pr
|
struct XLNT_API sheet_pr
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// is horizontally synced to the anchor point
|
/// is horizontally synced to the anchor point
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> sync_horizontal_;
|
optional<bool> sync_horizontal;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// is vertically synced to the anchor point
|
/// is vertically synced to the anchor point
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> sync_vertical_;
|
optional<bool> sync_vertical;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Anchor point for worksheet's window
|
/// Anchor point for worksheet's window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<cell_reference> sync_ref_;
|
optional<cell_reference> sync_ref;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lotus compatibility option
|
/// Lotus compatibility option
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> transition_evaluation_;
|
optional<bool> transition_evaluation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lotus compatibility option
|
/// Lotus compatibility option
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> transition_entry_;
|
optional<bool> transition_entry;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// worksheet is published
|
/// worksheet is published
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> published_;
|
optional<bool> published;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// stable name of the sheet
|
/// stable name of the sheet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<std::string> code_name_;
|
optional<std::string> code_name;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// worksheet has one or more autofilters or advanced filters on
|
/// worksheet has one or more autofilters or advanced filters on
|
||||||
|
@ -76,6 +76,6 @@ struct sheet_pr
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// whether the conditional formatting calculations shall be evaluated
|
/// whether the conditional formatting calculations shall be evaluated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
optional<bool> enable_format_condition_calculation_;
|
optional<bool> enable_format_condition_calculation;
|
||||||
};
|
};
|
||||||
} // namespace xlnt
|
} // namespace xlnt
|
|
@ -34,7 +34,7 @@ rich_text::rich_text(const std::string &plain_text)
|
||||||
}
|
}
|
||||||
|
|
||||||
rich_text::rich_text(const std::string &plain_text, const class font &text_font)
|
rich_text::rich_text(const std::string &plain_text, const class font &text_font)
|
||||||
: rich_text({plain_text, optional<font>(text_font), false})
|
: rich_text(rich_text_run{plain_text, optional<font>(text_font), false})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void rich_text::clear()
|
||||||
void rich_text::plain_text(const std::string &s, bool preserve_space = false)
|
void rich_text::plain_text(const std::string &s, bool preserve_space = false)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
add_run({s, {}, preserve_space});
|
add_run(rich_text_run{s, {}, preserve_space});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rich_text::plain_text() const
|
std::string rich_text::plain_text() const
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// @author: see AUTHORS file
|
// @author: see AUTHORS file
|
||||||
|
|
||||||
#include <detail/header_footer/header_footer_code.hpp>
|
#include <detail/header_footer/header_footer_code.hpp>
|
||||||
#include <sstream>
|
#include <xlnt/utils/serialisation_utils.hpp>
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -533,10 +533,7 @@ std::string encode_header_footer(const rich_text &t, header_footer::location whe
|
||||||
if (run.second.get().has_size())
|
if (run.second.get().has_size())
|
||||||
{
|
{
|
||||||
encoded.push_back('&');
|
encoded.push_back('&');
|
||||||
std::stringstream ss;
|
encoded.append(serialize_number_to_string(run.second.get().size()));
|
||||||
ss.precision(15);
|
|
||||||
ss << run.second.get().size();
|
|
||||||
encoded.append(ss.str());
|
|
||||||
}
|
}
|
||||||
if (run.second.get().underlined())
|
if (run.second.get().underlined())
|
||||||
{
|
{
|
||||||
|
|
|
@ -368,8 +368,7 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
|
||||||
target_.d_->sheet_title_rel_id_map_.end(),
|
target_.d_->sheet_title_rel_id_map_.end(),
|
||||||
[&](const std::pair<std::string, std::string> &p) {
|
[&](const std::pair<std::string, std::string> &p) {
|
||||||
return p.second == rel_id;
|
return p.second == rel_id;
|
||||||
})
|
})->first;
|
||||||
->first;
|
|
||||||
|
|
||||||
auto ws = worksheet(current_worksheet_);
|
auto ws = worksheet(current_worksheet_);
|
||||||
|
|
||||||
|
@ -385,31 +384,31 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
|
||||||
sheet_pr props;
|
sheet_pr props;
|
||||||
if (parser().attribute_present("syncHorizontal"))
|
if (parser().attribute_present("syncHorizontal"))
|
||||||
{ // optional, boolean, false
|
{ // optional, boolean, false
|
||||||
props.sync_horizontal_.set(parser().attribute<bool>("syncHorizontal"));
|
props.sync_horizontal.set(parser().attribute<bool>("syncHorizontal"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("syncVertical"))
|
if (parser().attribute_present("syncVertical"))
|
||||||
{// optional, boolean, false
|
{// optional, boolean, false
|
||||||
props.sync_vertical_.set(parser().attribute<bool>("syncVertical"));
|
props.sync_vertical.set(parser().attribute<bool>("syncVertical"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("syncRef"))
|
if (parser().attribute_present("syncRef"))
|
||||||
{ // optional, ST_Ref, false
|
{ // optional, ST_Ref, false
|
||||||
props.sync_ref_.set(cell_reference(parser().attribute("syncRef")));
|
props.sync_ref.set(cell_reference(parser().attribute("syncRef")));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("transitionEvaluation"))
|
if (parser().attribute_present("transitionEvaluation"))
|
||||||
{ // optional, boolean, false
|
{ // optional, boolean, false
|
||||||
props.transition_evaluation_.set(parser().attribute<bool>("transitionEvaluation"));
|
props.transition_evaluation.set(parser().attribute<bool>("transitionEvaluation"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("transitionEntry"))
|
if (parser().attribute_present("transitionEntry"))
|
||||||
{// optional, boolean, false
|
{// optional, boolean, false
|
||||||
props.transition_entry_.set(parser().attribute<bool>("transitionEntry"));
|
props.transition_entry.set(parser().attribute<bool>("transitionEntry"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("published"))
|
if (parser().attribute_present("published"))
|
||||||
{// optional, boolean, true
|
{// optional, boolean, true
|
||||||
props.published_.set(parser().attribute<bool>("published"));
|
props.published.set(parser().attribute<bool>("published"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("codeName"))
|
if (parser().attribute_present("codeName"))
|
||||||
{ // optional, string
|
{ // optional, string
|
||||||
props.code_name_.set(parser().attribute<std::string>("codeName"));
|
props.code_name.set(parser().attribute<std::string>("codeName"));
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("filterMode"))
|
if (parser().attribute_present("filterMode"))
|
||||||
{// optional, boolean, false
|
{// optional, boolean, false
|
||||||
|
@ -417,7 +416,7 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
|
||||||
}
|
}
|
||||||
if (parser().attribute_present("enableFormatConditionsCalculation"))
|
if (parser().attribute_present("enableFormatConditionsCalculation"))
|
||||||
{// optional, boolean, true
|
{// optional, boolean, true
|
||||||
props.enable_format_condition_calculation_.set(parser().attribute<bool>("enableFormatConditionsCalculation"));
|
props.enable_format_condition_calculation.set(parser().attribute<bool>("enableFormatConditionsCalculation"));
|
||||||
}
|
}
|
||||||
ws.d_->sheet_properties_.set(props);
|
ws.d_->sheet_properties_.set(props);
|
||||||
while (in_element(current_worksheet_element))
|
while (in_element(current_worksheet_element))
|
||||||
|
@ -1844,8 +1843,7 @@ void xlsx_consumer::read_office_document(const std::string &content_type) // CT_
|
||||||
target_.d_->sheet_title_rel_id_map_.end(),
|
target_.d_->sheet_title_rel_id_map_.end(),
|
||||||
[&](const std::pair<std::string, std::string> &p) {
|
[&](const std::pair<std::string, std::string> &p) {
|
||||||
return p.second == worksheet_rel.id();
|
return p.second == worksheet_rel.id();
|
||||||
})
|
})->first;
|
||||||
->first;
|
|
||||||
|
|
||||||
auto id = sheet_title_id_map_[title];
|
auto id = sheet_title_id_map_[title];
|
||||||
auto index = sheet_title_index_map_[title];
|
auto index = sheet_title_index_map_[title];
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <xlnt/packaging/manifest.hpp>
|
#include <xlnt/packaging/manifest.hpp>
|
||||||
#include <xlnt/utils/path.hpp>
|
#include <xlnt/utils/path.hpp>
|
||||||
#include <xlnt/utils/scoped_enum_hash.hpp>
|
#include <xlnt/utils/scoped_enum_hash.hpp>
|
||||||
|
#include <xlnt/utils/serialisation_utils.hpp>
|
||||||
#include <xlnt/workbook/workbook.hpp>
|
#include <xlnt/workbook/workbook.hpp>
|
||||||
#include <xlnt/workbook/workbook_view.hpp>
|
#include <xlnt/workbook/workbook_view.hpp>
|
||||||
#include <xlnt/worksheet/header_footer.hpp>
|
#include <xlnt/worksheet/header_footer.hpp>
|
||||||
|
@ -72,16 +73,6 @@ std::vector<std::pair<std::string, std::string>> core_property_namespace(xlnt::c
|
||||||
return {{constants::ns("core-properties"), "cp"}};
|
return {{constants::ns("core-properties"), "cp"}};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string number_to_string(double num)
|
|
||||||
{
|
|
||||||
// any more digits and excel won't match
|
|
||||||
constexpr int Excel_Digit_Precision = 15;
|
|
||||||
std::stringstream ss;
|
|
||||||
ss.precision(Excel_Digit_Precision);
|
|
||||||
ss << num;
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
@ -2220,41 +2211,41 @@ void xlsx_producer::write_worksheet(const relationship &rel)
|
||||||
{
|
{
|
||||||
write_start_element(xmlns, "sheetPr");
|
write_start_element(xmlns, "sheetPr");
|
||||||
auto &props = ws.d_->sheet_properties_.get();
|
auto &props = ws.d_->sheet_properties_.get();
|
||||||
if (props.sync_horizontal_.is_set())
|
if (props.sync_horizontal.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("syncHorizontal", props.sync_horizontal_.get());
|
write_attribute("syncHorizontal", props.sync_horizontal.get());
|
||||||
}
|
}
|
||||||
if (props.sync_vertical_.is_set())
|
if (props.sync_vertical.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("syncVertical", props.sync_vertical_.get());
|
write_attribute("syncVertical", props.sync_vertical.get());
|
||||||
}
|
}
|
||||||
if (props.sync_ref_.is_set())
|
if (props.sync_ref.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("syncRef", props.sync_ref_.get().to_string());
|
write_attribute("syncRef", props.sync_ref.get().to_string());
|
||||||
}
|
}
|
||||||
if (props.transition_evaluation_.is_set())
|
if (props.transition_evaluation.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("transitionEvaluation", props.transition_evaluation_.get());
|
write_attribute("transitionEvaluation", props.transition_evaluation.get());
|
||||||
}
|
}
|
||||||
if (props.transition_entry_.is_set())
|
if (props.transition_entry.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("transitionEntry", props.transition_entry_.get());
|
write_attribute("transitionEntry", props.transition_entry.get());
|
||||||
}
|
}
|
||||||
if (props.published_.is_set())
|
if (props.published.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("published", props.published_.get());
|
write_attribute("published", props.published.get());
|
||||||
}
|
}
|
||||||
if (props.code_name_.is_set())
|
if (props.code_name.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("codeName", props.code_name_.get());
|
write_attribute("codeName", props.code_name.get());
|
||||||
}
|
}
|
||||||
if (props.filter_mode.is_set())
|
if (props.filter_mode.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("filterMode", props.filter_mode.get());
|
write_attribute("filterMode", props.filter_mode.get());
|
||||||
}
|
}
|
||||||
if (props.enable_format_condition_calculation_.is_set())
|
if (props.enable_format_condition_calculation.is_set())
|
||||||
{
|
{
|
||||||
write_attribute("enableFormatConditionsCalculation", props.enable_format_condition_calculation_.get());
|
write_attribute("enableFormatConditionsCalculation", props.enable_format_condition_calculation.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
write_start_element(xmlns, "outlinePr");
|
write_start_element(xmlns, "outlinePr");
|
||||||
|
@ -2407,7 +2398,7 @@ void xlsx_producer::write_worksheet(const relationship &rel)
|
||||||
if (props.width.is_set())
|
if (props.width.is_set())
|
||||||
{
|
{
|
||||||
double width = (props.width.get() * 7 + 5) / 7;
|
double width = (props.width.get() * 7 + 5) / 7;
|
||||||
write_attribute("width", number_to_string(width));
|
write_attribute("width", serialize_number_to_string(width));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.best_fit)
|
if (props.best_fit)
|
||||||
|
@ -2505,7 +2496,7 @@ void xlsx_producer::write_worksheet(const relationship &rel)
|
||||||
if (props.height.is_set())
|
if (props.height.is_set())
|
||||||
{
|
{
|
||||||
auto height = props.height.get();
|
auto height = props.height.get();
|
||||||
write_attribute("ht", number_to_string(height));
|
write_attribute("ht", serialize_number_to_string(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.hidden)
|
if (props.hidden)
|
||||||
|
@ -2628,7 +2619,7 @@ void xlsx_producer::write_worksheet(const relationship &rel)
|
||||||
|
|
||||||
case cell::type::number:
|
case cell::type::number:
|
||||||
write_start_element(xmlns, "v");
|
write_start_element(xmlns, "v");
|
||||||
write_characters(number_to_string(cell.value<double>()));
|
write_characters(serialize_number_to_string(cell.value<double>()));
|
||||||
write_end_element(xmlns, "v");
|
write_end_element(xmlns, "v");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@
|
||||||
|
|
||||||
#include <xlnt/styles/font.hpp>
|
#include <xlnt/styles/font.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const std::string Default_Name = "Calibri";
|
||||||
|
constexpr double Default_Size = 12.0;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace xlnt {
|
namespace xlnt {
|
||||||
|
|
||||||
font::font()
|
font::font()
|
||||||
|
@ -138,7 +143,11 @@ font &font::size(double size)
|
||||||
|
|
||||||
double font::size() const
|
double font::size() const
|
||||||
{
|
{
|
||||||
|
if (size_.is_set())
|
||||||
|
{
|
||||||
return size_.get();
|
return size_.get();
|
||||||
|
}
|
||||||
|
return Default_Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool font::has_name() const
|
bool font::has_name() const
|
||||||
|
@ -152,13 +161,13 @@ font &font::name(const std::string &name)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string font::name() const
|
const std::string& font::name() const
|
||||||
{
|
{
|
||||||
if (name_.is_set())
|
if (name_.is_set())
|
||||||
{
|
{
|
||||||
return name_.get();
|
return name_.get();
|
||||||
}
|
}
|
||||||
return "Calibri";
|
return Default_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool font::has_color() const
|
bool font::has_color() const
|
||||||
|
@ -220,7 +229,7 @@ std::size_t font::family() const
|
||||||
return family_.get();
|
return family_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string font::scheme() const
|
const std::string& font::scheme() const
|
||||||
{
|
{
|
||||||
return scheme_.get();
|
return scheme_.get();
|
||||||
}
|
}
|
||||||
|
@ -243,8 +252,8 @@ bool font::operator==(const font &other) const
|
||||||
if (has_color() != other.has_color()) return false;
|
if (has_color() != other.has_color()) return false;
|
||||||
if (has_color() && color() != other.color()) return false;
|
if (has_color() && color() != other.color()) return false;
|
||||||
// charset
|
// charset
|
||||||
if (has_charset()!= other.has_charset()) return false;
|
if (has_charset() != other.has_charset()) return false;
|
||||||
if (has_charset() && charset()!= other.charset()) return false;
|
if (has_charset() && charset() != other.charset()) return false;
|
||||||
// modifiers
|
// modifiers
|
||||||
if (bold() != other.bold()) return false;
|
if (bold() != other.bold()) return false;
|
||||||
if (italic() != other.italic()) return false;
|
if (italic() != other.italic()) return false;
|
||||||
|
|
|
@ -31,8 +31,8 @@ const std::array<std::string, 4> Types{
|
||||||
"Hiragana",
|
"Hiragana",
|
||||||
"noConversion"};
|
"noConversion"};
|
||||||
|
|
||||||
// Order of elements defined by phonetic_pr::Alignment enum
|
// Order of elements defined by phonetic_pr::alignment enum
|
||||||
const std::array<std::string, 4> Alignments{
|
const std::array<std::string, 4> alignments{
|
||||||
"Center",
|
"Center",
|
||||||
"Distributed",
|
"Distributed",
|
||||||
"Left",
|
"Left",
|
||||||
|
@ -46,7 +46,7 @@ namespace xlnt {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
const std::string phonetic_pr::Serialised_ID = "phoneticPr";
|
const std::string phonetic_pr::Serialised_ID = "phoneticPr";
|
||||||
|
|
||||||
phonetic_pr::phonetic_pr(Font_ID font)
|
phonetic_pr::phonetic_pr(font_id_t font)
|
||||||
: font_id_(font)
|
: font_id_(font)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ void phonetic_pr::serialise(std::ostream &output_stream) const
|
||||||
output_stream << "/>";
|
output_stream << "/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
phonetic_pr::Font_ID phonetic_pr::font_id() const
|
phonetic_pr::font_id_t phonetic_pr::font_id() const
|
||||||
{
|
{
|
||||||
return font_id_;
|
return font_id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void phonetic_pr::font_id(Font_ID font)
|
void phonetic_pr::font_id(font_id_t font)
|
||||||
{
|
{
|
||||||
font_id_ = font;
|
font_id_ = font;
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,12 @@ bool phonetic_pr::has_type() const
|
||||||
return type_.is_set();
|
return type_.is_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
phonetic_pr::Type phonetic_pr::type() const
|
phonetic_pr::phonetic_type phonetic_pr::type() const
|
||||||
{
|
{
|
||||||
return type_.get();
|
return type_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void phonetic_pr::type(Type type)
|
void phonetic_pr::type(phonetic_type type)
|
||||||
{
|
{
|
||||||
type_.set(type);
|
type_.set(type);
|
||||||
}
|
}
|
||||||
|
@ -95,49 +95,49 @@ bool phonetic_pr::has_alignment() const
|
||||||
return alignment_.is_set();
|
return alignment_.is_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
phonetic_pr::Alignment phonetic_pr::alignment() const
|
phonetic_pr::align phonetic_pr::alignment() const
|
||||||
{
|
{
|
||||||
return alignment_.get();
|
return alignment_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void phonetic_pr::alignment(Alignment align)
|
void phonetic_pr::alignment(align align)
|
||||||
{
|
{
|
||||||
alignment_.set(align);
|
alignment_.set(align);
|
||||||
}
|
}
|
||||||
|
|
||||||
// serialisation
|
// serialisation
|
||||||
const std::string &phonetic_pr::type_as_string(phonetic_pr::Type type)
|
const std::string &phonetic_pr::type_as_string(phonetic_pr::phonetic_type type)
|
||||||
{
|
{
|
||||||
return Types[static_cast<int>(type)];
|
return Types[static_cast<int>(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
phonetic_pr::Type phonetic_pr::type_from_string(const std::string &str)
|
phonetic_pr::phonetic_type phonetic_pr::type_from_string(const std::string &str)
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < Types.size(); ++i)
|
for (std::size_t i = 0; i < Types.size(); ++i)
|
||||||
{
|
{
|
||||||
if (str == Types[i])
|
if (str == Types[i])
|
||||||
{
|
{
|
||||||
return static_cast<Type>(i);
|
return static_cast<phonetic_type>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Type::No_Conversion;
|
return phonetic_type::no_conversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &phonetic_pr::alignment_as_string(Alignment type)
|
const std::string &phonetic_pr::alignment_as_string(align type)
|
||||||
{
|
{
|
||||||
return Alignments[static_cast<int>(type)];
|
return alignments[static_cast<int>(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
phonetic_pr::Alignment phonetic_pr::alignment_from_string(const std::string &str)
|
phonetic_pr::align phonetic_pr::alignment_from_string(const std::string &str)
|
||||||
{
|
{
|
||||||
for (std::size_t i = 0; i < Alignments.size(); ++i)
|
for (std::size_t i = 0; i < alignments.size(); ++i)
|
||||||
{
|
{
|
||||||
if (str == Alignments[i])
|
if (str == alignments[i])
|
||||||
{
|
{
|
||||||
return static_cast<Alignment>(i);
|
return static_cast<align>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Alignment::No_Control;
|
return align::no_control;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xlnt
|
} // namespace xlnt
|
Loading…
Reference in New Issue
Block a user