xlnt/include/xlnt/cell/comment.hpp

167 lines
4.5 KiB
C++
Raw Normal View History

// Copyright (c) 2014-2021 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, ARISING 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-07-26 04:39:25 +08:00
#pragma once
#include <string>
2014-07-26 04:39:25 +08:00
#include <xlnt/xlnt_config.hpp>
#include <xlnt/cell/rich_text.hpp>
2014-07-26 04:39:25 +08:00
namespace xlnt {
/// <summary>
2016-10-29 22:23:04 +08:00
/// A comment can be applied to a cell to provide extra information about its contents.
/// </summary>
class XLNT_API comment
2014-07-26 04:39:25 +08:00
{
2016-01-18 14:23:31 +08:00
public:
/// <summary>
2016-10-29 22:23:04 +08:00
/// Constructs a new blank comment.
/// </summary>
comment();
2016-01-18 14:23:31 +08:00
/// <summary>
2016-10-29 22:23:04 +08:00
/// Constructs a new comment with the given text and author.
/// </summary>
comment(const rich_text &text, const std::string &author);
2016-01-18 14:23:31 +08:00
/// <summary>
2016-10-29 22:23:04 +08:00
/// Constructs a new comment with the given unformatted text and author.
/// </summary>
2016-10-29 22:23:04 +08:00
comment(const std::string &text, const std::string &author);
2016-01-18 14:23:31 +08:00
/// <summary>
/// Returns the text that will be displayed for this comment.
/// </summary>
rich_text text() const;
2016-12-04 20:29:10 +08:00
/// <summary>
/// Returns the plain text that will be displayed for this comment without formatting information.
/// </summary>
2016-10-29 22:23:04 +08:00
std::string plain_text() const;
2016-01-18 14:23:31 +08:00
/// <summary>
/// Returns the author of this comment.
/// </summary>
2016-10-29 22:23:04 +08:00
std::string author() const;
2016-01-18 14:23:31 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Makes this comment only visible when the associated cell is hovered.
2016-11-20 14:01:32 +08:00
/// </summary>
void hide();
2016-11-20 14:01:32 +08:00
/// <summary>
/// Makes this comment always visible.
2016-11-20 14:01:32 +08:00
/// </summary>
void show();
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Returns true if this comment is not hidden.
/// </summary>
bool visible() const;
2016-11-20 14:01:32 +08:00
/// <summary>
/// Sets the absolute position of this cell to the given coordinates.
2016-11-20 14:01:32 +08:00
/// </summary>
void position(int left, int top);
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Returns the distance from the left side of the sheet to the left side of the comment.
/// </summary>
int left() const;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Returns the distance from the top of the sheet to the top of the comment.
/// </summary>
int top() const;
2016-11-20 14:01:32 +08:00
/// <summary>
/// Sets the size of the comment.
2016-11-20 14:01:32 +08:00
/// </summary>
void size(int width, int height);
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Returns the width of this comment.
/// </summary>
int width() const;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Returns the height of this comment.
/// </summary>
int height() const;
/// <summary>
/// Return true if this comment is equivalent to other.
/// </summary>
bool operator==(const comment &other) const;
/// <summary>
/// Returns true if this comment is not equivalent to other.
/// </summary>
bool operator!=(const comment &other) const;
2016-10-29 22:23:04 +08:00
private:
2016-11-20 14:01:32 +08:00
/// <summary>
/// The formatted textual content in this cell displayed directly after the author.
/// </summary>
rich_text text_;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// The name of the person that created this comment.
/// </summary>
2016-10-29 22:23:04 +08:00
std::string author_;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// True if this comment is not hidden.
/// </summary>
bool visible_ = false;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// The fill color
/// </summary>
std::string fill_;
2016-11-20 14:01:32 +08:00
/// <summary>
/// Distance from the left side of the sheet.
/// </summary>
int left_ = 0;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Distance from the top of the sheet.
/// </summary>
int top_ = 0;
2016-11-20 14:01:32 +08:00
/// <summary>
/// Width of the comment box.
/// </summary>
2018-07-28 10:04:22 +08:00
int width_ = 200;
2016-12-04 20:29:10 +08:00
2016-11-20 14:01:32 +08:00
/// <summary>
/// Height of the comment box.
/// </summary>
2018-07-28 10:04:22 +08:00
int height_ = 100;
2014-07-26 04:39:25 +08:00
};
} // namespace xlnt