fix some windows build problems and warnings

This commit is contained in:
Thomas Fussell 2016-07-05 00:09:51 +08:00
parent 9ae506c1ea
commit 47f74fd4c1
5 changed files with 12 additions and 15 deletions

View File

@ -71,6 +71,7 @@ if(SHARED)
target_compile_definitions(xlnt.shared PRIVATE XLNT_SHARED=1)
if(MSVC)
target_compile_definitions(xlnt.shared PRIVATE XLNT_EXPORT=1)
target_compile_definitions(xlnt.shared PRIVATE PUGIXML_API=__declspec\(dllexport\))
set_target_properties(xlnt.shared PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
endif()
install(TARGETS xlnt.shared

View File

@ -268,8 +268,7 @@ void excel_serializer::write_data(bool /*as_template*/)
{
const auto &strings = workbook_.get_shared_strings();
pugi::xml_document shared_strings_xml;
shared_strings_serializer strings_serializer;
strings_serializer.write_shared_strings(strings, shared_strings_xml);
shared_strings_serializer::write_shared_strings(strings, shared_strings_xml);
shared_strings_xml.save(ss);
archive_.writestr(constants::ArcSharedString(), ss.str());

View File

@ -160,6 +160,7 @@ bool format_condition::satisfied_by(long double number) const
case condition_type::not_equal:
return number != value;
case condition_type::none:
default:
return false;
}
}
@ -471,11 +472,11 @@ void number_format_parser::finalize()
if (part.type == template_part::template_type::month_number
|| part.type == template_part::template_type::month_number_leading_zero)
{
if (i < code.parts.size() - 2)
if (code.parts.size() > 1 && i < code.parts.size() - 2)
{
const auto &next = code.parts[i + 1];
const auto &after_next = code.parts[i + 2];
if (next.type == template_part::template_type::text
&& next.string == ":"
&& (after_next.type == template_part::template_type::second ||

View File

@ -411,17 +411,13 @@ xlnt::alignment read_alignment(const pugi::xml_node alignment_node)
align.set_wrap_text(is_true(alignment_node.attribute("wrapText").value()));
align.set_shrink_to_fit(is_true(alignment_node.attribute("shrinkToFit").value()));
bool has_vertical = alignment_node.attribute("vertical");
if (has_vertical)
if (alignment_node.attribute("vertical"))
{
std::string vertical = alignment_node.attribute("vertical").value();
align.set_vertical(vertical_alignment_from_string(vertical));
}
bool has_horizontal = alignment_node.attribute("horizontal");
if (has_horizontal)
if (alignment_node.attribute("horizontal"))
{
std::string horizontal = alignment_node.attribute("horizontal").value();
align.set_horizontal(horizontal_alignment_from_string(horizontal));

View File

@ -129,17 +129,17 @@ bool worksheet_serializer::read_worksheet(const pugi::xml_document &xml, detail:
if (cell_found)
{
bool has_value = cell_node.child("v");
bool has_value = cell_node.child("v") != nullptr;
std::string value_string = has_value ? cell_node.child("v").text().get() : "";
bool has_type = cell_node.attribute("t");
bool has_type = cell_node.attribute("t") != nullptr;
std::string type = has_type ? cell_node.attribute("t").value() : "";
bool has_format = cell_node.attribute("s");
bool has_format = cell_node.attribute("s") != nullptr;
auto format_id = static_cast<std::size_t>(has_format ? std::stoull(cell_node.attribute("s").value()) : 0LL);
bool has_formula = cell_node.child("f");
bool has_shared_formula = has_formula && cell_node.child("f").attribute("t")
bool has_formula = cell_node.child("f") != nullptr;
bool has_shared_formula = has_formula && cell_node.child("f").attribute("t") != nullptr
&& cell_node.child("f").attribute("t").value() == std::string("shared");
auto cell = sheet_.get_cell(address);