summaryrefslogtreecommitdiff
path: root/configmgr/source
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-07-16 16:00:31 +0000
committerJörg Barfurth <jb@openoffice.org>2001-07-16 16:00:31 +0000
commit299268c9cbf615301ec038608493b345c2815f96 (patch)
tree451baa2d317149299e517d5c83170ea521015131 /configmgr/source
parent468f7f30cf8c257eaeef87e0b0d751c74ff4f6b9 (diff)
#89722# Changed handling of dummy nodes to try to preserve set-ness
Diffstat (limited to 'configmgr/source')
-rw-r--r--configmgr/source/inc/mergechange.hxx6
-rw-r--r--configmgr/source/misc/mergechange.cxx176
2 files changed, 142 insertions, 40 deletions
diff --git a/configmgr/source/inc/mergechange.hxx b/configmgr/source/inc/mergechange.hxx
index 5cc5fbd91d83..a6205ebfd8e4 100644
--- a/configmgr/source/inc/mergechange.hxx
+++ b/configmgr/source/inc/mergechange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ * last change: $Author: jb $ $Date: 2001-07-16 17:00:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,7 +124,7 @@ namespace configmgr
void mergeChanges(const SubtreeChange &_rChange);
private:
- void initRoot(const RelativePath& _aPathToChange);
+ void initRoot(const SubtreeChange &_rRootChange, const RelativePath& _aPathToChange);
private:
virtual void handle(ValueChange const& _rValueNode);
virtual void handle(AddNode const& _rAddNode);
diff --git a/configmgr/source/misc/mergechange.cxx b/configmgr/source/misc/mergechange.cxx
index da4edba4449f..6c240abac766 100644
--- a/configmgr/source/misc/mergechange.cxx
+++ b/configmgr/source/misc/mergechange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-07-06 15:28:50 $
+ * last change: $Author: jb $ $Date: 2001-07-16 17:00:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -66,6 +66,9 @@
#ifndef CONFIGMGR_CHANGE_HXX
#include "change.hxx"
#endif
+#ifndef CONFIGMGR_TREE_CHANGEFACTORY_HXX
+#include "treechangefactory.hxx"
+#endif
#ifndef CONFIGMGR_TREECHANGELIST_HXX
#include "treechangelist.hxx"
#endif
@@ -338,12 +341,21 @@ namespace configmgr
void adjustElementTemplate(SubtreeChange& _rChange, const rtl::OUString& _rName, const rtl::OUString& _rModule)
{
- if (!_rChange.isSetNodeChange())
+ if (!_rChange.isSetNodeChange() || isGenericSetElementType(_rChange.getElementTemplateName()))
{
_rChange.setElementTemplate(_rName,_rModule);
}
- OSL_POSTCOND(_rChange.getElementTemplateName() == _rName, "Adjusting: Template modules do not match");
- OSL_POSTCOND(_rChange.getElementTemplateModule() == _rModule, "Adjusting: Template modules do not match");
+ else if ( isDummySetElementModule(_rChange.getElementTemplateModule()) &&
+ !isGenericSetElementType(_rName) && !isDummySetElementModule(_rModule))
+ {
+ OSL_ENSURE(_rChange.getElementTemplateName() == _rName, "Adjusting: Template modules do not match");
+
+ _rChange.setElementTemplate(_rName,_rModule);
+ }
+ OSL_POSTCOND(_rChange.getElementTemplateName() == _rName || isGenericSetElementType(_rName),
+ "Adjusting: Template modules do not match");
+ OSL_POSTCOND(_rChange.getElementTemplateModule() == _rModule || isDummySetElementModule(_rModule),
+ "Adjusting: Template modules do not match");
}
// -----------------------------------------------------------------------------
@@ -370,32 +382,79 @@ namespace configmgr
RelativePath aEnsurePath = Path::stripPrefix(aStartPath,aThisRootPath);
+ OSL_PRECOND(aStartPath.getLocalName().getName().toString() == _aChanges.root.getNodeName(),
+ "Treechangelist has incorrect root path" );
+
SubtreeChange* pCurrentParent = &m_aTreeChangeList.root;
- for(RelativePath::Iterator it = aEnsurePath.begin(), stop = aEnsurePath.end();
- it != stop;
- ++it)
+ if (!aEnsurePath.isEmpty())
{
- Change *pChange = findExistingChange(pCurrentParent,*it);
+ RelativePath::Iterator const firstEnsure = aEnsurePath.begin();
+ RelativePath::Iterator lastEnsure = aEnsurePath.end();
- if (!pChange)
+ OSL_ASSERT( firstEnsure != lastEnsure );
+ --lastEnsure; // last to ensure is the actual root
+
+ for(RelativePath::Iterator it = firstEnsure; it != lastEnsure; ++it)
+ {
+ OSL_ASSERT( it != aEnsurePath.end() );
+
+ Change *pChange = findExistingChange(pCurrentParent,*it);
+
+ if (!pChange)
+ {
+ OSL_ASSERT( it+1 != aEnsurePath.end());
+ Name const aElementTypeName = (it+1)->getTypeName();
+
+ // create a correspondens for the name, we did not find.
+ auto_ptr<SubtreeChange> pNewChange =
+ OTreeChangeFactory::createDummyChange(it->getName(), aElementTypeName);
+
+ pChange = pNewChange.get();
+
+ pCurrentParent->addChange(base_ptr(pNewChange));
+
+ OSL_ENSURE(pChange == findExistingChange(pCurrentParent,*it),
+ "ERROR: Newly added change cannot be found in parent change");
+ }
+
+ if (!pChange->ISA(SubtreeChange))
+ {
+ OSL_ENSURE(false, "Change to merge does not point to a Subtree Change");
+ throw InvalidName(aEnsurePath.toString(), "points to a non- subtree change in this changes list, but a subtree change is required as root.");
+ }
+ pCurrentParent = static_cast<SubtreeChange*>( pChange);
+ }
+
+ Change *pRootChange = findExistingChange(pCurrentParent,*lastEnsure);
+
+ if (!pRootChange)
{
// create a correspondens for the name, we did not find.
- auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(it->getName().toString(), configuration::Attributes()));
- pChange = pNewChange.get();
+ auto_ptr<SubtreeChange> pNewChange(
+ new SubtreeChange(_aChanges.root, SubtreeChange::NoChildCopy()) );
- pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
+ pRootChange = pNewChange.get();
- OSL_ENSURE(pChange == findExistingChange(pCurrentParent,*it),
+ pCurrentParent->addChange(base_ptr(pNewChange));
+
+ OSL_ENSURE(pRootChange == findExistingChange(pCurrentParent,*it),
"ERROR: Newly added change cannot be found in parent change");
}
- if (!pChange->ISA(SubtreeChange))
+ if (!pRootChange->ISA(SubtreeChange))
+ {
+ OSL_ENSURE(false, "Change to merge does not point to a Subtree Change");
throw InvalidName(aEnsurePath.toString(), "points to a non- subtree change in this changes list, but a subtree change is required as root.");
-
- pCurrentParent = static_cast<SubtreeChange*>( pChange);
+ }
+ pCurrentParent = static_cast<SubtreeChange*>( pRootChange);
}
+ OSL_ENSURE(pCurrentParent->getNodeName() == _aChanges.root.getNodeName(),
+ "Change being merged has a different name" );
+
+ adjustElementTemplate(*pCurrentParent,_aChanges.root);
+
this->init(aStartPath);
m_pCurrentParent = pCurrentParent;
@@ -600,34 +659,81 @@ namespace configmgr
{
}
- void OMergeChanges::initRoot(const RelativePath& _aPathToChange)
+ void OMergeChanges::initRoot(const SubtreeChange &_rRootChange, const RelativePath& _aPathToChange)
{
SubtreeChange* pCurrentParent = &m_rSubtreeChange;
- for(RelativePath::Iterator it = _aPathToChange.begin(), stop = _aPathToChange.end();
- it != stop;
- ++it)
+ if (!_aPathToChange.isEmpty())
{
- Change *pChange = findExistingChange(pCurrentParent,*it);
+ OSL_PRECOND(_aPathToChange.getLocalName().getName().toString() == _rRootChange.getNodeName(),
+ "Path to change root does not match change being merged" );
- if (!pChange)
+ RelativePath::Iterator const firstEnsure = _aPathToChange.begin();
+ RelativePath::Iterator lastEnsure = _aPathToChange.end();
+
+ OSL_ASSERT( firstEnsure != lastEnsure );
+ --lastEnsure; // last to ensure is the actual root
+
+ for(RelativePath::Iterator it = firstEnsure; it != lastEnsure; ++it)
+ {
+ OSL_ASSERT( it != _aPathToChange.end() );
+
+ Change *pChange = findExistingChange(pCurrentParent,*it);
+
+ if (!pChange)
+ {
+ OSL_ASSERT( it+1 != _aPathToChange.end());
+ Name const aElementTypeName = (it+1)->getTypeName();
+
+ // create a correspondens for the name, we did not find.
+ auto_ptr<SubtreeChange> pNewChange =
+ OTreeChangeFactory::createDummyChange(it->getName(), aElementTypeName);
+
+ pChange = pNewChange.get();
+
+ pCurrentParent->addChange(base_ptr(pNewChange));
+
+ OSL_ENSURE(pChange == findExistingChange(pCurrentParent,*it),
+ "ERROR: Newly added change cannot be found in parent change");
+ }
+
+ if (!pChange->ISA(SubtreeChange))
+ {
+ OSL_ENSURE(false, "Change to merge does not point to a Subtree Change");
+ throw InvalidName(_aPathToChange.toString(), "points to a non- subtree change in this changes list, but a subtree change is required as root.");
+ }
+ pCurrentParent = static_cast<SubtreeChange*>( pChange);
+ }
+
+ Change *pRootChange = findExistingChange(pCurrentParent,*lastEnsure);
+
+ if (!pRootChange)
{
// create a correspondens for the name, we did not find.
- auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(it->getName().toString(), configuration::Attributes()));
- pChange = pNewChange.get();
+ auto_ptr<SubtreeChange> pNewChange(
+ new SubtreeChange(_rRootChange, SubtreeChange::NoChildCopy()) );
+
+ pRootChange = pNewChange.get();
- pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
+ pCurrentParent->addChange(base_ptr(pNewChange));
- OSL_ENSURE(pChange == findExistingChange(pCurrentParent,*it),
+ OSL_ENSURE(pRootChange == findExistingChange(pCurrentParent,*it),
"ERROR: Newly added change cannot be found in parent change");
}
- if (!pChange->ISA(SubtreeChange))
- throw InvalidName(_aPathToChange.toString(), "points to a non- subtree change in this changes list, but a subtree change is required as root.");
-
- pCurrentParent = static_cast<SubtreeChange*>( pChange);
+ if (!pRootChange->ISA(SubtreeChange))
+ {
+ OSL_ENSURE(false, "Change to merge does not point to a Subtree Change");
+ throw InvalidName(_aPathToChange.toString(), "points to a non-subtree change in this changes list, but a subtree change is required as root.");
+ }
+ pCurrentParent = static_cast<SubtreeChange*>( pRootChange);
}
+ OSL_ENSURE(pCurrentParent->getNodeName() == _rRootChange.getNodeName(),
+ "Change being merged has a different name");
+
+ adjustElementTemplate(*pCurrentParent,_rRootChange);
+
this->init(_aPathToChange);
m_pCurrentParent = pCurrentParent;
@@ -655,10 +761,7 @@ namespace configmgr
// WARNING this could be a big tree, because a change can contain subtreechanges!
void OMergeChanges::mergeChanges(const SubtreeChange &_rChange)
{
- initRoot( RelativePath() );
-
- this->applyToChildren(_rChange); //- semantics ?
- //this->applyToChange(_rChange);
+ mergeChanges(_rChange, RelativePath());
}
// -----------------------------------------------------------------------------
@@ -666,10 +769,9 @@ namespace configmgr
// WARNING this could be a big tree, because a change can contain subtreechanges!
void OMergeChanges::mergeChanges(const SubtreeChange &_rChange, const RelativePath& _aPathToChange)
{
- initRoot( _aPathToChange); // path location being merged must exist
+ initRoot(_rChange, _aPathToChange); // path location being merged must exist
this->applyToChildren(_rChange); //- semantics ?
- //this->applyToChange(_rChange);
}
// -----------------------------------------------------------------------------