mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Resolve warnings about global ctors and an unused variable
-- while unlikely to become an issue, ordering of ctors across source files is undefined and debugging issues related to it is not easy so just avoid that issue
This commit is contained in:
parent
d4cc538faf
commit
9a33210144
|
@ -26,15 +26,22 @@
|
|||
#include <xlnt/cell/rich_text.hpp>
|
||||
#include <xlnt/cell/rich_text_run.hpp>
|
||||
|
||||
namespace {
|
||||
bool has_trailing_whitespace(const std::string &s)
|
||||
{
|
||||
return !s.empty() && (s.front() == ' ' || s.back() == ' ');
|
||||
};
|
||||
}
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
rich_text::rich_text(const std::string &plain_text)
|
||||
: rich_text(rich_text_run{plain_text, optional<font>(), false})
|
||||
: rich_text(rich_text_run{plain_text, optional<font>(), has_trailing_whitespace(plain_text)})
|
||||
{
|
||||
}
|
||||
|
||||
rich_text::rich_text(const std::string &plain_text, const class font &text_font)
|
||||
: rich_text(rich_text_run{plain_text, optional<font>(text_font), false})
|
||||
: rich_text(rich_text_run{plain_text, optional<font>(text_font), has_trailing_whitespace(plain_text)})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -816,7 +816,6 @@ void xlsx_producer::write_pivot_table(const relationship & /*rel*/)
|
|||
void xlsx_producer::write_shared_string_table(const relationship & /*rel*/)
|
||||
{
|
||||
static const auto &xmlns = constants::ns("spreadsheetml");
|
||||
static const auto &xmlns_xml = constants::ns("xml");
|
||||
|
||||
write_start_element(xmlns, "sst");
|
||||
write_namespace(xmlns, "");
|
||||
|
@ -853,18 +852,13 @@ void xlsx_producer::write_shared_string_table(const relationship & /*rel*/)
|
|||
write_attribute("count", string_count);
|
||||
write_attribute("uniqueCount", source_.shared_strings().size());
|
||||
|
||||
auto has_trailing_whitespace = [](const std::string &s)
|
||||
{
|
||||
return !s.empty() && (s.front() == ' ' || s.back() == ' ');
|
||||
};
|
||||
|
||||
for (const auto &string : source_.shared_strings())
|
||||
{
|
||||
if (string.runs().size() == 1 && !string.runs().at(0).second.is_set())
|
||||
{
|
||||
write_start_element(xmlns, "si");
|
||||
write_start_element(xmlns, "t");
|
||||
write_characters(string.plain_text(),string.runs().front().preserve_space);
|
||||
write_characters(string.plain_text(), string.runs().front().preserve_space);
|
||||
write_end_element(xmlns, "t");
|
||||
write_end_element(xmlns, "si");
|
||||
|
||||
|
@ -926,7 +920,7 @@ void xlsx_producer::write_shared_string_table(const relationship & /*rel*/)
|
|||
}
|
||||
|
||||
write_start_element(xmlns, "t");
|
||||
write_characters(run.first, has_trailing_whitespace(run.first));
|
||||
write_characters(run.first, run.preserve_space);
|
||||
write_end_element(xmlns, "t");
|
||||
write_end_element(xmlns, "r");
|
||||
}
|
||||
|
|
|
@ -27,7 +27,11 @@
|
|||
#include <xlnt/styles/font.hpp>
|
||||
|
||||
namespace {
|
||||
const std::string Default_Name = "Calibri";
|
||||
const std::string &Default_Name()
|
||||
{
|
||||
static const std::string Default("Calibri");
|
||||
return Default;
|
||||
}
|
||||
constexpr double Default_Size = 12.0;
|
||||
} // namespace
|
||||
|
||||
|
@ -161,13 +165,13 @@ font &font::name(const std::string &name)
|
|||
return *this;
|
||||
}
|
||||
|
||||
const std::string& font::name() const
|
||||
const std::string &font::name() const
|
||||
{
|
||||
if (name_.is_set())
|
||||
{
|
||||
return name_.get();
|
||||
}
|
||||
return Default_Name;
|
||||
return Default_Name();
|
||||
}
|
||||
|
||||
bool font::has_color() const
|
||||
|
@ -229,7 +233,7 @@ std::size_t font::family() const
|
|||
return family_.get();
|
||||
}
|
||||
|
||||
const std::string& font::scheme() const
|
||||
const std::string &font::scheme() const
|
||||
{
|
||||
return scheme_.get();
|
||||
}
|
||||
|
|
|
@ -25,18 +25,27 @@
|
|||
#include <array>
|
||||
namespace {
|
||||
// Order of elements defined by phonetic_pr::Type enum
|
||||
const std::array<std::string, 4> Types{
|
||||
const std::array<std::string, 4>& Types()
|
||||
{
|
||||
static const std::array<std::string, 4> types{
|
||||
"fullwidthKatakana",
|
||||
"halfwidthKatakana",
|
||||
"Hiragana",
|
||||
"noConversion"};
|
||||
"noConversion"
|
||||
};
|
||||
return types;
|
||||
}
|
||||
|
||||
// Order of elements defined by phonetic_pr::alignment enum
|
||||
const std::array<std::string, 4> alignments{
|
||||
const std::array<std::string, 4> &Alignments()
|
||||
{
|
||||
static const std::array<std::string, 4> alignments{
|
||||
"Center",
|
||||
"Distributed",
|
||||
"Left",
|
||||
"NoControl"};
|
||||
return alignments;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -108,14 +117,14 @@ void phonetic_pr::alignment(align align)
|
|||
// serialisation
|
||||
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::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<phonetic_type>(i);
|
||||
}
|
||||
|
@ -125,14 +134,14 @@ phonetic_pr::phonetic_type phonetic_pr::type_from_string(const std::string &str)
|
|||
|
||||
const std::string &phonetic_pr::alignment_as_string(align type)
|
||||
{
|
||||
return alignments[static_cast<int>(type)];
|
||||
return Alignments()[static_cast<int>(type)];
|
||||
}
|
||||
|
||||
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<align>(i);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user