2015-12-25 06:10:02 +08:00
|
|
|
// Copyright (c) 2014-2016 Thomas Fussell
|
2015-11-21 09:41:32 +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
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#include <xlnt/styles/alignment.hpp>
|
|
|
|
|
|
|
|
namespace xlnt {
|
|
|
|
|
2016-12-30 08:00:27 +08:00
|
|
|
bool alignment::wrap() const
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
|
|
|
return wrap_text_;
|
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
alignment &alignment::wrap(bool wrap_text)
|
2016-03-10 17:12:51 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
wrap_text_ = wrap_text;
|
|
|
|
return *this;
|
2016-03-10 17:12:51 +08:00
|
|
|
}
|
|
|
|
|
2016-12-30 08:00:27 +08:00
|
|
|
bool alignment::shrink() const
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return shrink_to_fit_;
|
2015-11-21 09:41:32 +08:00
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
alignment &alignment::shrink(bool shrink_to_fit)
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
2016-08-16 12:23:49 +08:00
|
|
|
shrink_to_fit_ = shrink_to_fit;
|
2016-12-24 23:04:57 +08:00
|
|
|
return *this;
|
2015-11-21 09:41:32 +08:00
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
optional<horizontal_alignment> alignment::horizontal() const
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
|
|
|
return horizontal_;
|
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
alignment &alignment::horizontal(horizontal_alignment horizontal)
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
|
|
|
horizontal_ = horizontal;
|
2016-12-24 23:04:57 +08:00
|
|
|
return *this;
|
2015-11-21 09:41:32 +08:00
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
optional<vertical_alignment> alignment::vertical() const
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
|
|
|
return vertical_;
|
|
|
|
}
|
|
|
|
|
2016-08-16 12:23:49 +08:00
|
|
|
alignment &alignment::vertical(vertical_alignment vertical)
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
|
|
|
vertical_ = vertical;
|
2016-12-24 23:04:57 +08:00
|
|
|
return *this;
|
2016-08-18 19:34:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
alignment &alignment::indent(int value)
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
indent_ = value;
|
|
|
|
return *this;
|
2016-08-18 19:34:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
optional<int> alignment::indent() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return indent_;
|
2016-08-18 19:34:18 +08:00
|
|
|
}
|
|
|
|
|
2016-10-14 08:11:02 +08:00
|
|
|
alignment &alignment::rotation(int value)
|
2016-08-18 19:34:18 +08:00
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
text_rotation_ = value;
|
|
|
|
return *this;
|
2016-08-18 19:34:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
optional<int> alignment::rotation() const
|
|
|
|
{
|
2016-12-24 23:04:57 +08:00
|
|
|
return text_rotation_;
|
2015-11-21 09:41:32 +08:00
|
|
|
}
|
|
|
|
|
2016-11-01 09:53:22 +08:00
|
|
|
XLNT_API bool operator==(const alignment &left, const alignment &right)
|
2015-11-21 09:41:32 +08:00
|
|
|
{
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.horizontal().is_set() != right.horizontal().is_set())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.horizontal().is_set())
|
|
|
|
{
|
|
|
|
if (left.horizontal().get() != right.horizontal().get())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left.indent().is_set() != right.indent().is_set())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.indent().is_set())
|
|
|
|
{
|
|
|
|
if (left.indent().get() != right.indent().get())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left.rotation().is_set() != right.rotation().is_set())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.rotation().is_set())
|
|
|
|
{
|
|
|
|
if (left.rotation().get() != right.rotation().get())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-12-30 08:00:27 +08:00
|
|
|
if (left.shrink() != right.shrink())
|
2016-11-01 08:48:43 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.vertical().is_set() != right.vertical().is_set())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
if (left.vertical().is_set())
|
|
|
|
{
|
|
|
|
if (left.vertical().get() != right.vertical().get())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-12-30 08:00:27 +08:00
|
|
|
if (left.wrap() != right.wrap())
|
2016-11-01 08:48:43 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-24 23:04:57 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
return true;
|
2015-11-21 09:41:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace xlnt
|