diff options
author | Jörg Barfurth <jb@openoffice.org> | 2001-02-13 16:21:19 +0000 |
---|---|---|
committer | Jörg Barfurth <jb@openoffice.org> | 2001-02-13 16:21:19 +0000 |
commit | 7b0c17e7e7cb1d5e8f18bc1826eae5f1ff2f78b0 (patch) | |
tree | 48ea80a0da0ed88ba2b20bf686908c9520bb12ad /configmgr | |
parent | 9d5680a0c80c206b19ea4e197c956278f6748b45 (diff) |
Unified change information classes
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/api2/elementimpl.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/treemgr/nodechange.cxx | 43 | ||||
-rw-r--r-- | configmgr/source/treemgr/nodechangeimpl.cxx | 64 | ||||
-rw-r--r-- | configmgr/source/treemgr/nodechangeimpl.hxx | 32 | ||||
-rw-r--r-- | configmgr/source/treemgr/nodechangeinfo.cxx | 150 |
5 files changed, 197 insertions, 98 deletions
diff --git a/configmgr/source/api2/elementimpl.cxx b/configmgr/source/api2/elementimpl.cxx index 50b745ba0b82..55bec8cb3181 100644 --- a/configmgr/source/api2/elementimpl.cxx +++ b/configmgr/source/api2/elementimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: elementimpl.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jb $ $Date: 2000-11-16 18:11:30 $ + * last change: $Author: jb $ $Date: 2001-02-13 17:14:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -568,7 +568,7 @@ uno::Sequence< css::util::ElementChange > implGetPendingChanges( TreeElement& rE it != stop; ++it) { - configuration::ExtendedNodeChangeInfo aInfo; + configuration::NodeChangeInformation aInfo; if (it->getChangeInfo(aInfo)) { ElementChange aChange; diff --git a/configmgr/source/treemgr/nodechange.cxx b/configmgr/source/treemgr/nodechange.cxx index f28dc675ad64..525f3dcb0391 100644 --- a/configmgr/source/treemgr/nodechange.cxx +++ b/configmgr/source/treemgr/nodechange.cxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechange.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jb $ $Date: 2001-02-07 16:26:28 $ + * last change: $Author: jb $ $Date: 2001-02-13 17:17:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -140,18 +140,24 @@ bool NodeChange::isChange() const } //----------------------------------------------------------------------------- -bool NodeChange::getChangeInfo(NodeChangeInfo& rInfo) const +bool NodeChange::getChangeInfo(NodeChangeInformation& rInfo) const { - rInfo.type = NodeChangeInfo::eNoChange; + rInfo.change.type = NodeChangeData::eNoChange; if (m_pImpl) - m_pImpl->fillChange(rInfo); + m_pImpl->fillChangeInfo(rInfo); else - OSL_ASSERT(rInfo.isEmpty()); + OSL_ASSERT(rInfo.isEmptyChange()); - return !rInfo.isEmpty(); + return !rInfo.isEmptyChange(); } //----------------------------------------------------------------------------- +bool NodeChange::getChangeLocation(NodeChangeLocation& rLoc) const +{ + return m_pImpl && m_pImpl->fillChangeLocation(rLoc); +} +//----------------------------------------------------------------------------- +/* bool NodeChange::getChangeInfo(ExtendedNodeChangeInfo& rInfo) const { if (this->getChangeInfo( rInfo.change)) @@ -166,6 +172,7 @@ bool NodeChange::getChangeInfo(ExtendedNodeChangeInfo& rInfo) const return false; } } +*/ //----------------------------------------------------------------------------- Tree NodeChange::getBaseTree() const @@ -334,25 +341,7 @@ void NodeChanges::reset(Node const& aNode) } */ -bool NodeChanges::getChangesInfo(std::vector<NodeChangeInfo>& rInfos) const -{ - if (isEmpty()) return false; - - rInfos.clear(); - rInfos.reserve(getCount()); - - for (Iterator it = begin(); it != end(); ++it) - { - NodeChangeInfo aInfo; - if ( it->getChangeInfo(aInfo) ) - rInfos.push_back(aInfo); - } - - return !rInfos.empty(); -} -//----------------------------------------------------------------------------- - -bool NodeChanges::getChangesInfo(std::vector<ExtendedNodeChangeInfo>& rInfos) const +bool NodeChanges::getChangesInfo(NodeChangesInformation& rInfos) const { if (isEmpty()) return false; @@ -361,7 +350,7 @@ bool NodeChanges::getChangesInfo(std::vector<ExtendedNodeChangeInfo>& rInfos) co for (Iterator it = begin(); it != end(); ++it) { - ExtendedNodeChangeInfo aInfo; + NodeChangeInformation aInfo; if ( it->getChangeInfo(aInfo) ) rInfos.push_back(aInfo); } diff --git a/configmgr/source/treemgr/nodechangeimpl.cxx b/configmgr/source/treemgr/nodechangeimpl.cxx index ac6586250f9f..859c7b7a41f1 100644 --- a/configmgr/source/treemgr/nodechangeimpl.cxx +++ b/configmgr/source/treemgr/nodechangeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeimpl.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jb $ $Date: 2001-02-12 10:33:51 $ + * last change: $Author: jb $ $Date: 2001-02-13 17:17:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -194,10 +194,28 @@ bool NodeChangeImpl::isChange(bool bAllowUntested) const } //----------------------------------------------------------------------------- -bool NodeChangeImpl::fillChange(NodeChangeInfo& rChange) const +bool NodeChangeImpl::fillChangeData(NodeChangeData& rChange) const { OSL_ENSURE(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - fillChange is partially meaningless"); - return doFillChange(rChange) || rChange.isChange(); // force true if the data is signaling change + return doFillChange(rChange) || rChange.isDataChange(); // force true if the data is signaling change +} +//----------------------------------------------------------------------------- + +bool NodeChangeImpl::fillChangeLocation(NodeChangeLocation& rChange) const +{ + if (!m_aTargetTree.isValid()) return false; + + rChange.setBase( NodeID(this->getBaseTree().getBodyPtr(), this->getBaseNode()) ); + rChange.setAccessor(this->getPathToChangingNode()); + rChange.setTarget( NodeID(this->getAffectedTree().getBodyPtr(), this->getAffectedNode()) ); + + return true; +} +//----------------------------------------------------------------------------- + +bool NodeChangeImpl::fillChangeInfo(NodeChangeInformation& rChange) const +{ + return fillChangeLocation(rChange.location) & fillChangeData(rChange.change); } //----------------------------------------------------------------------------- @@ -372,11 +390,11 @@ bool ValueChangeImpl::doIsChange(bool ) const } //----------------------------------------------------------------------------- -bool ValueChangeImpl::doFillChange(NodeChangeInfo& rChange) const +bool ValueChangeImpl::doFillChange(NodeChangeData& rChange) const { - rChange.newValue = getNewValue(); - rChange.oldValue = getOldValue(); - return rChange.isChange(); + rChange.unoData.newValue = getNewValue(); + rChange.unoData.oldValue = getOldValue(); + return rChange.unoData.isDataChange(); } //----------------------------------------------------------------------------- @@ -437,9 +455,9 @@ void ValueReplaceImpl::doApplyChange( ValueNodeImpl& rNode) } //----------------------------------------------------------------------------- -bool ValueReplaceImpl::doFillChange( NodeChangeInfo& rChange) const +bool ValueReplaceImpl::doFillChange( NodeChangeData& rChange) const { - rChange.type = NodeChangeInfo::eSetValue; + rChange.type = NodeChangeData::eSetValue; return ValueChangeImpl::doFillChange(rChange); } @@ -465,11 +483,11 @@ void ValueResetImpl::doApplyChange( ValueNodeImpl& rNode) } //----------------------------------------------------------------------------- -bool ValueResetImpl::doFillChange( NodeChangeInfo& rChange) const +bool ValueResetImpl::doFillChange( NodeChangeData& rChange) const { - rChange.type = NodeChangeInfo::eSetDefault; + rChange.type = NodeChangeData::eSetDefault; ValueChangeImpl::doFillChange(rChange); - return rChange.isChange(); + return !rChange.isEmptyChange(); // do it defensively here - default (= 'new') may be unknown still } //----------------------------------------------------------------------------- @@ -606,11 +624,11 @@ bool SetInsertTreeImpl::doIsChange(bool ) const } //----------------------------------------------------------------------------- -bool SetInsertTreeImpl::doFillChange(NodeChangeInfo& rChange) const +bool SetInsertTreeImpl::doFillChange(NodeChangeData& rChange) const { - rChange.type = NodeChangeInfo::eInsertElement; + rChange.type = NodeChangeData::eInsertElement; if (m_aNewTree.isValid()) - rChange.newElement = m_aNewTree; + rChange.element.newValue = m_aNewTree; return isChange(true); } @@ -660,14 +678,14 @@ bool SetReplaceTreeImpl::doIsChange(bool) const //----------------------------------------------------------------------------- /// fills in pre- and post-change values, returns wether they differ -bool SetReplaceTreeImpl::doFillChange(NodeChangeInfo& rChange) const +bool SetReplaceTreeImpl::doFillChange(NodeChangeData& rChange) const { - rChange.type = NodeChangeInfo::eReplaceElement; + rChange.type = NodeChangeData::eReplaceElement; if (m_aNewTree.isValid()) - rChange.newElement = m_aNewTree; + rChange.element.newValue = m_aNewTree; if (m_aOldTree.isValid()) - rChange.oldElement = m_aOldTree; + rChange.element.oldValue = m_aOldTree; return isChange(true); } @@ -728,11 +746,11 @@ bool SetRemoveTreeImpl::doIsChange(bool) const //----------------------------------------------------------------------------- /// fills in pre- and post-change values, returns wether they differ -bool SetRemoveTreeImpl::doFillChange(NodeChangeInfo& rChange) const +bool SetRemoveTreeImpl::doFillChange(NodeChangeData& rChange) const { - rChange.type = NodeChangeInfo::eRemoveElement; + rChange.type = NodeChangeData::eRemoveElement; if (m_aOldTree.isValid()) - rChange.oldElement = m_aOldTree; + rChange.element.oldValue = m_aOldTree; return isChange(true); } diff --git a/configmgr/source/treemgr/nodechangeimpl.hxx b/configmgr/source/treemgr/nodechangeimpl.hxx index 5518b7d8b508..f21e23fd9ef6 100644 --- a/configmgr/source/treemgr/nodechangeimpl.hxx +++ b/configmgr/source/treemgr/nodechangeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeimpl.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2001-02-07 16:26:28 $ + * last change: $Author: jb $ $Date: 2001-02-13 17:17:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,7 +87,9 @@ namespace configmgr class ValueNodeImpl; class SetNodeImpl; //----------------------------------------------------------------------------- - struct NodeChangeInfo; + class NodeChangeData; + class NodeChangeLocation; + class NodeChangeInformation; /// represents a node position in some tree @@ -131,8 +133,14 @@ namespace configmgr /// checks, if this represents an actual change - with or without requiring a preceding test bool isChange(bool bAllowUntested) const; - /// fills in pre- and post-change values, returns wether they differ - bool fillChange(NodeChangeInfo& rChange) const; + /// fills in pre- and post-change values, returns whether they may differ + bool fillChangeData(NodeChangeData& rChange) const; + + /// fills in change location, returns whether it is set + bool fillChangeLocation(NodeChangeLocation& rChange) const; + + /// fills in change location and values, returns whether data may be changed + bool fillChangeInfo(NodeChangeInformation& rChange) const; /// test whether this really is a change to the stored 'changing' node void test(); @@ -174,7 +182,7 @@ namespace configmgr virtual bool doIsChange(bool bBefore) const = 0; /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const = 0; + virtual bool doFillChange(NodeChangeData& rChange) const = 0; /// dry-check whether this is a change virtual void doTest( Node& rTarget) = 0; @@ -226,7 +234,7 @@ namespace configmgr virtual bool doIsChange(bool bBefore) const; /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const = 0; + virtual bool doFillChange(NodeChangeData& rChange) const = 0; protected: // override apply functionality @@ -259,7 +267,7 @@ namespace configmgr virtual void doApplyChange( ValueNodeImpl& rNode); /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const; + virtual bool doFillChange(NodeChangeData& rChange) const; // friend class SetReplaceValueImpl; }; @@ -281,7 +289,7 @@ namespace configmgr virtual void doApplyChange( ValueNodeImpl& rNode); /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const; + virtual bool doFillChange(NodeChangeData& rChange) const; }; //----------------------------------------------------------------------------- @@ -362,7 +370,7 @@ namespace configmgr /// checks, if this represents an actual change (given whether the change has been applied or not) virtual bool doIsChange(bool bBefore) const; /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const; + virtual bool doFillChange(NodeChangeData& rChange) const; /// new overridable: retrieve the old value from a properly typed node virtual void doTestElement(SetNodeImpl& rNode, Name const& aName); @@ -385,7 +393,7 @@ namespace configmgr /// checks, if this represents an actual change (given whether the change has been applied or not) virtual bool doIsChange(bool bBefore) const; /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const; + virtual bool doFillChange(NodeChangeData& rChange) const; /// new overridable: retrieve the old value from a properly typed node virtual void doTestElement(SetNodeImpl& rNode, Name const& aName); @@ -407,7 +415,7 @@ namespace configmgr /// checks, if this represents an actual change (given whether the change has been applied or not) virtual bool doIsChange(bool bBefore) const; /// fills in pre- and post-change values, returns wether they differ - virtual bool doFillChange(NodeChangeInfo& rChange) const; + virtual bool doFillChange(NodeChangeData& rChange) const; /// new overridable: retrieve the old value from a properly typed node virtual void doTestElement(SetNodeImpl& rNode, Name const& aName); diff --git a/configmgr/source/treemgr/nodechangeinfo.cxx b/configmgr/source/treemgr/nodechangeinfo.cxx index 01924d8b0fee..62f82ac8cfa1 100644 --- a/configmgr/source/treemgr/nodechangeinfo.cxx +++ b/configmgr/source/treemgr/nodechangeinfo.cxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeinfo.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jb $ $Date: 2000-11-14 10:53:36 $ + * last change: $Author: jb $ $Date: 2001-02-13 17:21:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,62 +70,60 @@ namespace configmgr { //----------------------------------------------------------------------------- -NodeChangeInfo::NodeChangeInfo() +NodeChangeData::NodeChangeData() : type(eNoChange) -, oldValue() -, newValue() -, oldElement() -, newElement() +, unoData() +, element() { } //----------------------------------------------------------------------------- -NodeChangeInfo::NodeChangeInfo(NodeChangeInfo const& aOther) +NodeChangeData::NodeChangeData(NodeChangeData const& aOther) : type(aOther.type) -, oldValue(aOther.oldValue) -, newValue(aOther.newValue) -, oldElement(aOther.oldElement) -, newElement(aOther.newElement) +, unoData(aOther.unoData) +, element(aOther.element) { } //----------------------------------------------------------------------------- -NodeChangeInfo& NodeChangeInfo::operator=(NodeChangeInfo const& aOther) +NodeChangeData& NodeChangeData::operator=(NodeChangeData const& aOther) { type = aOther.type; - oldValue = aOther.oldValue; - newValue = aOther.newValue; - oldElement = aOther.oldElement; - newElement = aOther.newElement; + unoData = aOther.unoData; + element = aOther.element; return *this; } //----------------------------------------------------------------------------- -NodeChangeInfo::~NodeChangeInfo() +NodeChangeData::~NodeChangeData() { } //----------------------------------------------------------------------------- -bool NodeChangeInfo::isChange() const +bool NodeChangeData::isDataChange() const { - return !isEmpty() && (isSetChange() ? oldElement != newElement : oldValue != newValue); + if (isSetChange() && element.isDataChange()) + return true; + + return unoData.isDataChange(); } //----------------------------------------------------------------------------- -Tree NodeChangeInfo::getNewElementTree() const +Tree NodeChangeData::getNewElementTree() const { - return Tree( newElement.getBodyPtr() ); + return Tree( element.newValue.getBodyPtr() ); } //----------------------------------------------------------------------------- -Tree NodeChangeInfo::getOldElementTree() const +Tree NodeChangeData::getOldElementTree() const { - return Tree( oldElement.getBodyPtr() ); + return Tree( element.oldValue.getBodyPtr() ); } //----------------------------------------------------------------------------- -NodeRef NodeChangeInfo::getNewElementNodeRef() const +NodeRef NodeChangeData::getNewElementNodeRef() const { + ElementTreeHolder newElement = this->element.newValue; if ( newElement.isValid() && newElement->nodeCount() > 0) { NodeOffset n = newElement->root(); @@ -136,8 +134,9 @@ NodeRef NodeChangeInfo::getNewElementNodeRef() const } //----------------------------------------------------------------------------- -NodeRef NodeChangeInfo::getOldElementNodeRef() const +NodeRef NodeChangeData::getOldElementNodeRef() const { + ElementTreeHolder oldElement = this->element.oldValue; if ( oldElement.isValid() && oldElement->nodeCount() > 0) { NodeOffset n = oldElement->root(); @@ -148,8 +147,9 @@ NodeRef NodeChangeInfo::getOldElementNodeRef() const } //----------------------------------------------------------------------------- -NodeID NodeChangeInfo::getNewElementNodeID() const +NodeID NodeChangeData::getNewElementNodeID() const { + ElementTreeHolder newElement = this->element.newValue; if ( newElement.isValid() && newElement->nodeCount() > 0) { return NodeID( newElement.getBodyPtr(), newElement->root() ); @@ -159,8 +159,9 @@ NodeID NodeChangeInfo::getNewElementNodeID() const } //----------------------------------------------------------------------------- -NodeID NodeChangeInfo::getOldElementNodeID() const +NodeID NodeChangeData::getOldElementNodeID() const { + ElementTreeHolder oldElement = this->element.oldValue; if ( oldElement.isValid() && oldElement->nodeCount() > 0) { return NodeID( oldElement.getBodyPtr(), oldElement->root() ); @@ -170,14 +171,97 @@ NodeID NodeChangeInfo::getOldElementNodeID() const } //----------------------------------------------------------------------------- -ExtendedNodeChangeInfo::ExtendedNodeChangeInfo() -: change() -, baseTree(0) -, baseNode() -, accessor() +NodeChangeLocation::NodeChangeLocation() +: m_path() +, m_base(0,0) +, m_target(0,0) +, m_changed(0,0) +{ +} +//----------------------------------------------------------------------------- + +bool NodeChangeLocation::isValidLocation() const +{ + // TODO: Validate that base,target and accessor relate correctly (?) + return m_base.isValidNode() && + (m_target.isEmpty() + ? m_changed.isEmpty() + : ( m_target.isValidNode() && + (m_changed.isEmpty() || m_changed.isValidNode()) ) ); +} +//----------------------------------------------------------------------------- + +void NodeChangeLocation::setAccessor(RelativePath const& aAccessor) +{ + m_path = aAccessor; +} +//----------------------------------------------------------------------------- + +void NodeChangeLocation::setBase(NodeID const& aBaseNode) +{ + m_base = aBaseNode; +} +//----------------------------------------------------------------------------- + +void NodeChangeLocation::setTarget(NodeID const& aTargetNode) +{ + m_target = aTargetNode; + + if (m_base.isEmpty()) + setBase(aTargetNode); +} +//----------------------------------------------------------------------------- + +void NodeChangeLocation::setChanging(NodeID const& aChangedNode) +{ + m_changed = aChangedNode; + + if (m_target.isEmpty()) + setTarget(aChangedNode); +} +//----------------------------------------------------------------------------- + +Tree NodeChangeLocation::getBaseTree() const +{ + OSL_ENSURE(m_base.isValidNode(), "Invalid base location set in NodeChangeLocation"); + return Tree( TreeImplHelper::tree(m_base) ); +} +//----------------------------------------------------------------------------- + +NodeRef NodeChangeLocation::getBaseNode() const { + OSL_ENSURE(m_base.isValidNode(), "Invalid base location set in NodeChangeLocation"); + return TreeImplHelper::makeNode(m_base); + return TreeImplHelper::makeNode(m_base); } +//----------------------------------------------------------------------------- +Tree NodeChangeLocation::getAffectedTree() const +{ + NodeID aAffected = this->getAffectedNodeID(); + return Tree( TreeImplHelper::tree(aAffected) ); +} +//----------------------------------------------------------------------------- + +NodeRef NodeChangeLocation::getAffectedNode() const +{ + NodeID aAffected = this->getAffectedNodeID(); + return TreeImplHelper::makeNode(aAffected); +} +//----------------------------------------------------------------------------- + +NodeID NodeChangeLocation::getAffectedNodeID() const +{ + OSL_ENSURE(m_target.isEmpty() || m_target.isValidNode(), "Invalid target location set in NodeChangeLocation"); + return m_target; +} +//----------------------------------------------------------------------------- + +NodeID NodeChangeLocation::getChangedNodeID() const +{ + OSL_ENSURE(m_changed.isEmpty() || m_changed.isValidNode(), "Invalid change location set in NodeChangeLocation"); + return m_changed; +} //----------------------------------------------------------------------------- } } |