| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <App/Range.h> |
| | #include <Base/Reader.h> |
| | #include <Base/Writer.h> |
| |
|
| | #include "PropertyRowHeights.h" |
| | #include "PropertyRowHeightsPy.h" |
| | #include "Utils.h" |
| |
|
| |
|
| | using namespace Spreadsheet; |
| |
|
| | const int PropertyRowHeights::defaultHeight = 30; |
| |
|
| | TYPESYSTEM_SOURCE(Spreadsheet::PropertyRowHeights, App::Property) |
| |
|
| | PropertyRowHeights::PropertyRowHeights() = default; |
| |
|
| | PropertyRowHeights::PropertyRowHeights(const PropertyRowHeights& other) |
| | : Property() |
| | , std::map<int, int>(other) |
| | {} |
| |
|
| | App::Property* PropertyRowHeights::Copy() const |
| | { |
| | PropertyRowHeights* prop = new PropertyRowHeights(*this); |
| |
|
| | return prop; |
| | } |
| |
|
| | void PropertyRowHeights::Paste(const Property& from) |
| | { |
| | setValues(dynamic_cast<const PropertyRowHeights&>(from).getValues()); |
| | } |
| |
|
| | void PropertyRowHeights::setValues(const std::map<int, int>& values) |
| | { |
| | aboutToSetValue(); |
| |
|
| | std::map<int, int>::const_iterator i; |
| |
|
| | |
| | i = begin(); |
| | while (i != end()) { |
| | dirty.insert(i->first); |
| | ++i; |
| | } |
| |
|
| | |
| | clear(); |
| |
|
| | |
| | i = values.begin(); |
| | while (i != values.end()) { |
| | insert(*i); |
| | dirty.insert(i->first); |
| | ++i; |
| | } |
| | hasSetValue(); |
| | } |
| |
|
| | void PropertyRowHeights::Save(Base::Writer& writer) const |
| | { |
| | |
| | writer.Stream() << writer.ind() << "<RowInfo Count=\"" << size() << "\">" << std::endl; |
| | writer.incInd(); |
| |
|
| | std::map<int, int>::const_iterator ri = begin(); |
| | while (ri != end()) { |
| | writer.Stream() << writer.ind() << "<Row name=\"" << rowName(ri->first) << "\" height=\"" |
| | << ri->second << "\" />" << std::endl; |
| | ++ri; |
| | } |
| | writer.decInd(); |
| | writer.Stream() << writer.ind() << "</RowInfo>" << std::endl; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | void PropertyRowHeights::setValue(int row, int height) |
| | { |
| | if (height >= 0) { |
| | aboutToSetValue(); |
| | operator[](row) = height; |
| | dirty.insert(row); |
| | hasSetValue(); |
| | } |
| | } |
| |
|
| | void PropertyRowHeights::Restore(Base::XMLReader& reader) |
| | { |
| | int Cnt; |
| |
|
| | |
| | reader.readElement("RowInfo"); |
| | Cnt = reader.hasAttribute("Count") ? reader.getAttribute<long>("Count") : 0; |
| | for (int i = 0; i < Cnt; i++) { |
| | reader.readElement("Row"); |
| | const char* name = reader.hasAttribute("name") ? reader.getAttribute<const char*>("name") |
| | : nullptr; |
| | const char* height = reader.hasAttribute("height") |
| | ? reader.getAttribute<const char*>("height") |
| | : nullptr; |
| |
|
| | try { |
| | if (name && height) { |
| | int row = App::decodeRow(name); |
| | int rowHeight = atoi(height); |
| |
|
| | setValue(row, rowHeight); |
| | } |
| | } |
| | catch (...) { |
| | |
| | } |
| | } |
| | reader.readEndElement("RowInfo"); |
| | } |
| |
|
| | PyObject* PropertyRowHeights::getPyObject() |
| | { |
| | if (PythonObject.is(Py::_None())) { |
| | |
| | PythonObject = Py::Object(new PropertyRowHeightsPy(this), true); |
| | } |
| | return Py::new_reference_to(PythonObject); |
| | } |
| |
|
| | void PropertyRowHeights::clear() |
| | { |
| | std::map<int, int>::const_iterator i = begin(); |
| |
|
| | while (i != end()) { |
| | dirty.insert(i->first); |
| | ++i; |
| | } |
| | std::map<int, int>::clear(); |
| | } |
| |
|