mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge branch 'master' into patch-5
This commit is contained in:
commit
e55ac4f896
|
@ -9,6 +9,14 @@
|
|||
xlnt can be [found](https://aur.archlinux.org/packages/xlnt/) on the AUR.
|
||||
|
||||
## vcpkg
|
||||
`vcpkg` installs x86 by default
|
||||
```
|
||||
.\vcpkg install xlnt
|
||||
```
|
||||
if you need x64 use the following command
|
||||
```
|
||||
.\vcpkg install xlnt:x64-windows
|
||||
```
|
||||
|
||||
## Compiling xlnt 1.x.x from Source on Ubuntu 16.04 LTS (Xenial Xerus)
|
||||
Time required: Approximately 5 minutes (depending on your internet speed)
|
||||
|
@ -28,12 +36,9 @@ export CC=/usr/bin/gcc-6
|
|||
export CXX=/usr/bin/g++-6
|
||||
```
|
||||
The following steps will intall xlnt
|
||||
Download the zip file from the xlnt repository
|
||||
https://github.com/tfussell/xlnt/archive/master.zip
|
||||
```
|
||||
cd ~
|
||||
unzip Downloads/xlnt-master.zip
|
||||
cd xlnt-master
|
||||
git clone https://github.com/tfussell/xlnt.git xlnt --recurse-submodules
|
||||
cd xlnt
|
||||
cmake .
|
||||
make -j 2
|
||||
sudo make install
|
||||
|
|
|
@ -203,6 +203,12 @@ public:
|
|||
/// </summary>
|
||||
worksheet active_sheet();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the worksheet that is determined to be active. An active
|
||||
/// sheet is that which is initially shown by the spreadsheet editor.
|
||||
/// </summary>
|
||||
void active_sheet(std::size_t index);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the worksheet with the given name. This may throw an exception
|
||||
/// if the sheet isn't found. Use workbook::contains(const std::string &)
|
||||
|
|
|
@ -2037,6 +2037,7 @@ void xlsx_consumer::read_office_document(const std::string &content_type) // CT_
|
|||
if (parser().attribute_present("activeTab"))
|
||||
{
|
||||
view.active_tab = parser().attribute<std::size_t>("activeTab");
|
||||
target_.d_->active_sheet_index_.set(view.active_tab.get());
|
||||
}
|
||||
|
||||
target_.view(view);
|
||||
|
|
|
@ -743,6 +743,11 @@ worksheet workbook::active_sheet()
|
|||
{
|
||||
return sheet_by_index(d_->active_sheet_index_.is_set() ? d_->active_sheet_index_.get() : 0);
|
||||
}
|
||||
void workbook::active_sheet(std::size_t index)
|
||||
{
|
||||
d_->active_sheet_index_.set(index);
|
||||
d_->view_.get().active_tab = index;
|
||||
}
|
||||
|
||||
bool workbook::has_named_range(const std::string &name) const
|
||||
{
|
||||
|
|
BIN
tests/data/20_active_sheet.xlsx
Normal file
BIN
tests/data/20_active_sheet.xlsx
Normal file
Binary file not shown.
|
@ -57,7 +57,7 @@ public:
|
|||
void test_float_equals_zero()
|
||||
{
|
||||
// comparing relatively small numbers (2.3e-6) with 0 will be true by default
|
||||
const float comp_val = 2.3e-6; // about the largest difference allowed by default
|
||||
const float comp_val = 2.3e-6f; // about the largest difference allowed by default
|
||||
xlnt_assert(0.f != comp_val); // fail because not exactly equal
|
||||
xlnt_assert(xlnt::detail::float_equals(0.0, comp_val));
|
||||
xlnt_assert(xlnt::detail::float_equals(0.0, -comp_val));
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
// #1: reduce the epsilon_scale (default is 20)
|
||||
// This can bring the range down to FLT_EPSILON (scale factor of 1)
|
||||
xlnt_assert(!xlnt::detail::float_equals(0.0, comp_val, 10));
|
||||
const float closer_comp_val = 1.1e-6;
|
||||
const float closer_comp_val = 1.1e-6f;
|
||||
xlnt_assert(xlnt::detail::float_equals(0.0, closer_comp_val, 10));
|
||||
xlnt_assert(!xlnt::detail::float_equals(0.0, closer_comp_val + 0.1e-6, 10));
|
||||
xlnt_assert(xlnt::detail::float_equals(0.0, -closer_comp_val, 10));
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
// This makes the epsilon range quite significantly less
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, comp_val));
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, closer_comp_val));
|
||||
const float tiny_comp_val = 4.4e-15;
|
||||
const float tiny_comp_val = 4.4e-15f;
|
||||
xlnt_assert(xlnt::detail::float_equals<double>(0.0, tiny_comp_val));
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, tiny_comp_val + 0.1e-15));
|
||||
xlnt_assert(xlnt::detail::float_equals<double>(0.0, -tiny_comp_val));
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, comp_val, 1));
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, closer_comp_val, 1));
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, tiny_comp_val, 1));
|
||||
const float really_tiny_comp_val = 2.2e-16; // the limit is +/- std::numeric_limits<double>::epsilon()
|
||||
const float really_tiny_comp_val = 2.2e-16f; // the limit is +/- std::numeric_limits<double>::epsilon()
|
||||
xlnt_assert(xlnt::detail::float_equals<double>(0.0, really_tiny_comp_val, 1));
|
||||
xlnt_assert(!xlnt::detail::float_equals<double>(0.0, really_tiny_comp_val + 0.1e-16, 1));
|
||||
xlnt_assert(xlnt::detail::float_equals<double>(0.0, -really_tiny_comp_val, 1));
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
|
||||
void test_float_equals_nan()
|
||||
{
|
||||
const float nan = std::nan("");
|
||||
const float nan = std::nanf("");
|
||||
// nans always compare false
|
||||
xlnt_assert(!xlnt::detail::float_equals(nan, 0.f));
|
||||
xlnt_assert(!xlnt::detail::float_equals(nan, nan));
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
register_test(test_Issue492_stream_empty_row);
|
||||
register_test(test_Issue503_external_link_load);
|
||||
register_test(test_formatting);
|
||||
register_test(test_active_sheet);
|
||||
}
|
||||
|
||||
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
||||
|
@ -800,6 +801,13 @@ public:
|
|||
assert_run(rt.runs()[10], " first line ", "Calibri", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[11], "Bold And Underline", "Calibri (Body)", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::single);
|
||||
}
|
||||
|
||||
void test_active_sheet()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
wb.load(path_helper::test_file("20_active_sheet.xlsx"));
|
||||
xlnt_assert_equals(wb.active_sheet(), wb[2]);
|
||||
}
|
||||
};
|
||||
|
||||
static serialization_test_suite x;
|
||||
|
|
|
@ -77,6 +77,11 @@ public:
|
|||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt_assert_equals(wb.active_sheet(), wb[0]);
|
||||
|
||||
wb.create_sheet();
|
||||
wb.create_sheet();
|
||||
wb.active_sheet(2);
|
||||
xlnt_assert_equals(wb.active_sheet(), wb[2]);
|
||||
}
|
||||
|
||||
void test_create_sheet()
|
||||
|
|
12
third-party/miniz/miniz.c
vendored
12
third-party/miniz/miniz.c
vendored
|
@ -4460,7 +4460,8 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file
|
|||
{
|
||||
/* Temporarily allocate a read buffer. */
|
||||
read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
|
||||
if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
|
||||
int constExpression1 = (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF));
|
||||
if (constExpression1)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
|
||||
|
@ -4554,7 +4555,8 @@ void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, si
|
|||
uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
|
||||
|
||||
alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;
|
||||
if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
|
||||
int constExpression2 = (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF));
|
||||
if (constExpression2)
|
||||
{
|
||||
mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
return NULL;
|
||||
|
@ -4652,7 +4654,8 @@ mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_ind
|
|||
/* The file is stored or the caller has requested the compressed data. */
|
||||
if (pZip->m_pState->m_pMem)
|
||||
{
|
||||
if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > MZ_UINT32_MAX))
|
||||
int constExpression3 = (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > MZ_UINT32_MAX));
|
||||
if (constExpression3)
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
||||
|
||||
if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size)
|
||||
|
@ -5555,7 +5558,8 @@ static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const vo
|
|||
return 0;
|
||||
|
||||
/* An allocation this big is likely to just fail on 32-bit systems, so don't even go there. */
|
||||
if ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))
|
||||
int constExpression4 = ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF));
|
||||
if (constExpression4)
|
||||
{
|
||||
mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user