summaryrefslogtreecommitdiff
path: root/configmgr/source/tree
diff options
context:
space:
mode:
authorDirk Grobler <dg@openoffice.org>2000-11-30 07:32:38 +0000
committerDirk Grobler <dg@openoffice.org>2000-11-30 07:32:38 +0000
commite71f6ad50464c3e4e70fac09b725b3ceda4c4421 (patch)
tree3b370fe351b09a3c9f8f16e938e5fa698eb63c1d /configmgr/source/tree
parent77bdc4a9bac451a1e01d54b4e68428a4b66f586f (diff)
#79032# changes for localisation
Diffstat (limited to 'configmgr/source/tree')
-rw-r--r--configmgr/source/tree/changes.cxx12
-rw-r--r--configmgr/source/tree/cmtree.cxx226
-rw-r--r--configmgr/source/tree/cmtreemodel.cxx9
-rw-r--r--configmgr/source/tree/treeactions.cxx39
4 files changed, 88 insertions, 198 deletions
diff --git a/configmgr/source/tree/changes.cxx b/configmgr/source/tree/changes.cxx
index a6eccb30c083..5cefc49c3e1e 100644
--- a/configmgr/source/tree/changes.cxx
+++ b/configmgr/source/tree/changes.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: changes.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dg $ $Date: 2000-11-23 12:05:58 $
+ * last change: $Author: dg $ $Date: 2000-11-30 08:31:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,11 +72,12 @@ using namespace configmgr;
//= ValueChange
//==========================================================================
// -------------------------------------------------------------------------
-ValueChange::ValueChange(OUString const& _rName,Any aNewValue, Mode aMode, Any aOldValue)
+ValueChange::ValueChange(OUString const& _rName,Any aNewValue, const configuration::Attributes& _rAttributes, Mode aMode, Any aOldValue)
: Change(_rName)
,m_aValue(aNewValue)
,m_aOldValue(aOldValue)
,m_eMode(aMode)
+ ,m_aAttributes(_rAttributes)
{
}
// -------------------------------------------------------------------------
@@ -84,15 +85,17 @@ ValueChange::ValueChange(Any aNewValue, ValueNode const& aOldValue)
: Change(aOldValue.getName())
,m_aValue(aNewValue)
,m_aOldValue(aOldValue.getValue())
+ ,m_aAttributes(aOldValue.getAttributes())
{
m_eMode = aOldValue.isDefault() ? wasDefault : changeValue;
}
// -------------------------------------------------------------------------
-ValueChange::ValueChange(SetToDefault, ValueNode const& aOldValue)
+ValueChange::ValueChange(SetToDefault, ValueNode const& aOldValue)
: Change(aOldValue.getName())
,m_aValue(aOldValue.getDefault())
,m_aOldValue(aOldValue.getValue())
,m_eMode(setToDefault)
+ ,m_aAttributes(aOldValue.getAttributes())
{
}
@@ -102,6 +105,7 @@ ValueChange::ValueChange(const ValueChange& _rChange)
,m_aValue(_rChange.getNewValue())
,m_aOldValue(_rChange.getOldValue())
,m_eMode(_rChange.getMode())
+ ,m_aAttributes(_rChange.getAttributes())
{}
// -------------------------------------------------------------------------
diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx
index 48afad595405..ea37b6290ce8 100644
--- a/configmgr/source/tree/cmtree.cxx
+++ b/configmgr/source/tree/cmtree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtree.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: lla $ $Date: 2000-11-29 13:59:53 $
+ * last change: $Author: dg $ $Date: 2000-11-30 08:31:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,9 +81,7 @@
#ifndef _CONFIGMGR_TREEACCESS_HXX_
#include "treeaccess.hxx"
#endif
-#ifndef CONFIGMGR_API_CHANGESSET_HXX_
-#include "confchangesset.hxx"
-#endif
+
// WISDOM
// !!Never write same code twice!!
@@ -114,18 +112,14 @@ namespace configmgr
// ---------------------------- Node implementation ----------------------------
- INode::INode(){}
- INode::INode(OUString const& aName)
- :m_aName(aName){}
+ INode::INode(configuration::Attributes _aAttr):m_aAttributes(_aAttr){}
+ INode::INode(OUString const& aName, configuration::Attributes _aAttr)
+ :m_aName(aName)
+ ,m_aAttributes(_aAttr){}
// CopyCTor will be create automatically
INode::~INode() {}
- // Node* Node::clone() {}
-
- OUString INode::getName() const {return m_aName;}
- NodeAttributes INode::getAttributes() const {return m_aNodeAttribute;}
-
ISubtree* INode::asISubtree(){return NULL;}
ISubtree const* INode::asISubtree() const {return NULL;}
ValueNode* INode::asValueNode() {return NULL;}
@@ -133,104 +127,57 @@ namespace configmgr
// ------------------------- SearchNode implementation -------------------------
- SearchNode::SearchNode(){}
+ SearchNode::SearchNode():INode(configuration::Attributes()){}
SearchNode::SearchNode(OUString const& aName)
- :INode(aName){}
+ :INode(aName, configuration::Attributes()){}
INode* SearchNode::clone() const {return new SearchNode(*this);}
- OUString SearchNode::getName() const {return getName();}
SearchNode::~SearchNode(){}
+ //==========================================================================
+ //= OPropagateLevels
+ //==========================================================================
+ /** fills a subtree with the correct level informations
+ */
+ struct OPropagateLevels : public NodeModification
+ {
+ protected:
+ sal_Int32 nChildLevel;
+ public:
+ OPropagateLevels(sal_Int32 _nParentLevel)
+ {
+ nChildLevel = (ITreeProvider::ALL_LEVELS == _nParentLevel) ? ITreeProvider::ALL_LEVELS : _nParentLevel - 1;
+ }
+ virtual void handle(ValueNode&) { /* not interested in value nodes */ }
+ virtual void handle(ISubtree& _rSubtree)
+ {
+ if ((ITreeProvider::ALL_LEVELS == nChildLevel) || nChildLevel > _rSubtree.getLevel())
+ _rSubtree.setLevel(nChildLevel);
+ }
+ };
+
// -------------------------- ISubtree implementation --------------------------
ISubtree* ISubtree::asISubtree() {return this;}
ISubtree const* ISubtree::asISubtree() const {return this;}
-// --------------------------- Subtree implementation ---------------------------
-
- Subtree::Subtree(OUString const& aName)
- :ISubtree(aName)
- ,m_nLevel(0)
- {
- }
- Subtree::Subtree()
- :m_nLevel(0)
+ //--------------------------------------------------------------------------
+ void ISubtree::setLevel(sal_Int16 _nLevel)
{
+ m_nLevel = _nLevel;
+ if (0 == _nLevel)
+ // nothing more to do, this means "nothing known about any children"
+ return;
+
+ // forward the level number to any child subtrees we have
+ OPropagateLevels aDeeperInto(_nLevel);
+ aDeeperInto.applyToChildren(*this);
}
- Subtree::~Subtree() {}
-// #pragma message("__FILE__(__LINE__) Subtree::clone() has empty implementation")
+// --------------------------- Subtree implementation ---------------------------
INode* Subtree::clone() const {return new Subtree(*this);}
-// #define MAX_NODE_NAME_LENGTH 256
-
-// RECURSIVE: Node* Subtree::createChild(OUString const& aPath)
-// RECURSIVE: {
-// RECURSIVE: //? configmgr::Node searchObj(aName);
-// RECURSIVE: //? ChildList::iterator it = m_aNode->GetSet().find(&searchObj);
-// RECURSIVE: //? if (it == m_aNode->GetSet().end())
-// RECURSIVE: //? return NULL;
-// RECURSIVE: //? else
-// RECURSIVE: //? return *it;
-// RECURSIVE: sal_Unicode aName[MAX_NODE_NAME_LENGTH];
-// RECURSIVE: int nStartPos = 0;
-// RECURSIVE: int nPos = 0;
-// RECURSIVE:
-// RECURSIVE: if (aPath[0] == '/')
-// RECURSIVE: {
-// RECURSIVE: nStartPos++;
-// RECURSIVE: }
-// RECURSIVE: if (aPath[nStartPos] == '\0')
-// RECURSIVE: {
-// RECURSIVE: return this;
-// RECURSIVE: }
-// RECURSIVE:
-// RECURSIVE: int nEndPos = nStartPos;
-// RECURSIVE: while ((aPath[nEndPos] != '\0') && (aPath[nEndPos] != '/')) {
-// RECURSIVE: aName[nPos++] = aPath[nEndPos++];
-// RECURSIVE: }
-// RECURSIVE: aName[nPos] = '\0';
-// RECURSIVE:
-// RECURSIVE: #ifdef DEBUG
-// RECURSIVE: // list(cout << " searching for [" << aName << "] in\n");
-// RECURSIVE: #endif
-// RECURSIVE:
-// RECURSIVE: // search Node
-// RECURSIVE: SearchNode searchObj(aName);
-// RECURSIVE: ChildList::iterator it = m_aChildren->GetSet().find(&searchObj);
-// RECURSIVE: if (it == m_aChildren->GetSet().end())
-// RECURSIVE: {
-// RECURSIVE: // create new Child
-// RECURSIVE: auto_ptr<Node> pSubtree( new Subtree(aName));
-// RECURSIVE: Node *pN = addChild(pSubtree);
-// RECURSIVE: Subtree *pS = (Subtree*)pN;
-// RECURSIVE: return pS->createChild(aPath + nEndPos);
-// RECURSIVE: }
-// RECURSIVE: else {
-// RECURSIVE: // call recursive the inner child
-// RECURSIVE: Node *pN = *it;
-// RECURSIVE: Subtree *pP = (Subtree*)pN;
-// RECURSIVE: return pP->createChild(aPath + nEndPos);
-// RECURSIVE: }
-// RECURSIVE: }
-
- INode* Subtree::createChild(OUString const& aName)
- {
- // POST: create Subtree if not found
-
- // search Node
- SearchNode searchObj(aName);
- ChildList::iterator it = m_aChildren.GetSet().find(&searchObj);
- if (it == m_aChildren.GetSet().end())
- {
- // create new Child
- auto_ptr<INode> pSubtree( new Subtree(aName));
- return addChild(pSubtree);
- }
- return *it;
- }
-
INode* Subtree::doGetChild(OUString const& aName) const
{
SearchNode searchObj(aName);
@@ -278,28 +225,6 @@ namespace configmgr
}
//==========================================================================
- //= OPropagateLevels
- //==========================================================================
- /** fills a subtree with the correct level informations
- */
- struct OPropagateLevels : public NodeModification
- {
- protected:
- sal_Int32 nChildLevel;
- public:
- OPropagateLevels(sal_Int32 _nParentLevel)
- {
- nChildLevel = (ITreeProvider::ALL_LEVELS == _nParentLevel) ? ITreeProvider::ALL_LEVELS : _nParentLevel - 1;
- }
- virtual void handle(ValueNode&) { /* not interested in value nodes */ }
- virtual void handle(ISubtree& _rSubtree)
- {
- if ((ITreeProvider::ALL_LEVELS == nChildLevel) || nChildLevel > _rSubtree.getLevel())
- _rSubtree.setLevel(nChildLevel);
- }
- };
-
- //==========================================================================
//= OCompleteTree
//==========================================================================
/** completes the cache with missing subelements
@@ -411,7 +336,7 @@ namespace configmgr
OSL_ENSHURE(pSubTree, "OBuildChangeTree::handle : node must be a inner node!");
// generate a new change
- SubtreeChange* pChange = new SubtreeChange(aNodeName);
+ SubtreeChange* pChange = new SubtreeChange(_rSubtree);
OBuildChangeTree aNextLevel(*pChange, pSubTree);
aNextLevel.applyToChildren(_rSubtree);
@@ -429,22 +354,6 @@ namespace configmgr
};
- //--------------------------------------------------------------------------
- void Subtree::setLevel(sal_Int16 _nLevel)
- {
- m_nLevel = _nLevel;
- if (0 == _nLevel)
- // nothing more to do, this means "nothing known about any children"
- return;
-
- // forward the level number to any child subtrees we have
- OPropagateLevels aDeeperInto(_nLevel);
- aDeeperInto.applyToChildren(*this);
- }
-
- //--------------------------------------------------------------------------
- sal_Int16 Subtree::getLevel() const {return m_nLevel;}
-
void Subtree::forEachChild(NodeAction& anAction) const {
for(ChildList::const_iterator it = m_aChildren.GetSet().begin();
it != m_aChildren.GetSet().end();
@@ -502,7 +411,7 @@ namespace configmgr
bool ValueNode::hasDefault() const
{
// POST: true, if only m_aDefaultValue is set.
- return getAttributes().optional || m_aDefaultValue.hasValue();
+ return getAttributes().bNullable || m_aDefaultValue.hasValue();
}
bool ValueNode::isNull() const
@@ -604,7 +513,7 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
- ISubtree* Tree::requestSubtree( OUString const& aComponentName, sal_Int16 nLevel ) throw (container::NoSuchElementException)
+ ISubtree* Tree::requestSubtree( OUString const& aComponentName, const vos::ORef<OOptions>& _xOptions, sal_Int16 nLevel ) throw (container::NoSuchElementException)
{
// OLD:
// INode* pResult = m_pRoot->getChild(aComponentName);
@@ -778,7 +687,7 @@ namespace configmgr
if (i != _rLocation.end())
{
// do we still have (at least) one level to go than we need a new temporary node
- pNewChild = new Subtree(aNodeName);
+ pNewChild = new Subtree(aNodeName, rtl::OUString(), configuration::Attributes());
pNewChild = static_cast<Subtree*>(pInsertInto->addChild(::std::auto_ptr<INode>(pNewChild)));
pNewChild->setLevel(0); // which means "we know nothing about any children"
}
@@ -799,53 +708,14 @@ namespace configmgr
}
}
-
- std::auto_ptr<TreeChangeList> Tree::mergeSubTree(const ConfigurationName& _rLocation, std::auto_ptr<ISubtree> pSubtree)
- {
- // first look for the subtree
- Subtree* pEntry = m_pRoot;
- for (ConfigurationName::Iterator i = _rLocation.begin(); i != _rLocation.end() && pEntry != NULL; i++)
- pEntry = static_cast<Subtree*>(pEntry->getChild(*i));
-
-#ifdef DEBUG
- ::rtl::OString aStr("Tree: there is no Subtree for name:=");
- aStr += rtl::OUStringToOString(_rLocation.fullName(), RTL_TEXTENCODING_ASCII_US);
- OSL_ENSHURE(pEntry, aStr.getStr());
-#endif
- if (pEntry)
- {
- std::auto_ptr<TreeChangeList> pChangeList(new TreeChangeList(_rLocation.getParentName().fullName(), _rLocation.localName()));
- // now fill the change list
- OBuildChangeTree aTreeChange(pChangeList->root, pEntry);
- aTreeChange.applyToChildren(*pSubtree.get());
-
- // now count if there are any changes
- OChangeCounter aCounter;
- pChangeList->root.dispatch(aCounter);
-
- if (aCounter.nCount == 0)
- pChangeList.reset();
- else
- {
- TreeUpdate aTreeUpdate(pEntry);
- pChangeList->root.forEachChange(aTreeUpdate);
- }
- return pChangeList;
-
- }
- else
- return std::auto_ptr<TreeChangeList>(0);
- }
-
-
- void Tree::updateTree( TreeChangeList& aTree) throw (lang::WrappedTargetException, uno::RuntimeException)
+ void Tree::updateTree( TreeChangeList& aTree, const vos::ORef<OOptions>& _xOptions) throw (lang::WrappedTargetException, uno::RuntimeException)
{
ConfigurationName aSubtreeName(aTree.pathToRoot, aTree.root.getNodeName());
ISubtree *pSubtree = NULL;
try
{
// request the subtree, atleast one level must exist!
- pSubtree = requestSubtree(aSubtreeName.fullName(), 1);
+ pSubtree = requestSubtree(aSubtreeName.fullName(), _xOptions, 1);
}
catch(container::NoSuchElementException&e)
{
diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx
index 60bb59eff546..dbe3f960fabb 100644
--- a/configmgr/source/tree/cmtreemodel.cxx
+++ b/configmgr/source/tree/cmtreemodel.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtreemodel.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: dg $ $Date: 2000-11-23 12:05:58 $
+ * last change: $Author: dg $ $Date: 2000-11-30 08:31:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -287,11 +287,8 @@ bool operator==(SubtreeChange::ChildIterator const& lhs, SubtreeChange::ChildIte
//==========================================================================
//--------------------------------------------------------------------------
SubtreeChangeReferrer::SubtreeChangeReferrer(const SubtreeChange& _rSource)
- :SubtreeChange(_rSource.getNodeName())
+ :SubtreeChange(_rSource, SubtreeChange::NoChildCopy())
{
- // don't forget the template name
- setChildTemplateName(_rSource.getChildTemplateName());
-
ChildIterator aSourceChildren = _rSource.begin();
while (aSourceChildren != _rSource.end())
{
diff --git a/configmgr/source/tree/treeactions.cxx b/configmgr/source/tree/treeactions.cxx
index 35a9b3826523..f526c49af3b0 100644
--- a/configmgr/source/tree/treeactions.cxx
+++ b/configmgr/source/tree/treeactions.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeactions.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: lla $ $Date: 2000-11-29 13:59:53 $
+ * last change: $Author: dg $ $Date: 2000-11-30 08:31:49 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -127,7 +127,7 @@ void OMergeTreeAction::handle(ValueChange& _rChange)
}
else
{
- ValueNode* pNode = new ValueNode(_rChange.getNodeName(), _rChange.getNewValue());
+ ValueNode* pNode = new ValueNode(_rChange.getNodeName(), _rChange.getNewValue(), _rChange.getAttributes());
// add the tree to the change list
AddNode* pChange = new AddNode(auto_ptr<INode>(pNode),_rChange.getNodeName());
@@ -152,8 +152,7 @@ void OMergeTreeAction::handle(SubtreeChange& _rChange)
if (pSubTree)
{
// generate a new change
- SubtreeChange* pChange = new SubtreeChange(_rChange.getNodeName());
- pChange->setChildTemplateName(_rChange.getChildTemplateName());
+ SubtreeChange* pChange = new SubtreeChange(_rChange, SubtreeChange::NoChildCopy());
OMergeTreeAction aNextLevel(*pChange, pSubTree);
_rChange.forEachChange(aNextLevel);
@@ -171,8 +170,7 @@ void OMergeTreeAction::handle(SubtreeChange& _rChange)
// otherwise we have to create the node
else
{
- Subtree* pNode = new Subtree(_rChange.getNodeName());
- pNode->setChildTemplateName(_rChange.getChildTemplateName());
+ Subtree* pNode = new Subtree(_rChange.getNodeName(), _rChange.getChildTemplateName(), _rChange.getAttributes());
// add the subnodes
OCreateSubtreeAction aNextLevel(pNode);
@@ -228,6 +226,7 @@ void OMergeTreeAction::handle(AddNode& _rChange)
{
ValueChange* pChange = new ValueChange(_rChange.getNodeName(),
pNewValueNode->getValue(),
+ pNewValueNode->getAttributes(),
ValueChange::changeValue,
pValueNode->getValue());
m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
@@ -242,6 +241,27 @@ void OMergeTreeAction::handle(AddNode& _rChange)
}
//==========================================================================
+//= OChangeCounter
+//==========================================================================
+void OChangeCounter::handle(ValueChange const& aValueNode)
+{
+ ++nCount;
+}
+
+void OChangeCounter::handle(AddNode const& aAddNode)
+{
+ ++nCount;
+}
+
+void OChangeCounter::handle(RemoveNode const& aRemoveNode)
+{
+ ++nCount;
+}
+
+void OChangeCounter::handle(SubtreeChange const& aSubtree) { applyToChildren(aSubtree); }
+
+
+//==========================================================================
//= OCreateSubtreeAction
//==========================================================================
void OCreateSubtreeAction::ensure()
@@ -260,7 +280,7 @@ void OCreateSubtreeAction::handle(ValueChange& _rChange)
ensure();
// create a node by a ValueChange
- ValueNode* pNode = new ValueNode(_rChange.getNodeName(), _rChange.getNewValue());
+ ValueNode* pNode = new ValueNode(_rChange.getNodeName(), _rChange.getNewValue(), _rChange.getAttributes());
m_pTree->addChild(std::auto_ptr<INode>(pNode));
}
@@ -270,8 +290,7 @@ void OCreateSubtreeAction::handle(SubtreeChange& _rChange)
ensure();
// create a node by a ValueChange
- Subtree* pNode = new Subtree(_rChange.getNodeName());
- pNode->setChildTemplateName(_rChange.getChildTemplateName());
+ Subtree* pNode = new Subtree(_rChange.getNodeName(), _rChange.getChildTemplateName(), _rChange.getAttributes());
// add it to the tree
m_pTree->addChild(auto_ptr<INode>(pNode));