Merge branch 'dev' of github.com:tfussell/xlnt into dev

This commit is contained in:
Thomas Fussell 2017-12-08 15:20:36 -05:00
commit 182dea155b
2 changed files with 49 additions and 21 deletions

View File

@ -23,7 +23,9 @@
#pragma once
#include <algorithm>
#include <string>
#include <unordered_map>
#include <detail/default_case.hpp>
#include <detail/external/include_libstudxml.hpp>
@ -168,27 +170,53 @@ relationship_type from_string(const std::string &string)
template<>
pattern_fill_type from_string(const std::string &string)
{
if (string == "darkdown") return pattern_fill_type::darkdown;
else if (string == "darkgray") return pattern_fill_type::darkgray;
else if (string == "darkgrid") return pattern_fill_type::darkgrid;
else if (string == "darkhorizontal") return pattern_fill_type::darkhorizontal;
else if (string == "darktrellis") return pattern_fill_type::darktrellis;
else if (string == "darkup") return pattern_fill_type::darkup;
else if (string == "darkvertical") return pattern_fill_type::darkvertical;
else if (string == "gray0625") return pattern_fill_type::gray0625;
else if (string == "gray125") return pattern_fill_type::gray125;
else if (string == "lightdown") return pattern_fill_type::lightdown;
else if (string == "lightgray") return pattern_fill_type::lightgray;
else if (string == "lightgrid") return pattern_fill_type::lightgrid;
else if (string == "lighthorizontal") return pattern_fill_type::lighthorizontal;
else if (string == "lighttrellis") return pattern_fill_type::lighttrellis;
else if (string == "lightup") return pattern_fill_type::lightup;
else if (string == "lightvertical") return pattern_fill_type::lightvertical;
else if (string == "mediumgray") return pattern_fill_type::mediumgray;
else if (string == "none") return pattern_fill_type::none;
else if (string == "solid") return pattern_fill_type::solid;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
static std::unordered_map<std::string, pattern_fill_type> patternFill {
{"darkdown", pattern_fill_type::darkdown },
{ "darkgray", pattern_fill_type::darkgray },
{ "darkgrid", pattern_fill_type::darkgrid },
{ "darkhorizontal", pattern_fill_type::darkhorizontal },
{ "darktrellis", pattern_fill_type::darktrellis },
{ "darkup", pattern_fill_type::darkup },
{ "darkvertical", pattern_fill_type::darkvertical },
{ "gray0625", pattern_fill_type::gray0625 },
{ "gray125", pattern_fill_type::gray125 },
{ "lightdown", pattern_fill_type::lightdown },
{ "lightgray", pattern_fill_type::lightgray },
{ "lightgrid", pattern_fill_type::lightgrid },
{ "lighthorizontal", pattern_fill_type::lighthorizontal },
{ "lighttrellis", pattern_fill_type::lighttrellis },
{ "lightup", pattern_fill_type::lightup },
{ "lightvertical", pattern_fill_type::lightvertical },
{ "mediumgray", pattern_fill_type::mediumgray },
{ "none", pattern_fill_type::none },
{ "solid", pattern_fill_type::solid }
};
#pragma clang diagnostic pop
default_case(pattern_fill_type::none);
auto toLower = [](std::string str) {
auto bg{ std::begin (str) };
auto en{ std::end (str) };
std::transform (bg, en, bg, tolower);
return str;
};
auto patternLookup = [](const std::string& key) {
auto entry { patternFill.find (key) };
if (entry != std::end (patternFill)) {
return entry->second;
}
else {
// Note: there won't be an error if there is an unsupported pattern
return pattern_fill_type::none;
}
};
std::string lowerString {toLower (string) };
return patternLookup (lowerString);
}
template<>

View File

@ -2095,7 +2095,7 @@ void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int
for (y = 0; y < h; ++y)
{
tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH);
tdefl_compress_buffer(pComp, (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH);
tdefl_compress_buffer(pComp, (const mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH);
}
if (tdefl_compress_buffer(pComp, nullptr, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE)
{