2021-08-22 20:23:18 +08:00
|
|
|
// Copyright (c) 2014-2021 Thomas Fussell
|
2015-11-20 11:54:54 +08:00
|
|
|
// Copyright (c) 2010-2015 openpyxl
|
|
|
|
//
|
|
|
|
// 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
|
2021-08-22 20:23:18 +08:00
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
2015-11-20 11:54:54 +08:00
|
|
|
// 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
|
2019-11-18 14:23:33 +08:00
|
|
|
#include <xlnt/utils/numeric.hpp>
|
2019-12-27 01:03:12 +08:00
|
|
|
#include <xlnt/worksheet/page_setup.hpp>
|
2015-11-20 11:54:54 +08:00
|
|
|
|
|
|
|
namespace xlnt {
|
|
|
|
|
|
|
|
page_setup::page_setup()
|
2016-12-04 04:35:09 +08:00
|
|
|
: break_(xlnt::page_break::none),
|
|
|
|
sheet_state_(xlnt::sheet_state::visible),
|
2015-11-20 11:54:54 +08:00
|
|
|
fit_to_page_(false),
|
|
|
|
fit_to_height_(false),
|
2021-09-04 02:15:19 +08:00
|
|
|
fit_to_width_(false)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
page_break page_setup::page_break() const
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
return break_;
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:46:11 +08:00
|
|
|
void page_setup::page_break(xlnt::page_break b)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
break_ = b;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
sheet_state page_setup::sheet_state() const
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
return sheet_state_;
|
|
|
|
}
|
|
|
|
|
2016-12-03 17:46:11 +08:00
|
|
|
void page_setup::sheet_state(xlnt::sheet_state sheet_state)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
sheet_state_ = sheet_state;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
paper_size page_setup::paper_size() const
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
2021-08-29 02:56:57 +08:00
|
|
|
return paper_size_.get();
|
2015-11-20 11:54:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-03 17:46:11 +08:00
|
|
|
void page_setup::paper_size(xlnt::paper_size paper_size)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
paper_size_ = paper_size;
|
|
|
|
}
|
|
|
|
|
2021-08-29 02:56:57 +08:00
|
|
|
bool page_setup::has_paper_size() const
|
|
|
|
{
|
|
|
|
return this->paper_size_.is_set();
|
|
|
|
}
|
|
|
|
|
2015-11-20 11:54:54 +08:00
|
|
|
bool page_setup::fit_to_page() const
|
|
|
|
{
|
|
|
|
return fit_to_page_;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void page_setup::fit_to_page(bool fit_to_page)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
fit_to_page_ = fit_to_page;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool page_setup::fit_to_height() const
|
|
|
|
{
|
|
|
|
return fit_to_height_;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void page_setup::fit_to_height(bool fit_to_height)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
fit_to_height_ = fit_to_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool page_setup::fit_to_width() const
|
|
|
|
{
|
|
|
|
return fit_to_width_;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void page_setup::fit_to_width(bool fit_to_width)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
fit_to_width_ = fit_to_width;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
void page_setup::scale(double scale)
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
|
|
|
scale_ = scale;
|
|
|
|
}
|
|
|
|
|
2016-12-02 21:37:50 +08:00
|
|
|
double page_setup::scale() const
|
2015-11-20 11:54:54 +08:00
|
|
|
{
|
2021-08-29 02:56:57 +08:00
|
|
|
return scale_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool page_setup::has_scale() const
|
|
|
|
{
|
|
|
|
return this->scale_.is_set();
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& page_setup::rel_id() const
|
|
|
|
{
|
|
|
|
return this->rel_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void page_setup::rel_id(const std::string& val)
|
|
|
|
{
|
|
|
|
this->rel_id_ = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool page_setup::has_rel_id() const
|
|
|
|
{
|
|
|
|
return !rel_id_.empty();
|
2015-11-20 11:54:54 +08:00
|
|
|
}
|
|
|
|
|
2018-07-03 10:05:07 +08:00
|
|
|
bool page_setup::operator==(const page_setup &rhs) const
|
|
|
|
{
|
|
|
|
return break_ == rhs.break_
|
|
|
|
&& sheet_state_ == rhs.sheet_state_
|
|
|
|
&& paper_size_ == rhs.paper_size_
|
|
|
|
&& fit_to_page_ == rhs.fit_to_page_
|
|
|
|
&& fit_to_height_ == rhs.fit_to_height_
|
|
|
|
&& fit_to_width_ == rhs.fit_to_width_
|
2021-08-29 02:56:57 +08:00
|
|
|
&& scale_ == rhs.scale_
|
|
|
|
&& paper_size_ == rhs.paper_size_
|
|
|
|
&& rel_id_ == rhs.rel_id_;
|
2018-07-03 10:05:07 +08:00
|
|
|
}
|
|
|
|
|
2015-11-20 11:54:54 +08:00
|
|
|
} // namespace xlnt
|