mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
intermediate commit
This commit is contained in:
parent
1d34d966a8
commit
a2bfdee2f2
26
.gitmodules
vendored
26
.gitmodules
vendored
|
@ -1,32 +1,6 @@
|
|||
[submodule "third-party/libstudxml"]
|
||||
path = third-party/libstudxml
|
||||
url = http://scm.codesynthesis.com/libstudxml/libstudxml.git
|
||||
branch = master
|
||||
ignore = dirty
|
||||
|
||||
[submodule "third-party/cxxtest"]
|
||||
path = third-party/cxxtest
|
||||
url = https://github.com/CxxTest/cxxtest
|
||||
branch = master
|
||||
ignore = dirty
|
||||
|
||||
[submodule "third-party/utfcpp"]
|
||||
path = third-party/utfcpp
|
||||
url = https://github.com/nemtrif/utfcpp
|
||||
branch = master
|
||||
ignore = dirty
|
||||
|
||||
[submodule "third-party/botan"]
|
||||
path = third-party/botan
|
||||
url = https://github.com/randombit/botan
|
||||
branch = master
|
||||
ignore = dirty
|
||||
|
||||
[submodule "third-party/zlib"]
|
||||
path = third-party/zlib
|
||||
url = https://github.com/madler/zlib.git
|
||||
branch = develop
|
||||
ignore = dirty
|
||||
[submodule "third-party/cryptopp"]
|
||||
path = third-party/cryptopp
|
||||
url = https://github.com/weidai11/cryptopp
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
set(LIBRARY_NAME xlnt)
|
||||
project(${LIBRARY_NAME}_all VERSION ${LIBRARY_VERSION} LANGUAGES CXX C)
|
||||
project(xlnt_all)
|
||||
|
||||
# This indicates to CMakeLists in subdirectories that they are part of a larger project
|
||||
set(COMBINED_PROJECT 1)
|
||||
set(COMBINED_PROJECT TRUE)
|
||||
|
||||
# Library type
|
||||
option(STATIC "Set to ON to build ${PROJECT_NAME} as a static library instead of a shared library" OFF)
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
set(LIBRARY_NAME xlnt)
|
||||
set(LIBRARY_VERSION 0.9.3)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
|
||||
# Global library directories
|
||||
set(LIBRARY_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/../include)
|
||||
set(LIBRARY_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../source)
|
||||
set(THIRD_PARTY_DIR ${CMAKE_CURRENT_LIST_DIR}/../third-party)
|
||||
|
||||
# Put all output files in the same directory
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
|
||||
endforeach()
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) 2014-2017 Thomas Fussell
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE
|
||||
//
|
||||
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||
// @author: see AUTHORS file
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <xlnt/xlnt_config.hpp>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class XLNT_API utf8string
|
||||
{
|
||||
public:
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static utf8string from_utf8(const std::string &s);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static utf8string from_latin1(const std::string &s);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static utf8string from_utf16(const std::vector<std::uint16_t> &s);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static utf8string from_utf32(const std::vector<std::uint32_t> &s);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool is_valid() const;
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::uint8_t> bytes_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
|
@ -1,6 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/common.cmake)
|
||||
project(${LIBRARY_NAME} VERSION ${LIBRARY_VERSION} LANGUAGES CXX C)
|
||||
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")
|
||||
|
@ -37,20 +39,6 @@ if(NOT BIN_DEST_DIR)
|
|||
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
endif()
|
||||
|
||||
|
||||
# Put all output files in the same directory
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
|
||||
endforeach()
|
||||
|
||||
# Platform specific settings
|
||||
if(COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
@ -75,12 +63,9 @@ include_directories(${XLNT_INCLUDE_DIR}
|
|||
${XLNT_INCLUDE_DIR}/xlnt
|
||||
${XLNT_SOURCE_DIR}
|
||||
${XLNT_SOURCE_DIR}/detail
|
||||
${THIRD_PARTY_DIR}/miniz
|
||||
${THIRD_PARTY_DIR}/libstudxml
|
||||
${THIRD_PARTY_DIR}/utfcpp/source
|
||||
${THIRD_PARTY_DIR}/pole
|
||||
${THIRD_PARTY_DIR}/zlib
|
||||
${THIRD_PARTY_DIR}/cryptopp)
|
||||
${LIBSTUDXML_INCLUDE_DIR}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${CRYPTOPP_INCLUDE_DIR})
|
||||
|
||||
file(GLOB ROOT_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/*.hpp)
|
||||
file(GLOB CELL_HEADERS ${XLNT_INCLUDE_DIR}/xlnt/cell/*.hpp)
|
||||
|
@ -138,11 +123,11 @@ if(NOT STATIC)
|
|||
add_custom_command(
|
||||
TARGET xlnt
|
||||
POST_BUILD
|
||||
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
||||
COMMAND cp -R ../include/xlnt/* "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
|
||||
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
|
||||
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions" && ln -s "${PROJECT_VERSION_FULL}" Current
|
||||
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework" && ln -s Versions/Current/* ./
|
||||
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 "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" && ln -s Versions/Current/* ./
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
|
@ -160,11 +145,13 @@ else()
|
|||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
target_compile_definitions(xlnt
|
||||
PRIVATE LIBSTUDXML_STATIC_LIB=1
|
||||
PRIVATE NO_OS_DEPENDENCE=1
|
||||
PRIVATE CRYPTOPP_DISABLE_ASM=1)
|
||||
target_link_libraries(${PROJECT_NAME} xlnt.third-party)
|
||||
target_link_libraries(xlnt ${CRYPTOPP_LIBRARY})
|
||||
target_link_libraries(xlnt ${ZLIB_LIBRARY_RELEASE})
|
||||
target_link_libraries(xlnt libstudxml)
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")
|
||||
|
@ -194,7 +181,7 @@ set(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
|||
if(NOT MSVC)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../cmake/pkg-config.pc.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc")
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
|
@ -209,7 +196,7 @@ install(
|
|||
|
||||
if(NOT MSVC)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc"
|
||||
DESTINATION ${LIB_DEST_DIR}/pkgconfig)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
|
||||
#include <aes.h>
|
||||
#include <base64.h>
|
||||
#include <modes.h>
|
||||
#include <sha.h>
|
||||
#include <cryptopp/aes.h>
|
||||
#include <cryptopp/base64.h>
|
||||
#include <cryptopp/modes.h>
|
||||
#include <cryptopp/sha.h>
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
|
|
@ -53,6 +53,33 @@ bool is_integral(long double d)
|
|||
return std::fabs(d - static_cast<long double>(static_cast<long long int>(d))) == 0.L;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> core_property_namespace(xlnt::core_property type)
|
||||
{
|
||||
using xlnt::core_property;
|
||||
using xlnt::constants;
|
||||
|
||||
if (type == core_property::created
|
||||
|| type == core_property::modified)
|
||||
{
|
||||
return {{constants::ns("dcterms"), "dcterms"},
|
||||
{constants::ns("xsi"), "xsi"}};
|
||||
}
|
||||
else if (type == core_property::title
|
||||
|| type == core_property::subject
|
||||
|| type == core_property::creator
|
||||
|| type == core_property::description)
|
||||
{
|
||||
return {{constants::ns("dc"), "dc"}};
|
||||
}
|
||||
else if (type == core_property::keywords)
|
||||
{
|
||||
return {{constants::ns("core-properties"), "cp"},
|
||||
{constants::ns("vt"), "vt"}};
|
||||
}
|
||||
|
||||
return {{constants::ns("core-properties"), "cp"}};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace xlnt {
|
||||
|
@ -252,12 +279,13 @@ void xlsx_producer::write_property(const std::string &name, const variant &value
|
|||
write_start_element(constants::ns("vt"), "variant");
|
||||
}
|
||||
|
||||
switch (vector_element.value_type())
|
||||
{
|
||||
case variant::type::lpstr:
|
||||
if (vector_element.value_type() == variant::type::lpstr)
|
||||
{
|
||||
write_element(constants::ns("vt"), "lpstr", vector_element.get<std::string>());
|
||||
break;
|
||||
case variant::type::i4:
|
||||
}
|
||||
else if (vector_element.value_type() == variant::type::i4)
|
||||
{
|
||||
write_element(constants::ns("vt"), "i4", vector_element.get<std::int32_t>());
|
||||
break;
|
||||
}
|
||||
|
@ -284,30 +312,6 @@ void xlsx_producer::write_property(const std::string &name, const variant &value
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> core_property_namespace(core_property type)
|
||||
{
|
||||
if (type == core_property::created
|
||||
|| type == core_property::modified)
|
||||
{
|
||||
return {{constants::ns("dcterms"), "dcterms"},
|
||||
{constants::ns("xsi"), "xsi"}};
|
||||
}
|
||||
else if (type == core_property::title
|
||||
|| type == core_property::subject
|
||||
|| type == core_property::creator
|
||||
|| type == core_property::description)
|
||||
{
|
||||
return {{constants::ns("dc"), "dc"}};
|
||||
}
|
||||
else if (type == core_property::keywords)
|
||||
{
|
||||
return {{constants::ns("core-properties"), "cp"},
|
||||
{constants::ns("vt"), "vt"}};
|
||||
}
|
||||
|
||||
return {{constants::ns("core-properties"), "cp"}};
|
||||
}
|
||||
|
||||
void xlsx_producer::write_core_properties(const relationship &/*rel*/)
|
||||
{
|
||||
write_start_element(constants::ns("core-properties"), "coreProperties");
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) 2014-2017 Thomas Fussell
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE
|
||||
//
|
||||
// @license: http://www.opensource.org/licenses/mit-license.php
|
||||
// @author: see AUTHORS file
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wshadow"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#include <utf8.h>
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#include <xlnt/utils/utf8string.hpp>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
utf8string utf8string::from_utf8(const std::string &s)
|
||||
{
|
||||
utf8string result;
|
||||
std::copy(s.begin(), s.end(), std::back_inserter(result.bytes_));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
utf8string utf8string::from_latin1(const std::string &s)
|
||||
{
|
||||
utf8string result;
|
||||
std::copy(s.begin(), s.end(), std::back_inserter(result.bytes_));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
utf8string utf8string::from_utf16(const std::vector<std::uint16_t> &s)
|
||||
{
|
||||
utf8string result;
|
||||
utf8::utf16to8(s.begin(), s.end(), std::back_inserter(result.bytes_));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
utf8string utf8string::from_utf32(const std::vector<std::uint32_t> &s)
|
||||
{
|
||||
utf8string result;
|
||||
utf8::utf32to8(s.begin(), s.end(), std::back_inserter(result.bytes_));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool utf8string::is_valid() const
|
||||
{
|
||||
return utf8::is_valid(bytes_.begin(), bytes_.end());
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
|
@ -165,4 +165,4 @@ variant::type variant::value_type() const
|
|||
return type_;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -120,6 +120,165 @@ std::vector<typename T::key_type> keys(const T &container)
|
|||
return result;
|
||||
}
|
||||
|
||||
xlnt::path default_path(xlnt::relationship_type type, std::size_t index = 0)
|
||||
{
|
||||
using xlnt::path;
|
||||
using xlnt::relationship_type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case relationship_type::calculation_chain:
|
||||
return path("/xl/calcChain.xml");
|
||||
case relationship_type::chartsheet:
|
||||
return path("/xl/sheets/.xml");
|
||||
case relationship_type::comments:
|
||||
return path("/xl/comments.xml");
|
||||
case relationship_type::connections:
|
||||
return path("/xl/connections.xml");
|
||||
case relationship_type::core_properties:
|
||||
return path("/docProps/core.xml");
|
||||
case relationship_type::custom_properties:
|
||||
return path("/docProps/custom.xml");
|
||||
case relationship_type::custom_property:
|
||||
return path("/xl/customProperty.xml");
|
||||
case relationship_type::custom_xml_mappings:
|
||||
return path("/xl/customXmlMappings.xml");
|
||||
case relationship_type::dialogsheet:
|
||||
return path("/xl/dialogsheets/sheet.xml");
|
||||
case relationship_type::drawings:
|
||||
return path("/xl/drawings/drawing.xml");
|
||||
case relationship_type::extended_properties:
|
||||
return path("/docProps/app.xml");
|
||||
case relationship_type::external_workbook_references:
|
||||
return path("/xl/external.xml");
|
||||
case relationship_type::hyperlink:
|
||||
return path("/xl/hyperlink.xml");
|
||||
case relationship_type::image:
|
||||
return path("?");
|
||||
case relationship_type::office_document:
|
||||
return path("/xl/workbook.xml");
|
||||
case relationship_type::pivot_table:
|
||||
return path("/xl/pivotTable.xml");
|
||||
case relationship_type::pivot_table_cache_definition:
|
||||
return path("?");
|
||||
case relationship_type::pivot_table_cache_records:
|
||||
return path("?");
|
||||
case relationship_type::printer_settings:
|
||||
return path("/xl/printerSettings.xml");
|
||||
case relationship_type::query_table:
|
||||
return path("/xl/queryTable.xml");
|
||||
case relationship_type::revision_log:
|
||||
return path("/xl/revisionLog.xml");
|
||||
case relationship_type::shared_string_table:
|
||||
return path("/xl/sharedStrings.xml");
|
||||
case relationship_type::shared_workbook:
|
||||
return path("/xl/sharedWorkbook.xml");
|
||||
case relationship_type::shared_workbook_revision_headers:
|
||||
return path("?");
|
||||
case relationship_type::shared_workbook_user_data:
|
||||
return path("?");
|
||||
case relationship_type::single_cell_table_definitions:
|
||||
return path("?");
|
||||
case relationship_type::stylesheet:
|
||||
return path("/xl/styles.xml");
|
||||
case relationship_type::table_definition:
|
||||
return path("/xl/tableDefinition.xml");
|
||||
case relationship_type::theme:
|
||||
return path("/xl/theme/theme1.xml");
|
||||
case relationship_type::thumbnail:
|
||||
return path("/docProps/thumbnail.jpg");
|
||||
case relationship_type::unknown:
|
||||
return path("/xl/unknown.xml");
|
||||
case relationship_type::vml_drawing:
|
||||
return path("/xl/vmlDrawing.xml");
|
||||
case relationship_type::volatile_dependencies:
|
||||
return path("/xl/volatileDependencies.xml");
|
||||
case relationship_type::worksheet:
|
||||
return path("/xl/worksheets/sheet" + std::to_string(index) + ".xml");
|
||||
}
|
||||
|
||||
default_case(path("/xl/unknownPart.xml"));
|
||||
}
|
||||
|
||||
std::string content_type(xlnt::relationship_type type)
|
||||
{
|
||||
using xlnt::relationship_type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case relationship_type::calculation_chain:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
|
||||
case relationship_type::chartsheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml";
|
||||
case relationship_type::comments:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
|
||||
case relationship_type::connections:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml";
|
||||
case relationship_type::core_properties:
|
||||
return "application/vnd.openxmlformats-package.core-properties+xml";
|
||||
case relationship_type::custom_properties:
|
||||
return "application/vnd.openxmlformats-officedocument.custom-properties+xml";
|
||||
case relationship_type::custom_property:
|
||||
return "";
|
||||
case relationship_type::custom_xml_mappings:
|
||||
return "application/xml";
|
||||
case relationship_type::dialogsheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml";
|
||||
case relationship_type::drawings:
|
||||
return "application/vnd.openxmlformats-officedocument.drawing+xml";
|
||||
case relationship_type::extended_properties:
|
||||
return "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
||||
case relationship_type::external_workbook_references:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
||||
case relationship_type::hyperlink:
|
||||
return "";
|
||||
case relationship_type::image:
|
||||
return "";
|
||||
case relationship_type::office_document:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
||||
case relationship_type::pivot_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
|
||||
case relationship_type::pivot_table_cache_definition:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
|
||||
case relationship_type::pivot_table_cache_records:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
|
||||
case relationship_type::printer_settings:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings";
|
||||
case relationship_type::query_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml";
|
||||
case relationship_type::revision_log:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml";
|
||||
case relationship_type::shared_string_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
|
||||
case relationship_type::shared_workbook:
|
||||
return "";
|
||||
case relationship_type::shared_workbook_revision_headers:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml";
|
||||
case relationship_type::shared_workbook_user_data:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml";
|
||||
case relationship_type::single_cell_table_definitions:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml";
|
||||
case relationship_type::stylesheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml";
|
||||
case relationship_type::table_definition:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
||||
case relationship_type::theme:
|
||||
return "application/vnd.openxmlformats-officedocument.theme+xml";
|
||||
case relationship_type::thumbnail:
|
||||
return "image/jpeg";
|
||||
case relationship_type::unknown:
|
||||
return "";
|
||||
case relationship_type::vml_drawing:
|
||||
return "application/vnd.openxmlformats-officedocument.vmlDrawing";
|
||||
case relationship_type::volatile_dependencies:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml";
|
||||
case relationship_type::worksheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
||||
}
|
||||
|
||||
default_case("application/xml");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace xlnt {
|
||||
|
@ -309,160 +468,6 @@ workbook::workbook(detail::workbook_impl *impl)
|
|||
}
|
||||
}
|
||||
|
||||
path default_path(relationship_type type, std::size_t index = 0)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case relationship_type::calculation_chain:
|
||||
return path("/xl/calcChain.xml");
|
||||
case relationship_type::chartsheet:
|
||||
return path("/xl/sheets/.xml");
|
||||
case relationship_type::comments:
|
||||
return path("/xl/comments.xml");
|
||||
case relationship_type::connections:
|
||||
return path("/xl/connections.xml");
|
||||
case relationship_type::core_properties:
|
||||
return path("/docProps/core.xml");
|
||||
case relationship_type::custom_properties:
|
||||
return path("/docProps/custom.xml");
|
||||
case relationship_type::custom_property:
|
||||
return path("/xl/customProperty.xml");
|
||||
case relationship_type::custom_xml_mappings:
|
||||
return path("/xl/customXmlMappings.xml");
|
||||
case relationship_type::dialogsheet:
|
||||
return path("/xl/dialogsheets/sheet.xml");
|
||||
case relationship_type::drawings:
|
||||
return path("/xl/drawings/drawing.xml");
|
||||
case relationship_type::extended_properties:
|
||||
return path("/docProps/app.xml");
|
||||
case relationship_type::external_workbook_references:
|
||||
return path("/xl/external.xml");
|
||||
case relationship_type::hyperlink:
|
||||
return path("/xl/hyperlink.xml");
|
||||
case relationship_type::image:
|
||||
return path("?");
|
||||
case relationship_type::office_document:
|
||||
return path("/xl/workbook.xml");
|
||||
case relationship_type::pivot_table:
|
||||
return path("/xl/pivotTable.xml");
|
||||
case relationship_type::pivot_table_cache_definition:
|
||||
return path("?");
|
||||
case relationship_type::pivot_table_cache_records:
|
||||
return path("?");
|
||||
case relationship_type::printer_settings:
|
||||
return path("/xl/printerSettings.xml");
|
||||
case relationship_type::query_table:
|
||||
return path("/xl/queryTable.xml");
|
||||
case relationship_type::revision_log:
|
||||
return path("/xl/revisionLog.xml");
|
||||
case relationship_type::shared_string_table:
|
||||
return path("/xl/sharedStrings.xml");
|
||||
case relationship_type::shared_workbook:
|
||||
return path("/xl/sharedWorkbook.xml");
|
||||
case relationship_type::shared_workbook_revision_headers:
|
||||
return path("?");
|
||||
case relationship_type::shared_workbook_user_data:
|
||||
return path("?");
|
||||
case relationship_type::single_cell_table_definitions:
|
||||
return path("?");
|
||||
case relationship_type::stylesheet:
|
||||
return path("/xl/styles.xml");
|
||||
case relationship_type::table_definition:
|
||||
return path("/xl/tableDefinition.xml");
|
||||
case relationship_type::theme:
|
||||
return path("/xl/theme/theme1.xml");
|
||||
case relationship_type::thumbnail:
|
||||
return path("/docProps/thumbnail.jpg");
|
||||
case relationship_type::unknown:
|
||||
return path("/xl/unknown.xml");
|
||||
case relationship_type::vml_drawing:
|
||||
return path("/xl/vmlDrawing.xml");
|
||||
case relationship_type::volatile_dependencies:
|
||||
return path("/xl/volatileDependencies.xml");
|
||||
case relationship_type::worksheet:
|
||||
return path("/xl/worksheets/sheet" + std::to_string(index) + ".xml");
|
||||
}
|
||||
|
||||
default_case(path("/xl/unknownPart.xml"));
|
||||
}
|
||||
|
||||
std::string content_type(relationship_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case relationship_type::calculation_chain:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
|
||||
case relationship_type::chartsheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml";
|
||||
case relationship_type::comments:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
|
||||
case relationship_type::connections:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml";
|
||||
case relationship_type::core_properties:
|
||||
return "application/vnd.openxmlformats-package.core-properties+xml";
|
||||
case relationship_type::custom_properties:
|
||||
return "application/vnd.openxmlformats-officedocument.custom-properties+xml";
|
||||
case relationship_type::custom_property:
|
||||
return "";
|
||||
case relationship_type::custom_xml_mappings:
|
||||
return "application/xml";
|
||||
case relationship_type::dialogsheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml";
|
||||
case relationship_type::drawings:
|
||||
return "application/vnd.openxmlformats-officedocument.drawing+xml";
|
||||
case relationship_type::extended_properties:
|
||||
return "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
||||
case relationship_type::external_workbook_references:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
||||
case relationship_type::hyperlink:
|
||||
return "";
|
||||
case relationship_type::image:
|
||||
return "";
|
||||
case relationship_type::office_document:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
||||
case relationship_type::pivot_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
|
||||
case relationship_type::pivot_table_cache_definition:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
|
||||
case relationship_type::pivot_table_cache_records:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
|
||||
case relationship_type::printer_settings:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings";
|
||||
case relationship_type::query_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml";
|
||||
case relationship_type::revision_log:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml";
|
||||
case relationship_type::shared_string_table:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
|
||||
case relationship_type::shared_workbook:
|
||||
return "";
|
||||
case relationship_type::shared_workbook_revision_headers:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml";
|
||||
case relationship_type::shared_workbook_user_data:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml";
|
||||
case relationship_type::single_cell_table_definitions:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml";
|
||||
case relationship_type::stylesheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml";
|
||||
case relationship_type::table_definition:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
||||
case relationship_type::theme:
|
||||
return "application/vnd.openxmlformats-officedocument.theme+xml";
|
||||
case relationship_type::thumbnail:
|
||||
return "image/jpeg";
|
||||
case relationship_type::unknown:
|
||||
return "";
|
||||
case relationship_type::vml_drawing:
|
||||
return "application/vnd.openxmlformats-officedocument.vmlDrawing";
|
||||
case relationship_type::volatile_dependencies:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml";
|
||||
case relationship_type::worksheet:
|
||||
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
||||
}
|
||||
|
||||
default_case("application/xml");
|
||||
}
|
||||
|
||||
void workbook::register_package_part(relationship_type type)
|
||||
{
|
||||
if (!manifest().has_relationship(path("/"), type))
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/common.cmake)
|
||||
project(${LIBRARY_NAME}.test VERSION ${LIBRARY_VERSION} LANGUAGES CXX C)
|
||||
project(xlnt.test)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(NOT COMBINED_PROJECT)
|
||||
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../third-party ${CMAKE_CURRENT_BINARY_DIR}/third-party)
|
||||
endif()
|
||||
|
||||
include_directories(${LIBRARY_INCLUDE_DIR})
|
||||
include_directories(${LIBRARY_SOURCE_DIR})
|
||||
include_directories(${LIBRARY_SOURCE_DIR}/detail)
|
||||
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(${THIRD_PARTY_DIR}/cxxtest)
|
||||
include_directories(${THIRD_PARTY_DIR}/libstudxml)
|
||||
include_directories(${THIRD_PARTY_DIR}/utfcpp/source)
|
||||
include_directories(${THIRD_PARTY_DIR}/zlib)
|
||||
include_directories(${CXXTEST_INCLUDE_DIR})
|
||||
include_directories(${LIBSTUDXML_INCLUDE_DIR})
|
||||
include_directories(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
file(GLOB CELL_TESTS ${LIBRARY_SOURCE_DIR}/cell/tests/test_*.hpp)
|
||||
file(GLOB CHARTS_TESTS ${LIBRARY_SOURCE_DIR}/charts/tests/test_*.hpp)
|
||||
file(GLOB CHARTSHEET_TESTS ${LIBRARY_SOURCE_DIR}/chartsheet/tests/test_*.hpp)
|
||||
file(GLOB DRAWING_TESTS ${LIBRARY_SOURCE_DIR}/drawing/tests/test_*.hpp)
|
||||
file(GLOB FORMULA_TESTS ${LIBRARY_SOURCE_DIR}/formula/tests/test_*.hpp)
|
||||
file(GLOB PACKAGING_TESTS ${LIBRARY_SOURCE_DIR}/packaging/tests/test_*.hpp)
|
||||
file(GLOB STYLES_TESTS ${LIBRARY_SOURCE_DIR}/styles/tests/test_*.hpp)
|
||||
file(GLOB UTILS_TESTS ${LIBRARY_SOURCE_DIR}/utils/tests/test_*.hpp)
|
||||
file(GLOB WORKBOOK_TESTS ${LIBRARY_SOURCE_DIR}/workbook/tests/test_*.hpp)
|
||||
file(GLOB WORKSHEET_TESTS ${LIBRARY_SOURCE_DIR}/worksheet/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 CHARTSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/chartsheet/tests/test_*.hpp)
|
||||
file(GLOB DRAWING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/drawing/tests/test_*.hpp)
|
||||
file(GLOB FORMULA_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/formula/tests/test_*.hpp)
|
||||
file(GLOB PACKAGING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/packaging/tests/test_*.hpp)
|
||||
file(GLOB STYLES_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/styles/tests/test_*.hpp)
|
||||
file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/utils/tests/test_*.hpp)
|
||||
file(GLOB WORKBOOK_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/workbook/tests/test_*.hpp)
|
||||
file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/worksheet/tests/test_*.hpp)
|
||||
|
||||
set(XLNT_ZIP
|
||||
${LIBRARY_SOURCE_DIR}/detail/zstream.cpp
|
||||
${LIBRARY_SOURCE_DIR}/detail/zstream.hpp)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/zstream.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../source//detail/zstream.hpp)
|
||||
|
||||
set(TESTS ${CELL_TESTS} ${CHARTS_TESTS} ${CHARTSHEET_TESTS} ${DRAWING_TESTS}
|
||||
${FORMULA_TESTS} ${PACKAGING_TESTS} ${STYLES_TESTS} ${UTILS_TESTS}
|
||||
|
@ -48,9 +48,9 @@ if(COVERAGE)
|
|||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage")
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP})
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE LIBSTUDXML_STATIC_LIB=1)
|
||||
target_link_libraries(${PROJECT_NAME} xlnt.third-party)
|
||||
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)
|
||||
|
||||
source_group(helpers FILES ${TEST_HELPERS})
|
||||
source_group(xlnt\\detail FILES ${XLNT_ZIP})
|
||||
|
@ -67,26 +67,23 @@ source_group(tests\\workbook FILES ${WORKBOOK_TESTS})
|
|||
source_group(tests\\worksheet FILES ${WORKSHEET_TESTS})
|
||||
source_group(runner FILES ${RUNNER})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBRARY_NAME})
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\"")
|
||||
# Needed for PathFileExists in path_helper
|
||||
target_link_libraries(${PROJECT_NAME} Shlwapi)
|
||||
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\"")
|
||||
else()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} Threads::Threads)
|
||||
target_link_libraries(xlnt.test Threads::Threads)
|
||||
endif()
|
||||
|
||||
find_package(PythonInterp)
|
||||
find_package(PythonInterp REQUIRED)
|
||||
find_package(CxxTest REQUIRED)
|
||||
|
||||
add_custom_command(OUTPUT ${RUNNER}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ${RUNNER} ${TESTS}
|
||||
COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS}
|
||||
DEPENDS ${TESTS}
|
||||
COMMENT "Generating test runner ${RUNNER}")
|
||||
|
||||
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
|
||||
add_dependencies(${PROJECT_NAME} generate-test-runner)
|
||||
add_dependencies(xlnt.test generate-test-runner)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ${CMAKE_BINARY_DIR}/bin)
|
||||
|
|
185
third-party/CMakeLists.txt
vendored
185
third-party/CMakeLists.txt
vendored
|
@ -1,136 +1,65 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/common.cmake)
|
||||
project(${LIBRARY_NAME}.third-party VERSION ${LIBRARY_VERSION} LANGUAGES CXX C)
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(xlnt.third-party)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# Includes
|
||||
include_directories(libstudxml
|
||||
utfcpp/source
|
||||
zlib
|
||||
cryptopp
|
||||
${LIBRARY_SOURCE_DIR}/detail)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(CryptoPP REQUIRED)
|
||||
find_package(CxxTest REQUIRED)
|
||||
|
||||
include(ExternalProject)
|
||||
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
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/parser.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/qname.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/serializer.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/value-traits.cxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/content
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/exception
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/forward
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/parser
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/qname
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/serializer
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/value-traits)
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/parser.cxx
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/qname.cxx
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/serializer.cxx
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/value-traits.cxx
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/content
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/exception
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/forward
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/parser
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/qname
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/serializer
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/value-traits)
|
||||
|
||||
set(EXPAT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmlparse.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmlrole.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmltok_impl.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmltok_ns.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmltok.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/ascii.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/asciitab.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/expat_external.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/expat.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/iasciitab.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/internal.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/latin1tab.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/nametab.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/utf8tab.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmlrole.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmltok_impl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/expat/xmltok.h)
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlparse.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_ns.c
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.c
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/ascii.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/asciitab.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/config.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/expat_external.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/expat.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/iasciitab.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/internal.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/latin1tab.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/nametab.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/utf8tab.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_impl.h
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.h)
|
||||
|
||||
set(GENX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/genx/char-props.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/genx/genx.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/xml/details/genx/genx.h)
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/char-props.c
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.c
|
||||
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.h)
|
||||
|
||||
set(ZLIB ${CMAKE_CURRENT_SOURCE_DIR}/zlib/adler32.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/compress.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/crc32.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/deflate.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/infback.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inffast.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inflate.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inftrees.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/trees.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/uncompr.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/zutil.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/crc32.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/deflate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inffast.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inffixed.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inflate.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/inftrees.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/trees.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/zconf.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/zlib.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zlib/zutil.h)
|
||||
|
||||
file(GLOB CRYPTOPP ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/*.cpp)
|
||||
list(REMOVE_ITEM CRYPTOPP
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/simple.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rdrand.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/pch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/cryplib_bds.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/bench1.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/bench2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/validat0.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/validat1.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/validat2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/validat3.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/adhoc.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/datatest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/regtest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/fipsalgt.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/dlltest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/fipstest.cpp)
|
||||
if(MINGW OR WIN32)
|
||||
list(APPEND CRYPTOPP ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/basecode.cpp PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-unused-private-field")
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rw.cpp PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-unused-const-variable")
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/filters.cpp PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-reorder")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(${ZLIB} PROPERTIES COMPILE_FLAGS "-Wno-implicit-function-declaration")
|
||||
else()
|
||||
set_source_files_properties(${ZLIB} PROPERTIES COMPILE_FLAGS "/wd\"4018\"")
|
||||
endif()
|
||||
|
||||
add_library(xlnt.third-party STATIC
|
||||
${LIBSTUDXML}
|
||||
${GENX}
|
||||
${EXPAT}
|
||||
${ZLIB}
|
||||
${CRYPTOPP})
|
||||
target_compile_definitions(xlnt.third-party
|
||||
PRIVATE LIBSTUDXML_STATIC_LIB=1
|
||||
PRIVATE NO_OS_DEPENDENCE=1
|
||||
PRIVATE CRYPTOPP_DISABLE_ASM=1)
|
||||
|
||||
if(NOT STATIC)
|
||||
set_target_properties(xlnt.third-party PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_compile_definitions(xlnt.third-party PRIVATE
|
||||
_CRT_SECURE_NO_WARNINGS=1
|
||||
NOMINMAX)
|
||||
set_target_properties(xlnt.third-party PROPERTIES COMPILE_FLAGS "/MP")
|
||||
endif()
|
||||
|
||||
source_group(libstudxml FILES ${LIBSTUDXML})
|
||||
source_group(libstudxml\\genx FILES ${GENX})
|
||||
source_group(libstudxml\\expat FILES ${EXPAT})
|
||||
source_group(zlib FILES ${ZLIB})
|
||||
add_library(libstudxml STATIC ${LIBSTUDXML} ${EXPAT} ${GENX})
|
||||
target_compile_definitions(libstudxml PRIVATE LIBSTUDXML_STATIC_LIB=1)
|
||||
add_dependencies(libstudxml libstudxml-download)
|
||||
|
|
108
third-party/FindCryptoPP.cmake
vendored
Normal file
108
third-party/FindCryptoPP.cmake
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
# Module for locating the Crypto++ encryption library.
|
||||
#
|
||||
# Customizable variables:
|
||||
# CRYPTOPP_ROOT_DIR
|
||||
# This variable points to the CryptoPP root directory. On Windows the
|
||||
# library location typically will have to be provided explicitly using the
|
||||
# -D command-line option. The directory should include the include/cryptopp,
|
||||
# lib and/or bin sub-directories.
|
||||
#
|
||||
# Read-only variables:
|
||||
# CRYPTOPP_FOUND
|
||||
# Indicates whether the library has been found.
|
||||
#
|
||||
# CRYPTOPP_INCLUDE_DIRS
|
||||
# Points to the CryptoPP include directory.
|
||||
#
|
||||
# CRYPTOPP_LIBRARIES
|
||||
# Points to the CryptoPP libraries that should be passed to
|
||||
# target_link_libararies.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2012 Sergiu Dotenco
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
INCLUDE (FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PATH (CRYPTOPP_ROOT_DIR
|
||||
NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
|
||||
PATHS ENV CRYPTOPPROOT
|
||||
DOC "CryptoPP root directory")
|
||||
|
||||
# Re-use the previous path:
|
||||
FIND_PATH (CRYPTOPP_INCLUDE_DIR
|
||||
NAMES cryptopp/cryptlib.h
|
||||
HINTS ${CRYPTOPP_ROOT_DIR}
|
||||
PATH_SUFFIXES include
|
||||
DOC "CryptoPP include directory")
|
||||
|
||||
FIND_LIBRARY (CRYPTOPP_LIBRARY_DEBUG
|
||||
NAMES cryptlibd cryptoppd
|
||||
HINTS ${CRYPTOPP_ROOT_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
DOC "CryptoPP debug library")
|
||||
|
||||
FIND_LIBRARY (CRYPTOPP_LIBRARY_RELEASE
|
||||
NAMES cryptlib cryptopp
|
||||
HINTS ${CRYPTOPP_ROOT_DIR}
|
||||
PATH_SUFFIXES lib
|
||||
DOC "CryptoPP release library")
|
||||
|
||||
IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
|
||||
SET (CRYPTOPP_LIBRARY
|
||||
optimized ${CRYPTOPP_LIBRARY_RELEASE}
|
||||
debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library")
|
||||
ELSEIF (CRYPTOPP_LIBRARY_RELEASE)
|
||||
SET (CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC
|
||||
"CryptoPP library")
|
||||
ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
|
||||
|
||||
IF (CRYPTOPP_INCLUDE_DIR)
|
||||
SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h)
|
||||
|
||||
IF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
|
||||
FILE (STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX
|
||||
"^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
|
||||
|
||||
STRING (REGEX REPLACE
|
||||
"^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP
|
||||
${_CRYPTOPP_VERSION_TMP})
|
||||
|
||||
STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR
|
||||
${_CRYPTOPP_VERSION_TMP})
|
||||
STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR
|
||||
${_CRYPTOPP_VERSION_TMP})
|
||||
STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
|
||||
${_CRYPTOPP_VERSION_TMP})
|
||||
|
||||
SET (CRYPTOPP_VERSION_COUNT 3)
|
||||
SET (CRYPTOPP_VERSION
|
||||
${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH})
|
||||
ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
|
||||
ENDIF (CRYPTOPP_INCLUDE_DIR)
|
||||
|
||||
SET (CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
|
||||
SET (CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY})
|
||||
|
||||
MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG
|
||||
CRYPTOPP_LIBRARY_RELEASE)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS (CryptoPP REQUIRED_VARS CRYPTOPP_ROOT_DIR
|
||||
CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION)
|
1
third-party/cryptopp
vendored
1
third-party/cryptopp
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit 1a17ade299c3a05e5a63a8cb3f390d21845c21c6
|
1
third-party/cxxtest
vendored
1
third-party/cxxtest
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit 191adddb3876ab389c0c856e1c03874bf70f8ee4
|
1
third-party/libstudxml
vendored
1
third-party/libstudxml
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit 132522ca4c895e9b07d7e323d5529474806e5829
|
1
third-party/utfcpp
vendored
1
third-party/utfcpp
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit a5ad5ec9d936d63e9c010d1054f8b11fed0fabbc
|
1
third-party/zlib
vendored
1
third-party/zlib
vendored
|
@ -1 +0,0 @@
|
|||
Subproject commit 94575859cf7f657f0f31aff4c50761fe3f182699
|
Loading…
Reference in New Issue
Block a user