mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge branch 'dev' of github.com:tfussell/xlnt into dev
This commit is contained in:
commit
182dea155b
|
@ -23,7 +23,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <detail/default_case.hpp>
|
#include <detail/default_case.hpp>
|
||||||
#include <detail/external/include_libstudxml.hpp>
|
#include <detail/external/include_libstudxml.hpp>
|
||||||
|
@ -168,27 +170,53 @@ relationship_type from_string(const std::string &string)
|
||||||
template<>
|
template<>
|
||||||
pattern_fill_type from_string(const std::string &string)
|
pattern_fill_type from_string(const std::string &string)
|
||||||
{
|
{
|
||||||
if (string == "darkdown") return pattern_fill_type::darkdown;
|
#pragma clang diagnostic push
|
||||||
else if (string == "darkgray") return pattern_fill_type::darkgray;
|
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||||
else if (string == "darkgrid") return pattern_fill_type::darkgrid;
|
static std::unordered_map<std::string, pattern_fill_type> patternFill {
|
||||||
else if (string == "darkhorizontal") return pattern_fill_type::darkhorizontal;
|
{"darkdown", pattern_fill_type::darkdown },
|
||||||
else if (string == "darktrellis") return pattern_fill_type::darktrellis;
|
{ "darkgray", pattern_fill_type::darkgray },
|
||||||
else if (string == "darkup") return pattern_fill_type::darkup;
|
{ "darkgrid", pattern_fill_type::darkgrid },
|
||||||
else if (string == "darkvertical") return pattern_fill_type::darkvertical;
|
{ "darkhorizontal", pattern_fill_type::darkhorizontal },
|
||||||
else if (string == "gray0625") return pattern_fill_type::gray0625;
|
{ "darktrellis", pattern_fill_type::darktrellis },
|
||||||
else if (string == "gray125") return pattern_fill_type::gray125;
|
{ "darkup", pattern_fill_type::darkup },
|
||||||
else if (string == "lightdown") return pattern_fill_type::lightdown;
|
{ "darkvertical", pattern_fill_type::darkvertical },
|
||||||
else if (string == "lightgray") return pattern_fill_type::lightgray;
|
{ "gray0625", pattern_fill_type::gray0625 },
|
||||||
else if (string == "lightgrid") return pattern_fill_type::lightgrid;
|
{ "gray125", pattern_fill_type::gray125 },
|
||||||
else if (string == "lighthorizontal") return pattern_fill_type::lighthorizontal;
|
{ "lightdown", pattern_fill_type::lightdown },
|
||||||
else if (string == "lighttrellis") return pattern_fill_type::lighttrellis;
|
{ "lightgray", pattern_fill_type::lightgray },
|
||||||
else if (string == "lightup") return pattern_fill_type::lightup;
|
{ "lightgrid", pattern_fill_type::lightgrid },
|
||||||
else if (string == "lightvertical") return pattern_fill_type::lightvertical;
|
{ "lighthorizontal", pattern_fill_type::lighthorizontal },
|
||||||
else if (string == "mediumgray") return pattern_fill_type::mediumgray;
|
{ "lighttrellis", pattern_fill_type::lighttrellis },
|
||||||
else if (string == "none") return pattern_fill_type::none;
|
{ "lightup", pattern_fill_type::lightup },
|
||||||
else if (string == "solid") return pattern_fill_type::solid;
|
{ "lightvertical", pattern_fill_type::lightvertical },
|
||||||
|
{ "mediumgray", pattern_fill_type::mediumgray },
|
||||||
|
{ "none", pattern_fill_type::none },
|
||||||
|
{ "solid", pattern_fill_type::solid }
|
||||||
|
};
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
|
auto toLower = [](std::string str) {
|
||||||
|
auto bg{ std::begin (str) };
|
||||||
|
auto en{ std::end (str) };
|
||||||
|
std::transform (bg, en, bg, tolower);
|
||||||
|
|
||||||
default_case(pattern_fill_type::none);
|
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<>
|
template<>
|
||||||
|
|
|
@ -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)
|
for (y = 0; y < h; ++y)
|
||||||
{
|
{
|
||||||
tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH);
|
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)
|
if (tdefl_compress_buffer(pComp, nullptr, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user