2018-01-22 22:38:48 +08:00
|
|
|
// Copyright (c) 2014-2018 Thomas Fussell
|
2015-12-25 04:51:11 +08:00
|
|
|
//
|
|
|
|
// 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
|
2017-04-21 02:03:03 +08:00
|
|
|
|
2014-05-22 05:48:51 +08:00
|
|
|
#include <limits>
|
|
|
|
|
2017-04-21 02:03:03 +08:00
|
|
|
#include <detail/constants.hpp>
|
2016-08-03 12:12:18 +08:00
|
|
|
#include <xlnt/xlnt_config.hpp>
|
2016-11-25 21:13:55 +08:00
|
|
|
#include <xlnt/utils/exceptions.hpp>
|
2014-05-21 22:20:30 +08:00
|
|
|
|
|
|
|
namespace xlnt {
|
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
row_t constants::min_row()
|
2015-11-04 03:53:48 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
row_t constants::max_row()
|
2015-11-04 03:53:48 +08:00
|
|
|
{
|
|
|
|
return std::numeric_limits<row_t>::max();
|
|
|
|
}
|
|
|
|
|
2016-07-23 08:26:02 +08:00
|
|
|
const column_t constants::min_column()
|
2015-11-04 03:53:48 +08:00
|
|
|
{
|
|
|
|
return column_t(1);
|
|
|
|
}
|
|
|
|
|
2016-07-23 08:26:02 +08:00
|
|
|
const column_t constants::max_column()
|
2015-11-04 03:53:48 +08:00
|
|
|
{
|
2016-07-24 09:24:25 +08:00
|
|
|
return column_t(std::numeric_limits<column_t::index_t>::max());
|
2015-11-04 03:53:48 +08:00
|
|
|
}
|
2014-05-21 22:20:30 +08:00
|
|
|
|
|
|
|
// constants
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_properties()
|
|
|
|
{
|
|
|
|
return path("docProps");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_xl()
|
|
|
|
{
|
|
|
|
return path("/xl");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_root_rels()
|
|
|
|
{
|
|
|
|
return path(std::string("_rels"));
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_theme()
|
|
|
|
{
|
|
|
|
return package_xl().append("theme");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_worksheets()
|
|
|
|
{
|
|
|
|
return package_xl().append("worksheets");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::package_drawings()
|
|
|
|
{
|
|
|
|
return package_xl().append("drawings");
|
|
|
|
}
|
|
|
|
|
|
|
|
const path constants::part_content_types()
|
|
|
|
{
|
|
|
|
return path("[Content_Types].xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_root_relationships()
|
|
|
|
{
|
|
|
|
return package_root_rels().append(".rels");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_core()
|
|
|
|
{
|
|
|
|
return package_properties().append("core.xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_app()
|
|
|
|
{
|
|
|
|
return package_properties().append("app.xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_workbook()
|
|
|
|
{
|
|
|
|
return package_xl().append("workbook.xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_styles()
|
|
|
|
{
|
|
|
|
return package_xl().append("styles.xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_theme()
|
|
|
|
{
|
|
|
|
return package_theme().append("theme1.xml");
|
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
2016-12-24 23:04:57 +08:00
|
|
|
const path constants::part_shared_strings()
|
|
|
|
{
|
|
|
|
return package_xl().append("sharedStrings.xml");
|
|
|
|
}
|
2015-11-03 05:45:05 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
const std::unordered_map<std::string, std::string> &constants::namespaces()
|
2015-11-03 05:45:05 +08:00
|
|
|
{
|
2016-11-10 08:52:18 +08:00
|
|
|
static const std::unordered_map<std::string, std::string> *namespaces =
|
2016-12-24 23:04:57 +08:00
|
|
|
new std::unordered_map<std::string, std::string>{
|
|
|
|
{"spreadsheetml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"},
|
|
|
|
{"content-types", "http://schemas.openxmlformats.org/package/2006/content-types"},
|
|
|
|
{"relationships", "http://schemas.openxmlformats.org/package/2006/relationships"},
|
|
|
|
{"drawingml", "http://schemas.openxmlformats.org/drawingml/2006/main"},
|
|
|
|
{"workbook", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"},
|
|
|
|
{"core-properties", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"},
|
|
|
|
{"extended-properties", "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"},
|
2017-01-03 06:42:16 +08:00
|
|
|
{"custom-properties", "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"},
|
2016-12-24 23:04:57 +08:00
|
|
|
|
|
|
|
{"encryption", "http://schemas.microsoft.com/office/2006/encryption"},
|
|
|
|
{"encryption-password", "http://schemas.microsoft.com/office/2006/keyEncryptor/password"},
|
|
|
|
{"encryption-certificate", "http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"},
|
|
|
|
|
2017-01-15 03:09:01 +08:00
|
|
|
{"dc", "http://purl.org/dc/elements/1.1/"},
|
|
|
|
{"dcterms", "http://purl.org/dc/terms/"},
|
2016-12-24 23:04:57 +08:00
|
|
|
{"dcmitype", "http://purl.org/dc/dcmitype/"},
|
|
|
|
{"mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"},
|
|
|
|
{"mx", "http://schemas.microsoft.com/office/mac/excel/2008/main"},
|
|
|
|
{"r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"},
|
|
|
|
{"thm15", "http://schemas.microsoft.com/office/thememl/2012/main"},
|
|
|
|
{"vt", "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"},
|
|
|
|
{"x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"},
|
|
|
|
{"x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"},
|
|
|
|
{"x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"},
|
|
|
|
{"x15ac", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"},
|
2017-05-09 20:46:12 +08:00
|
|
|
{"xml", "http://www.w3.org/XML/1998/namespace"},
|
|
|
|
{"xsi", "http://www.w3.org/2001/XMLSchema-instance"},
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2017-09-13 20:48:22 +08:00
|
|
|
{"loext", "http://schemas.libreoffice.org/"}
|
|
|
|
};
|
2016-07-23 08:26:02 +08:00
|
|
|
|
|
|
|
return *namespaces;
|
2015-11-03 05:45:05 +08:00
|
|
|
}
|
|
|
|
|
2017-01-11 09:25:59 +08:00
|
|
|
const std::string &constants::ns(const std::string &id)
|
2015-11-03 05:45:05 +08:00
|
|
|
{
|
2016-12-02 21:37:50 +08:00
|
|
|
auto match = namespaces().find(id);
|
2016-11-25 21:13:55 +08:00
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
if (match == namespaces().end())
|
2016-11-25 21:13:55 +08:00
|
|
|
{
|
|
|
|
throw xlnt::exception("bad namespace");
|
|
|
|
}
|
|
|
|
|
|
|
|
return match->second;
|
2015-11-03 05:45:05 +08:00
|
|
|
}
|
2017-09-13 20:48:22 +08:00
|
|
|
|
|
|
|
} // namespace xlnt
|