remove unused zip_file function and delete removed source file packaging/document_properties

This commit is contained in:
Thomas Fussell 2016-08-03 07:41:42 -04:00
parent ccc3995709
commit d15ef0f6bf
6 changed files with 22 additions and 167 deletions

View File

@ -1,41 +0,0 @@
// Copyright (c) 2014-2016 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// 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 <string>
#include <xlnt/xlnt_config.hpp>
namespace xlnt {
/// <summary>
/// High-level properties of the OOXML document regarding the app that created it.
/// </summary>
class XLNT_CLASS app_properties
{
public:
};
} // namespace xlnt

View File

@ -1,44 +0,0 @@
// Copyright (c) 2014-2016 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// 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 <string>
#include <xlnt/xlnt_config.hpp>
#include <xlnt/utils/datetime.hpp>
namespace xlnt {
/// <summary>
/// High-level properties of the OOXML document.
/// </summary>
class XLNT_CLASS document_properties
{
public:
document_properties();
};
} // namespace xlnt

View File

@ -3,6 +3,7 @@
#include <detail/constants.hpp>
#include <detail/include_pugixml.hpp>
#include <xlnt/utils/path.hpp>
#include <xlnt/packaging/manifest.hpp>
#include <xlnt/packaging/zip_file.hpp>
#include <xlnt/workbook/const_worksheet_iterator.hpp>
#include <xlnt/workbook/workbook.hpp>
@ -46,17 +47,19 @@ void write_content_types(const xlnt::workbook &target, xlnt::zip_file &archive)
auto types_node = document.append_child("Types");
types_node.append_attribute("xmlns").set_value("http://schemas.openxmlformats.org/package/2006/content-types");
for (const auto &default_type : target.get_manifest().get_default_types())
{
auto default_node = types_node.append_child("Default");
default_node.append_attribute("Extension").set_value("rels");
default_node.append_attribute("ContentType").set_value("application/vnd.openxmlformats-package.relationships+xml");
default_node.append_attribute("Extension").set_value(default_type.second.get_extension().c_str());
default_node.append_attribute("ContentType").set_value(default_type.second.get_content_type().c_str());
}
auto workbook_override_node = types_node.append_child("Override");
workbook_override_node.append_attribute("PartName").set_value("/workbook.xml");
workbook_override_node.append_attribute("ContentType").set_value("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml");
auto sheet_override_node = types_node.append_child("Default");
sheet_override_node.append_attribute("PartName").set_value("/sheet1.xml");
sheet_override_node.append_attribute("ContentType").set_value("application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
for (const auto &override_type : target.get_manifest().get_override_types())
{
auto override_node = types_node.append_child("Override");
override_node.append_attribute("PartName").set_value(override_type.second.get_part().to_string('/').c_str());
override_node.append_attribute("ContentType").set_value(override_type.second.get_content_type().c_str());
}
write_document_to_archive(document, xlnt::constants::part_content_types(), archive);
}

View File

@ -1,35 +0,0 @@
// Copyright (c) 2014-2016 Thomas Fussell
// Copyright (c) 2010-2015 openpyxl
//
// 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
#include <xlnt/packaging/document_properties.hpp>
namespace xlnt {
document_properties::document_properties()
: created(1900, 1, 1),
modified(1900, 1, 1),
excel_base_date(calendar::windows_1900)
{
}
} // namespace xlnt

View File

@ -21,6 +21,7 @@
//
// @license: http://www.opensource.org/licenses/mit-license.php
// @author: see AUTHORS file
#include <algorithm>
#include <cassert>
#include <cstring>
@ -28,38 +29,11 @@
#include <iterator>
#include <miniz.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <detail/include_windows.hpp>
#include <xlnt/packaging/zip_file.hpp>
#include <xlnt/utils/path.hpp>
namespace {
void mkdir_recursive(const xlnt::path &path)
{
if (path.exists()) return;
auto parent = path.parent();
if (!parent.is_root())
{
mkdir_recursive(parent);
}
#ifdef _WIN32
_mkdir(path.to_string().c_str());
#else
mkdir(path.c_str(), 0755);
#endif
}
uint32_t crc32buf(const char *buf, std::size_t len)
{
uint32_t oldcrc32 = 0xFFFFFFFF;

View File

@ -64,6 +64,10 @@ workbook workbook::minimal()
auto impl = new detail::workbook_impl();
workbook wb(impl);
wb.create_sheet();
wb.d_->root_relationships_.push_back(relationship(relationship::type::office_document, "rId1", constants::part_workbook().to_string()));
return wb;
}
@ -72,6 +76,10 @@ workbook workbook::empty_excel()
auto impl = new detail::workbook_impl();
xlnt::workbook wb(impl);
wb.d_->root_relationships_.push_back(relationship(relationship::type::core_properties, "rId1", constants::part_core().to_string()));
wb.d_->root_relationships_.push_back(relationship(relationship::type::extended_properties, "rId2", constants::part_app().to_string()));
wb.d_->root_relationships_.push_back(relationship(relationship::type::office_document, "rId3", constants::part_workbook().to_string()));
wb.set_application("Microsoft Excel");
wb.create_sheet();
wb.add_format(format());
@ -711,16 +719,6 @@ const manifest &workbook::get_manifest() const
const std::vector<relationship> &workbook::get_root_relationships() const
{
if (d_->root_relationships_.empty())
{
d_->root_relationships_.push_back(
relationship(relationship::type::core_properties, "rId1", constants::part_core().to_string()));
d_->root_relationships_.push_back(
relationship(relationship::type::extended_properties, "rId2", constants::part_app().to_string()));
d_->root_relationships_.push_back(
relationship(relationship::type::office_document, "rId3", constants::part_workbook().to_string()));
}
return d_->root_relationships_;
}