2018-01-22 22:38:48 +08:00
|
|
|
// Copyright (c) 2014-2018 Thomas Fussell
|
2014-06-06 04:19:31 +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
|
2016-12-04 20:29:10 +08:00
|
|
|
|
2014-06-06 04:19:31 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <xlnt/xlnt_config.hpp>
|
2015-10-21 01:53:47 +08:00
|
|
|
|
2014-06-06 04:19:31 +08:00
|
|
|
namespace xlnt {
|
2015-10-19 03:30:46 +08:00
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
class alignment;
|
|
|
|
class border;
|
2016-11-04 07:26:11 +08:00
|
|
|
class cell;
|
2016-08-16 12:23:49 +08:00
|
|
|
class fill;
|
|
|
|
class font;
|
|
|
|
class number_format;
|
|
|
|
class protection;
|
2016-12-24 23:04:57 +08:00
|
|
|
class style;
|
2016-08-16 12:23:49 +08:00
|
|
|
|
|
|
|
namespace detail {
|
2016-11-20 14:01:32 +08:00
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
struct format_impl;
|
|
|
|
struct stylesheet;
|
2017-03-26 22:30:26 +08:00
|
|
|
class xlsx_producer;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
} // namespace detail
|
2016-05-01 23:08:56 +08:00
|
|
|
|
2015-11-21 09:41:32 +08:00
|
|
|
/// <summary>
|
2016-05-01 04:19:45 +08:00
|
|
|
/// Describes the formatting of a particular cell.
|
2015-11-21 09:41:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
class XLNT_API format
|
2014-06-06 04:19:31 +08:00
|
|
|
{
|
2015-12-25 04:51:11 +08:00
|
|
|
public:
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the alignment of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class alignment alignment() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the alignment of this format to new_alignment. Applied, which defaults
|
|
|
|
/// to true, determines whether the alignment should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format alignment(const xlnt::alignment &new_alignment, bool applied = true);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the alignment of this format should be applied to cells
|
|
|
|
/// using it.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
bool alignment_applied() const;
|
2016-09-10 22:05:06 +08:00
|
|
|
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the border of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class border border() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the border of this format to new_border. Applied, which defaults
|
|
|
|
/// to true, determines whether the border should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format border(const xlnt::border &new_border, bool applied = true);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the border set for this format should be applied to cells using the format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
bool border_applied() const;
|
2016-09-10 22:05:06 +08:00
|
|
|
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the fill of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class fill fill() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the fill of this format to new_fill. Applied, which defaults
|
|
|
|
/// to true, determines whether the border should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format fill(const xlnt::fill &new_fill, bool applied = true);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the fill set for this format should be applied to cells using the format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
bool fill_applied() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the font of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class font font() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the font of this format to new_font. Applied, which defaults
|
|
|
|
/// to true, determines whether the font should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format font(const xlnt::font &new_font, bool applied = true);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the font set for this format should be applied to cells using the format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
bool font_applied() const;
|
|
|
|
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the number format of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class number_format number_format() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the number format of this format to new_number_format. Applied, which defaults
|
|
|
|
/// to true, determines whether the number format should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format number_format(const xlnt::number_format &new_number_format, bool applied = true);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the number_format set for this format should be applied to cells using the format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
bool number_format_applied() const;
|
2016-08-16 12:23:49 +08:00
|
|
|
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the protection of this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
class protection protection() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the protection set for this format should be applied to cells using the format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
bool protection_applied() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the protection of this format to new_protection. Applied, which defaults
|
|
|
|
/// to true, determines whether the protection should be enabled for cells using
|
|
|
|
/// this format.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
format protection(const xlnt::protection &new_protection, bool applied = true);
|
2016-08-16 12:23:49 +08:00
|
|
|
|
2017-02-15 05:02:51 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if the pivot table interface is enabled for this format.
|
2017-02-15 05:02:51 +08:00
|
|
|
/// </summary>
|
2017-02-19 10:33:59 +08:00
|
|
|
bool pivot_button() const;
|
2017-02-15 05:02:51 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// If show is true, a pivot table interface will be displayed for cells using
|
|
|
|
/// this format.
|
2017-02-15 05:02:51 +08:00
|
|
|
/// </summary>
|
2017-02-19 10:33:59 +08:00
|
|
|
void pivot_button(bool show);
|
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if this format should add a single-quote prefix for all text values.
|
2017-02-19 10:33:59 +08:00
|
|
|
/// </summary>
|
|
|
|
bool quote_prefix() const;
|
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// If quote is true, enables a single-quote prefix for all text values in cells
|
|
|
|
/// using this format (e.g. "abc" will appear as "'abc"). The text will also not
|
|
|
|
/// be stored in sharedStrings when this is enabled.
|
2017-02-19 10:33:59 +08:00
|
|
|
/// </summary>
|
|
|
|
void quote_prefix(bool quote);
|
2017-02-15 05:02:51 +08:00
|
|
|
|
2016-11-20 14:01:32 +08:00
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns true if this format has a corresponding style applied.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-12-04 20:29:10 +08:00
|
|
|
bool has_style() const;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Removes the style from this format if it exists.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-11-08 10:11:30 +08:00
|
|
|
void clear_style();
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the style of this format to a style with the given name.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-12-04 20:29:10 +08:00
|
|
|
format style(const std::string &name);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Sets the style of this format to new_style.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-12-24 23:04:57 +08:00
|
|
|
format style(const class style &new_style);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Returns the style of this format. If it has no style, an invalid_parameter
|
|
|
|
/// exception will be thrown.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2017-03-26 22:30:26 +08:00
|
|
|
class style style();
|
|
|
|
|
2017-03-31 11:52:57 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the style of this format. If it has no style, an invalid_parameters
|
|
|
|
/// exception will be thrown.
|
|
|
|
/// </summary>
|
|
|
|
const class style style() const;
|
2016-08-16 12:23:49 +08:00
|
|
|
|
|
|
|
private:
|
2016-12-04 20:29:10 +08:00
|
|
|
friend struct detail::stylesheet;
|
2017-03-31 11:52:57 +08:00
|
|
|
friend class detail::xlsx_producer;
|
2016-11-08 10:11:30 +08:00
|
|
|
friend class cell;
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// Constructs a format from an impl pointer.
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-12-04 20:29:10 +08:00
|
|
|
format(detail::format_impl *d);
|
2016-11-20 14:01:32 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2017-03-31 11:52:57 +08:00
|
|
|
/// The internal implementation of this format
|
2016-11-20 14:01:32 +08:00
|
|
|
/// </summary>
|
2016-12-04 20:29:10 +08:00
|
|
|
detail::format_impl *d_;
|
2014-06-06 04:19:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xlnt
|