| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef PROPERTYSHEET_H |
| | #define PROPERTYSHEET_H |
| |
|
| | #ifdef _MSC_VER |
| | # ifdef PropertySheet |
| | # undef PropertySheet |
| | # endif |
| | #endif |
| |
|
| | #include <map> |
| |
|
| | #include <App/DocumentObject.h> |
| | #include <App/PropertyLinks.h> |
| |
|
| | #include <Mod/Spreadsheet/SpreadsheetGlobal.h> |
| |
|
| | #include "Cell.h" |
| |
|
| |
|
| | namespace Spreadsheet |
| | { |
| |
|
| | class Sheet; |
| | class PropertySheet; |
| | class SheetObserver; |
| |
|
| | class SpreadsheetExport PropertySheet: public App::PropertyExpressionContainer, |
| | private App::AtomicPropertyChangeInterface<PropertySheet> |
| | { |
| | TYPESYSTEM_HEADER_WITH_OVERRIDE(); |
| |
|
| | public: |
| | explicit PropertySheet(Sheet* _owner = nullptr); |
| |
|
| | ~PropertySheet() override; |
| |
|
| | std::map<App::ObjectIdentifier, const App::Expression*> getExpressions() const override; |
| | void setExpressions(std::map<App::ObjectIdentifier, App::ExpressionPtr>&& exprs) override; |
| | void onRelabeledDocument(const App::Document& doc) override; |
| | void onRenameDynamicProperty(const App::Property& prop, const char* oldName) override; |
| |
|
| | void updateElementReference( |
| | App::DocumentObject* feature, |
| | bool reverse = false, |
| | bool notify = false |
| | ) override; |
| | bool referenceChanged() const override; |
| | bool adjustLink(const std::set<App::DocumentObject*>& inList) override; |
| | Property* CopyOnImportExternal(const std::map<std::string, std::string>& nameMap) const override; |
| | Property* CopyOnLabelChange( |
| | App::DocumentObject* obj, |
| | const std::string& ref, |
| | const char* newLabel |
| | ) const override; |
| | Property* CopyOnLinkReplace( |
| | const App::DocumentObject* parent, |
| | App::DocumentObject* oldObj, |
| | App::DocumentObject* newObj |
| | ) const override; |
| | void breakLink(App::DocumentObject* obj, bool clear) override; |
| |
|
| | void afterRestore() override; |
| | void onContainerRestored() override; |
| |
|
| | Property* Copy() const override; |
| |
|
| | void Paste(const Property& from) override; |
| |
|
| | void Save(Base::Writer& writer) const override; |
| |
|
| | void Restore(Base::XMLReader& reader) override; |
| |
|
| | void getLinksTo( |
| | std::vector<App::ObjectIdentifier>& identifiers, |
| | App::DocumentObject* obj, |
| | const char* subname = nullptr, |
| | bool all = false |
| | ) const override; |
| |
|
| | void copyCells(Base::Writer& writer, const std::vector<App::Range>& ranges) const; |
| |
|
| | void pasteCells(Base::XMLReader& reader, App::Range dstRange); |
| |
|
| | Cell* createCell(App::CellAddress address); |
| |
|
| | void setValue() |
| | {} |
| |
|
| | void setContent(App::CellAddress address, const char* value); |
| |
|
| | void setAlignment(App::CellAddress address, int _alignment); |
| |
|
| | void setStyle(App::CellAddress address, const std::set<std::string>& _style); |
| |
|
| | void setForeground(App::CellAddress address, const Base::Color& color); |
| |
|
| | void setBackground(App::CellAddress address, const Base::Color& color); |
| |
|
| | void setDisplayUnit(App::CellAddress address, const std::string& unit); |
| |
|
| | void setAlias(App::CellAddress address, const std::string& alias); |
| |
|
| | void setComputedUnit(App::CellAddress address, const Base::Unit& unit); |
| |
|
| | void setSpans(App::CellAddress address, int rows, int columns); |
| |
|
| | void clear(App::CellAddress address, bool toClearAlias = true); |
| |
|
| | void clear(); |
| |
|
| | Cell* getValue(App::CellAddress key); |
| |
|
| | const Cell* getValue(App::CellAddress key) const; |
| |
|
| | Cell* getValueFromAlias(const std::string& alias); |
| |
|
| | const Cell* getValueFromAlias(const std::string& alias) const; |
| |
|
| | bool isValidAlias(const std::string& candidate); |
| |
|
| | |
| | bool isValidCellAddressName(const std::string& candidate); |
| |
|
| | std::vector<App::CellAddress> getUsedCells() const; |
| |
|
| | std::tuple<App::CellAddress, App::CellAddress> getUsedRange() const; |
| |
|
| | std::vector<App::CellAddress> getNonEmptyCells() const; |
| |
|
| | std::tuple<App::CellAddress, App::CellAddress> getNonEmptyRange() const; |
| |
|
| | Sheet* sheet() const |
| | { |
| | return owner; |
| | } |
| |
|
| | const std::set<App::CellAddress>& getDirty() |
| | { |
| | return dirty; |
| | } |
| |
|
| | void setDirty(App::CellAddress address); |
| |
|
| | void setDirty(); |
| |
|
| | void clearDirty(App::CellAddress key) |
| | { |
| | dirty.erase(key); |
| | } |
| |
|
| | void clearDirty() |
| | { |
| | dirty.clear(); |
| | purgeTouched(); |
| | } |
| |
|
| | bool isDirty() const |
| | { |
| | return dirty.size() > 0; |
| | } |
| |
|
| | void pasteCells(const std::map<App::CellAddress, std::string>& cells, int rowOffset, int colOffset); |
| |
|
| | void insertRows(int row, int count); |
| |
|
| | std::vector<App::CellAddress> getRows(int row, int count) const; |
| |
|
| | void removeRows(int row, int count); |
| |
|
| | void insertColumns(int col, int count); |
| |
|
| | std::vector<App::CellAddress> getColumns(int column, int count) const; |
| |
|
| | void removeColumns(int col, int count); |
| |
|
| | unsigned int getMemSize() const override; |
| |
|
| | bool mergeCells(App::CellAddress from, App::CellAddress to); |
| |
|
| | void splitCell(App::CellAddress address); |
| |
|
| | void getSpans(App::CellAddress address, int& rows, int& cols) const; |
| |
|
| | bool hasSpan() const; |
| |
|
| | App::CellAddress getAnchor(App::CellAddress address) const; |
| |
|
| | bool isMergedCell(App::CellAddress address) const; |
| |
|
| | bool isHidden(App::CellAddress address) const; |
| |
|
| | const std::set<App::CellAddress>& getDeps(const std::string& name) const; |
| |
|
| | const std::set<std::string>& getDeps(App::CellAddress pos) const; |
| |
|
| | void recomputeDependencies(App::CellAddress key); |
| |
|
| | PyObject* getPyObject() override; |
| | void setPyObject(PyObject*) override; |
| |
|
| | PyObject* getPyValue(PyObject* key); |
| |
|
| | void invalidateDependants(const App::DocumentObject* docObj); |
| |
|
| | void renameObjectIdentifiers(const std::map<App::ObjectIdentifier, App::ObjectIdentifier>& paths); |
| |
|
| | void deletedDocumentObject(const App::DocumentObject* docObj); |
| |
|
| | void documentSet(); |
| |
|
| | App::CellAddress getCellAddress(const char* addr, bool silent = false) const; |
| | App::Range getRange(const char* range, bool silent = false) const; |
| |
|
| | std::string getRow(int offset = 0) const; |
| |
|
| | std::string getColumn(int offset = 0) const; |
| |
|
| | void setPathValue(const App::ObjectIdentifier& path, const boost::any& value) override; |
| | const boost::any getPathValue(const App::ObjectIdentifier& path) const override; |
| |
|
| | unsigned getBindingBorder(App::CellAddress address) const; |
| |
|
| | bool isBindingPath( |
| | const App::ObjectIdentifier& path, |
| | App::CellAddress* from = nullptr, |
| | App::CellAddress* to = nullptr, |
| | bool* href = nullptr |
| | ) const; |
| |
|
| | enum BindingType |
| | { |
| | BindingNone, |
| | BindingNormal, |
| | BindingHiddenRef, |
| | }; |
| | BindingType getBinding( |
| | const App::Range& range, |
| | App::ExpressionPtr* pStart = nullptr, |
| | App::ExpressionPtr* pEnd = nullptr, |
| | App::ObjectIdentifier* pTarget = nullptr |
| | ) const; |
| |
|
| | protected: |
| | void hasSetValue() override; |
| | void hasSetChildValue(App::Property& prop) override; |
| | void onBreakLink(App::DocumentObject* obj) override; |
| | void onAddDep(App::DocumentObject* obj) override; |
| | void onRemoveDep(App::DocumentObject* obj) override; |
| |
|
| | private: |
| | PropertySheet(const PropertySheet& other); |
| | PropertySheet& operator=(const PropertySheet&); |
| |
|
| | |
| |
|
| | friend class AtomicPropertyChange; |
| |
|
| | friend class SheetObserver; |
| |
|
| | friend class Cell; |
| |
|
| | friend class Sheet; |
| |
|
| | Cell* cellAt(App::CellAddress address); |
| |
|
| | Cell* nonNullCellAt(App::CellAddress address); |
| |
|
| | const Cell* cellAt(App::CellAddress address) const; |
| |
|
| | bool colSortFunc(const App::CellAddress& a, const App::CellAddress& b); |
| |
|
| | bool rowSortFunc(const App::CellAddress& a, const App::CellAddress& b); |
| |
|
| | |
| | std::set<App::CellAddress> dirty; |
| |
|
| | |
| | std::map<App::CellAddress, Cell*> data; |
| |
|
| | |
| | std::map<App::CellAddress, App::CellAddress> mergedCells; |
| |
|
| | |
| | Sheet* owner; |
| |
|
| | void clearAlias(App::CellAddress address); |
| |
|
| | void moveAlias(App::CellAddress currPos, App::CellAddress newPos); |
| |
|
| | void moveCell( |
| | App::CellAddress currPos, |
| | App::CellAddress newPos, |
| | std::map<App::ObjectIdentifier, App::ObjectIdentifier>& renames |
| | ); |
| |
|
| | |
| | |
| | |
| |
|
| | void addDependencies(App::CellAddress key); |
| |
|
| | void removeDependencies(App::CellAddress key); |
| |
|
| | void slotChangedObject(const App::DocumentObject& obj, const App::Property& prop); |
| | void recomputeDependants(const App::DocumentObject* obj, const char* propName); |
| |
|
| | |
| | |
| | |
| | std::map<std::string, std::set<App::CellAddress>> propertyNameToCellMap; |
| |
|
| | |
| | std::map<App::CellAddress, std::set<std::string>> cellToPropertyNameMap; |
| |
|
| | |
| | |
| | |
| | std::map<std::string, std::set<App::CellAddress>> documentObjectToCellMap; |
| |
|
| | |
| | std::map<App::CellAddress, std::set<std::string>> cellToDocumentObjectMap; |
| |
|
| | |
| | std::map<App::CellAddress, std::string> aliasProp; |
| |
|
| | |
| | std::map<std::string, App::CellAddress> revAliasProp; |
| |
|
| | |
| | Py::SmartPtr PythonObject; |
| |
|
| | std::map<const App::DocumentObject*, fastsignals::scoped_connection> depConnections; |
| |
|
| | int updateCount = 0; |
| | bool restoring = false; |
| | }; |
| |
|
| | } |
| | #endif |
| |
|