summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-02-23 09:50:59 +0000
committerJörg Barfurth <jb@openoffice.org>2001-02-23 09:50:59 +0000
commit390b279f4aa31984cafd10ecd6fe67695a437ffe (patch)
treec0ad0791630a40fa0a70719e20c6d61cdf1e2395 /configmgr
parentdb7910d524c14ffa8e03cdded71225993b4861d4 (diff)
Optimization: Node caches the name. Related change: ElementTreeImpl now handles renaming - no renaming of non-root nodes
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/treemgr/nodeimpl.cxx57
-rw-r--r--configmgr/source/treemgr/nodeimpl.hxx33
-rw-r--r--configmgr/source/treemgr/nodeimplobj.cxx235
-rw-r--r--configmgr/source/treemgr/nodeimplobj.hxx40
-rw-r--r--configmgr/source/treemgr/treeimpl.cxx61
-rw-r--r--configmgr/source/treemgr/treeimpl.hxx20
6 files changed, 121 insertions, 325 deletions
diff --git a/configmgr/source/treemgr/nodeimpl.cxx b/configmgr/source/treemgr/nodeimpl.cxx
index 51d80c02a20d..b4e0f929f4e1 100644
--- a/configmgr/source/treemgr/nodeimpl.cxx
+++ b/configmgr/source/treemgr/nodeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimpl.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:20:54 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,14 +82,14 @@ namespace configmgr
namespace
{
- inline void fillInfo(NodeInfo& rInfo,OUString const& sName, Attributes const& aAttributes)
+/* inline void fillInfo(NodeInfo& rInfo,OUString const& sName, Attributes const& aAttributes)
{
rInfo.aName = Name(sName,Name::NoValidate());
rInfo.aAttributes = aAttributes;
}
- inline void fetchInfo(NodeInfo& rInfo,INode const& rNode)
+*/ inline Attributes fetchAttributes(INode const& rNode)
{
- fillInfo(rInfo,rNode.getName(),rNode.getAttributes());
+ return rNode.getAttributes();
}
}
@@ -139,21 +139,21 @@ GroupNodeImpl::GroupNodeImpl(GroupNodeImpl& rOriginal)
}
//-----------------------------------------------------------------------------
-NodeType::Enum GroupNodeImpl::doGetType() const
+OUString GroupNodeImpl::getOriginalNodeName() const
{
- return NodeType::eGROUP;
+ return m_rOriginal.getName();
}
//-----------------------------------------------------------------------------
-void GroupNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
+NodeType::Enum GroupNodeImpl::doGetType() const
{
- fetchInfo(rInfo,m_rOriginal);
+ return NodeType::eGROUP;
}
//-----------------------------------------------------------------------------
-void GroupNodeImpl::doSetNodeName(Name const& aName)
+Attributes GroupNodeImpl::doGetAttributes() const
{
- m_rOriginal.setName(aName.toString());
+ return fetchAttributes(m_rOriginal);
}
//-----------------------------------------------------------------------------
@@ -230,6 +230,12 @@ SetNodeImpl::~SetNodeImpl()
}
//-----------------------------------------------------------------------------
+OUString SetNodeImpl::getOriginalNodeName() const
+{
+ return m_rOriginal.getName();
+}
+//-----------------------------------------------------------------------------
+
TreeImpl* SetNodeImpl::getParentTree() const
{
OSL_ENSURE(m_pParentTree,"Set Node: Parent tree not set !");
@@ -292,18 +298,12 @@ SetNodeVisitor::Result SetNodeImpl::dispatchToElements(SetNodeVisitor& aVisitor)
}
//-----------------------------------------------------------------------------
-void SetNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
+Attributes SetNodeImpl::doGetAttributes() const
{
- fetchInfo(rInfo,m_rOriginal);
+ return fetchAttributes(m_rOriginal);
}
//-----------------------------------------------------------------------------
-void SetNodeImpl::doSetNodeName(Name const& aName)
-{
- m_rOriginal.setName(aName.toString());
-}
-
-//-----------------------------------------------------------------------------
NodeType::Enum SetNodeImpl::doGetType() const
{
return NodeType::eSET;
@@ -389,6 +389,12 @@ ValueNodeImpl::ValueNodeImpl(ValueNodeImpl& rOriginal)
}
//-----------------------------------------------------------------------------
+OUString ValueNodeImpl::getOriginalNodeName() const
+{
+ return m_rOriginal.getName();
+}
+//-----------------------------------------------------------------------------
+
bool ValueNodeImpl::isDefault() const
{
return m_rOriginal.isDefault();
@@ -431,16 +437,11 @@ void ValueNodeImpl::setDefault()
}
//-----------------------------------------------------------------------------
-void ValueNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- fetchInfo(rInfo,m_rOriginal);
- rInfo.aAttributes.bDefaultable = m_rOriginal.hasDefault();
-}
-//-----------------------------------------------------------------------------
-
-void ValueNodeImpl::doSetNodeName(Name const& aName)
+Attributes ValueNodeImpl::doGetAttributes() const
{
- m_rOriginal.setName(aName.toString());
+ Attributes aResult = fetchAttributes(m_rOriginal);
+ aResult.bDefaultable = m_rOriginal.hasDefault();
+ return aResult;
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/nodeimpl.hxx b/configmgr/source/treemgr/nodeimpl.hxx
index 2ac6c81c0751..4f056aef354a 100644
--- a/configmgr/source/treemgr/nodeimpl.hxx
+++ b/configmgr/source/treemgr/nodeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimpl.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:20:54 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -96,6 +96,7 @@ namespace configmgr
class TreeImpl;
class ElementTreeImpl;
+ struct Attributes;
struct NodeInfo;
class NodeChangeImpl;
class NodeChange;
@@ -137,15 +138,13 @@ namespace configmgr
static void makeIndirect(NodeImplHolder& aThis, bool bIndirect);
- NodeType::Enum getType() const { return doGetType(); }
- void getNodeInfo(NodeInfo& rInfo) const { doGetNodeInfo(rInfo); }
- void setNodeName(Name const& rName_) { doSetNodeName(rName_); }
+ NodeType::Enum getType() const { return doGetType(); }
+ Attributes getAttributes() const { return doGetAttributes(); };
void dispatch(INodeHandler& rHandler_) { doDispatch(rHandler_); }
private:
- virtual NodeType::Enum doGetType() const = 0;
- virtual void doGetNodeInfo(NodeInfo& rInfo_) const = 0;
- virtual void doSetNodeName(Name const& rName_) = 0;
+ virtual NodeType::Enum doGetType() const = 0;
+ virtual Attributes doGetAttributes() const = 0;
virtual void doDispatch(INodeHandler& rHandler_) = 0;
virtual bool doHasChanges() const = 0;
@@ -173,6 +172,9 @@ namespace configmgr
explicit GroupNodeImpl(ISubtree& rOriginal);
explicit GroupNodeImpl(GroupNodeImpl& rOriginal); // only for makeIndirect
+ /// retrieve the name of the underlying node
+ OUString getOriginalNodeName() const;
+
std::auto_ptr<SubtreeChange> preCommitChanges();
void finishCommit(SubtreeChange& rChanges) { doFinishCommit(rChanges); }
void revertCommit(SubtreeChange& rChanges) { doRevertCommit(rChanges); }
@@ -189,8 +191,7 @@ namespace configmgr
virtual void doCollectChangesWithTarget(NodeChanges& rChanges, TreeImpl* pParent, NodeOffset nNode) const;
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName) = 0;
+ virtual Attributes doGetAttributes() const;
private:
virtual NodeType::Enum doGetType() const;
@@ -234,6 +235,9 @@ namespace configmgr
/// 'Moving constructor': Constructs a set that takes the data from rOriginal, leaves rOriginal empty
explicit SetNodeImpl(SetNodeImpl& rOriginal); // only for makeIndirect
+ /// retrieve the name of the underlying node
+ OUString getOriginalNodeName() const;
+
// the following willmostly be implemented by derived classes (using the virtual equivalents)
/// does this set contain any elements (loads elements if needed)
bool isEmpty();
@@ -300,8 +304,7 @@ namespace configmgr
// NodeImpl implementation - direct clients don't need it
protected:
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName) = 0;
+ virtual Attributes doGetAttributes() const;
virtual NodeType::Enum doGetType() const;
private:
@@ -325,6 +328,9 @@ namespace configmgr
explicit ValueNodeImpl(ValueNode& rOriginal) ;
explicit ValueNodeImpl(ValueNodeImpl& rOriginal) ; // only for makeIndirect
+ /// retrieve the name of the underlying node
+ OUString getOriginalNodeName() const;
+
// the following are implemented, though pure
// they delegate directly to m_rOriginal
@@ -358,8 +364,7 @@ namespace configmgr
protected:
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName) = 0;
+ virtual Attributes doGetAttributes() const;
// NodeImpl implementation - direct clients don't need it
virtual NodeChangeImpl* doAdjustToChange(ValueChange const& rExternalChange);
diff --git a/configmgr/source/treemgr/nodeimplobj.cxx b/configmgr/source/treemgr/nodeimplobj.cxx
index 4d3aa130fd9c..11c4f04d8f9f 100644
--- a/configmgr/source/treemgr/nodeimplobj.cxx
+++ b/configmgr/source/treemgr/nodeimplobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimplobj.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:20:54 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,13 @@ static void failReadOnly()
throw ConstraintViolation("INTERNAL ERROR: Trying to update a read-only node");
}
+static
+inline
+Attributes forceReadOnly(Attributes aAttributes)
+{
+ aAttributes.bWritable = false;
+ return aAttributes;
+}
// Specific types of nodes for direct or read only access
//-----------------------------------------------------------------------------
@@ -133,16 +140,9 @@ void ReadOnlyValueNodeImpl::setDefault()
}
//-----------------------------------------------------------------------------
-void ReadOnlyValueNodeImpl::doSetNodeName(Name const& )
-{
- failReadOnly();
-}
-//-----------------------------------------------------------------------------
-
-void ReadOnlyValueNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
+Attributes ReadOnlyValueNodeImpl::doGetAttributes() const
{
- ValueNodeImpl::doGetNodeInfo(rInfo);
- rInfo.aAttributes.bWritable = false;
+ return forceReadOnly( ValueNodeImpl::doGetAttributes() );
}
//-----------------------------------------------------------------------------
@@ -228,12 +228,6 @@ void DirectValueNodeImpl::setDefault()
}
//-----------------------------------------------------------------------------
-void DirectValueNodeImpl::doSetNodeName(Name const& aName)
-{
- ValueNodeImpl::doSetNodeName(aName);
-}
-//-----------------------------------------------------------------------------
-
bool DirectValueNodeImpl::doHasChanges() const
{
return false;
@@ -268,7 +262,6 @@ NodeImplHolder DirectValueNodeImpl::doCloneIndirect(bool bIndirect)
DeferredValueNodeImpl::DeferredValueNodeImpl(ValueNode& rOriginal)
: ValueNodeImpl(rOriginal)
-, m_pNewName(0)
, m_pNewValue(0)
, m_bDefault(false)
{
@@ -277,7 +270,6 @@ DeferredValueNodeImpl::DeferredValueNodeImpl(ValueNode& rOriginal)
DeferredValueNodeImpl::DeferredValueNodeImpl(DirectValueNodeImpl& rOriginal)
: ValueNodeImpl(rOriginal)
-, m_pNewName(0)
, m_pNewValue(0)
, m_bDefault(false)
{
@@ -286,7 +278,6 @@ DeferredValueNodeImpl::DeferredValueNodeImpl(DirectValueNodeImpl& rOriginal)
DeferredValueNodeImpl::~DeferredValueNodeImpl()
{
- delete m_pNewName;
delete m_pNewValue;
}
//-----------------------------------------------------------------------------
@@ -369,31 +360,14 @@ void DeferredValueNodeImpl::setDefault()
}
//-----------------------------------------------------------------------------
-void DeferredValueNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- ValueNodeImpl::doGetNodeInfo(rInfo);
- if (m_pNewName)
- rInfo.aName = *m_pNewName;
-}
-//-----------------------------------------------------------------------------
-
-void DeferredValueNodeImpl::doSetNodeName(Name const& aNewName)
-{
- std::auto_ptr<Name> pNewName( new Name(aNewName) );
- delete m_pNewName;
- m_pNewName = pNewName.release();
-}
-//-----------------------------------------------------------------------------
-
bool DeferredValueNodeImpl::doHasChanges() const
{
- return m_pNewValue || m_pNewName || m_bDefault;
+ return m_pNewValue || m_bDefault;
}
//-----------------------------------------------------------------------------
NodeChangeImpl* DeferredValueNodeImpl::doCollectChange() const
{
- OSL_ENSURE(!m_pNewName,"No support for renaming existing value nodes in current changes lists");
// TODO
if (m_bDefault)
{
@@ -414,8 +388,6 @@ NodeChangeImpl* DeferredValueNodeImpl::doCollectChange() const
NodeChangeImpl* DeferredValueNodeImpl::doAdjustToChange(ValueChange const& rExternalChange)
{
- OSL_ENSURE(!m_pNewName,"Renamed value node may be the wrong one for update adjustment");
-
if (m_bDefault && rExternalChange.getMode() == ValueChange::changeDefault)
{
OSL_ASSERT(!m_pNewValue);
@@ -451,20 +423,11 @@ void DeferredValueNodeImpl::doCommitChanges()
delete m_pNewValue, m_pNewValue = 0;
m_bDefault = false;
-
- if (m_pNewName)
- {
- ValueNodeImpl::doSetNodeName(*m_pNewName);
-
- delete m_pNewName, m_pNewName = 0;
- }
}
//-----------------------------------------------------------------------------
std::auto_ptr<ValueChange> DeferredValueNodeImpl::doPreCommitChange()
{
- OSL_ENSURE( !m_pNewName, "Renaming not supported with old changes !");
-
// first find the mode of the change
// initial value is harmless (done locally) or produces an error elsewhere
ValueChange::Mode eMode = ValueChange::changeDefault;
@@ -486,13 +449,9 @@ std::auto_ptr<ValueChange> DeferredValueNodeImpl::doPreCommitChange()
else
eMode = ValueChange::wasDefault;
- // now get the name of this node
- NodeInfo aInfo;
- doGetNodeInfo(aInfo);
-
// now make a ValueChange
- ValueChange* pChange = new ValueChange( aInfo.aName.toString(), getValue(),
- aInfo.aAttributes, eMode, ValueNodeImpl::getValue());
+ ValueChange* pChange = new ValueChange( this->getOriginalNodeName(), getValue(),
+ this->getAttributes(), eMode, ValueNodeImpl::getValue());
return std::auto_ptr<ValueChange>( pChange);
}
@@ -547,20 +506,12 @@ NodeImplHolder DeferredValueNodeImpl::doCloneIndirect(bool bIndirect)
// class ReadOnlyGroupNodeImpl
//-----------------------------------------------------------------------------
-void ReadOnlyGroupNodeImpl::doSetNodeName(Name const& )
-{
- failReadOnly();
-}
-//-----------------------------------------------------------------------------
-
-void ReadOnlyGroupNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
+Attributes ReadOnlyGroupNodeImpl::doGetAttributes() const
{
- GroupNodeImpl::doGetNodeInfo(rInfo);
- rInfo.aAttributes.bWritable = false;
+ return forceReadOnly( GroupNodeImpl::doGetAttributes() );
}
//-----------------------------------------------------------------------------
-
bool ReadOnlyGroupNodeImpl::doHasChanges() const
{
return false;
@@ -600,12 +551,6 @@ DirectGroupNodeImpl::DirectGroupNodeImpl(DeferredGroupNodeImpl& rOriginal)
{}
//-----------------------------------------------------------------------------
-void DirectGroupNodeImpl::doSetNodeName(Name const& rName)
-{
- GroupNodeImpl::doSetNodeName(rName);
-}
-//-----------------------------------------------------------------------------
-
bool DirectGroupNodeImpl::doHasChanges() const
{
return false;
@@ -639,7 +584,6 @@ NodeImplHolder DirectGroupNodeImpl::doCloneIndirect(bool bIndirect)
DeferredGroupNodeImpl::DeferredGroupNodeImpl(ISubtree& rOriginal)
: GroupNodeImpl(rOriginal)
-, m_pNewName(0)
, m_bChanged(false)
{
}
@@ -647,7 +591,6 @@ DeferredGroupNodeImpl::DeferredGroupNodeImpl(ISubtree& rOriginal)
DeferredGroupNodeImpl::DeferredGroupNodeImpl(DirectGroupNodeImpl& rOriginal)
: GroupNodeImpl(rOriginal)
-, m_pNewName(0)
, m_bChanged(false)
{
}
@@ -655,35 +598,17 @@ DeferredGroupNodeImpl::DeferredGroupNodeImpl(DirectGroupNodeImpl& rOriginal)
DeferredGroupNodeImpl::~DeferredGroupNodeImpl()
{
- delete m_pNewName;
-}
-//-----------------------------------------------------------------------------
-
-void DeferredGroupNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- GroupNodeImpl::doGetNodeInfo(rInfo);
- if (m_pNewName)
- rInfo.aName = *m_pNewName;
-}
-//-----------------------------------------------------------------------------
-
-void DeferredGroupNodeImpl::doSetNodeName(Name const& aNewName)
-{
- std::auto_ptr<Name> pNewName( new Name(aNewName) );
- delete m_pNewName;
- m_pNewName = pNewName.release();
}
//-----------------------------------------------------------------------------
bool DeferredGroupNodeImpl::doHasChanges() const
{
- return m_bChanged || m_pNewName;
+ return m_bChanged;
}
//-----------------------------------------------------------------------------
void DeferredGroupNodeImpl::doCollectChangesWithTarget(NodeChanges& , TreeImpl* , NodeOffset ) const
{
- OSL_ENSURE(!m_pNewName,"No support for renaming value nodes in current changes tree");
// TODO
}
//-----------------------------------------------------------------------------
@@ -691,30 +616,19 @@ void DeferredGroupNodeImpl::doCollectChangesWithTarget(NodeChanges& , TreeImpl*
void DeferredGroupNodeImpl::doCommitChanges()
{
m_bChanged = false;
-
- if (m_pNewName)
- {
- GroupNodeImpl::doSetNodeName(*m_pNewName);
-
- delete m_pNewName, m_pNewName = 0;
- }
}
//-----------------------------------------------------------------------------
std::auto_ptr<SubtreeChange> DeferredGroupNodeImpl::doPreCommitChanges()
{
- OSL_ENSURE( !m_pNewName, "Renaming not supported with old changes !");
-
std::auto_ptr<SubtreeChange> aRet;
if (m_bChanged)
{
// get the name of this node
- NodeInfo aInfo;
- doGetNodeInfo(aInfo);
- aRet.reset( new SubtreeChange(aInfo.aName.toString(),
+ aRet.reset( new SubtreeChange(this->getOriginalNodeName(),
rtl::OUString(),
- aInfo.aAttributes) );
+ this->getAttributes()) );
}
return aRet;
}
@@ -789,16 +703,9 @@ ReadOnlyTreeSetNodeImpl::Element ReadOnlyTreeSetNodeImpl::doMakeAdditionalElemen
}
//-----------------------------------------------------------------------------
-void ReadOnlyTreeSetNodeImpl::doSetNodeName(Name const& )
+Attributes ReadOnlyTreeSetNodeImpl::doGetAttributes() const
{
- failReadOnly();
-}
-//-----------------------------------------------------------------------------
-
-void ReadOnlyTreeSetNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- TreeSetNodeImpl::doGetNodeInfo(rInfo);
- rInfo.aAttributes.bWritable = false;
+ return forceReadOnly( TreeSetNodeImpl::doGetAttributes() );
}
//-----------------------------------------------------------------------------
@@ -859,16 +766,9 @@ ReadOnlyValueSetNodeImpl::Element ReadOnlyValueSetNodeImpl::doMakeAdditionalElem
}
//-----------------------------------------------------------------------------
-void ReadOnlyValueSetNodeImpl::doSetNodeName(Name const& )
-{
- failReadOnly();
-}
-//-----------------------------------------------------------------------------
-
-void ReadOnlyValueSetNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
+Attributes ReadOnlyValueSetNodeImpl::doGetAttributes() const
{
- ValueSetNodeImpl::doGetNodeInfo(rInfo);
- rInfo.aAttributes.bWritable = false;
+ return forceReadOnly( ValueSetNodeImpl::doGetAttributes() );
}
//-----------------------------------------------------------------------------
@@ -944,12 +844,6 @@ DirectTreeSetNodeImpl::Element DirectTreeSetNodeImpl::doMakeAdditionalElement(Ad
}
//-----------------------------------------------------------------------------
-void DirectTreeSetNodeImpl::doSetNodeName(Name const& aNewName)
-{
- TreeSetNodeImpl::doSetNodeName(aNewName);
-}
-//-----------------------------------------------------------------------------
-
bool DirectTreeSetNodeImpl::doHasChanges() const
{
return false;
@@ -1024,12 +918,6 @@ DirectValueSetNodeImpl::Element DirectValueSetNodeImpl::doMakeAdditionalElement(
}
//-----------------------------------------------------------------------------
-void DirectValueSetNodeImpl::doSetNodeName(Name const& aName)
-{
- ValueSetNodeImpl::doSetNodeName(aName);
-}
-//-----------------------------------------------------------------------------
-
bool DirectValueSetNodeImpl::doHasChanges() const
{
return false;
@@ -1069,7 +957,6 @@ NodeImplHolder DirectValueSetNodeImpl::doCloneIndirect(bool bIndirect)
DeferredTreeSetNodeImpl::DeferredTreeSetNodeImpl(ISubtree& rOriginal, Template* pTemplate)
: TreeSetNodeImpl(rOriginal,pTemplate)
, m_aChangedData()
-, m_pNewName(0)
, m_bChanged(false)
{
}
@@ -1078,7 +965,6 @@ DeferredTreeSetNodeImpl::DeferredTreeSetNodeImpl(ISubtree& rOriginal, Template*
DeferredTreeSetNodeImpl::DeferredTreeSetNodeImpl(DirectTreeSetNodeImpl& rOriginal)
: TreeSetNodeImpl(rOriginal)
, m_aChangedData()
-, m_pNewName(0)
, m_bChanged(false)
{
implMakeIndirect(true);
@@ -1157,22 +1043,6 @@ SetNodeVisitor::Result DeferredTreeSetNodeImpl::doDispatchToElements(SetNodeVisi
}
//-----------------------------------------------------------------------------
-void DeferredTreeSetNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- TreeSetNodeImpl::doGetNodeInfo(rInfo);
- if (m_pNewName)
- rInfo.aName = *m_pNewName;
-}
-//-----------------------------------------------------------------------------
-
-void DeferredTreeSetNodeImpl::doSetNodeName(Name const& aNewName)
-{
- std::auto_ptr<Name> pNewName( new Name(aNewName) );
- delete m_pNewName;
- m_pNewName = pNewName.release();
-}
-//-----------------------------------------------------------------------------
-
void DeferredTreeSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
implInsertNewElement(aName, TreeSetNodeImpl::implMakeElement(aNewEntry.tree()));
@@ -1200,14 +1070,12 @@ DeferredTreeSetNodeImpl::Element DeferredTreeSetNodeImpl::doMakeAdditionalElemen
bool DeferredTreeSetNodeImpl::doHasChanges() const
{
- return m_bChanged || m_pNewName || !m_aChangedData.isEmpty();
+ return m_bChanged || !m_aChangedData.isEmpty();
}
//-----------------------------------------------------------------------------
void DeferredTreeSetNodeImpl::doCollectChanges(NodeChanges& rChanges) const
{
- OSL_ENSURE(!m_pNewName,"No real support for renaming nodes preexisting trees");
-
// collect added and deleted nodes
{for(NativeIterator it = m_aChangedData.beginNative(), stop = m_aChangedData.endNative();
it != stop;
@@ -1326,28 +1194,18 @@ void DeferredTreeSetNodeImpl::doCommitChanges()
}
m_bChanged = false;
-
- if (m_pNewName)
- {
- TreeSetNodeImpl::doSetNodeName(*m_pNewName);
-
- delete m_pNewName, m_pNewName = 0;
- }
}
//-----------------------------------------------------------------------------
std::auto_ptr<SubtreeChange> DeferredTreeSetNodeImpl::doPreCommitChanges()
{
- OSL_ENSURE( !m_pNewName, "Renaming not supported with old changes !");
-
// nowfirst get the name of this node
- NodeInfo aInfo;
- doGetNodeInfo(aInfo);
+ OUString aName = this->getOriginalNodeName();
// and make a SubtreeChange
- std::auto_ptr<SubtreeChange> pSetChange( new SubtreeChange(aInfo.aName.toString(),
+ std::auto_ptr<SubtreeChange> pSetChange( new SubtreeChange(aName,
getElementTemplate()->getPath().toString(),
- aInfo.aAttributes) );
+ this->getAttributes()) );
// commit preexisting nodes
{for(NativeIterator it = TreeSetNodeImpl::beginElementSet(), stop = TreeSetNodeImpl::endElementSet();
@@ -1851,7 +1709,6 @@ NodeChangeImpl* DeferredTreeSetNodeImpl::doAdjustToRemovedElement(Name const& aN
DeferredValueSetNodeImpl::DeferredValueSetNodeImpl(ISubtree& rOriginal, Template* pTemplate)
: ValueSetNodeImpl(rOriginal,pTemplate)
, m_aChangedData()
-, m_pNewName(0)
, m_bChanged(false)
{
}
@@ -1860,7 +1717,6 @@ DeferredValueSetNodeImpl::DeferredValueSetNodeImpl(ISubtree& rOriginal, Template
DeferredValueSetNodeImpl::DeferredValueSetNodeImpl(DirectValueSetNodeImpl& rOriginal)
: ValueSetNodeImpl(rOriginal)
, m_aChangedData()
-, m_pNewName(0)
, m_bChanged(false)
{
implMakeIndirect(true);
@@ -1939,22 +1795,6 @@ SetNodeVisitor::Result DeferredValueSetNodeImpl::doDispatchToElements(SetNodeVis
}
//-----------------------------------------------------------------------------
-void DeferredValueSetNodeImpl::doGetNodeInfo(NodeInfo& rInfo) const
-{
- ValueSetNodeImpl::doGetNodeInfo(rInfo);
- if (m_pNewName)
- rInfo.aName = *m_pNewName;
-}
-//-----------------------------------------------------------------------------
-
-void DeferredValueSetNodeImpl::doSetNodeName(Name const& aNewName)
-{
- std::auto_ptr<Name> pNewName( new Name(aNewName) );
- delete m_pNewName;
- m_pNewName = pNewName.release();
-}
-//-----------------------------------------------------------------------------
-
void DeferredValueSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
implInsertNewElement(aName, ValueSetNodeImpl::implMakeElement(aNewEntry.tree()));
@@ -1981,14 +1821,12 @@ DeferredValueSetNodeImpl::Element DeferredValueSetNodeImpl::doMakeAdditionalElem
bool DeferredValueSetNodeImpl::doHasChanges() const
{
- return m_bChanged || m_pNewName || !m_aChangedData.isEmpty();
+ return m_bChanged || !m_aChangedData.isEmpty();
}
//-----------------------------------------------------------------------------
void DeferredValueSetNodeImpl::doCollectChanges(NodeChanges& rChanges) const
{
- OSL_ENSURE(!m_pNewName,"No real support for renaming nodes preexisting trees");
-
// collect added and deleted nodes
{for(NativeIterator it = m_aChangedData.beginNative(), stop = m_aChangedData.endNative();
it != stop;
@@ -2106,26 +1944,15 @@ void DeferredValueSetNodeImpl::doCommitChanges()
}
m_bChanged = false;
-
- if (m_pNewName)
- {
- ValueSetNodeImpl::doSetNodeName(*m_pNewName);
-
- delete m_pNewName, m_pNewName = 0;
- }
}
//-----------------------------------------------------------------------------
std::auto_ptr<SubtreeChange> DeferredValueSetNodeImpl::doPreCommitChanges()
{
- OSL_ENSURE( !m_pNewName, "Renaming not supported with old changes !");
-
- // nowfirst get the name of this node
- NodeInfo aInfo;
- doGetNodeInfo(aInfo);
-
// and make a SubtreeChange
- std::auto_ptr<SubtreeChange> pSetChange( new SubtreeChange(aInfo.aName.toString(), getElementTemplate()->getPath().toString(), aInfo.aAttributes) );
+ std::auto_ptr<SubtreeChange> pSetChange( new SubtreeChange(this->getOriginalNodeName(),
+ getElementTemplate()->getPath().toString(),
+ this->getAttributes()) );
// commit preexisting nodes
{for(NativeIterator it = ValueSetNodeImpl::beginElementSet(), stop = ValueSetNodeImpl::endElementSet();
diff --git a/configmgr/source/treemgr/nodeimplobj.hxx b/configmgr/source/treemgr/nodeimplobj.hxx
index bfce035929c6..de398f758e30 100644
--- a/configmgr/source/treemgr/nodeimplobj.hxx
+++ b/configmgr/source/treemgr/nodeimplobj.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimplobj.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:20:54 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -98,8 +98,7 @@ namespace configmgr
protected:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
+ virtual Attributes doGetAttributes() const;
virtual bool doHasChanges() const;
virtual void doCommitChanges();
@@ -130,8 +129,6 @@ namespace configmgr
protected:
// NodeImpl implementation
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doHasChanges() const;
virtual void doCommitChanges();
virtual void doMarkChanged();
@@ -169,16 +166,12 @@ namespace configmgr
virtual NodeChangeImpl* doAdjustToChange(ValueChange const& rExternalChange);
protected:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doHasChanges() const;
virtual NodeChangeImpl* doCollectChange() const;
virtual void doCommitChanges();
virtual void doMarkChanged();
virtual NodeImplHolder doCloneIndirect(bool bIndirect);
private:
- Name* m_pNewName;
UnoAny* m_pNewValue;
bool m_bDefault;
};
@@ -200,8 +193,7 @@ namespace configmgr
// Base obverrideables
private:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
+ virtual Attributes doGetAttributes() const;
virtual bool doHasChanges() const;
virtual void doCommitChanges();
@@ -223,8 +215,6 @@ namespace configmgr
// Base obverrideables
private:
// NodeImpl implementation
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doHasChanges() const;
virtual void doCommitChanges();
virtual void doMarkChanged();
@@ -252,16 +242,12 @@ namespace configmgr
// Base obverrideables
private:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doHasChanges() const;
virtual void doCollectChangesWithTarget(NodeChanges& rChanges, TreeImpl* pParent, NodeOffset nNode) const;
virtual void doCommitChanges();
virtual void doMarkChanged();
virtual NodeImplHolder doCloneIndirect(bool bIndirect);
- Name* m_pNewName;
bool m_bChanged;
};
//-----------------------------------------------------------------------------
@@ -281,8 +267,7 @@ namespace configmgr
// Base Overrideables
private:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
+ virtual Attributes doGetAttributes() const;
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
@@ -316,8 +301,7 @@ namespace configmgr
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TemplateProvider const& aTemplateProvider, TreeDepth nDepth);
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
+ virtual Attributes doGetAttributes() const;
virtual bool doHasChanges() const;
virtual void doCollectChanges(NodeChanges& rChanges) const;
@@ -341,8 +325,6 @@ namespace configmgr
// Base Overrideables
private:
// NodeImpl implementation
- virtual void doSetNodeName(Name const& rName);
-
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
@@ -370,8 +352,6 @@ namespace configmgr
// Base Overrideables
private:
// NodeImpl implementation
- virtual void doSetNodeName(Name const& rName);
-
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
@@ -405,9 +385,6 @@ namespace configmgr
// Base Overrideables
private:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doIsEmpty() const;
virtual SetEntry doFindElement(Name const& aName) ;
virtual void doClearElements();
@@ -436,7 +413,6 @@ namespace configmgr
void implRemoveOldElement(Name const& aName);
ElementSet m_aChangedData;
- Name* m_pNewName;
bool m_bChanged;
};
//-----------------------------------------------------------------------------
@@ -461,9 +437,6 @@ namespace configmgr
// Base Overrideables
private:
// NodeImpl implementation
- virtual void doGetNodeInfo(NodeInfo& rInfo) const;
- virtual void doSetNodeName(Name const& rName);
-
virtual bool doIsEmpty() const;
virtual SetEntry doFindElement(Name const& aName) ;
virtual void doClearElements();
@@ -492,7 +465,6 @@ namespace configmgr
void implRemoveOldElement(Name const& aName);
ElementSet m_aChangedData;
- Name* m_pNewName;
bool m_bChanged;
};
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/treeimpl.cxx b/configmgr/source/treemgr/treeimpl.cxx
index aa864cf7f60d..964139e6a55b 100644
--- a/configmgr/source/treemgr/treeimpl.cxx
+++ b/configmgr/source/treemgr/treeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:09:24 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,6 +79,13 @@ namespace configmgr
{
//-----------------------------------------------------------------------------
+inline
+static
+Name nodeName(INode const& aNode)
+{
+ return Name(aNode.getName(),Name::NoValidate());
+}
+//-----------------------------------------------------------------------------
// class TreeImplBuilder - friend of TreeImpl
//-----------------------------------------------------------------------------
@@ -145,7 +152,7 @@ void TreeImplBuilder::addValue(ValueNode& rValue)
// TODO:!isValid() => maybe substitute a SimpleValueNodeImpl if possible
if( aValueNode.isValid() )
{
- m_rTree.m_aNodes.push_back( Node(aValueNode,m_nParent) );
+ m_rTree.m_aNodes.push_back( Node(aValueNode,nodeName(rValue),m_nParent) );
}
}
//-----------------------------------------------------------------------------
@@ -158,7 +165,7 @@ void TreeImplBuilder::addGroup(ISubtree& rTree)
// TODO:!isValid() => maybe substitute a SimpleValueNodeImpl if possible
if( aGroupNode.isValid() )
{
- m_rTree.m_aNodes.push_back( Node(aGroupNode,m_nParent) );
+ m_rTree.m_aNodes.push_back( Node(aGroupNode,nodeName(rTree),m_nParent) );
// now fill in group members
if (m_nDepthLeft > 0)
@@ -191,7 +198,7 @@ void TreeImplBuilder::addSet(ISubtree& rTree)
// TODO:!isValid() => maybe substitute a SimpleValueNodeImpl if possible
if( aSetNode.isValid() )
{
- m_rTree.m_aNodes.push_back( Node(aSetNode,m_nParent) );
+ m_rTree.m_aNodes.push_back( Node(aSetNode,nodeName(rTree),m_nParent) );
// this also relies on one based offsets
NodeOffset nNodeAdded = m_rTree.m_aNodes.size() + m_rTree.root() - 1;
@@ -204,47 +211,23 @@ void TreeImplBuilder::addSet(ISubtree& rTree)
// class Node
//-----------------------------------------------------------------------------
-Node::Node(NodeImplHolder const& aSpecificNode, NodeOffset nParent)
+Node::Node(NodeImplHolder const& aSpecificNode, Name const& aName, NodeOffset nParent)
: m_pSpecificNode(aSpecificNode)
, m_nParent(nParent)
+, m_aName(aName)
{
}
//-----------------------------------------------------------------------------
-static
-inline
-NodeInfo implInfo(NodeImpl const& aNode)
+NodeInfo Node::info() const
{
NodeInfo info;
- aNode.getNodeInfo(info);
+ info.aName = this->name();
+ info.aAttributes = this->attributes();
return info;
}
//-----------------------------------------------------------------------------
-Name Node::name() const
-{
- return implInfo(*m_pSpecificNode).aName;
-}
-//-----------------------------------------------------------------------------
-
-Attributes Node::attributes() const
-{
- return implInfo(*m_pSpecificNode).aAttributes;
-}
-//-----------------------------------------------------------------------------
-
-NodeInfo Node::info() const
-{
- return implInfo(*m_pSpecificNode);
-}
-//-----------------------------------------------------------------------------
-
-void Node::renameNode(Name const& aName)
-{
- m_pSpecificNode->setNodeName(aName);
-}
-//-----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
// class TreeImpl
//-----------------------------------------------------------------------------
@@ -1031,6 +1014,7 @@ void ElementTreeImpl::attachTo(ISubtree& rOwningSet, Name const& aElementName)
if (m_pOwnedNode)
{
+ OSL_ENSURE(this->name(root()) == aElementName,"ElementTree: Attaching with unexpected element name");
m_pOwnedNode->setName(aElementName.toString());
std::auto_ptr<INode> aNode(m_pOwnedNode);
@@ -1047,6 +1031,7 @@ void ElementTreeImpl::detachFrom(ISubtree& rOwningSet, Name const& aElementName)
OSL_ENSURE(!m_pOwnedNode,"ERROR: Cannot detach a already owned node from a subtree");
if (!m_pOwnedNode)
{
+ OSL_ENSURE(this->name(root()) == aElementName,"ElementTree: Detaching with unexpected element name");
std::auto_ptr<INode> aNode( rOwningSet.removeChild(aElementName.toString()) );
OSL_ENSURE(aNode.get(),"ERROR: Detached node not found in the given subtree");
@@ -1071,6 +1056,11 @@ void ElementTreeImpl::takeNodeFrom(std::auto_ptr<INode>& rOldOwner)
void ElementTreeImpl::releaseTo(std::auto_ptr<INode>& rNewOwner)
{
OSL_ENSURE(m_pOwnedNode,"ERROR: Cannot release a non-owned node");
+ if (m_pOwnedNode)
+ {
+ Name aNodeName = node(root())->name();
+ m_pOwnedNode->setName( aNodeName.toString() );
+ }
rNewOwner.reset(m_pOwnedNode);
m_pOwnedNode = 0;
@@ -1085,8 +1075,7 @@ void ElementTreeImpl::releaseAs(std::auto_ptr<INode>& rNewOwner, Name const& aEl
if (m_pOwnedNode)
renameTree(aElementName);
- rNewOwner.reset(m_pOwnedNode);
- m_pOwnedNode = 0;
+ this->releaseTo(rNewOwner);
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/treeimpl.hxx b/configmgr/source/treemgr/treeimpl.hxx
index be8d11bd2c93..1fe6971be86e 100644
--- a/configmgr/source/treemgr/treeimpl.hxx
+++ b/configmgr/source/treemgr/treeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.hxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:09:24 $
+ * last change: $Author: jb $ $Date: 2001-02-23 10:50:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -160,17 +160,20 @@ namespace configmgr
*/
class Node
{
+ Name m_aName; // cached for better performance
NodeImplHolder m_pSpecificNode;
NodeOffset m_nParent;
+
+ friend class ElementTreeImpl; // can rename root nodes
public:
- Node(NodeImplHolder const& aSpecificNodeImpl, NodeOffset nParent);
+ Node(NodeImplHolder const& aSpecificNodeImpl, Name const& aName, NodeOffset nParent);
// COMMON: information
NodeOffset parent() const { return m_nParent; }
NodeType::Enum getNodeType() const { return m_pSpecificNode->getType(); }
- Name name() const;
- Attributes attributes() const;
+ Name name() const { return m_aName; }
+ Attributes attributes() const { return m_pSpecificNode->getAttributes(); }
NodeInfo info() const;
// change management
@@ -182,9 +185,6 @@ namespace configmgr
void collectChanges(NodeChanges& rChanges, TreeImpl* pTree, NodeOffset nContext) const
{ m_pSpecificNode->collectChanges(rChanges,pTree,nContext); }
- /// renames a node without concern for context consistency ! Only works for nodes without parent
- void renameNode(Name const& aName);
-
// COMMON: handler dispatch
void dispatch(INodeHandler& rHandler) { m_pSpecificNode->dispatch(rHandler); }
@@ -204,10 +204,12 @@ namespace configmgr
GroupNodeImpl const&groupImpl() const { return implGetGroupImpl(); }
private:
+ void renameNode(Name const& aNewName) { m_aName = aNewName; }
+ friend class ElementTreeImpl; // can rename root nodes
+ private:
SetNodeImpl& implGetSetImpl() const;
GroupNodeImpl& implGetGroupImpl() const ;
ValueNodeImpl& implGetValueImpl() const ;
-
};
//-----------------------------------------------------------------------------
class RootTreeImpl; // for 'dynamic-casting'