page_setup.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/utils/numeric.hpp>
  25. #include <xlnt/worksheet/page_setup.hpp>
  26. namespace xlnt {
  27. page_setup::page_setup()
  28. : break_(xlnt::page_break::none),
  29. sheet_state_(xlnt::sheet_state::visible),
  30. fit_to_page_(false),
  31. fit_to_height_(false),
  32. fit_to_width_(false)
  33. {
  34. }
  35. page_break page_setup::page_break() const
  36. {
  37. return break_;
  38. }
  39. void page_setup::page_break(xlnt::page_break b)
  40. {
  41. break_ = b;
  42. }
  43. sheet_state page_setup::sheet_state() const
  44. {
  45. return sheet_state_;
  46. }
  47. void page_setup::sheet_state(xlnt::sheet_state sheet_state)
  48. {
  49. sheet_state_ = sheet_state;
  50. }
  51. paper_size page_setup::paper_size() const
  52. {
  53. return paper_size_.get();
  54. }
  55. void page_setup::paper_size(xlnt::paper_size paper_size)
  56. {
  57. paper_size_ = paper_size;
  58. }
  59. bool page_setup::has_paper_size() const
  60. {
  61. return this->paper_size_.is_set();
  62. }
  63. bool page_setup::fit_to_page() const
  64. {
  65. return fit_to_page_;
  66. }
  67. void page_setup::fit_to_page(bool fit_to_page)
  68. {
  69. fit_to_page_ = fit_to_page;
  70. }
  71. bool page_setup::fit_to_height() const
  72. {
  73. return fit_to_height_;
  74. }
  75. void page_setup::fit_to_height(bool fit_to_height)
  76. {
  77. fit_to_height_ = fit_to_height;
  78. }
  79. bool page_setup::fit_to_width() const
  80. {
  81. return fit_to_width_;
  82. }
  83. void page_setup::fit_to_width(bool fit_to_width)
  84. {
  85. fit_to_width_ = fit_to_width;
  86. }
  87. void page_setup::scale(double scale)
  88. {
  89. scale_ = scale;
  90. }
  91. double page_setup::scale() const
  92. {
  93. return scale_.get();
  94. }
  95. bool page_setup::has_scale() const
  96. {
  97. return this->scale_.is_set();
  98. }
  99. const std::string& page_setup::rel_id() const
  100. {
  101. return this->rel_id_;
  102. }
  103. void page_setup::rel_id(const std::string& val)
  104. {
  105. this->rel_id_ = val;
  106. }
  107. bool page_setup::has_rel_id() const
  108. {
  109. return !rel_id_.empty();
  110. }
  111. bool page_setup::operator==(const page_setup &rhs) const
  112. {
  113. return break_ == rhs.break_
  114. && sheet_state_ == rhs.sheet_state_
  115. && paper_size_ == rhs.paper_size_
  116. && fit_to_page_ == rhs.fit_to_page_
  117. && fit_to_height_ == rhs.fit_to_height_
  118. && fit_to_width_ == rhs.fit_to_width_
  119. && scale_ == rhs.scale_
  120. && paper_size_ == rhs.paper_size_
  121. && rel_id_ == rhs.rel_id_;
  122. }
  123. } // namespace xlnt