comment.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright (c) 2014-2021 Thomas Fussell
  2. // Copyright (c) 2010-2015 openpyxl
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE
  21. //
  22. // @license: http://www.opensource.org/licenses/mit-license.php
  23. // @author: see AUTHORS file
  24. #include <xlnt/cell/comment.hpp>
  25. namespace xlnt {
  26. comment::comment()
  27. : comment("", "")
  28. {
  29. }
  30. comment::comment(const rich_text &text, const std::string &author)
  31. : text_(text), author_(author)
  32. {
  33. }
  34. comment::comment(const std::string &text, const std::string &author)
  35. : text_(), author_(author)
  36. {
  37. text_.plain_text(text, false);
  38. }
  39. rich_text comment::text() const
  40. {
  41. return text_;
  42. }
  43. std::string comment::plain_text() const
  44. {
  45. return text_.plain_text();
  46. }
  47. std::string comment::author() const
  48. {
  49. return author_;
  50. }
  51. void comment::hide()
  52. {
  53. visible_ = false;
  54. }
  55. void comment::show()
  56. {
  57. visible_ = true;
  58. }
  59. void comment::position(int left, int top)
  60. {
  61. left_ = left;
  62. top_ = top;
  63. }
  64. void comment::size(int width, int height)
  65. {
  66. width_ = width;
  67. height_ = height;
  68. }
  69. bool comment::visible() const
  70. {
  71. return visible_;
  72. }
  73. int comment::left() const
  74. {
  75. return left_;
  76. }
  77. int comment::top() const
  78. {
  79. return top_;
  80. }
  81. int comment::width() const
  82. {
  83. return width_;
  84. }
  85. int comment::height() const
  86. {
  87. return height_;
  88. }
  89. bool comment::operator==(const comment &other) const
  90. {
  91. // not comparing top/left as this is set on a per cell basis
  92. return text_ == other.text_
  93. && author_ == other.author_
  94. && width_ == other.width_
  95. && height_ == other.height_;
  96. }
  97. bool comment::operator!=(const comment &other) const
  98. {
  99. return !(*this == other);
  100. }
  101. } // namespace xlnt