mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
use system packages for zlib, cryptopp, and cxxtest. WIP [ci skip]
This commit is contained in:
parent
a2bfdee2f2
commit
e4ec1a2850
7
.gitmodules
vendored
7
.gitmodules
vendored
|
@ -1,6 +1,5 @@
|
||||||
[submodule "third-party/botan"]
|
[submodule "third-party/libstudxml"]
|
||||||
path = third-party/botan
|
path = third-party/libstudxml
|
||||||
url = https://github.com/randombit/botan
|
url = http://scm.codesynthesis.com/libstudxml/libstudxml.git
|
||||||
branch = master
|
branch = master
|
||||||
ignore = dirty
|
ignore = dirty
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,24 @@
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project(xlnt VERSION 0.9.3)
|
project(xlnt VERSION 0.9.3)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
|
|
||||||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../third-party ${CMAKE_CURRENT_BINARY_DIR}/third-party)
|
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(PROJECT_VENDOR "Thomas Fussell")
|
set(PROJECT_VENDOR "Thomas Fussell")
|
||||||
set(PROJECT_CONTACT "thomas.fussell@gmail.com")
|
set(PROJECT_CONTACT "thomas.fussell@gmail.com")
|
||||||
set(PROJECT_URL "https://github.com/tfussell/xlnt")
|
set(PROJECT_URL "https://github.com/tfussell/xlnt")
|
||||||
set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
|
set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
|
||||||
|
|
||||||
set(XLNT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
if(APPLE)
|
||||||
set(XLNT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
|
||||||
set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party)
|
|
||||||
|
|
||||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
||||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" CACHE PATH "default install path" FORCE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT INC_DEST_DIR)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT LIB_DEST_DIR)
|
set(XLNT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT BIN_DEST_DIR)
|
set(XLNT_INCLUDE_DIR ${XLNT_ROOT_DIR}/include)
|
||||||
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
|
set(XLNT_SOURCE_DIR ${XLNT_ROOT_DIR}/source)
|
||||||
endif()
|
set(THIRD_PARTY_DIR ${XLNT_ROOT_DIR}/third-party)
|
||||||
|
add_subdirectory(${THIRD_PARTY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/third-party)
|
||||||
|
|
||||||
if(COVERAGE)
|
if(COVERAGE)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
@ -58,15 +39,6 @@ if(APPLE)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_VERSION})
|
set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_VERSION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Includes
|
|
||||||
include_directories(${XLNT_INCLUDE_DIR}
|
|
||||||
${XLNT_INCLUDE_DIR}/xlnt
|
|
||||||
${XLNT_SOURCE_DIR}
|
|
||||||
${XLNT_SOURCE_DIR}/detail
|
|
||||||
${LIBSTUDXML_INCLUDE_DIR}
|
|
||||||
${ZLIB_INCLUDE_DIR}
|
|
||||||
${CRYPTOPP_INCLUDE_DIR})
|
|
||||||
|
|
||||||
file(GLOB ROOT_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/*.hpp)
|
file(GLOB ROOT_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/*.hpp)
|
||||||
file(GLOB CELL_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/cell/*.hpp)
|
file(GLOB CELL_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/cell/*.hpp)
|
||||||
file(GLOB CELL_SOURCES ${XLNT_SOURCE_DIR}/cell/*.cpp)
|
file(GLOB CELL_SOURCES ${XLNT_SOURCE_DIR}/cell/*.cpp)
|
||||||
|
@ -100,6 +72,23 @@ set(XLNT_SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES}
|
||||||
${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES}
|
${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES}
|
||||||
${WORKSHEET_SOURCES} ${DETAIL_SOURCES})
|
${WORKSHEET_SOURCES} ${DETAIL_SOURCES})
|
||||||
|
|
||||||
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed"
|
||||||
|
CACHE PATH "default install path" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT INC_DEST_DIR)
|
||||||
|
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT LIB_DEST_DIR)
|
||||||
|
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT BIN_DEST_DIR)
|
||||||
|
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT STATIC)
|
if(NOT STATIC)
|
||||||
add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES})
|
add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES})
|
||||||
target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1)
|
target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1)
|
||||||
|
@ -108,23 +97,17 @@ if(NOT STATIC)
|
||||||
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1 _CRT_SECURE_NO_WARNINGS=1)
|
target_compile_definitions(xlnt PRIVATE XLNT_EXPORT=1 _CRT_SECURE_NO_WARNINGS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS xlnt
|
set_target_properties(xlnt
|
||||||
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
|
||||||
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
|
||||||
RUNTIME DESTINATION ${BIN_DEST_DIR})
|
|
||||||
set_target_properties(
|
|
||||||
xlnt
|
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||||
INSTALL_NAME_DIR "${LIB_DEST_DIR}")
|
INSTALL_NAME_DIR "${LIB_DEST_DIR}")
|
||||||
|
|
||||||
if(FRAMEWORK)
|
if(FRAMEWORK)
|
||||||
add_custom_command(
|
add_custom_command(TARGET xlnt
|
||||||
TARGET xlnt
|
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
||||||
COMMAND cp -R ../include/xlnt/* "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
COMMAND cp -R ${XLNT_INCLUDE_DIR}/xlnt/* "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
||||||
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
|
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
|
||||||
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions" && ln -s "${PROJECT_VERSION_FULL}" Current
|
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework/Versions" && ln -s "${PROJECT_VERSION_FULL}" Current
|
||||||
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework" && ln -s Versions/Current/* ./
|
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/xlnt.framework" && ln -s Versions/Current/* ./
|
||||||
|
@ -135,23 +118,17 @@ else()
|
||||||
target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1)
|
target_compile_definitions(xlnt PUBLIC XLNT_STATIC=1)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_definitions(xlnt PRIVATE _CRT_SECURE_NO_WARNINGS=1 NOMINMAX)
|
target_compile_definitions(xlnt PRIVATE _CRT_SECURE_NO_WARNINGS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS xlnt
|
|
||||||
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
|
||||||
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
|
||||||
RUNTIME DESTINATION ${BIN_DEST_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(xlnt
|
target_link_libraries(xlnt ${CRYPTOPP_LIBRARY} ${ZLIB_LIBRARY_RELEASE} libstudxml)
|
||||||
PRIVATE LIBSTUDXML_STATIC_LIB=1
|
|
||||||
PRIVATE NO_OS_DEPENDENCE=1
|
target_include_directories(xlnt
|
||||||
PRIVATE CRYPTOPP_DISABLE_ASM=1)
|
PUBLIC ${XLNT_INCLUDE_DIR}
|
||||||
target_link_libraries(xlnt ${CRYPTOPP_LIBRARY})
|
PRIVATE ${XLNT_SOURCE_DIR}
|
||||||
target_link_libraries(xlnt ${ZLIB_LIBRARY_RELEASE})
|
PRIVATE ${ZLIB_INCLUDE_DIR}
|
||||||
target_link_libraries(xlnt libstudxml)
|
PRIVATE ${CRYPTOPP_INCLUDE_DIR})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")
|
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")
|
||||||
|
@ -171,35 +148,31 @@ source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES})
|
||||||
source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES})
|
source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES})
|
||||||
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
|
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
|
||||||
|
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
|
|
||||||
set(PKG_CONFIG_LIBDIR ${LIB_DEST_DIR})
|
set(PKG_CONFIG_LIBDIR ${LIB_DEST_DIR})
|
||||||
set(PKG_CONFIG_INCLUDEDIR ${INC_DEST_DIR})
|
set(PKG_CONFIG_INCLUDEDIR ${INC_DEST_DIR})
|
||||||
set(PKG_CONFIG_LIBS "-L\${libdir} -lxlnt")
|
set(PKG_CONFIG_LIBS "-L\${libdir} -lxlnt")
|
||||||
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
||||||
|
|
||||||
|
install(TARGETS xlnt
|
||||||
|
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
||||||
|
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
||||||
|
RUNTIME DESTINATION ${BIN_DEST_DIR})
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
configure_file(
|
configure_file("${XLNT_ROOT_DIR}/cmake/pkg-config.pc.cmake"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake/pkg-config.pc.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc")
|
"${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc")
|
||||||
endif()
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc"
|
||||||
|
|
||||||
configure_file(
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake/cmake_uninstall.cmake.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
||||||
IMMEDIATE @ONLY)
|
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY ${XLNT_INCLUDE_DIR}/xlnt
|
|
||||||
DESTINATION include
|
|
||||||
PATTERN ".DS_Store" EXCLUDE)
|
|
||||||
|
|
||||||
if(NOT MSVC)
|
|
||||||
install(
|
|
||||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc"
|
|
||||||
DESTINATION ${LIB_DEST_DIR}/pkgconfig)
|
DESTINATION ${LIB_DEST_DIR}/pkgconfig)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_target(
|
install(DIRECTORY ${XLNT_INCLUDE_DIR}/xlnt
|
||||||
uninstall
|
DESTINATION include
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
PATTERN ".DS_Store" EXCLUDE)
|
||||||
|
|
||||||
|
configure_file("${XLNT_ROOT_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
|
IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
add_custom_target(uninstall
|
||||||
|
COMMAND ${CMAKE_COMMAND} -P
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cxxtest/TestSuite.h>
|
|
||||||
|
|
||||||
#include <xlnt/utils/utf8string.hpp>
|
|
||||||
|
|
||||||
class test_utf8string : public CxxTest::TestSuite
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void test_utf8()
|
|
||||||
{
|
|
||||||
auto utf8_valid = xlnt::utf8string::from_utf8("abc");
|
|
||||||
auto utf8_invalid = xlnt::utf8string::from_utf8("\xc3\x28");
|
|
||||||
|
|
||||||
TS_ASSERT(utf8_valid.is_valid());
|
|
||||||
TS_ASSERT(!utf8_invalid.is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_latin1()
|
|
||||||
{
|
|
||||||
auto latin1_valid = xlnt::utf8string::from_latin1("abc");
|
|
||||||
TS_ASSERT(latin1_valid.is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_utf16()
|
|
||||||
{
|
|
||||||
auto utf16_valid = xlnt::utf8string::from_utf16({ 'a', 'b', 'c' });
|
|
||||||
TS_ASSERT(utf16_valid.is_valid());
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_utf32()
|
|
||||||
{
|
|
||||||
auto utf32_valid = xlnt::utf8string::from_utf32({ 'a', 'b', 'c' });
|
|
||||||
TS_ASSERT(utf32_valid.is_valid());
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -13,31 +13,31 @@ public:
|
||||||
void test_decrypt_agile()
|
void test_decrypt_agile()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load(path_helper::get_data_directory("11_encrypted_excel_2016.xlsx"), "secret");
|
wb.load(path_helper::data_directory("11_encrypted_excel_2016.xlsx"), "secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_decrypt_libre_office()
|
void test_decrypt_libre_office()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load(path_helper::get_data_directory("12_encrypted_libre_office.xlsx"), "secret");
|
wb.load(path_helper::data_directory("12_encrypted_libre_office.xlsx"), "secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_decrypt_standard()
|
void test_decrypt_standard()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load(path_helper::get_data_directory("13_encrypted_excel_2007.xlsx"), "password");
|
wb.load(path_helper::data_directory("13_encrypted_excel_2007.xlsx"), "password");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_decrypt_numbers()
|
void test_decrypt_numbers()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load(path_helper::get_data_directory("14_encrypted_numbers.xlsx"), "secret");
|
wb.load(path_helper::data_directory("14_encrypted_numbers.xlsx"), "secret");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_comments()
|
void test_comments()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/15_basic_comments.xlsx");
|
wb.load(path_helper::data_directory("15_basic_comments.xlsx"));
|
||||||
|
|
||||||
auto sheet1 = wb[0];
|
auto sheet1 = wb[0];
|
||||||
TS_ASSERT_EQUALS(sheet1.cell("A1").value<std::string>(), "Sheet1!A1");
|
TS_ASSERT_EQUALS(sheet1.cell("A1").value<std::string>(), "Sheet1!A1");
|
||||||
|
@ -54,12 +54,13 @@ public:
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
|
static const std::string data_dir = STRING_LITERAL(XLNT_TEST_DATA_DIR);
|
||||||
wb.load(L"data\\16_unicode_Λ.xlsx");
|
wb.load(L"data\\16_unicode_Λ.xlsx");
|
||||||
TS_ASSERT_EQUALS(wb.active_sheet().cell("A1").value<std::string>(), "unicode!");
|
TS_ASSERT_EQUALS(wb.active_sheet().cell("A1").value<std::string>(), "unicode!");
|
||||||
#endif
|
#endif
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
xlnt::workbook wb2;
|
xlnt::workbook wb2;
|
||||||
wb2.load(u8"data/16_unicode_Λ.xlsx");
|
wb2.load(U8STRING_LITERAL(XLNT_TEST_DATA_DIR) u8"/16_unicode_Λ.xlsx");
|
||||||
TS_ASSERT_EQUALS(wb2.active_sheet().cell("A1").value<std::string>(), "unicode!");
|
TS_ASSERT_EQUALS(wb2.active_sheet().cell("A1").value<std::string>(), "unicode!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,7 @@ public:
|
||||||
void test_read_hyperlink()
|
void test_read_hyperlink()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/17_with_hyperlink.xlsx");
|
wb.load(path_helper::data_directory("17_with_hyperlink.xlsx"));
|
||||||
TS_ASSERT(wb.active_sheet().cell("A1").has_hyperlink());
|
TS_ASSERT(wb.active_sheet().cell("A1").has_hyperlink());
|
||||||
TS_ASSERT_EQUALS(wb.active_sheet().cell("A1").hyperlink(),
|
TS_ASSERT_EQUALS(wb.active_sheet().cell("A1").hyperlink(),
|
||||||
"https://fr.wikipedia.org/wiki/Ille-et-Vilaine");
|
"https://fr.wikipedia.org/wiki/Ille-et-Vilaine");
|
||||||
|
@ -76,7 +77,7 @@ public:
|
||||||
void test_read_headers_and_footers()
|
void test_read_headers_and_footers()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/18_headers_and_footers.xlsx");
|
wb.load(path_helper::data_directory("18_headers_and_footers.xlsx"));
|
||||||
auto ws = wb.active_sheet();
|
auto ws = wb.active_sheet();
|
||||||
|
|
||||||
TS_ASSERT_EQUALS(ws.cell("A1").value<std::string>(), "header");
|
TS_ASSERT_EQUALS(ws.cell("A1").value<std::string>(), "header");
|
||||||
|
@ -108,7 +109,7 @@ public:
|
||||||
void test_read_custom_properties()
|
void test_read_custom_properties()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/21_custom_properties.xlsx");
|
wb.load(path_helper::data_directory("21_custom_properties.xlsx"));
|
||||||
TS_ASSERT(wb.has_custom_property("Client"));
|
TS_ASSERT(wb.has_custom_property("Client"));
|
||||||
TS_ASSERT_EQUALS(wb.custom_property("Client").get<std::string>(), "me!");
|
TS_ASSERT_EQUALS(wb.custom_property("Client").get<std::string>(), "me!");
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,7 @@ public:
|
||||||
void test_read_formulae()
|
void test_read_formulae()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/22_formulae.xlsx");
|
wb.load(path_helper::data_directory("22_formulae.xlsx"));
|
||||||
auto ws = wb.active_sheet();
|
auto ws = wb.active_sheet();
|
||||||
TS_ASSERT_EQUALS(ws.cell("A1").value<int>(), 6);
|
TS_ASSERT_EQUALS(ws.cell("A1").value<int>(), 6);
|
||||||
TS_ASSERT(ws.cell("A1").has_formula());
|
TS_ASSERT(ws.cell("A1").has_formula());
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
void test_produce_empty()
|
void test_produce_empty()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb = xlnt::workbook::empty();
|
xlnt::workbook wb = xlnt::workbook::empty();
|
||||||
TS_ASSERT(workbook_matches_file(wb, path_helper::get_data_directory("9_default-excel.xlsx")));
|
TS_ASSERT(workbook_matches_file(wb, path_helper::data_directory("9_default-excel.xlsx")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_produce_simple_excel()
|
void test_produce_simple_excel()
|
||||||
|
@ -152,13 +152,13 @@ public:
|
||||||
sheet2.cell("A2").value("Sheet2!A2");
|
sheet2.cell("A2").value("Sheet2!A2");
|
||||||
sheet2.cell("A2").comment("Sheet2 comment2", comment_font, "Microsoft Office User");
|
sheet2.cell("A2").comment("Sheet2 comment2", comment_font, "Microsoft Office User");
|
||||||
|
|
||||||
TS_ASSERT(workbook_matches_file(wb, xlnt::path("data/15_basic_comments.xlsx")));
|
TS_ASSERT(workbook_matches_file(wb, path_helper::data_directory("15_basic_comments.xlsx")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_save_after_clear_all_formulae()
|
void test_save_after_clear_all_formulae()
|
||||||
{
|
{
|
||||||
xlnt::workbook wb;
|
xlnt::workbook wb;
|
||||||
wb.load("data/22_formulae.xlsx");
|
wb.load(path_helper::data_directory("22_formulae.xlsx"));
|
||||||
auto ws = wb.active_sheet();
|
auto ws = wb.active_sheet();
|
||||||
TS_ASSERT(ws.cell("A1").has_formula());
|
TS_ASSERT(ws.cell("A1").has_formula());
|
||||||
TS_ASSERT_EQUALS(ws.cell("A1").formula(), "A2*A3");
|
TS_ASSERT_EQUALS(ws.cell("A1").formula(), "A2*A3");
|
||||||
|
|
|
@ -65,31 +65,31 @@ public:
|
||||||
|
|
||||||
void test_round_trip_empty_excel_rw()
|
void test_round_trip_empty_excel_rw()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("9_default-excel.xlsx");
|
auto path = path_helper::data_directory("9_default-excel.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_all_styles_rw()
|
void test_round_trip_all_styles_rw()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("10_all_styles.xlsx");
|
auto path = path_helper::data_directory("10_all_styles.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_headers_footers()
|
void test_round_trip_headers_footers()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("18_headers_and_footers.xlsx");
|
auto path = path_helper::data_directory("18_headers_and_footers.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_row_and_col_props()
|
void test_round_trip_row_and_col_props()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("19_row_and_col_properties.xlsx");
|
auto path = path_helper::data_directory("19_row_and_col_properties.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_page_breaks()
|
void test_round_trip_page_breaks()
|
||||||
{
|
{
|
||||||
auto path = path_helper::get_data_directory("20_page_breaks.xlsx");
|
auto path = path_helper::data_directory("20_page_breaks.xlsx");
|
||||||
TS_ASSERT(round_trip_matches_rw(path));
|
TS_ASSERT(round_trip_matches_rw(path));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,14 +8,6 @@ if(NOT COMBINED_PROJECT)
|
||||||
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
|
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../source)
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../source/detail)
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
include_directories(${CXXTEST_INCLUDE_DIR})
|
|
||||||
include_directories(${LIBSTUDXML_INCLUDE_DIR})
|
|
||||||
include_directories(${ZLIB_INCLUDE_DIR})
|
|
||||||
|
|
||||||
file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/cell/tests/test_*.hpp)
|
file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/cell/tests/test_*.hpp)
|
||||||
file(GLOB CHARTS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/charts/tests/test_*.hpp)
|
file(GLOB CHARTS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/charts/tests/test_*.hpp)
|
||||||
file(GLOB CHARTSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/chartsheet/tests/test_*.hpp)
|
file(GLOB CHARTSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/chartsheet/tests/test_*.hpp)
|
||||||
|
@ -49,8 +41,13 @@ if(COVERAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP})
|
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP})
|
||||||
target_compile_definitions(xlnt.test PRIVATE LIBSTUDXML_STATIC_LIB=1)
|
|
||||||
target_link_libraries(xlnt.test xlnt)
|
target_link_libraries(xlnt.test xlnt)
|
||||||
|
target_include_directories(xlnt.test
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
|
||||||
|
PRIVATE ${CXXTEST_INCLUDE_DIR})
|
||||||
|
set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
||||||
|
target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})
|
||||||
|
|
||||||
source_group(helpers FILES ${TEST_HELPERS})
|
source_group(helpers FILES ${TEST_HELPERS})
|
||||||
source_group(xlnt\\detail FILES ${XLNT_ZIP})
|
source_group(xlnt\\detail FILES ${XLNT_ZIP})
|
||||||
|
@ -85,5 +82,3 @@ add_custom_command(OUTPUT ${RUNNER}
|
||||||
|
|
||||||
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
|
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
|
||||||
add_dependencies(xlnt.test generate-test-runner)
|
add_dependencies(xlnt.test generate-test-runner)
|
||||||
|
|
||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${CMAKE_BINARY_DIR}/bin)
|
|
||||||
|
|
|
@ -20,13 +20,20 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STRING_LITERAL2(a) #a
|
||||||
|
#define LSTRING_LITERAL2(a) L#a
|
||||||
|
#define U8STRING_LITERAL2(a) u8#a
|
||||||
|
#define STRING_LITERAL(a) STRING_LITERAL2(a)
|
||||||
|
#define LSTRING_LITERAL(a) STRING_LITERAL2(a)
|
||||||
|
#define U8STRING_LITERAL(a) STRING_LITERAL2(a)
|
||||||
|
|
||||||
class path_helper
|
class path_helper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static xlnt::path get_data_directory(const std::string &append = "")
|
static xlnt::path data_directory(const std::string &append = "")
|
||||||
{
|
{
|
||||||
return xlnt::path("data")
|
static const std::string data_dir = STRING_LITERAL(XLNT_TEST_DATA_DIR);
|
||||||
.append(xlnt::path(append));
|
return xlnt::path(data_dir).append(xlnt::path(append));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_file(const xlnt::path &source, const xlnt::path &destination, bool overwrite)
|
static void copy_file(const xlnt::path &source, const xlnt::path &destination, bool overwrite)
|
||||||
|
|
33
third-party/CMakeLists.txt
vendored
33
third-party/CMakeLists.txt
vendored
|
@ -1,26 +1,12 @@
|
||||||
cmake_minimum_required(VERSION 3.2)
|
cmake_minimum_required(VERSION 3.2)
|
||||||
project(xlnt.third-party)
|
project(xlnt.third-party)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(CryptoPP REQUIRED)
|
find_package(CryptoPP REQUIRED)
|
||||||
find_package(CxxTest REQUIRED)
|
find_package(CxxTest REQUIRED)
|
||||||
|
|
||||||
include(ExternalProject)
|
set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libstudxml)
|
||||||
ExternalProject_Add(libstudxml-download
|
|
||||||
GIT_REPOSITORY http://scm.codesynthesis.com/libstudxml/libstudxml.git
|
|
||||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libstudxml
|
|
||||||
UPDATE_COMMAND ""
|
|
||||||
PATCH_COMMAND ""
|
|
||||||
CONFIGURE_COMMAND ""
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ""
|
|
||||||
STEP_TARGETS build
|
|
||||||
EXCLUDE_FROM_ALL TRUE)
|
|
||||||
|
|
||||||
set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/libstudxml/src/libstudxml)
|
|
||||||
|
|
||||||
include_directories(${LIBSTUDXML_ROOT_DIR})
|
|
||||||
|
|
||||||
set(LIBSTUDXML
|
set(LIBSTUDXML
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/parser.cxx
|
${LIBSTUDXML_ROOT_DIR}/xml/parser.cxx
|
||||||
|
@ -38,8 +24,8 @@ set(LIBSTUDXML
|
||||||
set(EXPAT
|
set(EXPAT
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlparse.c
|
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlparse.c
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.c
|
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.c
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_impl.c
|
# ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_impl.c
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_ns.c
|
# ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_ns.c
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.c
|
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.c
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/ascii.h
|
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/ascii.h
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/asciitab.h
|
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/asciitab.h
|
||||||
|
@ -61,5 +47,12 @@ set(GENX
|
||||||
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.h)
|
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.h)
|
||||||
|
|
||||||
add_library(libstudxml STATIC ${LIBSTUDXML} ${EXPAT} ${GENX})
|
add_library(libstudxml STATIC ${LIBSTUDXML} ${EXPAT} ${GENX})
|
||||||
target_compile_definitions(libstudxml PRIVATE LIBSTUDXML_STATIC_LIB=1)
|
target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1)
|
||||||
add_dependencies(libstudxml libstudxml-download)
|
target_include_directories(libstudxml PUBLIC ${LIBSTUDXML_ROOT_DIR})
|
||||||
|
|
||||||
|
add_custom_target(libstudxml-config)
|
||||||
|
add_custom_command(TARGET libstudxml-config PRE_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
|
copy ${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/xml/details/config.h
|
||||||
|
${LIBSTUDXML_ROOT_DIR}/xml/details)
|
||||||
|
add_dependencies(libstudxml libstudxml-config)
|
||||||
|
|
1
third-party/libstudxml
vendored
Submodule
1
third-party/libstudxml
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 132522ca4c895e9b07d7e323d5529474806e5829
|
Loading…
Reference in New Issue
Block a user