summaryrefslogtreecommitdiff
path: root/configmgr/source
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-07-05 16:05:51 +0000
committerJörg Barfurth <jb@openoffice.org>2001-07-05 16:05:51 +0000
commit7187b23ccdb0b75119edadf3b2db7953f85055d9 (patch)
treeaf34144221557f77011cfb523f513220a83ea16a /configmgr/source
parent8c55d81ec9612a9b949549c5d7dbe64f5fc5d63d (diff)
#87904# New path format; Adjusted Name and Path Handling
Diffstat (limited to 'configmgr/source')
-rw-r--r--configmgr/source/api/confeventhelpers.cxx259
-rw-r--r--configmgr/source/api/confeventhelpers.hxx50
-rw-r--r--configmgr/source/api/confevents.cxx18
-rw-r--r--configmgr/source/api2/accessimpl.cxx205
-rw-r--r--configmgr/source/api2/accessimpl.hxx14
-rw-r--r--configmgr/source/api2/apinodeaccess.cxx6
-rw-r--r--configmgr/source/api2/apinotifierimpl.cxx24
-rw-r--r--configmgr/source/api2/apitreeimplobj.cxx211
-rw-r--r--configmgr/source/api2/apitreeimplobj.hxx15
-rw-r--r--configmgr/source/api2/committer.cxx8
-rw-r--r--configmgr/source/api2/confprovider2.cxx10
-rw-r--r--configmgr/source/api2/confproviderimpl2.cxx58
-rw-r--r--configmgr/source/api2/elementimpl.cxx35
-rw-r--r--configmgr/source/api2/propertyinfohelper.cxx11
-rw-r--r--configmgr/source/api2/propsetaccessimpl.cxx89
-rw-r--r--configmgr/source/api2/providerimpl.cxx155
-rw-r--r--configmgr/source/api2/providerimpl.hxx22
-rw-r--r--configmgr/source/api2/setaccess.cxx12
-rw-r--r--configmgr/source/api2/translatechanges.cxx70
-rw-r--r--configmgr/source/api2/updateimpl.cxx57
-rw-r--r--configmgr/source/inc/anynoderef.hxx31
-rw-r--r--configmgr/source/inc/apitypes.hxx19
-rw-r--r--configmgr/source/inc/change.hxx5
-rw-r--r--configmgr/source/inc/confevents.hxx26
-rw-r--r--configmgr/source/inc/configpath.hxx665
-rw-r--r--configmgr/source/inc/configset.hxx18
-rw-r--r--configmgr/source/inc/mergechange.hxx84
-rw-r--r--configmgr/source/inc/namecreator.hxx127
-rw-r--r--configmgr/source/inc/noderef.hxx125
-rw-r--r--configmgr/source/inc/roottree.hxx8
-rw-r--r--configmgr/source/inc/template.hxx6
-rw-r--r--configmgr/source/inc/treechangelist.hxx212
-rw-r--r--configmgr/source/inc/treeprovider.hxx147
-rw-r--r--configmgr/source/misc/anypair.cxx11
-rw-r--r--configmgr/source/misc/mergechange.cxx612
-rw-r--r--configmgr/source/registry/cfgregistrykey.cxx270
-rw-r--r--configmgr/source/registry/cfgregistrykey.hxx13
-rw-r--r--configmgr/source/tree/changes.cxx29
-rw-r--r--configmgr/source/tree/cmtree.cxx57
-rw-r--r--configmgr/source/tree/cmtreemodel.cxx37
-rw-r--r--configmgr/source/tree/treeactions.cxx9
-rw-r--r--configmgr/source/treecache/invalidatetree.cxx107
-rw-r--r--configmgr/source/treemgr/collectchanges.cxx36
-rw-r--r--configmgr/source/treemgr/collectchanges.hxx9
-rw-r--r--configmgr/source/treemgr/configpath.cxx1085
-rw-r--r--configmgr/source/treemgr/configset.cxx54
-rw-r--r--configmgr/source/treemgr/nodechangeimpl.cxx22
-rw-r--r--configmgr/source/treemgr/nodechangeimpl.hxx23
-rw-r--r--configmgr/source/treemgr/nodechangeinfo.cxx8
-rw-r--r--configmgr/source/treemgr/nodeimpl.cxx12
-rw-r--r--configmgr/source/treemgr/nodeimplobj.cxx24
-rw-r--r--configmgr/source/treemgr/noderef.cxx361
-rw-r--r--configmgr/source/treemgr/roottree.cxx44
-rw-r--r--configmgr/source/treemgr/roottreeimpl.hxx12
-rw-r--r--configmgr/source/treemgr/setnodeimpl.cxx24
-rw-r--r--configmgr/source/treemgr/template.cxx8
-rw-r--r--configmgr/source/treemgr/templateimpl.cxx16
-rw-r--r--configmgr/source/treemgr/templateimpl.hxx44
-rw-r--r--configmgr/source/treemgr/treeimpl.cxx129
-rw-r--r--configmgr/source/treemgr/treeimpl.hxx39
-rw-r--r--configmgr/source/treemgr/valuemembernode.cxx6
61 files changed, 3569 insertions, 2334 deletions
diff --git a/configmgr/source/api/confeventhelpers.cxx b/configmgr/source/api/confeventhelpers.cxx
index ca532eed5616..e8028b83645f 100644
--- a/configmgr/source/api/confeventhelpers.cxx
+++ b/configmgr/source/api/confeventhelpers.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confeventhelpers.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jl $ $Date: 2001-03-21 12:06:54 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,14 +62,28 @@
#include <stdio.h>
#include "confeventhelpers.hxx"
-#ifndef CONFIGMGR_CONFNAME_HXX_
-#include "confname.hxx"
+#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX
+#include "namecreator.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
+#include "configexcept.hxx"
+#endif
+#ifndef CONFIGMGR_CHANGE_HXX
+#include "change.hxx"
+#endif
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#include "treechangelist.hxx"
#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
+#ifndef INCLUDED_ALGORITHM
+#include <algorithm>
+#define INCLUDED_ALGORITHM
+#endif
+
namespace configmgr
{
namespace internal
@@ -81,59 +95,10 @@ namespace configmgr
}
////////////////////////////////////////////////////////////////////////
-/* template <class Listener>
- class BroadcastImplHelper
- {
- public:
- osl::Mutex m_aMutex;
-
- BroadcastImplHelper() {}
- ~BroadcastImplHelper() {}
-
- typedef std::set<Listener*> Interfaces;
- typedef Interfaces::const_iterator Iterator;
-
- void addInterface(Listener* aListener) { m_aInterfaces.insert(aListener); }
- void removeInterface(Listener* aListener) { m_aInterfaces.erase(aListener); }
-
- void disposing(ConfigChangeBroadcaster* pSource);
-
- Iterator begin() const { return m_aInterfaces.begin(); }
- Iterator end() const { return m_aInterfaces.end(); }
- private:
- Interfaces m_aInterfaces;
-
- // no implementation - not copyable
- BroadcastImplHelper(BroadcastImplHelper&);
- void operator=(BroadcastImplHelper&);
- };
-*/
+ using namespace configuration;
+ namespace Path = configuration::Path;
/////////////////////////////////////////////////////////////////////////
-/*
- struct NodeListenerInfo
- {
- INodeListener* m_pListener;
- OUString m_path;
-
- // fake a pointer for generic clients
- INodeListener* operator->() const { return m_pListener; }
- INodeListener& operator*() const { return *m_pListener; }
-
- bool operator < (NodeListenerInfo const& aInfo) const;
- };
-*/
-/////////////////////////////////////////////////////////////////////////
-
-/*
- class ConfigChangesBroadcasterImpl
- {
- private:
- typedef BroadcastImplHelper<NodeListenerInfo> Listeners;
- Listeners m_aListeners;
- std::map<OUString, Listeners::Iterator> m_aDispatchInfos;
- };
-*/
/////////////////////////////////////////////////////////////////////////
ConfigChangesBroadcasterImpl::ConfigChangesBroadcasterImpl()
{
@@ -147,10 +112,8 @@ ConfigChangesBroadcasterImpl::~ConfigChangesBroadcasterImpl()
}
/////////////////////////////////////////////////////////////////////////
-void ConfigChangesBroadcasterImpl::add(OUString const& aName, INodeListenerRef const& pListener)
+void ConfigChangesBroadcasterImpl::add(AbsolutePath const& aName, INodeListenerRef const& pListener)
{
- OSL_ASSERT( ! ConfigurationName(aName).isRelative() );
-
osl::MutexGuard aGuard(m_aListeners.mutex);
InfoRef aAdded = m_aListeners.addListener(NodeListenerInfo(pListener));
@@ -188,78 +151,46 @@ void ConfigChangesBroadcasterImpl::remove(INodeListenerRef const& pListener)
m_aListeners.removeListener(pListener);
}
}
-/*
-void ConfigChangesBroadcasterImpl::removed(OUString const& aBasePath, bool bRemovedFromModel, IConfigBroadcaster* pSource)
-{
- OSL_ASSERT( ! ConfigurationName(aBasePath).isRelative() );
-
- // Dispatch 'deleted' to descendants of the changed path
-
- for( PathMap::const_iterator it = m_aPathMap.lower_bound(aBasePath);
- it != m_aPathMap.end() && 0 == aBasePath.compareTo(it->first, aBasePath.getLength());
- )
- {
- OSL_ASSERT( m_aListeners.find(it->second->get()) != m_aListeners.end() );
-
- OUString aDispatchPath = it->first;
- OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
-
- INodeListenerRef pTarget = it->second->get();
- ++it;
-
- // we allow a listener to remove itself from within the callback
- // the simple increment above wont work, if the following listener is the same listener
- // (which really shouldn't happen)
- PathMap::const_iterator next = it;
- while (next != m_aPathMap.end() && next->second->get() == pTarget)
- ++next;
-
- pTarget->nodeDeleted(aBasePath, pSource);
-
- // if a listener removes itself from within the callback, it will be missing by now
- // so we check whether our listener is still there and if necessary patch our position
- if (m_aListeners.find(pTarget) == m_aListeners.end())
- it = next;
- }
-}
-*/
/////////////////////////////////////////////////////////////////////////
// This should actually be available from the TreeChangeList
/////////////////////////////////////////////////////////////////////////
-static Change const* resolvePath(Change const* pChange, ConfigurationName& aRelativePath, RemoveNode const*& pRemoveNode)
+static Change const* resolvePath(Change const& rChange, RelativePath& aRelativePath, RemoveNode const*& pRemoveNode)
{
- OSL_ASSERT(aRelativePath.isRelative());
- OSL_ASSERT(pRemoveNode == 0);
- pRemoveNode = 0;
+ OSL_ASSERT(pRemoveNode == NULL);
+ pRemoveNode = NULL;
- ConfigurationName::Iterator aIter(aRelativePath.begin());
- ConfigurationName::Iterator const aEnd(aRelativePath.end());
+ Change const* pChange = &rChange;
+ if (rChange.ISA(RemoveNode))
+ pRemoveNode = static_cast<RemoveNode const*>(pChange);
- OSL_ASSERT(pChange);
- OSL_ASSERT(aIter != aEnd);
+ RelativePath::Iterator const aEnd(aRelativePath.end());
- while (pChange)
+ for( RelativePath::Iterator aIter = aRelativePath.begin();
+ aIter != aEnd;
+ ++aIter)
{
- if (pChange->ISA(RemoveNode))
- pRemoveNode = static_cast<RemoveNode const*>(pChange);
+ OSL_ASSERT( pChange != NULL );
- OSL_ASSERT(*aIter == pChange->getNodeName());
- if (++aIter == aEnd)
- break; // found it
+ pChange = pChange->getSubChange(aIter->getName().toString());
- pChange = pChange->getSubChange(*aIter);
+ if (pChange == NULL) break;
- OSL_ASSERT(pRemoveNode == NULL || pChange == NULL);
+ OSL_ASSERT(pRemoveNode == NULL);
+ OSL_ASSERT(aIter->getName().toString() == pChange->getNodeName());
+
+ if (pChange->ISA(RemoveNode))
+ pRemoveNode = static_cast<RemoveNode const*>(pChange);
}
+
if (pRemoveNode)
{
- aRelativePath = ConfigurationName(aRelativePath.begin(),aIter);
- OSL_ASSERT( aRelativePath.localName() == pRemoveNode->getNodeName());
+ aRelativePath = RelativePath( Path::Rep(aRelativePath.begin(),aIter) );
+ OSL_ASSERT( aRelativePath.getLocalName().getName().toString() == pRemoveNode->getNodeName());
}
else
- OSL_ASSERT(pChange == 0 || aRelativePath == ConfigurationName(aRelativePath.begin(),aIter));
+ OSL_ASSERT( pChange == 0 || configuration::matches(aRelativePath, RelativePath( Path::Rep(aRelativePath.begin(),aIter) )) );
return pChange;
}
@@ -268,30 +199,36 @@ static Change const* resolvePath(Change const* pChange, ConfigurationName& aRela
void ConfigChangesBroadcasterImpl::dispatchInner
(
INodeListenerRef const& pTarget,
- OUString const& sTargetPath,
+ AbsolutePath const& _aTargetPath,
Change const& rBaseChange,
- OUString const& sChangeContext,
+ AbsolutePath const& _aChangeLocation,
sal_Bool , //_bError,
IConfigBroadcaster* pSource
)
{
- ConfigurationName aContext(sChangeContext);
+ using namespace configuration;
+ try
+ {
+ OSL_ASSERT(pTarget.isValid());
+ OSL_ASSERT( Path::hasPrefix( _aTargetPath, _aChangeLocation ) );
- OSL_ASSERT(pTarget.isValid());
- OSL_ASSERT( ConfigurationName(sTargetPath).isNestedIn( aContext ) );
+ RelativePath aLocalPath = Path::stripPrefix( _aTargetPath, _aChangeLocation );
- ConfigurationName aLocalPath = ConfigurationName(sTargetPath).relativeTo( aContext );
- RemoveNode const* pRemoved = 0;
- Change const* pTargetChange = resolvePath(&rBaseChange, aLocalPath, pRemoved );
+ RemoveNode const* pRemoved = 0;
+ Change const* pTargetChange = resolvePath(rBaseChange, aLocalPath, pRemoved );
+
+ OSL_ASSERT( !pTargetChange || matches(_aChangeLocation.compose(aLocalPath),_aTargetPath) );
+
+ if (pRemoved)
+ pTarget->nodeDeleted(_aChangeLocation.compose(aLocalPath), pSource);
+
+ else if (pTargetChange)
+ pTarget->nodeChanged(*pTargetChange, _aTargetPath, pSource);
- if (pRemoved)
- {
- pTarget->nodeDeleted(aContext.composeWith(aLocalPath).fullName(), pSource);
}
- else if (pTargetChange)
+ catch (InvalidName& )
{
- OSL_ASSERT(aContext.composeWith(aLocalPath) == sTargetPath);
- pTarget->nodeChanged(*pTargetChange, sTargetPath, pSource);
+ OSL_ENSURE(false,"ConfigChangesBroadcasterImpl: Could not dispatch notification: context path mismatch");
}
}
@@ -299,33 +236,34 @@ void ConfigChangesBroadcasterImpl::dispatchInner
void ConfigChangesBroadcasterImpl::dispatchOuter
(
INodeListenerRef const& pTarget,
- OUString const& sTargetPath,
+ AbsolutePath const& _aTargetPath,
Change const& rBaseChange,
- OUString const& sChangeContext,
+ AbsolutePath const& _aChangeLocation,
sal_Bool , //_bError,
IConfigBroadcaster* pSource
)
{
- ConfigurationName sChangesRoot(sChangeContext,rBaseChange.getNodeName());
-
OSL_ASSERT(pTarget.isValid());
- OSL_ASSERT( sChangesRoot.isNestedIn( sTargetPath ) );
+ OSL_ASSERT( Path::hasPrefix( _aChangeLocation, _aTargetPath) );
- pTarget->nodeChanged(rBaseChange, sChangesRoot.fullName(), pSource);
+ pTarget->nodeChanged(rBaseChange, _aChangeLocation, pSource);
}
/////////////////////////////////////////////////////////////////////////
void ConfigChangesBroadcasterImpl::dispatch(TreeChangeList const& rList_, sal_Bool _bError, IConfigBroadcaster* pSource)
{
- dispatch(rList_.root, rList_.pathToRoot.fullName(),_bError, pSource);
+ dispatch(rList_.root, rList_.getRootNodePath(),_bError, pSource);
}
/////////////////////////////////////////////////////////////////////////
namespace
{
struct DispatchTarget
{
- INodeListenerRef pTarget;
- OUString sDispatchPath;
+ DispatchTarget(INodeListenerRef _pTarget, AbsolutePath const* _pDispatchPath)
+ : pTarget(_pTarget), pDispatchPath( _pDispatchPath) {}
+
+ INodeListenerRef pTarget;
+ AbsolutePath const* pDispatchPath;
};
typedef std::vector<DispatchTarget> DispatchTargets;
}
@@ -333,48 +271,36 @@ namespace
void ConfigChangesBroadcasterImpl::dispatch
(
Change const& rBaseChange,
- OUString const& sChangeContext,
+ AbsolutePath const& _aChangeLocation,
sal_Bool _bError,
IConfigBroadcaster* pSource
)
{
- // listeners registered under multiple sub-pathes will be called multiple times !
-
- ConfigurationName aRootName(sChangeContext);
- OSL_ASSERT(!aRootName.isRelative());
+ OSL_ENSURE(!_aChangeLocation.isRoot(),"Cannot dispatch changes directly to the root node");
- ConfigurationName aNodeName(aRootName, rBaseChange.getNodeName());
- OUString aBasePath( aNodeName.fullName() );
- OSL_ASSERT(!aNodeName.isRelative());
-
- OSL_ASSERT(aNodeName.getParentName() == aRootName);
+ // listeners registered under multiple sub-pathes will be called multiple times !
// Collect the targets
osl::ClearableMutexGuard aGuard(m_aListeners.mutex);
// Dispatch listeners to ancestors of the change root
DispatchTargets aOuterTargets;
+ if (_aChangeLocation.getDepth() > 1)
{
+ AbsolutePath const aModulePath( Path::Rep(*_aChangeLocation.begin()) );
- PathMap::const_iterator itOuter = m_aPathMap.lower_bound( ConfigurationName::rootname() += aRootName.moduleName() );
- PathMap::const_iterator const endOuter = m_aPathMap.upper_bound(aRootName.fullName());
+ PathMap::const_iterator itOuter = m_aPathMap.lower_bound( aModulePath );
+ PathMap::const_iterator const endOuter = m_aPathMap.upper_bound(_aChangeLocation.getParentPath());
// TODO: Both loops are so similar - they should be a single function
while (itOuter != endOuter)
{
OSL_ASSERT( m_aListeners.find(itOuter->second->get()) != m_aListeners.end() );
- OUString aDispatchPath = itOuter->first;
- OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
-
// check whether this should be dispatched at all
- if (aBasePath == aDispatchPath || aNodeName.isNestedIn(aDispatchPath))
+ if ( Path::hasPrefix(_aChangeLocation,itOuter->first) )
{
- DispatchTarget aTarget;
- aTarget.sDispatchPath = aDispatchPath;
- aTarget.pTarget = itOuter->second->get();
-
- aOuterTargets.push_back(aTarget);
+ aOuterTargets.push_back( DispatchTarget(itOuter->second->get(), &itOuter->first) );
}
++itOuter;
}
@@ -383,25 +309,14 @@ void ConfigChangesBroadcasterImpl::dispatch
// Dispatch listeners to descendants of the change root
DispatchTargets aInnerTargets;
{
- PathMap::const_iterator itInner = m_aPathMap.lower_bound(aBasePath);
+ PathMap::const_iterator itInner = m_aPathMap.lower_bound(_aChangeLocation);
- while( itInner != m_aPathMap.end() &&
- 0 == aBasePath.compareTo(itInner->first, aBasePath.getLength()))
+ while( itInner != m_aPathMap.end() && Path::hasPrefix(itInner->first,_aChangeLocation) )
{
OSL_ASSERT( m_aListeners.find(itInner->second->get()) != m_aListeners.end() );
- OUString aDispatchPath = itInner->first;
- OSL_ASSERT( ! ConfigurationName(aDispatchPath).isRelative() );
+ aInnerTargets.push_back( DispatchTarget(itInner->second->get(), &itInner->first) );
- // check whether this should be dispatched at all
- if (aBasePath == aDispatchPath || ConfigurationName(aDispatchPath).isNestedIn(aRootName))
- {
- DispatchTarget aTarget;
- aTarget.sDispatchPath = aDispatchPath;
- aTarget.pTarget = itInner->second->get();
-
- aInnerTargets.push_back(aTarget);
- }
++itInner;
}
}
@@ -409,10 +324,10 @@ void ConfigChangesBroadcasterImpl::dispatch
aGuard.clear();
{for (DispatchTargets::const_iterator it = aOuterTargets.begin(); it != aOuterTargets.end(); ++it){
- this->dispatchOuter(it->pTarget, it->sDispatchPath, rBaseChange, sChangeContext, _bError, pSource);
+ this->dispatchOuter(it->pTarget, *it->pDispatchPath, rBaseChange, _aChangeLocation, _bError, pSource);
}}
{for (DispatchTargets::const_iterator it = aInnerTargets.begin(); it != aInnerTargets.end(); ++it){
- this->dispatchInner(it->pTarget, it->sDispatchPath, rBaseChange, sChangeContext, _bError, pSource);
+ this->dispatchInner(it->pTarget, *it->pDispatchPath, rBaseChange, _aChangeLocation, _bError, pSource);
}}
}
diff --git a/configmgr/source/api/confeventhelpers.hxx b/configmgr/source/api/confeventhelpers.hxx
index 881c638400c5..a955c24fe247 100644
--- a/configmgr/source/api/confeventhelpers.hxx
+++ b/configmgr/source/api/confeventhelpers.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confeventhelpers.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jl $ $Date: 2001-03-21 12:06:54 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,14 +61,18 @@
#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
#define CONFIGMGR_API_EVENTHELPERS_HXX_
-#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
-#include <com/sun/star/uno/RuntimeException.hpp>
-#endif
-
#ifndef CONFIGMGR_API_EVENTS_HXX_
#include "confevents.hxx"
#endif
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
+#include "configpath.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
+#include <com/sun/star/uno/RuntimeException.hpp>
+#endif
+
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
@@ -76,11 +80,21 @@
#include <osl/mutex.hxx>
#endif
-#ifndef __SGI_STL_MAP
+#ifndef INCLUDED_MAP
#include <map>
+#define INCLUDED_MAP
#endif
-#ifndef __SGI_STL_SET
+#ifndef INCLUDED_FUNCTIONAL
+#include <functional>
+#define INCLUDED_FUNCTIONAL
+#endif
+#ifndef INCLUDED_HASH_SET
+#include <hash_set>
+#define INCLUDED_HASH_SET
+#endif
+#ifndef INCLUDED_SET
#include <set>
+#define INCLUDED_SET
#endif
namespace configmgr
@@ -88,7 +102,7 @@ namespace configmgr
namespace internal
{
-
+ using namespace configuration;
////////////////////////////////////////////////////////////////////////
template <class ListenerRef>
class BroadcastImplHelper
@@ -160,7 +174,7 @@ namespace configmgr
class NodeListenerInfo
{
public:
- typedef std::set<OUString> Pathes;
+ typedef std::hash_set<AbsolutePath, Path::Hash, Path::Equiv> Pathes;
public:
NodeListenerInfo(INodeListenerRef const& pListener)
@@ -171,8 +185,8 @@ namespace configmgr
// path handling
Pathes const& pathList() const { return m_aPathes; }
- void addPath(OUString const& sPath) const { m_aPathes.insert(sPath); }
- void removePath(OUString const& sPath) const { m_aPathes.erase(sPath); }
+ void addPath(AbsolutePath const& sPath) const { m_aPathes.insert(sPath); }
+ void removePath(AbsolutePath const& sPath) const { m_aPathes.erase(sPath); }
//void removeChildPathes(OUString const& sPath);
// behave as pointer for use as a 'reference' class
@@ -201,7 +215,7 @@ namespace configmgr
private:
INodeListenerRef m_pListener;
- mutable Pathes m_aPathes; // hack to be mutable as set element
+ mutable Pathes m_aPathes; // hack to be mutable even as set element
};
class ConfigChangesBroadcasterImpl
{
@@ -209,23 +223,23 @@ namespace configmgr
ConfigChangesBroadcasterImpl();
~ConfigChangesBroadcasterImpl();
- void add(OUString const& aName, INodeListenerRef const& pListener);
+ void add(AbsolutePath const& aPath, INodeListenerRef const& pListener);
void remove(INodeListenerRef const& pListener);
// void removed(OUString const& aPath, bool bRemovedFromModel, IConfigBroadcaster* pSource);
- void dispatch(Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void dispatch(Change const& rBaseChange, AbsolutePath const& sChangeLocation, sal_Bool _bError, IConfigBroadcaster* pSource);
void dispatch(TreeChangeList const& rList_, sal_Bool _bError, IConfigBroadcaster* pSource);
void disposing(IConfigBroadcaster* pSource);
private:
typedef BroadcastImplHelper<NodeListenerInfo> Listeners;
typedef Listeners::FullIterator InfoRef;
- typedef std::multimap<OUString, InfoRef> PathMap;
+ typedef std::multimap<AbsolutePath, InfoRef, Path::Before> PathMap;
Listeners m_aListeners;
PathMap m_aPathMap;
private:
- void dispatchInner(INodeListenerRef const& pTarget, OUString const& sTargetPath, Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
- void dispatchOuter(INodeListenerRef const& pTarget, OUString const& sTargetPath, Change const& rBaseChange, OUString const& sChangeContext, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void dispatchInner(INodeListenerRef const& pTarget, AbsolutePath const& sTargetPath, Change const& rBaseChange, AbsolutePath const& sChangeLocation, sal_Bool _bError, IConfigBroadcaster* pSource);
+ void dispatchOuter(INodeListenerRef const& pTarget, AbsolutePath const& sTargetPath, Change const& rBaseChange, AbsolutePath const& sChangeLocation, sal_Bool _bError, IConfigBroadcaster* pSource);
};
/////////////////////////////////////////////////////////////////////////
diff --git a/configmgr/source/api/confevents.cxx b/configmgr/source/api/confevents.cxx
index 1ababd2dbbd2..82756c024044 100644
--- a/configmgr/source/api/confevents.cxx
+++ b/configmgr/source/api/confevents.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confevents.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2000-12-08 11:19:22 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:43 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,6 +65,10 @@
#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
#include "confeventhelpers.hxx"
#endif
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#include "treechangelist.hxx"
+#endif
+
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
@@ -85,11 +89,9 @@ namespace configmgr
public:
// IConfigBroadcaster implementation helper
- void addListener(OUString const& aName, INodeListenerRef const& );
+ void addListener(AbsolutePath const& aName, INodeListenerRef const& );
void removeListener(INodeListenerRef const&);
-// void removeNode(OUString const& aPath, bool bRemovedFromModel, IConfigBroadcaster* pSource);
-
void dispose(IConfigBroadcaster* pSource);
};
@@ -120,7 +122,7 @@ namespace configmgr
/////////////////////////////////////////////////////////////////////////
// IConfigBroadcaster implementation
- void ConfigChangeBroadcaster::addListener(OUString const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler)
+ void ConfigChangeBroadcaster::addListener(AbsolutePath const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler)
{
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,true))
{
@@ -149,7 +151,7 @@ namespace configmgr
/////////////////////////////////////////////////////////////////////////
void ConfigChangeBroadcaster::fireChanges(TreeChangeList const& rList_, sal_Bool bError_)
{
- if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(rList_.m_xOptions,false))
+ if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(rList_.getOptions(),false))
{
pHelper->broadcast(rList_, bError_, this);
}
@@ -171,7 +173,7 @@ namespace configmgr
}
/////////////////////////////////////////////////////////////////////////
// IConfigBroadcaster implementation help
- void ConfigChangeBroadcastHelper::addListener(OUString const& aName, INodeListenerRef const& pHandler)
+ void ConfigChangeBroadcastHelper::addListener(AbsolutePath const& aName, INodeListenerRef const& pHandler)
{
m_changes.add(aName, pHandler);
}
diff --git a/configmgr/source/api2/accessimpl.cxx b/configmgr/source/api2/accessimpl.cxx
index 16109e8cff45..e9a608e4a029 100644
--- a/configmgr/source/api2/accessimpl.cxx
+++ b/configmgr/source/api2/accessimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessimpl.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,9 +59,8 @@
*
************************************************************************/
#include <stdio.h>
-#ifndef CONFIGMGR_API_BASEACCESSIMPL_HXX_
+
#include "accessimpl.hxx"
-#endif
#ifndef CONFIGMGR_API_NODEACCESS_HXX_
#include "apinodeaccess.hxx"
@@ -87,7 +86,7 @@
#ifndef CONFIGMGR_API_PROPERTYINFOIMPL_HXX_
#include "propertyinfohelper.hxx"
#endif
-#ifndef _CONFIGMGR_TREEITERATORS_HXX_
+#ifndef CONFIGMGR_TREEITERATORS_HXX_
#include "treeiterators.hxx"
#endif
@@ -119,7 +118,6 @@ namespace configmgr
using configuration::Tree;
using configuration::Name;
- using configuration::Path;
using configuration::AbsolutePath;
using configuration::RelativePath;
using configuration::Attributes;
@@ -143,8 +141,7 @@ OUString implGetHierarchicalName( NodeAccess& rNode ) throw(RuntimeException)
Tree aTree( impl->getTree());
- RelativePath const aLocalPath = aTree.getLocalPath(impl->getNode());
- AbsolutePath const aFullPath = aTree.getContextPath().compose(aLocalPath);
+ AbsolutePath const aFullPath = aTree.getAbsolutePath(impl->getNode());
sRet = aFullPath.toString();
}
catch (configuration::Exception& ex)
@@ -158,10 +155,10 @@ OUString implGetHierarchicalName( NodeAccess& rNode ) throw(RuntimeException)
}
//------------------------------------------------------------------------------------------------------------------
-OUString implComposeHierarchicalName(NodeAccess& rNode, const OUString& sRelativeName )
+OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const OUString& sRelativeName )
throw(css::lang::IllegalArgumentException, NoSupportException, RuntimeException)
{
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails there
+ using configuration::validateRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails there
OUString sRet;
try
{
@@ -169,11 +166,47 @@ OUString implComposeHierarchicalName(NodeAccess& rNode, const OUString& sRelativ
NodeRef aNode( impl->getNode() );
Tree aTree( impl->getTree() );
- RelativePath const aAddedPath = reduceRelativePath(sRelativeName, aTree, aNode);
+ RelativePath const aAddedPath = validateRelativePath(sRelativeName, aTree, aNode);
// TODO: add (relative) name validation based on node type - may then need provider lock
- RelativePath const aLocalPath = aTree.getLocalPath(aNode).compose(aAddedPath);
- AbsolutePath const aFullPath = aTree.getContextPath().compose(aLocalPath);
+ AbsolutePath const aFullPath = aTree.getAbsolutePath(aNode).compose(aAddedPath);
+
+ sRet = aFullPath.toString();
+ }
+ catch (configuration::InvalidName& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.illegalArgument(1);
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+
+
+ return sRet;
+}
+
+//------------------------------------------------------------------------------------------------------------------
+OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const OUString& sElementName )
+ throw(css::lang::IllegalArgumentException, NoSupportException, RuntimeException)
+{
+ using configuration::validateElementPathComponent; // should actually be found by "Koenig" lookup, but MSVC6 fails there
+ using configuration::Path::Component;
+ OUString sRet;
+ try
+ {
+ GuardedNodeAccess impl( rNode );
+ NodeRef aNode( impl->getNode() );
+ Tree aTree( impl->getTree() );
+
+ /*Path::*/Component const aAddedName = validateElementPathComponent(sElementName, aTree, aNode);
+
+ // TODO: add (relative) name validation based on node type - may then need provider lock
+ AbsolutePath const aFullPath = aTree.getAbsolutePath(aNode).compose(aAddedName);
sRet = aFullPath.toString();
}
@@ -287,7 +320,7 @@ sal_Bool implHasElements(NodeSetInfoAccess& rNode) throw(RuntimeException)
//------------------------------------------------------------------------------------------------------------------
namespace internal
{
- using configuration::NodeVisitor;
+ using namespace configuration;
struct SearchExactName : private NodeVisitor
{
protected:
@@ -301,11 +334,11 @@ namespace internal
, pSearchComponent(aSearchPath.begin_mutate())
{}
- bool complete() const { return aSearchPath.end() == pSearchComponent; }
+ bool complete() { return aSearchPath.end_mutate() == pSearchComponent; }
bool search(NodeRef const& aNode, Tree const& aTree);
- OUString getBestMatch() const { return aSearchPath.toString(); }
+ RelativePath const& getBestMatch() const { return aSearchPath; }
private:
bool findMatch(NodeRef& aNode, Tree& aTree);
@@ -320,7 +353,7 @@ namespace internal
if ( !aNode.isValid() ) return false;
using configuration::hasChildOrElement;
- using configuration::findInnerChildNode;
+ using configuration::findInnerChildOrAvailableElement;
// exact match ?
if (!hasChildOrElement(aTree,aNode,*pSearchComponent))
@@ -330,12 +363,26 @@ namespace internal
}
OSL_ASSERT(hasChildOrElement(aTree,aNode,*pSearchComponent));
- if (! findInnerChildNode(aTree,aNode,*pSearchComponent++) )
- aNode = NodeRef(); // will stop recursion (value found)
+ if (! findInnerChildOrAvailableElement(aTree,aNode,pSearchComponent->getName()) )
+ aNode = NodeRef(); // will stop recursion (value or unloaded element found)
+ ++pSearchComponent;
return true;
}
//..................................................................................................................
+ // helper
+ static Path::Component getExtendedNodeName(Tree const& aTree, NodeRef const& aNode, Name const& aSimpleNodeName)
+ {
+ OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" );
+ OSL_PRECOND( !aNode.isValid() || aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" );
+
+ if (aTree.isRootNode(aNode))
+ return aTree.getRootName();
+
+ else
+ return Path::wrapSimpleName(aSimpleNodeName);
+ }
+ //..................................................................................................................
NodeVisitor::Result SearchExactName::handle(Tree const& aTree, NodeRef const& aNode)
{
OSL_ASSERT( aNode.isValid() );
@@ -344,9 +391,10 @@ namespace internal
// find inexact match (the first one, but the order is unspecified)
// TODO: Add support for node-type-specific element names
Name aNodeName = aTree.getName(aNode);
- if (aNodeName.toString().equalsIgnoreAsciiCase(pSearchComponent->toString()))
+ Name aSearchName = pSearchComponent->getName();
+ if (aNodeName.toString().equalsIgnoreAsciiCase(aSearchName.toString()))
{
- *pSearchComponent = aNodeName;
+ *pSearchComponent = getExtendedNodeName(aTree,aNode,aNodeName);
return DONE; // for this level
}
else
@@ -361,9 +409,12 @@ namespace internal
// find inexact match (the first one, but the order is unspecified)
// TODO: Add support for node-type-specific element names
Name aNodeName = aTree.getName(aNode);
- if (aNodeName.toString().equalsIgnoreAsciiCase(pSearchComponent->toString()))
+ OSL_ASSERT( isSimpleName(aNodeName) );
+
+ // value refs are group members and thus have to have simple names
+ if (aNodeName.toString().equalsIgnoreAsciiCase(pSearchComponent->getName().toString()))
{
- *pSearchComponent = aNodeName;
+ *pSearchComponent = Path::wrapSimpleName(aNodeName);
return DONE; // for this level
}
else
@@ -387,26 +438,71 @@ namespace internal
} // namespace internal
//..................................................................................................................
-OUString implGetExactName(NodeAccess& rNode, const OUString& rApproximateName ) throw(RuntimeException)
+OUString implGetExactName(NodeGroupInfoAccess& rNode, const OUString& rApproximateName ) throw(RuntimeException)
{
+ // here we try to support both tree-fragment-local pathes and simple names (the latter ones are just an instance of the first)
try
{
using internal::SearchExactName;
- using configuration::reduceRelativePath;
+ using configuration::validateRelativePath;
GuardedNodeDataAccess impl( rNode );
Tree aTree(impl->getTree());
NodeRef aNode(impl->getNode());
- // TODO: (?) handle absolute pathes' prefix part properly:
- RelativePath aApproximatePath = configuration::reduceRelativePath(rApproximateName,aTree,aNode);
+ RelativePath aApproximatePath = validateRelativePath(rApproximateName,aTree,aNode);
SearchExactName aSearch(aApproximatePath);
aSearch.search(aNode, aTree);
- return aSearch.getBestMatch();
+ OSL_ENSURE( aSearch.getBestMatch().getDepth() == aApproximatePath.getDepth(),
+ "Search for exact names changed number of path components !?");
+
+ return aSearch.getBestMatch().toString();
+ }
+ catch (configuration::InvalidName& )
+ {
+ OSL_TRACE("WARNING: Configuration::getExactName: query uses locally invalid Path");
+ return rApproximateName;
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+ // unreachable, but still there to make compiler happy
+ OSL_ASSERT(!"Unreachable code");
+ return rApproximateName;
+}
+
+//..................................................................................................................
+OUString implGetExactName(NodeSetInfoAccess& rNode, const OUString& rApproximateName ) throw(RuntimeException)
+{
+ // here we can support only local names
+ try
+ {
+ using internal::SearchExactName;
+ using configuration::validateElementPathComponent;
+ using configuration::Path::Component;
+
+ GuardedNodeDataAccess impl( rNode );
+
+ Tree aTree(impl->getTree());
+ NodeRef aNode(impl->getNode());
+
+ /*Path::*/Component aApproximateName = validateElementPathComponent(rApproximateName,aTree,aNode);
+
+ SearchExactName aSearch(aApproximateName);
+
+ aSearch.search(aNode, aTree);
+
+ OSL_ENSURE( aSearch.getBestMatch().getDepth() == 1,
+ "Search for exact names changed number of path components !?");
+
+ return aSearch.getBestMatch().getLocalName().getName().toString();
}
catch (configuration::InvalidName& )
{
@@ -472,7 +568,7 @@ sal_Bool implHasByName(NodeAccess& rNode, const OUString& sName ) throw(RuntimeE
{
GuardedNodeDataAccess impl( rNode );
- Name aChildName = configuration::makeName(sName);
+ Name aChildName = configuration::makeName(sName, Name::NoValidate());
return hasChildOrElement(impl->getTree(), impl->getNode(), aChildName);
}
@@ -509,7 +605,7 @@ Any implGetByName(NodeAccess& rNode, const OUString& sName )
Tree aTree( impl->getTree() );
NodeRef aNode( impl->getNode() );
- Name aChildName = configuration::validateNodeName(sName,aTree,aNode);
+ Name aChildName = configuration::validateChildOrElementName(sName,aTree,aNode);
AnyNodeRef aChildNode = getChildOrElement(aTree,aNode, aChildName);
if (!aChildNode.isValid())
@@ -517,7 +613,7 @@ Any implGetByName(NodeAccess& rNode, const OUString& sName )
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Child Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -569,33 +665,6 @@ Sequence< OUString > implGetElementNames( NodeAccess& rNode ) throw( RuntimeExce
// XHierarchicalNameAccess
//-----------------------------------------------------------------------------------
-/*
-// if NULL is returned, aPath may have a Partial path appended
-NodeRef findDescendant(RelativePath const& aRelativePath, TreePath& aPath)
-{
- checkInitialized();
-
- ConfigurationName aName( aRelativePath );
- if (!normalizeNestedPath(aName))
- return 0;
-
- ConfigurationName::Iterator it = aName.begin();
- ConfigurationName::Iterator const stop = aName.end();
-
- for(TreeRef pTree = m_aSubtree; pTree != 0; )
- {
- NodeRef pFound = pTree->getChild(*it);
- aPath.push_back(pTree);
-
- if (++it == stop || !pFound)
- return pFound;
-
- pTree = pFound->asISubtree();
- }
-
- return 0;
-}
-*/
//-----------------------------------------------------------------------------------
// TO DO: optimization - cache the node found for subsequent getByHierarchicalName()
@@ -603,8 +672,8 @@ NodeRef findDescendant(RelativePath const& aRelativePath, TreePath& aPath)
sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const OUString& sHierarchicalName ) throw(RuntimeException)
{
using namespace com::sun::star::container;
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateAndReducePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getDeepDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
try
{
GuardedNodeDataAccess impl( rNode );
@@ -612,9 +681,9 @@ sal_Bool implHasByHierarchicalName(NodeAccess& rNode, const OUString& sHierarchi
Tree aTree( impl->getTree() );
NodeRef aNode( impl->getNode() );
- RelativePath aRelPath = reduceRelativePath( sHierarchicalName, aTree, aNode );
+ RelativePath aRelPath = validateAndReducePath( sHierarchicalName, aTree, aNode );
- return getDescendant(aTree, aNode, aRelPath).isValid();
+ return getDeepDescendant(aTree, aNode, aRelPath).isValid();
}
catch (configuration::InvalidName& )
{
@@ -637,8 +706,8 @@ Any implGetByHierarchicalName(NodeAccess& rNode, const OUString& sHierarchicalNa
throw(css::container::NoSuchElementException, RuntimeException)
{
using namespace com::sun::star::container;
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateAndReducePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getDeepDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
try
{
GuardedNodeDataAccess impl( rNode );
@@ -646,15 +715,15 @@ Any implGetByHierarchicalName(NodeAccess& rNode, const OUString& sHierarchicalNa
Tree aTree( impl->getTree() );
NodeRef aNode( impl->getNode() );
- RelativePath aRelPath = reduceRelativePath( sHierarchicalName, aTree, aNode );
+ RelativePath aRelPath = validateAndReducePath( sHierarchicalName, aTree, aNode );
- AnyNodeRef aNestedNode = getDescendant( aTree, aNode, aRelPath );
+ AnyNodeRef aNestedNode = getDeepDescendant( aTree, aNode, aRelPath );
if (!aNestedNode.isValid())
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Descendant Element '") );
sMessage += aRelPath.toString();
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Node ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( impl->getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -691,7 +760,7 @@ OUString SAL_CALL implGetElementTemplateName(NodeSetInfoAccess& rNode)
throw(uno::RuntimeException)
{
GuardedNode<NodeSetInfoAccess> impl(rNode);
- return impl->getElementInfo().getTemplatePath().toString();
+ return impl->getElementInfo().getTemplatePathString();
}
// XStringEscape
diff --git a/configmgr/source/api2/accessimpl.hxx b/configmgr/source/api2/accessimpl.hxx
index cbe6754a529d..9b87dc8ee7cd 100644
--- a/configmgr/source/api2/accessimpl.hxx
+++ b/configmgr/source/api2/accessimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessimpl.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -110,7 +110,10 @@ namespace configmgr
OUString implGetHierarchicalName(NodeAccess& rNode)
throw(uno::RuntimeException);
- OUString implComposeHierarchicalName(NodeAccess& rNode, const OUString& aRelativeName )
+ OUString implComposeHierarchicalName(NodeGroupInfoAccess& rNode, const OUString& aRelativeName )
+ throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException);
+
+ OUString implComposeHierarchicalName(NodeSetInfoAccess& rNode, const OUString& aRelativeName )
throw(css::lang::IllegalArgumentException, css::lang::NoSupportException, uno::RuntimeException);
// XElementAccess, base class of XNameAccess
@@ -144,7 +147,10 @@ namespace configmgr
throw(uno::RuntimeException);
// XExactName
- OUString implGetExactName(NodeAccess& rNode, const OUString& aApproximateName )
+ OUString implGetExactName(NodeGroupInfoAccess& rNode, const OUString& aApproximateName )
+ throw(uno::RuntimeException);
+
+ OUString implGetExactName(NodeSetInfoAccess& rNode, const OUString& aApproximateName )
throw(uno::RuntimeException);
// XProperty
diff --git a/configmgr/source/api2/apinodeaccess.cxx b/configmgr/source/api2/apinodeaccess.cxx
index a418e1bcba02..0059e1cb03eb 100644
--- a/configmgr/source/api2/apinodeaccess.cxx
+++ b/configmgr/source/api2/apinodeaccess.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apinodeaccess.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -204,7 +204,7 @@ configuration::ElementTree extractElementTree(configapi::Factory& rFactory, UnoA
return ElementTree(0);
if (aFoundTemplate != aRequestedTemplate)
- throw configuration::TypeMismatch(aFoundTemplate->getPath().toString(), aRequestedTemplate->getPath().toString());
+ throw configuration::TypeMismatch(aFoundTemplate->getPathString(), aRequestedTemplate->getPathString());
aRet = pSetElement->getElementTree();
}
diff --git a/configmgr/source/api2/apinotifierimpl.cxx b/configmgr/source/api2/apinotifierimpl.cxx
index 35ad7d750d61..437f291aa205 100644
--- a/configmgr/source/api2/apinotifierimpl.cxx
+++ b/configmgr/source/api2/apinotifierimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apinotifierimpl.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,12 +60,22 @@
************************************************************************/
#include "apinotifierimpl.hxx"
-#include "apinodeaccess.hxx"
+#ifndef CONFIGMGR_API_NODEACCESS_HXX_
+#include "apinodeaccess.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGVALUEREF_HXX_
#include "valueref.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "confignotifier.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
#include "configexcept.hxx"
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
@@ -120,7 +130,7 @@ template <class Listener>
inline
bool genericAddChildListener(NodeGroupInfoAccess& rNode, const Reference< Listener >& xListener, const OUString& sName )
{
- using configuration::validateNodeName;
+ using configuration::validateChildName;
if (sName.getLength() != 0)
{
@@ -130,7 +140,7 @@ bool genericAddChildListener(NodeGroupInfoAccess& rNode, const Reference< Listen
Tree aTree( aGuardedNode->getTree() );
NodeRef aNode( aGuardedNode->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateChildName(sName,aTree,aNode);
if (!aTree.hasChild(aNode,aChildName)) return false;
@@ -157,7 +167,7 @@ template <class Listener>
inline
bool genericRemoveChildListener(NodeGroupInfoAccess& rNode, const Reference< Listener >& xListener, const OUString& sName )
{
- using configuration::validateNodeName;
+ using configuration::validateChildName;
if (sName.getLength() != 0)
{
@@ -167,7 +177,7 @@ bool genericRemoveChildListener(NodeGroupInfoAccess& rNode, const Reference< Lis
Tree aTree( aGuardedNode->getTree() );
NodeRef aNode( aGuardedNode->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateChildName(sName,aTree,aNode);
if (!aTree.hasChild(aNode,aChildName)) return false;
diff --git a/configmgr/source/api2/apitreeimplobj.cxx b/configmgr/source/api2/apitreeimplobj.cxx
index a9794d18210f..43e8e7c051e9 100644
--- a/configmgr/source/api2/apitreeimplobj.cxx
+++ b/configmgr/source/api2/apitreeimplobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apitreeimplobj.cxx,v $
*
- * $Revision: 1.27 $
+ * $Revision: 1.28 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,22 +59,52 @@
*
************************************************************************/
#include <stdio.h>
+
#include "apitreeimplobj.hxx"
+
+#ifndef CONFIGMGR_API_PROVIDERIMPL2_HXX_
#include "confproviderimpl2.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "confignotifier.hxx"
+#endif
+#ifndef CONFIGMGR_API_NOTIFIERIMPL_HXX_
#include "notifierimpl.hxx"
+#endif
+#ifndef CONFIGMGR_API_FACTORY_HXX_
#include "apifactory.hxx"
+#endif
+#ifndef CONFIGMGR_API_TREEACCESS_HXX_
#include "apitreeaccess.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
#include "nodechangeinfo.hxx"
+#endif
+#ifndef CONFIGMGR_API_BROADCASTER_HXX_
#include "broadcaster.hxx"
+#endif
+#ifndef CONFIGMGR_CHANGE_HXX
+#include "change.hxx"
+#endif
+#ifndef CONFIGMGR_ROOTTREE_HXX_
#include "roottree.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGANYNODE_HXX_
#include "anynoderef.hxx"
-
+#endif
+#ifndef _CONFIGMGR_TRACER_HXX_
#include "tracer.hxx"
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _VOS_REFERNCE_HXX_
#include <vos/refernce.hxx>
+#endif
namespace configmgr
{
@@ -233,11 +263,12 @@ class ApiRootTreeImpl::NodeListener : public INodeListener
IConfigBroadcaster* pSource;
vos::ORef< OOptions > m_xOptions;
- OUString m_aLocationPath;
+ AbsolutePath m_aLocationPath;
public:
NodeListener(ApiRootTreeImpl& _rParent)
: pParent(&_rParent)
, pSource(NULL)
+ , m_aLocationPath( AbsolutePath::root() )
{}
~NodeListener()
{
@@ -263,14 +294,14 @@ public:
pSource = pNew;
if (pNew)
{
- OSL_ENSURE(m_aLocationPath.getLength() > 0, "Cannot register for notifications: no location set");
+ OSL_ENSURE(!m_aLocationPath.isRoot(), "Cannot register for notifications: no location set");
pNew->addListener(m_aLocationPath, m_xOptions, this);
}
}
}
}
- void setLocation(OUString const& _aLocation, vos::ORef< OOptions > const& _xOptions)
+ void setLocation(AbsolutePath const& _aLocation, vos::ORef< OOptions > const& _xOptions)
{
osl::MutexGuard aGuard(mutex);
@@ -293,7 +324,7 @@ public:
{
pSource->removeListener(m_xOptions, this);
m_xOptions.unbind();
- m_aLocationPath = OUString();
+ m_aLocationPath = AbsolutePath::root();
}
}
@@ -312,7 +343,7 @@ public:
pSource = 0;
m_xOptions.unbind();
- m_aLocationPath = OUString();
+ m_aLocationPath = AbsolutePath::root();
aGuard.clear();
@@ -323,8 +354,8 @@ public:
// Interfaces
virtual void disposing(IConfigBroadcaster* pSource);
- virtual void nodeChanged(Change const& aChange, OUString const& sPath, IConfigBroadcaster* pSource);
- virtual void nodeDeleted(OUString const& sPath, IConfigBroadcaster* pSource);
+ virtual void nodeChanged(Change const& aChange, AbsolutePath const& sPath, IConfigBroadcaster* pSource);
+ virtual void nodeDeleted(AbsolutePath const& sPath, IConfigBroadcaster* pSource);
};
//-------------------------------------------------------------------------
@@ -384,6 +415,7 @@ ApiRootTreeImpl::ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider
: m_aTreeImpl(pInstance, rProvider, aTree, 0)
, m_pNotificationListener(NULL)
, m_xOptions(_xOptions)
+, m_aLocationPath( configuration::Path::Rep() )
{
implSetLocation();
enableNotification(true);
@@ -722,20 +754,19 @@ void ApiRootTreeImpl::implSetLocation()
Tree aTree = getApiTree().getTree();
if (!aTree.isEmpty())
{
- configuration::Name aRootName = aTree.getRootName();
- m_aLocationPath = aTree.getContextPath().compose( configuration::RelativePath(aRootName) ).toString();
+ m_aLocationPath = aTree.getRootPath();
+ OSL_ENSURE(!m_aLocationPath.isRoot(), "Setting up a RootTree without location");
}
else
{
OSL_ENSURE(false, "Setting up a RootTree without data");
- m_aLocationPath = OUString();
+ m_aLocationPath = configuration::AbsolutePath::root();
}
- OSL_ENSURE(m_aLocationPath.getLength() > 0, "Setting up a RootTree without location");
if (!m_pNotificationListener.isValid())
m_pNotificationListener = new NodeListener(*this);
- OSL_ENSURE(m_aLocationPath.getLength() > 0, "Cannot reregister for notifications: setting empty location");
+ OSL_ENSURE(!m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Cannot reregister for notifications: setting empty location");
OSL_ENSURE( m_xOptions.isValid(), "Cannot reregister for notifications: no options available" );
m_pNotificationListener->setLocation(m_aLocationPath, m_xOptions);
@@ -744,18 +775,18 @@ void ApiRootTreeImpl::implSetLocation()
void ApiRootTreeImpl::releaseData()
{
- CFG_TRACE_INFO("Api Root TreeImpl at %s: releasing the Data",OUSTRING2ASCII(m_aLocationPath));
+ CFG_TRACE_INFO("Api Root TreeImpl at %s: releasing the Data",OUSTRING2ASCII(m_aLocationPath.toString()));
Tree aTree( m_aTreeImpl.getTree() );
aTree.disposeData();
OSL_ASSERT(aTree.isEmpty());
- OSL_ENSURE( m_aLocationPath.getLength(), "Location still needed to release data" );
+ OSL_ENSURE( !m_aLocationPath.isRoot() && !m_aLocationPath.isDetached(), "Location still needed to release data" );
OSL_ENSURE( m_xOptions.isValid(), "Options still needed to release data" );
getApiTree().getProvider().getProviderImpl().releaseSubtree(m_aLocationPath,m_xOptions);
m_xOptions.unbind();
- m_aLocationPath = OUString();
+ m_aLocationPath = configuration::AbsolutePath::detachedRoot();
}
// ---------------------------------------------------------------------------------------------------
@@ -777,7 +808,7 @@ void ApiRootTreeImpl::NodeListener::disposing(IConfigBroadcaster* _pSource)
void ApiRootTreeImpl::disposing(IConfigBroadcaster* pSource)
{
CFG_TRACE_INFO("Api Root TreeImpl at %s: Cache data is disposed - dispose and release own data",
- OUSTRING2ASCII(m_aLocationPath));
+ OUSTRING2ASCII(m_aLocationPath.toString()));
// ensure our provider stays alive
UnoInterfaceRef xKeepProvider( m_aTreeImpl.getUnoProviderInstance() );
@@ -840,7 +871,7 @@ void disposeRemovedNodes(configuration::NodeChangesInformation const& aChanges,
}
// ---------------------------------------------------------------------------------------------------
//INodeListener : IConfigListener
-void ApiRootTreeImpl::NodeListener::nodeChanged(Change const& aChange, OUString const& sPath, IConfigBroadcaster* _pSource)
+void ApiRootTreeImpl::NodeListener::nodeChanged(Change const& aChange, AbsolutePath const& sPath, IConfigBroadcaster* _pSource)
{
osl::ClearableMutexGuard aGuard(mutex);
@@ -858,12 +889,12 @@ void ApiRootTreeImpl::NodeListener::nodeChanged(Change const& aChange, OUString
// ---------------------------------------------------------------------------------------------------
//INodeListener : IConfigListener
-void ApiRootTreeImpl::nodeChanged(Change const& aChange, OUString const& sPath, IConfigBroadcaster* pSource)
+void ApiRootTreeImpl::nodeChanged(Change const& aChange, AbsolutePath const& aChangePath, IConfigBroadcaster* pSource)
{
using configuration::AnyNodeRef;
- using configuration::Path;
using configuration::NodeChanges;
using configuration::RelativePath;
+ using configuration::AbsolutePath;
// do not dipatch if we are dying/dead anyway
if (m_aTreeImpl.isAlive())
@@ -873,81 +904,88 @@ void ApiRootTreeImpl::nodeChanged(Change const& aChange, OUString const& sPath,
Tree aTree( m_aTreeImpl.getTree() );
- OSL_ENSURE( Path(sPath, Path::NoValidate()).getType() == configuration::PathType::eABSOLUTE,
- "Unexpected format for 'nodeChanged' Path location - path is not absolute" );
-
- bool bValidNotification = sPath.indexOf(m_aLocationPath) == 0;
- OSL_ENSURE(bValidNotification, "Notified Path does not match this tree's path - ignoring notification");
-
- if (bValidNotification)
- {
- // find the node and change
- NodeRef aNode;
+ OSL_ENSURE(configuration::Path::hasPrefix(aChangePath, m_aLocationPath),
+ "'changed' Path does not indicate this tree or its context: ");
- if (sPath != m_aLocationPath)
- {
- OSL_ASSERT(sPath.getLength() > m_aLocationPath.getLength());
- OSL_ENSURE(sPath[m_aLocationPath.getLength()] == sal_Unicode('/'),
- "'nodeChanged' Path does not respect directory boundaries - erratic notification");
+ RelativePath aLocalChangePath = configuration::Path::stripPrefix(aChangePath,m_aLocationPath);
- OSL_ENSURE(sPath.getLength() > m_aLocationPath.getLength()+1, "Unexpected path format: slash terminated");
+ // find the node and change
+ NodeRef aNode;
- NodeRef aBaseNode = aTree.getRootNode();
+ if ( !aLocalChangePath.isEmpty() )
+ {
+ NodeRef aBaseNode = aTree.getRootNode();
- RelativePath aLocalConfigPath = configuration::reduceRelativePath(sPath, aTree, aBaseNode);
+#ifdef DBG_UTIL
+ try {
+ RelativePath aLocalPathOld = configuration::validateAndReducePath(aChangePath.toString(), aTree, aBaseNode);
+ OSL_ENSURE( configuration::matches(aLocalPathOld,aLocalChangePath),
+ "New local path different from validateAndReducePath(...) result in notification dispatch");
+ }
+ catch (configuration::Exception& e) {
+ rtl::OString sMsg("Cannot validate new path handling for notification dispatch: ");
+ sMsg += e.what();
+ OSL_ENSURE(false, sMsg.getStr() );
+ }
+#endif // DBG_UTIL
- AnyNodeRef aFoundNode = configuration::getDescendant(aTree, aBaseNode, aLocalConfigPath);
- if ( aFoundNode.isValid() )
+ AnyNodeRef aFoundNode = configuration::getDeepDescendant(aTree, aBaseNode, aLocalChangePath);
+ if ( aFoundNode.isValid() )
+ {
+ if (aFoundNode.isNode())
{
- if (aFoundNode.isNode())
- {
- aNode = aFoundNode.toNode();
- }
- else
- {
- // TODO: Notify using parent node and temporary dummy change
- OSL_ENSURE( false, "Notification broken: Node being adressed is a Value");
- }
+ aNode = aFoundNode.toNode();
+ }
+ else
+ {
+ // TODO: Notify using parent node and temporary dummy change
+ OSL_ENSURE( false, "Notification broken: Node being adressed is a Value");
}
}
- else
- {
- aNode = aTree.getRootNode();
- }
+ }
+ else
+ {
+ aNode = aTree.getRootNode();
+ }
- SubtreeChange const* pTreeChange = NULL;
- if (aNode.isValid())
- {
- if (aChange.ISA(SubtreeChange))
- pTreeChange = static_cast<SubtreeChange const*>(&aChange);
+ SubtreeChange const* pTreeChange = NULL;
+ if (aNode.isValid())
+ {
+ if (aChange.ISA(SubtreeChange))
+ pTreeChange = static_cast<SubtreeChange const*>(&aChange);
- else // TODO: Notify set change using parent (if available) and temporary dummy change
- OSL_ENSURE( false, "Notification broken: Change to inner node is not a subtree change");
- }
+ else // TODO: Notify set change using parent (if available) and temporary dummy change
+ OSL_ENSURE( false, "Notification broken: Change to inner node is not a subtree change");
+ }
- if (pTreeChange != NULL) // implies aNode.isValid()
- {
- OSL_ENSURE( aChange.getNodeName() == aTree.getName(aNode).toString(),
- "Change's node-name does not match found node's name - erratic notification");
+ if (pTreeChange != NULL) // implies aNode.isValid()
+ {
+ OSL_ENSURE( aChange.getNodeName() == aTree.getName(aNode).toString(),
+ "Change's node-name does not match found node's name - erratic notification");
- configuration::NodeChangesInformation aChanges;
+ configuration::NodeChangesInformation aChanges;
- if (configuration::adjustToChanges(aChanges, aTree,aNode, *pTreeChange))
- {
- OSL_ASSERT(aChanges.size() > 0);
+ if (configuration::adjustToChanges(aChanges, aTree,aNode, *pTreeChange))
+ {
+ OSL_ASSERT(aChanges.size() > 0);
- Broadcaster aSender(m_aTreeImpl.getNotifier(),aChanges,false);
+ Broadcaster aSender(m_aTreeImpl.getNotifier(),aChanges,false);
- // Should be improved later. Maybe this is the wrong lock for disposeTree ?
- // aLocalGuard.downgrade(); // partial clear for broadcast
+ // Should be improved later. Maybe this is the wrong lock for disposeTree ?
+ // aLocalGuard.downgrade(); // partial clear for broadcast
- aSender.notifyListeners(aChanges, false);
+ aSender.notifyListeners(aChanges, false);
- disposeRemovedNodes(aChanges, m_aTreeImpl.getFactory());
- }
+ disposeRemovedNodes(aChanges, m_aTreeImpl.getFactory());
}
}
}
+ catch (configuration::InvalidName& i)
+ {
+ rtl::OString sMsg("Cannot locate change within this tree: ");
+ sMsg += i.what();
+ OSL_ENSURE(false, sMsg.getStr() );
+ }
catch (configuration::Exception& e)
{
rtl::OString sMsg("Unexpected error trying to react on update: ");
@@ -957,7 +995,7 @@ void ApiRootTreeImpl::nodeChanged(Change const& aChange, OUString const& sPath,
}
// ---------------------------------------------------------------------------------------------------
-void ApiRootTreeImpl::NodeListener::nodeDeleted(OUString const& sPath, IConfigBroadcaster* _pSource)
+void ApiRootTreeImpl::NodeListener::nodeDeleted(AbsolutePath const& _aPath, IConfigBroadcaster* _pSource)
{
osl::ClearableMutexGuard aGuard(mutex);
@@ -969,31 +1007,22 @@ void ApiRootTreeImpl::NodeListener::nodeDeleted(OUString const& sPath, IConfigBr
ApiRootTreeImpl* pKeepParent = pParent;
aGuard.clear();
- pKeepParent->nodeDeleted(sPath,_pSource);
+ pKeepParent->nodeDeleted(_aPath,_pSource);
}
}
// ---------------------------------------------------------------------------------------------------
-void ApiRootTreeImpl::nodeDeleted(OUString const& sPath, IConfigBroadcaster* pSource)
+void ApiRootTreeImpl::nodeDeleted(AbsolutePath const& _aDeletedPath, IConfigBroadcaster* pSource)
{
// this is a non-UNO external entry point - we need to keep this object alive for the duration of the call
UnoInterfaceRef xKeepAlive( m_aTreeImpl.getUnoInstance() );
#ifdef DBG_UTIL
- using configuration::Path;
-
{
OReadSynchronized aLocalGuard(m_aTreeImpl.getDataLock());
- OSL_ENSURE( Path(sPath, Path::NoValidate()).getType() == configuration::PathType::eABSOLUTE,
- "Unexpected format for 'deleted' Path location - path is not absolute" );
-
-
- OSL_ENSURE( m_aLocationPath.indexOf( sPath ) == 0, "'deleted' Path does not indicate this tree or its context");
-
- const OUString delimiter = OUString::createFromAscii("/");
- OSL_ENSURE( m_aLocationPath.indexOf( sPath ) == m_aLocationPath.concat(delimiter).indexOf( sPath.concat(delimiter) ),
- "'deleted' Path does not check subdirectory boundaries");
+ OSL_ENSURE(configuration::Path::hasPrefix(m_aLocationPath, _aDeletedPath),
+ "'deleted' Path does not indicate this tree or its context: ");
}
#endif
// ensure our provider stays alive
diff --git a/configmgr/source/api2/apitreeimplobj.hxx b/configmgr/source/api2/apitreeimplobj.hxx
index cd1ec847cc13..c968095127f5 100644
--- a/configmgr/source/api2/apitreeimplobj.hxx
+++ b/configmgr/source/api2/apitreeimplobj.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apitreeimplobj.hxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: jb $ $Date: 2001-04-19 15:20:07 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -200,6 +200,7 @@ namespace configmgr
class ApiRootTreeImpl
{
typedef configuration::Tree Tree;
+ typedef configuration::AbsolutePath AbsolutePath;
vos::ORef< OOptions > m_xOptions;
public:
@@ -229,13 +230,13 @@ namespace configmgr
// IConfigListener
void disposing(IConfigBroadcaster* pSource) ;
//INodeListener : IConfigListener
- void nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource);
- void nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource);
+ void nodeChanged(Change const& aChange, AbsolutePath const& aPath, IConfigBroadcaster* pSource);
+ void nodeDeleted(AbsolutePath const& aPath, IConfigBroadcaster* pSource);
private:
- ApiTreeImpl m_aTreeImpl;
- OUString m_aLocationPath;
- vos::ORef<NodeListener> m_pNotificationListener;
+ ApiTreeImpl m_aTreeImpl;
+ AbsolutePath m_aLocationPath;
+ vos::ORef<NodeListener> m_pNotificationListener;
};
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/api2/committer.cxx b/configmgr/source/api2/committer.cxx
index e6da1e2147d1..25e3535dec83 100644
--- a/configmgr/source/api2/committer.cxx
+++ b/configmgr/source/api2/committer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: committer.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -123,8 +123,8 @@ void Committer::commit()
OSL_ENSURE(m_rTree.getOptions().isValid(),"INTERNAL ERROR: Invalid Options used.");
TreeChangeList aChangeList(m_rTree.getOptions(),
- aTree.getContextPath().toString(),
- aTree.getRootName().toString(),
+ aTree.getRootPath(),
+ Chg(),
aTree.getAttributes(aTree.getRootNode()));
ITreeManager* pUpdateProvider = getUpdateProvider();
diff --git a/configmgr/source/api2/confprovider2.cxx b/configmgr/source/api2/confprovider2.cxx
index bb33d7a74a50..f33419ae0424 100644
--- a/configmgr/source/api2/confprovider2.cxx
+++ b/configmgr/source/api2/confprovider2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confprovider2.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: jb $ $Date: 2001-04-03 16:33:57 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -394,7 +394,11 @@ namespace configmgr
::vos::ORef<OOptions> xOptions(new OOptions(m_pImpl->getDefaultOptions()));
for (sal_Int32 i = 0; i < aNodeList.getLength(); i++)
- m_pImpl->fetchSubtree(aNodeList[i], xOptions);
+ {
+ using namespace configuration;
+ AbsolutePath aModulePath = AbsolutePath::makeModulePath(aNodeList[i], AbsolutePath::NoValidate());
+ m_pImpl->fetchSubtree(aModulePath , xOptions);
+ }
}
} // namespace configmgr
diff --git a/configmgr/source/api2/confproviderimpl2.cxx b/configmgr/source/api2/confproviderimpl2.cxx
index a4e269eaff68..3b949e044e01 100644
--- a/configmgr/source/api2/confproviderimpl2.cxx
+++ b/configmgr/source/api2/confproviderimpl2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confproviderimpl2.cxx,v $
*
- * $Revision: 1.25 $
+ * $Revision: 1.26 $
*
- * last change: $Author: jb $ $Date: 2001-06-22 12:30:34 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -147,27 +147,16 @@ namespace configmgr
// create the access object
uno::Reference< uno::XInterface > xReturn;
- try
- {
- if (aArgs.getLength() != 0)
- {
- NodeElement* pElement = buildReadAccess(sPath, xOptions, nLevels);
- if (pElement != 0)
- {
- xReturn = pElement->getUnoInstance();
- if (xReturn.is())
- // acquired once by buildReadAccess
- xReturn->release();
- }
- }
- }
- catch (configuration::Exception& e)
+
+ NodeElement* pElement = buildReadAccess(sPath, xOptions, nLevels);
+ if (pElement != 0)
{
- configapi::ExceptionMapper ec(e);
- ec.setContext(this->getProviderInstance());
- //ec.unhandled();
- throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
+ xReturn = pElement->getUnoInstance();
+ if (xReturn.is())
+ // acquired once by buildReadAccess
+ xReturn->release();
}
+
return xReturn;
}
@@ -225,27 +214,16 @@ namespace configmgr
// create the access object
uno::Reference< uno::XInterface > xReturn;
- try
- {
- if (aArgs.getLength() != 0)
- {
- NodeElement* pElement = buildUpdateAccess(sPath, xOptions, nLevels);
- if (pElement != 0)
- {
- xReturn = pElement->getUnoInstance();
- if (xReturn.is())
- // acquired once by buildReadAccess
- xReturn->release();
- }
- }
- }
- catch (configuration::Exception& e)
+
+ NodeElement* pElement = buildUpdateAccess(sPath, xOptions, nLevels);
+ if (pElement != 0)
{
- configapi::ExceptionMapper ec(e);
- ec.setContext(this->getProviderInstance());
- //ec.unhandled();
- throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
+ xReturn = pElement->getUnoInstance();
+ if (xReturn.is())
+ // acquired once by buildReadAccess
+ xReturn->release();
}
+
return xReturn;
}
} // namespace configmgr
diff --git a/configmgr/source/api2/elementimpl.cxx b/configmgr/source/api2/elementimpl.cxx
index 1b1f9f7ca482..3d346e63db89 100644
--- a/configmgr/source/api2/elementimpl.cxx
+++ b/configmgr/source/api2/elementimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: elementimpl.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,24 +61,52 @@
#include "elementimpl.hxx"
+#ifndef CONFIGMGR_API_TREEACCESS_HXX_
#include "apitreeaccess.hxx"
+#endif
+#ifndef CONFIGMGR_API_NODEACCESS_HXX_
#include "apinodeaccess.hxx"
+#endif
+#ifndef CONFIGMGR_API_FACTORY_HXX_
#include "apifactory.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGE_HXX_
#include "nodechange.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
#include "nodechangeinfo.hxx"
+#endif
+#ifndef CONFIGMGR_API_TRANSLATECHANGES_HXX_
#include "translatechanges.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGSET_HXX_
#include "configset.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "confignotifier.hxx"
+#endif
+#ifndef CONFIGMGR_API_SVCCOMPONENT_HXX_
#include "confsvccomponent.hxx"
+#endif
+#ifndef CONFIGMGR_API_COMMITTER_HXX_
#include "committer.hxx"
+#endif
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONFIGURATION_XTEMPLATECONTAINER_HPP_
#include <com/sun/star/configuration/XTemplateContainer.hpp>
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
@@ -103,7 +131,6 @@ namespace configmgr
using configuration::Tree;
using configuration::ElementTree;
using configuration::Name;
- using configuration::Path;
using configuration::AbsolutePath;
using configuration::RelativePath;
@@ -603,7 +630,7 @@ OUString implGetTemplateName(SetElement& rElement)
try
{
GuardedSetElement aLocked(rElement);
- return aLocked->getTemplateInfo().getTemplatePath().toString();
+ return aLocked->getTemplateInfo().getTemplatePathString();
}
catch (configuration::Exception& ex)
{
diff --git a/configmgr/source/api2/propertyinfohelper.cxx b/configmgr/source/api2/propertyinfohelper.cxx
index 3896448b646a..382b1c6fe5fd 100644
--- a/configmgr/source/api2/propertyinfohelper.cxx
+++ b/configmgr/source/api2/propertyinfohelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertyinfohelper.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,13 +60,18 @@
************************************************************************/
#include "propertyinfohelper.hxx"
+
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
#include "configpath.hxx"
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HDL_
#include <com/sun/star/beans/PropertyAttribute.hdl>
+#endif
+
namespace configmgr
{
namespace css = ::com::sun::star;
namespace uno = ::com::sun::star::uno;
- namespace lang = ::com::sun::star::lang;
namespace beans = ::com::sun::star::beans;
namespace configapi
diff --git a/configmgr/source/api2/propsetaccessimpl.cxx b/configmgr/source/api2/propsetaccessimpl.cxx
index abd3fa09479f..cea23a10a1d5 100644
--- a/configmgr/source/api2/propsetaccessimpl.cxx
+++ b/configmgr/source/api2/propsetaccessimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propsetaccessimpl.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,10 +87,12 @@
#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "confignotifier.hxx"
#endif
-
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
-
+#endif
+#ifndef CONFIGMGR_API_BROADCASTER_HXX_
#include "broadcaster.hxx"
+#endif
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
@@ -109,7 +111,10 @@
#include <cppuhelper/implbase1.hxx>
#endif
+#ifndef INCLUDED_ALGORITHM
#include <algorithm>
+#define INCLUDED_ALGORITHM
+#endif
namespace configmgr
{
@@ -138,10 +143,10 @@ namespace configmgr
using configuration::NodeChanges;
using configuration::Name;
- using configuration::Path;
using configuration::AbsolutePath;
using configuration::RelativePath;
- using configuration::validateNodeName;
+ using configuration::validateChildName;
+ using configuration::validateChildOrElementName;
using namespace beans;
using namespace uno;
@@ -279,7 +284,8 @@ Property SAL_CALL TreeNodePropertySetInfo::getPropertyByName(const OUString& _rP
throw(UnknownPropertyException, RuntimeException)
{
OReadSynchronized aGuard(m_rNodeAccess.getDataLock());
- Name aName(_rPropertyName, Name::NoValidate());
+
+ Name aName = configuration::makeNodeName(_rPropertyName, Name::NoValidate());
if (!m_aTree.hasChild(m_aNode, aName))
{
@@ -300,7 +306,8 @@ sal_Bool SAL_CALL TreeNodePropertySetInfo::hasPropertyByName(const OUString& _rP
throw(RuntimeException)
{
OReadSynchronized aGuard(m_rNodeAccess.getDataLock());
- Name aName(_rPropertyName, Name::NoValidate());
+
+ Name aName = configuration::makeNodeName(_rPropertyName, Name::NoValidate());
return m_aTree.hasChild(m_aNode, aName);
}
@@ -447,7 +454,7 @@ void implSetPropertyValue( NodeGroupAccess& rNode, const OUString& sPropertyName
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sPropertyName,aTree,aNode);
+ Name aChildName = validateChildName(sPropertyName,aTree,aNode);
ValueRef aChild( aTree.getChildValue(aNode, aChildName) );
@@ -471,7 +478,7 @@ void implSetPropertyValue( NodeGroupAccess& rNode, const OUString& sPropertyName
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
sMessage += sPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -541,7 +548,7 @@ void implSetPropertyValues( NodeGroupAccess& rNode, const Sequence< OUString >&
NodeChanges aChanges;
for(sal_Int32 i = 0, count= aValues.getLength(); i < count; ++i)
{
- Name aChildName = configuration::makeName( aPropertyNames[i] ); // not validated
+ Name aChildName = configuration::makeNodeName( aPropertyNames[i], Name::NoValidate() ); // not validated
ValueRef aChild( aTree.getChildValue(aNode, aChildName) );
@@ -616,8 +623,8 @@ void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& a
throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, RuntimeException)
{
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getLocalDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
try
{
@@ -626,20 +633,20 @@ void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& a
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- RelativePath const aRelPath = reduceRelativePath( aPropertyName, aTree, aNode );
+ RelativePath const aRelPath = validateRelativePath( aPropertyName, aTree, aNode );
Tree aNestedTree( aTree );
NodeRef aNestedNode( aNode );
RelativePath aResolvePath( aRelPath );
- AnyNodeRef aNestedValue = getDescendant( aNestedTree, aNestedNode, aResolvePath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aResolvePath );
if (!aNestedValue.isValid())
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") );
sMessage += aResolvePath.toString();
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' was not found in ") );
- sMessage += aNestedTree.getLocalPath(aNestedNode).toString();
+ sMessage += aNestedTree.getAbsolutePath(aNestedNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -708,8 +715,8 @@ void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const Sequence<
throw(beans::PropertyVetoException, lang::IllegalArgumentException,
lang::WrappedTargetException, RuntimeException)
{
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getLocalDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
try
{
@@ -722,13 +729,13 @@ void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const Sequence<
for(sal_Int32 i = 0, count= aValues.getLength(); i < count; ++i)
try
{
- RelativePath aRelPath = reduceRelativePath( aPropertyNames[i], aTree, aNode );
+ RelativePath aRelPath = validateRelativePath( aPropertyNames[i], aTree, aNode );
Tree aNestedTree( aTree );
NodeRef aNestedNode( aNode );
RelativePath aResolvePath( aRelPath );
- AnyNodeRef aNestedValue = getDescendant( aNestedTree, aNestedNode, aResolvePath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aResolvePath );
if (!aNestedValue.isValid())
{
@@ -814,7 +821,7 @@ Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const OUString& aPropertyNa
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(aPropertyName,aTree,aNode);
+ Name aChildName = validateChildName(aPropertyName,aTree,aNode);
AnyNodeRef aChild( aTree.getAnyChild(aNode, aChildName) );
@@ -825,7 +832,7 @@ Any implGetPropertyValue( NodeGroupInfoAccess& rNode,const OUString& aPropertyNa
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") );
sMessage += aPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -874,7 +881,7 @@ Sequence< Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const Sequenc
for(sal_Int32 i = 0; i < count; ++i)
{
- Name aChildName = configuration::makeName( aPropertyNames[i] ); // not validated
+ Name aChildName = configuration::makeNodeName( aPropertyNames[i], Name::NoValidate() ); // not validated
AnyNodeRef aChild( aTree.getAnyChild(aNode, aChildName) );
@@ -904,8 +911,8 @@ Sequence< Any > implGetPropertyValues( NodeGroupInfoAccess& rNode, const Sequenc
Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
{
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getLocalDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
try
{
GuardedNodeDataAccess impl( rNode );
@@ -913,16 +920,16 @@ Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString
Tree aTree( impl->getTree() );
NodeRef aNode( impl->getNode() );
- RelativePath aRelPath = reduceRelativePath( aPropertyName, aTree, aNode );
+ RelativePath aRelPath = validateRelativePath( aPropertyName, aTree, aNode );
- AnyNodeRef aNestedNode = getDescendant( aTree, aNode, aRelPath );
+ AnyNodeRef aNestedNode = getLocalDescendant( aTree, aNode, aRelPath );
if (!aNestedNode.isValid())
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Property Value. Property '") );
sMessage += aRelPath.toString();
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -954,8 +961,8 @@ Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString
Sequence< Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, const Sequence< OUString >& aPropertyNames )
throw(RuntimeException)
{
- using configuration::reduceRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
- using configuration::getDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::validateRelativePath; // should actually be found by "Koenig" lookup, but MSVC6 fails
+ using configuration::getLocalDescendant; // should actually be found by "Koenig" lookup, but MSVC6 fails
sal_Int32 const count = aPropertyNames.getLength();
Sequence<Any> aRet(count);
@@ -970,12 +977,12 @@ Sequence< Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, c
for(sal_Int32 i = 0; i < count; ++i)
try
{
- RelativePath aRelPath = reduceRelativePath( aPropertyNames[i], aTree, aNode );
+ RelativePath aRelPath = validateRelativePath( aPropertyNames[i], aTree, aNode );
Tree aNestedTree( aTree );
NodeRef aNestedNode( aNode );
- AnyNodeRef aNestedValue = getDescendant( aNestedTree, aNestedNode, aRelPath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aRelPath );
if (aNestedValue.isValid())
{
@@ -1030,7 +1037,7 @@ void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const Sequence<
for(sal_Int32 i = 0; i < count; ++i)
{
- Name aChildName = configuration::makeName( aPropertyNames[i] ); // not validated
+ Name aChildName = configuration::makeNodeName( aPropertyNames[i], Name::NoValidate() ); // not validated
AnyNodeRef aChild( aTree.getAnyChild(aNode, aChildName) );
@@ -1078,7 +1085,7 @@ beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& sP
Tree aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sPropertyName,aTree,aNode);
+ Name aChildName = validateChildOrElementName(sPropertyName,aTree,aNode);
AnyNodeRef aChild = getChildOrElement(aTree,aNode,aChildName);
if (!aChild.isValid())
@@ -1086,7 +1093,7 @@ beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& sP
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyState. Property '") );
sMessage += sPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -1138,7 +1145,7 @@ Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const
{
using configuration::getChildOrElement;
- Name aChildName = validateNodeName(aPropertyNames[i],aTree,aNode);
+ Name aChildName = validateChildOrElementName(aPropertyNames[i],aTree,aNode);
Tree aChildTree( aTree);
@@ -1148,7 +1155,7 @@ Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get PropertyStates. Property '") );
sMessage += aPropertyNames[i];
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' could not be found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -1188,7 +1195,7 @@ void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& sProperty
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sPropertyName,aTree,aNode);
+ Name aChildName = validateChildOrElementName(sPropertyName,aTree,aNode);
Tree aChildTree( aTree);
@@ -1198,7 +1205,7 @@ void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& sProperty
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default. Property '") );
sMessage += sPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in NodeRef ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -1255,7 +1262,7 @@ Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
Tree aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(aPropertyName,aTree,aNode);
+ Name aChildName = validateChildOrElementName(aPropertyName,aTree,aNode);
AnyNodeRef aChildNode = getChildOrElement(aTree, aNode, aChildName);
if (!aChildNode.isValid())
@@ -1263,7 +1270,7 @@ Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") );
sMessage += aPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
diff --git a/configmgr/source/api2/providerimpl.cxx b/configmgr/source/api2/providerimpl.cxx
index 1dda9cac7089..c12aa2234371 100644
--- a/configmgr/source/api2/providerimpl.cxx
+++ b/configmgr/source/api2/providerimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerimpl.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: jb $ $Date: 2001-06-22 12:42:25 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -176,8 +176,8 @@ namespace configmgr
#else
static ::rtl::OUString ssUserProfile(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.UserProfile"));
#endif
-
- if (ISubtree* pSubTree = m_pTreeMgr->requestSubtree(ssUserProfile, m_xDefaultOptions))
+ AbsolutePath aProfileModule = AbsolutePath::makeModulePath(ssUserProfile, AbsolutePath::NoValidate());
+ if (ISubtree* pSubTree = m_pTreeMgr->requestSubtree(aProfileModule, m_xDefaultOptions))
implInitFromProfile(pSubTree);
// should we clean this up ?
@@ -223,7 +223,7 @@ namespace configmgr
if (_rSettings.hasAsyncSetting())
{
- m_xDefaultOptions->setLazyWrite(_rSettings.getAsyncSetting());
+ m_xDefaultOptions->setLazyWrite( !!_rSettings.getAsyncSetting() );
}
// call the template method
@@ -308,10 +308,34 @@ namespace configmgr
// ITreeProvider /ITreeManager
//-----------------------------------------------------------------------------
- ISubtree* OProviderImpl::requestSubtree( OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions,
+ ISubtree* OProviderImpl::requestSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions,
sal_Int16 nMinLevels) throw (uno::Exception)
{
- return m_pTreeMgr->requestSubtree(aSubtreePath, _xOptions, nMinLevels);
+ ISubtree* pTree = NULL;
+ try
+ {
+ pTree = m_pTreeMgr->requestSubtree(aSubtreePath, _xOptions, nMinLevels);
+ }
+ catch(uno::Exception&e)
+ {
+ ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _xOptions);
+ // append the error message given by the tree provider
+ sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe backend returned the following error:\n"));
+ sMessage += e.Message;
+
+ throw lang::WrappedTargetException(sMessage, getProviderInstance(), uno::makeAny(e));
+ }
+
+ if (!pTree)
+ {
+ ::rtl::OUString sMessage = getErrorMessage(aSubtreePath, _xOptions);
+
+ sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nNo backend error message available\n"));
+
+ throw uno::Exception(sMessage, getProviderInstance());
+ }
+
+ return pTree;
}
//-----------------------------------------------------------------------------
@@ -321,7 +345,7 @@ namespace configmgr
}
//-----------------------------------------------------------------------------
- void OProviderImpl::releaseSubtree( OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) throw ()
+ void OProviderImpl::releaseSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) throw ()
{
m_pTreeMgr->releaseSubtree(aSubtreePath, _xOptions);
}
@@ -339,7 +363,7 @@ namespace configmgr
}
//-----------------------------------------------------------------------------
- void OProviderImpl::fetchSubtree(OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels) throw()
+ void OProviderImpl::fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels) throw()
{
m_pTreeMgr->fetchSubtree(aSubtreePath, _xOptions, nMinLevels);
}
@@ -401,23 +425,16 @@ namespace configmgr
}
//-----------------------------------------------------------------------------------
- OUString OProviderImpl::getBasePath(OUString const& _rAccessor)
+ OUString OProviderImpl::getErrorMessage(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions)
{
- sal_Int32 nNameStart = _rAccessor.lastIndexOf(ConfigurationName::delimiter);
- if (nNameStart == (_rAccessor.getLength() - 1))
- nNameStart = _rAccessor.lastIndexOf(ConfigurationName::delimiter, nNameStart);
- return nNameStart > 0 ? _rAccessor.copy(0,nNameStart) : ConfigurationName::rootname();
- }
+ OUString const sAccessor = _rAccessor.toString();
- //-----------------------------------------------------------------------------------
- OUString OProviderImpl::getErrorMessage(OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions)
- {
CFG_TRACE_ERROR("config provider: the cache manager could not provide the tree (neither from the cache nor from the session)");
::rtl::OUString sMessage;
::rtl::OUString sUser(_xOptions->getUser());
::rtl::OUString sLocale(_xOptions->getLocale());
- CFG_TRACE_INFO_NI("config provider: the user we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sUser), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(_rAccessor));
- sMessage += _rAccessor;
+ CFG_TRACE_INFO_NI("config provider: the user we tried this for is \"%s\", the locale \"%s\", the path \"%s\"", OUSTRING2ASCII(sUser), OUSTRING2ASCII(sLocale), OUSTRING2ASCII(sAccessor));
+ sMessage += sAccessor;
if (sUser.getLength())
{
@@ -443,40 +460,33 @@ namespace configmgr
{
CFG_TRACE_INFO("config provider: requesting the tree from the cache manager");
- ISubtree* pTree = NULL;
- ::rtl::OUString sErrorMessage;
+ OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
+
try
{
- OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
- pTree = requestSubtree(_rAccessor,_xOptions, sal_Int16(nMinLevels));
- }
- catch(uno::Exception&e)
- {
- sErrorMessage = e.Message;
- }
+ using namespace configuration;
- if (!pTree)
- {
- ::rtl::OUString sMessage = getErrorMessage(_rAccessor, _xOptions);
+ AbsolutePath aAccessorPath = AbsolutePath::parse(_rAccessor);
- // append the error message given by the tree provider
- if (sErrorMessage.getLength())
- {
- sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe server returned the following error:\n"));
- sMessage += sErrorMessage;
- }
- throw uno::Exception(sMessage, getProviderInstance());
- }
- using namespace configuration;
- TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels);
+ ISubtree* pTree = this->requestSubtree(aAccessorPath,_xOptions, sal_Int16(nMinLevels));
- RootTree aRootTree( createReadOnlyTree(
- AbsolutePath(getBasePath(_rAccessor), Path::NoValidate()),
- *pTree, nDepth,
- TemplateProvider( this->getTemplateProvider(), _xOptions )
- ));
+ TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels);
- return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _xOptions);
+ RootTree aRootTree( createReadOnlyTree(
+ aAccessorPath,
+ *pTree, nDepth,
+ TemplateProvider( this->getTemplateProvider(), _xOptions )
+ ));
+
+ return m_pNewProviders->getReaderFactory().makeAccessRoot(aRootTree, _xOptions);
+ }
+ catch (configuration::Exception& e)
+ {
+ configapi::ExceptionMapper ec(e);
+ ec.setContext(this->getProviderInstance());
+ //ec.unhandled();
+ throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
+ }
}
@@ -486,43 +496,34 @@ namespace configmgr
{
CFG_TRACE_INFO("config provider: requesting the tree from the cache manager");
- ISubtree* pTree = NULL;
- ::rtl::OUString sErrorMessage;
+ OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
+
try
{
- OSL_ASSERT(sal_Int16(nMinLevels) == nMinLevels);
- pTree = requestSubtree(_rAccessor, _xOptions, sal_Int16(nMinLevels));
- }
- catch(uno::Exception &e)
- {
- sErrorMessage = e.Message;
- }
+ using namespace configuration;
- if (!pTree)
- {
- ::rtl::OUString sMessage = getErrorMessage(_rAccessor, _xOptions);
+ AbsolutePath aAccessorPath = AbsolutePath::parse(_rAccessor);
- // append the error message given by the tree provider
- if (sErrorMessage.getLength())
- {
- sMessage += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n\nThe server returned the following error:\n"));
- sMessage += sErrorMessage;
- }
- throw uno::Exception(sMessage, getProviderInstance());
- }
- //ConfigurationName aPathToUpdateRoot(getBasePath(_rAccessor), ConfigurationName::Absolute());
+ ISubtree* pTree = requestSubtree(aAccessorPath, _xOptions, sal_Int16(nMinLevels));
- using namespace configuration;
- TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels);
+ TreeDepth nDepth = (nMinLevels == ALL_LEVELS) ? C_TreeDepthAll : TreeDepth(nMinLevels);
- RootTree aRootTree( createUpdatableTree(
- AbsolutePath(getBasePath(_rAccessor),Path::NoValidate()),
- *pTree, nDepth,
- TemplateProvider( this->getTemplateProvider(), _xOptions )
- ));
+ RootTree aRootTree( createUpdatableTree(
+ aAccessorPath,
+ *pTree, nDepth,
+ TemplateProvider( this->getTemplateProvider(), _xOptions )
+ ));
- return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _xOptions);
+ return m_pNewProviders->getWriterFactory().makeAccessRoot(aRootTree, _xOptions);
+ }
+ catch (configuration::Exception& e)
+ {
+ configapi::ExceptionMapper ec(e);
+ ec.setContext(this->getProviderInstance());
+ //ec.unhandled();
+ throw lang::WrappedTargetException(ec.message(), ec.context(), uno::Any());
+ }
}
//=============================================================================
diff --git a/configmgr/source/api2/providerimpl.hxx b/configmgr/source/api2/providerimpl.hxx
index dc569cac0620..c871fbc8cb47 100644
--- a/configmgr/source/api2/providerimpl.hxx
+++ b/configmgr/source/api2/providerimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerimpl.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-05-28 15:33:37 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,9 +62,7 @@
#ifndef CONFIGMGR_API_PROVIDERIMPL_HXX_
#define CONFIGMGR_API_PROVIDERIMPL_HXX_
-#ifndef CONFIGMGR_API_EVENTS_HXX_
-#include "confevents.hxx"
-#endif
+#include "treeprovider.hxx"
#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
#include <com/sun/star/script/XTypeConverter.hpp>
@@ -113,6 +111,8 @@ namespace configmgr
class TreeManager;
class ConnectionSettings;
+ struct IConfigBroadcaster;
+
namespace configapi
{
class NodeElement;
@@ -194,16 +194,15 @@ namespace configmgr
virtual ~OProviderImpl();
- /// ITreeProvider
- virtual ISubtree * requestSubtree(OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions,
+ /// ITreeManager
+ virtual ISubtree * requestSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions,
sal_Int16 nMinLevels = ALL_LEVELS) throw (uno::Exception);
virtual void updateTree(TreeChangeList& aChanges) throw (uno::Exception);
- /// ITreeManager
- virtual void releaseSubtree( OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) throw ();
+ virtual void releaseSubtree( AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions ) throw ();
virtual void notifyUpdate(TreeChangeList const& aChanges) throw (uno::RuntimeException);
virtual void disposeData(const vos::ORef < OOptions >& _xOptions) throw();
- virtual void fetchSubtree(OUString const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels = ALL_LEVELS) throw();
+ virtual void fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels = ALL_LEVELS) throw();
// IInterface
virtual void SAL_CALL acquire( ) throw ();
@@ -222,8 +221,7 @@ namespace configmgr
virtual void acquireWriteAccess();
virtual void releaseWriteAccess();
- static OUString getBasePath(OUString const& _rAccessor);
- static OUString getErrorMessage(OUString const& _rAccessor, const vos::ORef < OOptions >& _xOptions);
+ static OUString getErrorMessage(AbsolutePath const& _rAccessor, const vos::ORef < OOptions >& _xOptions);
virtual void SAL_CALL dispose() throw();
public:
diff --git a/configmgr/source/api2/setaccess.cxx b/configmgr/source/api2/setaccess.cxx
index 7b992f02c277..e166d0e01f55 100644
--- a/configmgr/source/api2/setaccess.cxx
+++ b/configmgr/source/api2/setaccess.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setaccess.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2000-11-07 14:34:32 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -187,13 +187,21 @@ OUString SAL_CALL BasicSetAccess::getElementTemplateName( )
OUString SAL_CALL BasicSetAccess::escapeString( const OUString& aString )
throw(css::lang::IllegalArgumentException, RuntimeException)
{
+#ifndef CFG_ESCAPE_ENABLED
+ return aString;
+#else
return implEscapeString( getNode(), aString );
+#endif
}
OUString SAL_CALL BasicSetAccess::unescapeString( const OUString& aEscapedString )
throw(css::lang::IllegalArgumentException, RuntimeException)
{
+#ifndef CFG_ESCAPE_ENABLED
+ return aEscapedString;
+#else
return implUnescapeString( getNode(), aEscapedString );
+#endif
}
//-----------------------------------------------------------------------------------
diff --git a/configmgr/source/api2/translatechanges.cxx b/configmgr/source/api2/translatechanges.cxx
index d2b93e5fbcfd..3616f44e8ffc 100644
--- a/configmgr/source/api2/translatechanges.cxx
+++ b/configmgr/source/api2/translatechanges.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: translatechanges.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:15:37 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,10 +61,18 @@
#include "translatechanges.hxx"
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGE_HXX_
#include "nodechange.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
#include "nodechangeinfo.hxx"
+#endif
+#ifndef CONFIGMGR_API_FACTORY_HXX_
#include "apifactory.hxx"
+#endif
namespace configmgr
{
@@ -91,7 +99,6 @@ namespace configmgr
{
using configuration::Tree;
using configuration::Name;
- using configuration::Path;
using configuration::AbsolutePath;
using configuration::RelativePath;
using configuration::NodeRef;
@@ -110,43 +117,22 @@ bool resolveChangeLocation(RelativePath& aPath, NodeChangeLocation const& aChang
{
OSL_ENSURE(aChange.isValidLocation(), "Trying to resolve against change location that wasn't set up properly");
+ namespace Path = configuration::Path;
+
typedef Path::Iterator Iter;
Tree aChangeBaseTree = aChange.getBaseTree();
- AbsolutePath aOuterBaseTreePath = aBaseTree.getContextPath();
- AbsolutePath aChangeBaseTreePath = aChangeBaseTree.getContextPath();
- RelativePath aOuterBaseNodePath = aBaseTree.getLocalPath(aBaseNode);
- RelativePath aChangeBaseNodePath = aChangeBaseTree.getLocalPath(aChange.getBaseNode());
+ AbsolutePath aOuterBasePath = aBaseTree.getAbsolutePath(aBaseNode);
+ AbsolutePath aChangeBasePath = aChangeBaseTree.getAbsolutePath(aChange.getBaseNode());
- // First start resolving the context pathes
- Iter aChangeIt = aChangeBaseTreePath.begin(), aChangeEnd = aChangeBaseTreePath.end();
- Iter aOuterIt = aOuterBaseTreePath.begin(), aOuterEnd = aOuterBaseTreePath.end();
+ Iter aChangeIt = aChangeBasePath.begin(), aChangeEnd = aChangeBasePath.end();
+ Iter aOuterIt = aOuterBasePath.begin(), aOuterEnd = aOuterBasePath.end();
+ // First by resolve the base node pathes
while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd)
{
- if (*aOuterIt != *aChangeIt) return false; // mismatch
- ++aOuterIt;
- ++aChangeIt;
- }
-
- // Prepend any remaining parts to the respective node pathes
- if (aChangeIt != aChangeEnd)
- {
- aChangeBaseNodePath = RelativePath( Path::Components(aChangeIt,aChangeEnd) ).compose(aChangeBaseNodePath);
- }
- else if (aOuterIt != aOuterEnd)
- {
- aOuterBaseNodePath = RelativePath( Path::Components(aOuterIt,aOuterEnd) ).compose(aOuterBaseNodePath);
- }
-
- // Continue by resolving the node pathes
- aChangeIt = aChangeBaseNodePath.begin(); aChangeEnd = aChangeBaseNodePath.end();
- aOuterIt = aOuterBaseNodePath.begin(); aOuterEnd = aOuterBaseNodePath.end();
-
- while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd)
- {
- if (*aOuterIt != *aChangeIt) return false; // mismatch
+ if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch
++aOuterIt;
++aChangeIt;
}
@@ -154,13 +140,15 @@ bool resolveChangeLocation(RelativePath& aPath, NodeChangeLocation const& aChang
// Next consider the stored accessor
if (aChangeIt != aChangeEnd) // stepping outward - prepend
{
- aPath = RelativePath( Path::Components(aChangeIt, aChangeEnd) ).compose(aChange.getAccessor());
+ Path::Rep aRemaining(aChangeIt, aChangeEnd);
+
+ aPath = RelativePath(aRemaining).compose(aChange.getAccessor());
}
else if (aOuterIt == aOuterEnd) // exact match outside
{
aPath = aChange.getAccessor();
}
- else //(aChangeIt == aChangeEnd) but outer left // shall we support actually going inside the accessor?
+ else //(aChangeIt == aChangeEnd) but outer left
{
RelativePath aAccessor = aChange.getAccessor();
aChangeIt = aAccessor.begin();
@@ -169,14 +157,16 @@ bool resolveChangeLocation(RelativePath& aPath, NodeChangeLocation const& aChang
// resolve the outer path against the change accessor
while (aOuterIt != aOuterEnd && aChangeIt != aChangeEnd)
{
- if (*aOuterIt != *aChangeIt) return false; // mismatch
+ if ( ! Path::matches(*aOuterIt,*aChangeIt) ) return false; // mismatch
++aOuterIt;
++aChangeIt;
}
if (aOuterIt == aOuterEnd)
{
- aPath = RelativePath( Path::Components(aChangeIt, aChangeEnd) );
+ Path::Rep aRemaining(aChangeIt, aChangeEnd);
+
+ aPath = RelativePath( aRemaining );
}
}
@@ -295,7 +285,7 @@ bool fillEventData(container::ContainerEvent& rEvent, NodeChangeInformation cons
return false;
}
- rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().toString();
+ rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().getName().toString();
rEvent.Element = aUnoChange.newValue;
rEvent.ReplacedElement = aUnoChange.oldValue;
@@ -305,7 +295,7 @@ bool fillEventData(container::ContainerEvent& rEvent, NodeChangeInformation cons
/// fill a event from a NodeChangeInfo (uno objects are assumed to be resolved already)
bool fillEventDataFromResolved(container::ContainerEvent& rEvent, NodeChangeInformation const& aInfo)
{
- rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().toString();
+ rEvent.Accessor <<= aInfo.location.getAccessor().getLocalName().getName().toString();
rEvent.Element = aInfo.change.unoData.newValue;
rEvent.ReplacedElement = aInfo.change.unoData.oldValue;
@@ -322,7 +312,7 @@ bool fillEventData(beans::PropertyChangeEvent& rEvent, NodeChangeInformation con
if (!resolveUnoObjects(aUnoChange, aInfo.change, rFactory))
OSL_ENSURE(false, "WARNING: Cannot find out old/new UNO objects involved in change");
- rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().toString();
+ rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().getName().toString();
rEvent.NewValue = aUnoChange.newValue;
rEvent.OldValue = aUnoChange.oldValue;
@@ -339,7 +329,7 @@ bool fillEventDataFromResolved(beans::PropertyChangeEvent& rEvent, NodeChangeInf
if (!aInfo.isValueChange())
return false;
- rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().toString();
+ rEvent.PropertyName = aInfo.location.getAccessor().getLocalName().getName().toString();
rEvent.NewValue = aInfo.change.unoData.newValue;
rEvent.OldValue = aInfo.change.unoData.oldValue;
diff --git a/configmgr/source/api2/updateimpl.cxx b/configmgr/source/api2/updateimpl.cxx
index 72f7eca924ea..5466cb2e26e3 100644
--- a/configmgr/source/api2/updateimpl.cxx
+++ b/configmgr/source/api2/updateimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: updateimpl.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,11 +60,16 @@
************************************************************************/
#include "updateimpl.hxx"
-#include "accessimpl.hxx"
+#ifndef CONFIGMGR_API_BASEACCESSIMPL_HXX_
+#include "accessimpl.hxx"
+#endif
+#ifndef CONFIGMGR_API_NODEACCESS_HXX_
#include "apinodeaccess.hxx"
+#endif
+#ifndef CONFIGMGR_API_NODEUPDATE_HXX_
#include "apinodeupdate.hxx"
-
+#endif
#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
#endif
@@ -72,13 +77,25 @@
#include "valueref.hxx"
#endif
+#ifndef CONFIGMGR_CONFIGCHANGE_HXX_
#include "nodechange.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGSET_HXX_
#include "configset.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGGROUP_HXX_
#include "configgroup.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNOTIFIER_HXX_
#include "confignotifier.hxx"
+#endif
+#ifndef CONFIGMGR_API_BROADCASTER_HXX_
#include "broadcaster.hxx"
+#endif
+#ifndef CONFIGMGR_API_ENCODENAME_HXX_
#include "encodename.hxx"
+#endif
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
@@ -118,10 +135,10 @@ namespace configmgr
using configuration::ElementTree;
using configuration::Tree;
using configuration::Name;
- using configuration::Path;
using configuration::AbsolutePath;
using configuration::RelativePath;
- using configuration::validateNodeName;
+ using configuration::validateChildName;
+ using configuration::validateElementName;
// Interface methods
//-----------------------------------------------------------------------------------
@@ -142,7 +159,7 @@ void implReplaceByName(NodeGroupAccess& rNode, const OUString& sName, const Any&
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateChildName(sName,aTree,aNode);
ValueRef aChildValue( aTree.getChildValue(aNode, aChildName) );
@@ -163,7 +180,7 @@ void implReplaceByName(NodeGroupAccess& rNode, const OUString& sName, const Any&
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Value. Value '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -234,7 +251,7 @@ void implReplaceByName(NodeTreeSetAccess& rNode, const OUString& sName, const An
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
ElementRef aElement( aTree.getElement(aNode,aChildName) );
@@ -245,7 +262,7 @@ void implReplaceByName(NodeTreeSetAccess& rNode, const OUString& sName, const An
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -314,7 +331,7 @@ void implReplaceByName(NodeValueSetAccess& rNode, const OUString& sName, const A
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
ElementRef aElement( aTree.getElement(aNode,aChildName) );
@@ -325,7 +342,7 @@ void implReplaceByName(NodeValueSetAccess& rNode, const OUString& sName, const A
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot replace Set Element. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -390,14 +407,14 @@ void implInsertByName(NodeTreeSetAccess& rNode, const OUString& sName, const Any
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
if( aTree.hasElement(aNode,aChildName) )
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw ElementExistException( sMessage, xContext );
@@ -468,14 +485,14 @@ void implInsertByName(NodeValueSetAccess& rNode, const OUString& sName, const An
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
if( aTree.hasElement(aNode,aChildName) )
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot insert into Set. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' is already present in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw ElementExistException( sMessage, xContext );
@@ -540,7 +557,7 @@ void implRemoveByName(NodeTreeSetAccess& rNode, const OUString& sName )
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
ElementRef aElement( aTree.getElement(aNode,aChildName) );
@@ -551,7 +568,7 @@ void implRemoveByName(NodeTreeSetAccess& rNode, const OUString& sName )
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
@@ -604,7 +621,7 @@ void implRemoveByName(NodeValueSetAccess& rNode, const OUString& sName )
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateNodeName(sName,aTree,aNode);
+ Name aChildName = validateElementName(sName,aTree,aNode);
ElementRef aElement = aTree.getElement(aNode,aChildName);
if (!aElement.isValid())
@@ -614,7 +631,7 @@ void implRemoveByName(NodeValueSetAccess& rNode, const OUString& sName )
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot remove Set Element. Element '") );
sMessage += sName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in Set ") );
- sMessage += aTree.getLocalPath(aNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw NoSuchElementException( sMessage, xContext );
diff --git a/configmgr/source/inc/anynoderef.hxx b/configmgr/source/inc/anynoderef.hxx
index fe7310efac28..73c042ee70b8 100644
--- a/configmgr/source/inc/anynoderef.hxx
+++ b/configmgr/source/inc/anynoderef.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: anynoderef.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:19:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -177,34 +177,20 @@ namespace configmgr
*/
AnyNodeRef getChildOrElement(Tree& aTree, NodeRef const& aParentNode, Name const& aName);
- /** tries to find the immediate child of <var>aNode</var> (which is in <var>aTree</var>)
- specified by <var>aName</var>
- <p> On return <var>aNode</var> is modified to refer to the node found and
- <var>aTree</var> will then refer to the tree that node is in.
- <p/>
- <p>Caution: May miss an existing child unless the child has been accessed before.</p>
-
- @return The requested child node, if it exists
- (then <var>aTree</var> refers to the tree containing the desired node)
-
- @see NodeRef::getAvailableChild
- */
- AnyNodeRef getAvailableChildOrElement(Tree& aTree, NodeRef const& aNode, Name const& aName);
-
- /** tries to find the descendant of <var>aNode</var> (which is in <var>aTree</var>) specified by <var>aPath</var>
+ /** tries to find the descendant of <var>aNode</var> specified by <var>aPath</var> within <var>aTree</var>
<p> This function follows the given path stepwise, until a requested node is missing in the tree.</p>
- <p> On return <var>aNode</var> is modified to refer to the last inner node found and
- <var>aTree</var> will then refer to the tree that node is in.
+ <p> On return <var>aNode</var> is modified to refer to the last inner node found
+ and <var>aTree</var> will be unchanged (except for deprecated usage).
<p/>
<p> Also, <var>aPath</var> is modified to contain the unresolved part of the original path.
</p>
@return the requested node, if the path could be resolved completely
- (so <var>aNode</var> and <var>aTree</var> refer to the desired node or its parent,
+ (so <var>aNode</var> refers to the desired node or its parent,
and <var>aPath</var> is empty)<BR/>
an invalid node otherwise
*/
- AnyNodeRef getDescendant(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
+ AnyNodeRef getLocalDescendant(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
/** tries to find the descendant of <var>aNode</var> (which is in <var>aTree</var>) specified by <var>aPath</var>
<p> This function follows the given path stepwise, until a requested node is missing in the tree.</p>
@@ -213,14 +199,13 @@ namespace configmgr
<p/>
<p> Also, <var>aPath</var> is modified to contain the unresolved part of the original path.
</p>
- <p>Caution: May miss existing descendants unless the node has been accessed before.</p>
@return the requested node, if the path could be resolved completely
(so <var>aNode</var> and <var>aTree</var> refer to the desired node or its parent,
and <var>aPath</var> is empty)<BR/>
an invalid node otherwise
*/
- AnyNodeRef getDescendantAvailable(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
+ AnyNodeRef getDeepDescendant(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
//-------------------------------------------------------------------------
inline bool AnyNodeRef::isValid() const
diff --git a/configmgr/source/inc/apitypes.hxx b/configmgr/source/inc/apitypes.hxx
index d020aa99d5bf..32c047dc3f54 100644
--- a/configmgr/source/inc/apitypes.hxx
+++ b/configmgr/source/inc/apitypes.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apitypes.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:20:20 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,15 +62,30 @@
#ifndef CONFIGMGR_API_APITYPES_HXX_
#define CONFIGMGR_API_APITYPES_HXX_
+#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
#include <com/sun/star/uno/Type.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
#include <com/sun/star/uno/Any.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_
#include <com/sun/star/uno/XInterface.hpp>
+#endif
+#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
+#endif
+#ifndef INCLUDED_VECTOR
#include <vector>
+#define INCLUDED_VECTOR
+#endif INCLUDED_VECTOR
namespace configmgr
{
diff --git a/configmgr/source/inc/change.hxx b/configmgr/source/inc/change.hxx
index c12142a7885b..f0b0f8b9e2b1 100644
--- a/configmgr/source/inc/change.hxx
+++ b/configmgr/source/inc/change.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: change.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-04-05 14:43:13 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -189,6 +189,7 @@ namespace configmgr
void setModeAsString(const rtl::OUString& _rMode);
void applyTo(ValueNode& aNode);
+ void applyChangeNoRecover(ValueNode& aNode) const;
virtual void dispatch(ChangeTreeAction& anAction) const { anAction.handle(*this); }
virtual void dispatch(ChangeTreeModification& anAction) { anAction.handle(*this); }
diff --git a/configmgr/source/inc/confevents.hxx b/configmgr/source/inc/confevents.hxx
index e177414919a0..61ae1d9bbb8c 100644
--- a/configmgr/source/inc/confevents.hxx
+++ b/configmgr/source/inc/confevents.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: confevents.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2000-12-08 11:19:23 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,15 +62,20 @@
#ifndef CONFIGMGR_API_EVENTS_HXX_
#define CONFIGMGR_API_EVENTS_HXX_
-#include "cmtreemodel.hxx"
-#include <vos/refernce.hxx>
+#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
+#endif
namespace rtl { class OUString; }
namespace configmgr
{
- using ::rtl::OUString;
+ class Change;
+ struct TreeChangeList;
+ class OOptions;
+
+ namespace configuration { class AbsolutePath; }
+ using configuration::AbsolutePath;
struct IConfigBroadcaster;
struct IConfigListener : public virtual vos::OReference
@@ -79,8 +84,8 @@ namespace configmgr
};
struct INodeListener : IConfigListener
{
- virtual void nodeChanged(Change const& aChange, OUString const& aPath, IConfigBroadcaster* pSource) = 0;
- virtual void nodeDeleted(OUString const& aPath, IConfigBroadcaster* pSource) = 0;
+ virtual void nodeChanged(Change const& aChange, AbsolutePath const& aPath, IConfigBroadcaster* pSource) = 0;
+ virtual void nodeDeleted(AbsolutePath const& aPath, IConfigBroadcaster* pSource) = 0;
};
typedef vos::ORef<INodeListener> INodeListenerRef;
@@ -90,10 +95,9 @@ namespace configmgr
IConfigBroadcaster() {}
~IConfigBroadcaster() {}
public:
- virtual void addListener(OUString const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener) = 0;
+ virtual void addListener(AbsolutePath const& aPath, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener) = 0;
virtual void removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener) = 0;
-// virtual void removeNode(OUString const& aPath, const vos::ORef < OOptions >& _xOptions, bool bRemovedFromModel = false) = 0;
};
class ConfigChangeBroadcastHelper; // broadcasts changes for a given set of options
@@ -103,11 +107,9 @@ namespace configmgr
ConfigChangeBroadcaster();
virtual ~ConfigChangeBroadcaster();
- virtual void addListener(OUString const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener);
+ virtual void addListener(AbsolutePath const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener);
virtual void removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pListener);
-// virtual void removeNode(OUString const& aPath, const vos::ORef < OOptions >& _xOptions, bool bRemovedFromModel = false);
-
protected:
virtual void fireChanges(TreeChangeList const& _aChanges, sal_Bool _bError);
protected:
diff --git a/configmgr/source/inc/configpath.hxx b/configmgr/source/inc/configpath.hxx
index 29f876b491eb..d5a3ea8564ce 100644
--- a/configmgr/source/inc/configpath.hxx
+++ b/configmgr/source/inc/configpath.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configpath.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:23:17 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,11 +62,18 @@
#ifndef CONFIGMGR_CONFIGPATH_HXX_
#define CONFIGMGR_CONFIGPATH_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
-#include "configexcept.hxx"
-#include <vector>
+#endif
+
+#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_
+#include "attributes.hxx" // used to be defined in this header
+#endif
-#include "attributes.hxx"
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#define INCLUDED_VECTOR
+#endif INCLUDED_VECTOR
namespace configmgr
{
@@ -77,10 +84,10 @@ namespace configmgr
namespace argument { struct NoValidate {}; }
class Name;
- class Path;
class AbsolutePath;
class RelativePath;
//------------------------------------------------------------------------
+ namespace Path { struct PackageOnly; }
/// represents a name for a node in the configuration
class Name
@@ -89,40 +96,63 @@ namespace configmgr
/// A dummy parameter for disabling validity checking on arguments
typedef argument::NoValidate NoValidate;
- /// construct an empty Name
- Name() : m_sRep() {}
+ /// construct a Name from a String (internal use only - use creation wrapper functions)
+ explicit Name(OUString const& aString, Path::PackageOnly) SAL_THROW(());
- /// construct a Name from a String without checking whether it is a valid node-name
- explicit Name(OUString const& aString, NoValidate);
+ public:
+ /// construct an empty Name
+ Name() SAL_THROW(()) : m_sRep() {}
/// check whether this is an empty Name
- bool isEmpty() const { return m_sRep.getLength() == 0; }
+ bool isEmpty() const SAL_THROW(()) { return m_sRep.getLength() == 0; }
/// get a string representation of this Name
- const OUString& toString() const { return m_sRep; }
+ const OUString& toString() const SAL_THROW(()) { return m_sRep; }
public:
// comparison operators
// equality (== is primary)
- friend bool operator==(Name const& lhs, Name const& rhs)
+ friend bool operator==(Name const& lhs, Name const& rhs) SAL_THROW(())
{ return !!(lhs.m_sRep == rhs.m_sRep); }
// comparison operators
// ordering (< is primary)
- friend bool operator< (Name const& lhs, Name const& rhs)
+ friend bool operator< (Name const& lhs, Name const& rhs) SAL_THROW(())
{ return !!(lhs.m_sRep < rhs.m_sRep); }
// hashing support
- size_t hashCode() const { return m_sRep.hashCode(); }
+ size_t hashCode() const SAL_THROW(()) { return m_sRep.hashCode(); }
private:
OUString m_sRep;
};
//--------------------------------------------------------------------
+ /** check if this is a well-formed name for a
+ config Node (excluding set elements)
+ */
+ bool isSimpleName(OUString const& sName) SAL_THROW(());
+
+ /** check if this is a well-formed name for a
+ config Node (excluding set elements)
+ */
+ inline
+ bool isSimpleName(Name const& sName) SAL_THROW(())
+ { return isSimpleName(sName.toString()); }
+
/** make a <type>Name</type> out of <var>sName</var>
without full Validation.
*/
- Name makeName(OUString const& sName);
+ Name makeName(OUString const& sName, argument::NoValidate) SAL_THROW(());
+
+ /** make a <type>Name</type> out of <var>sName</var>,
+ which should be used for a config Node (excluding set elements)
+ */
+ Name makeNodeName(OUString const& sName, argument::NoValidate) SAL_THROW(());
+
+ /** make a <type>Name</type> out of <var>sName</var>,
+ which should be used for a config Node (excluding set elements)
+ */
+ Name makeElementName(OUString const& sName, argument::NoValidate) SAL_THROW(());
/** make a <type>Name</type> out of <var>sName</var>,
validating that it can be used for a config Node (excluding set elements)
@@ -134,7 +164,6 @@ namespace configmgr
/** make a <type>Name</type> out of <var>sName</var>
validating that it can be used for a config set element
- or template name.
@throws InvalidName
if the name is not valid for that purpose
*/
@@ -142,369 +171,451 @@ namespace configmgr
//------------------------------------------------------------------------
//------------------------------------------------------------------------
- /// lower-level representation a path within the configuration
- class PathRep
+ namespace Path
{
- public:
- /// a sequence of element names which make up a path
- typedef std::vector<Name> Components;
- /// a (read-only) iterator to the element names which make up a path
- typedef Components::const_iterator Iterator;
- /// a (mutating) iterator to the element names which make up a path
- typedef Components::iterator MutatingIterator;
- public:
- /// construct a path consisting of the components of <var>aComponents</var>
- explicit PathRep(Components const& sComponents);
+ //------------------------------------------------------------------------
+ /// tag for disabling validity checking on arguments
+ using argument::NoValidate;
- /// build the path that results from appending <var>aRelativePath</var> to this
- PathRep compose(PathRep const& aRelativePath) const;
+ //------------------------------------------------------------------------
- /// construct a path by appending <var>aName</var>
- PathRep child(Name const& aName) const;
+ class Component
+ {
+ /// holds the contents of this path component
+ Name m_aName;
+ public:
+ /// construct a path component from a string, without any validation
+ Component(OUString const& _sName, PackageOnly) SAL_THROW(());
+ /// construct a path component from a Name, without any validation
+ Component(Name const& _aName, PackageOnly) SAL_THROW(());
+
+ /// is this component an empty name ?
+ bool isEmpty() const SAL_THROW(()) { return m_aName.isEmpty(); }
+ /// is this component a simple name ?
+ bool isSimpleName() const SAL_THROW(());
+ /// get the inner name for this component
+ Name getName() const SAL_THROW(());
+ /// get the embedded type name for this component (if any)
+ Name getTypeName() const SAL_THROW(());
+ /// get inner name and the embedded type name (if any) for this component
+ bool splitCompositeName(Name& _rName, Name& _rType) const SAL_THROW(());
+ /// get inner name and the embedded type name (if any) for this component as strings
+ bool splitCompositeName(OUString& _rName, OUString& _rType) const SAL_THROW(());
+
+ /// get the contents of this as string (unparsed).
+ OUString toPathString() const SAL_THROW(()) { return m_aName.toString(); }
+
+ // hashing - for hash maps. compatible to equiv or matches
+ size_t hashCode() const SAL_THROW(())
+ { return this->getName().hashCode(); }
+
+ /// get the contents of this as a Name (unparsed). Use with care !
+ Name const& getInternalName() const SAL_THROW(()) { return m_aName; }
+
+ };
+
+ //-------------------------------------------------------------------------
+
+ /// compare taking type wildcards into account
+ bool matches(Component const& lhs,Component const& rhs) SAL_THROW(());
+
+ /// compare by inner names only
+ bool before(Component const& lhs,Component const& rhs) SAL_THROW(());
+
+ /// compare by inner names only
+ bool equiv(Component const& lhs,Component const& rhs) SAL_THROW(());
+ //-------------------------------------------------------------------------
+
+ /// construct a empty path component
+ Component makeEmptyComponent() SAL_THROW(());
+
+ //-------------------------------------------------------------------------
+ /// construct a path component from a name, validating it as simple name
+ Component wrapSimpleName(Name const& _aName);
+
+ /// construct a path component from a type and element name, using a wildcard if no type is available
+ Component makeCompositeName(Name const& _aElementName, Name const& _aTypeName);
+
+ //-------------------------------------------------------------------------
+ /// construct a path component from a string, validating it as simple name
+ Component wrapSimpleName(OUString const& _sName);
+
+ /// construct a path component from a type and element name as strings, using a wildcard if no type is available
+ Component makeCompositeName(OUString const& _sElementName, OUString const& _sTypeName);
+
+ //-----------------------------------------------------------------------------
+ /// construct a composite path component from a element name or string, using a wildcard type
+ template <class NameRep>
+ Component wrapElementName(NameRep const& _aElementName) SAL_THROW(())
+ {
+ return makeCompositeName(_aElementName, NameRep());
+ }
+
+ //-------------------------------------------------------------------------
+ /// construct a path component from an arbitrary na,e or string
+ template <class NameRep>
+ Component wrapSafeName(NameRep const& _aName) SAL_THROW(())
+ {
+ return isSimpleName(_aName) ? wrapSimpleName(_aName) : wrapElementName(_aName);
+ }
+
+ //-----------------------------------------------------------------------------
+ /** lower-level representation of a path within the configuration
+ <p>Keeps the data in a vector of names in reverse order! </P>
+ */
+ class Rep
+ {
+ public:
+ /// a sequence of element names which make up a path
+ typedef std::vector<Component> Components;
+ /// a (read-only) iterator to the element names which make up a path
+ typedef Components::const_reverse_iterator Iterator;
+ /// a (mutating) iterator to the element names which make up a path
+ typedef Components::reverse_iterator MutatingIterator;
+ /// a (mutating) iterator to the element names which make up a path
+ typedef Components::size_type size_type;
+
+ public:
+ /// construct an empty path
+ Rep() SAL_THROW(()) : m_aComponents() {}
+
+ /// construct a path consisting of a single component <var>_aName</var>
+ explicit Rep(Component const& _aName) SAL_THROW(()) : m_aComponents(1,_aName) {}
+
+ /// construct a path consisting of a path subrange
+ explicit Rep(Iterator const& _first, Iterator const& _last)
+ : m_aComponents(_last.base(), _first.base()) {}
+
+ /// swap contents with another instance
+ void swap(Rep& _aOther) SAL_THROW(()) { m_aComponents.swap(_aOther.m_aComponents); }
+
+ /// modify a path by prepending <var>aName</var>
+ void prepend(Component const& _aName) SAL_THROW(()) { m_aComponents.push_back(_aName); }
+
+ /// modify a path by prepending <var>aName</var>
+ void prepend(Rep const& _aOther) SAL_THROW(());
+
+ /// get the local name (the last component of this path)
+ Component const& getLocalName() const { check_not_empty(); return m_aComponents.front(); }
- /// build the path that results from dropping the last component off this
- PathRep parent() const;
+ /// get the next name (the first component of this path)
+ Component const& getFirstName() const { check_not_empty(); return m_aComponents.back(); }
- /// get the local name (the last component of this path)
- Name getLocalName() const;
+ /// set this to the remainder after the first name (drop the first component of this path)
+ void dropFirstName() { check_not_empty(); m_aComponents.pop_back(); }
- /// get a /-separated string representation of this
- OUString toString() const;
- public:
- /// Get a reference to (or copy of) a collection of all components of this
- Components const& components() const { return m_aComponents; }
+ /// get a /-separated string representation of this
+ OUString toString(bool _bAbsolute) const SAL_THROW(());
- /// check if this is an empty path
- bool isEmpty() const { return m_aComponents.empty(); }
+ public:
+ /// check if this is an empty path
+ bool isEmpty() const SAL_THROW(()) { return m_aComponents.empty(); }
- /// Count the components of this
- Components::size_type countComponents() const { return m_aComponents.size(); }
+ /// Count the components of this
+ size_type countComponents() const SAL_THROW(()) { return m_aComponents.size(); }
- /// Insert a component into this path
- void insertComponent(MutatingIterator it, Name aName = Name()) { m_aComponents.insert(it,aName); }
- /// Remove a component from this path
- void removeComponent(MutatingIterator it) { m_aComponents.erase(it); }
- /// Remove all components from this path
- void clearComponents() { m_aComponents.clear(); }
+ /// Insert a component into this path
+ void insertComponent(MutatingIterator _it, Component _aName)
+ { m_aComponents.insert(_it.base(),_aName); }
+
+ /// Remove a component from this path
+ void removeComponent(MutatingIterator _it) { m_aComponents.erase(_it.base()); }
+
+ /// Remove all components from this path
+ void clearComponents() SAL_THROW(()) { m_aComponents.clear(); }
+
+ /// get a STL style iterator to the first component
+ Iterator begin() const SAL_THROW(()) { return m_aComponents.rbegin(); }
+ /// get a STL style iterator to after the last component
+ Iterator end() const SAL_THROW(()) { return m_aComponents.rend(); }
+
+ /// get a STL style iterator to the first component
+ MutatingIterator begin_mutate() SAL_THROW(()) { return m_aComponents.rbegin(); }
+ /// get a STL style iterator to after the last component
+ MutatingIterator end_mutate() SAL_THROW(()) { return m_aComponents.rend(); }
+
+ // hashing - for hash maps
+ size_t hashCode() const SAL_THROW(());
+
+ /// preflight check for operations that require a non-empty path
+ void check_not_empty() const;
+
+ private:
+ Components m_aComponents;
+ };
+ //------------------------------------------------------------------------
- /// get a STL style iterator to the first component
- Iterator begin() const { return m_aComponents.begin(); }
- /// get a STL style iterator to after the last component
- Iterator end() const { return m_aComponents.end(); }
+ /// compare taking type wildcards into account
+ bool matches(Rep const& lhs,Rep const& rhs) SAL_THROW(());
- /// get a STL style iterator to the first component
- MutatingIterator begin_mutate() { return m_aComponents.begin(); }
- /// get a STL style iterator to after the last component
- MutatingIterator end_mutate() { return m_aComponents.end(); }
+ /// compare by inner names only
+ bool before(Rep const& lhs,Rep const& rhs) SAL_THROW(());
- // comparison
- // equality (== is primary)
- friend bool operator==(PathRep const& lhs, PathRep const& rhs);
- friend bool operator!=(PathRep const& lhs, PathRep const& rhs)
- { return !(lhs == rhs); }
- // ordering - for maps
- bool before(PathRep const& rhs) const;
- // hashing - for hash maps
- size_t hashCode() const;
- private:
- Components m_aComponents;
- };
+ /// compare by inner names only
+ bool equiv(Rep const& lhs,Rep const& rhs) SAL_THROW(());
+ //------------------------------------------------------------------------
+
+ /// check a path for a prefix
+ bool hasMatchingPrefix(Rep const& _aPath,Rep const& _aPrefix) SAL_THROW(());
+
+ /// remove a prefix from a path. Throws InvalidName if it isn't a prefix
+ Rep stripMatchingPrefix(Rep const& _aPath,Rep const& _aPrefix);
+ //------------------------------------------------------------------------
+
+ /// a (read-only) iterator to the element names which make up a path
+ typedef Rep::Iterator Iterator;
+ /// a (mutating) iterator to the element names which make up a path
+ typedef Rep::MutatingIterator MutatingIterator;
+ /// a (mutating) iterator to the element names which make up a path
+ typedef Rep::size_type size_type;
+ //------------------------------------------------------------------------
+ /// distinguishes which kind of path is present in a string
+ bool isAbsolutePath(OUString const& _sPath);
+ //------------------------------------------------------------------------
+ }
//------------------------------------------------------------------------
class RelativePath
{
- PathRep m_aRep;
+ Path::Rep m_aRep;
public:
- /// A dummy parameter for disabling validity checking on arguments
- typedef argument::NoValidate NoValidate;
-
- /// a sequence of element names which make up a path
- typedef PathRep::Components Components;
/// a (read-only) iterator to the element names which make up a path
- typedef PathRep::Iterator Iterator;
+ typedef Path::Iterator Iterator;
/// a (mutating) iterator to the element names which make up a path
- typedef PathRep::MutatingIterator MutatingIterator;
+ typedef Path::MutatingIterator MutatingIterator;
public:
// Construction
+ /// construct a relative path from <var>aString</var> throwing InvalidName for parse errors
+ static RelativePath parse(OUString const& _aString);
+
/// construct an empty relative path
- RelativePath();
- /// construct a relative path from <var>aString</var> ignoring any parse errors
- explicit RelativePath(OUString const& aString, NoValidate);
- /// construct a relative path having <var>aName</var> as single component
- explicit RelativePath(Name const& aName);
- /// construct a relative path having <var>aRep</var> as representation
- explicit RelativePath(PathRep const& aRep) : m_aRep(aRep) { init(); }
- /// construct a relative path consisting of the components of <var>aComponents</var>
- explicit RelativePath(Components const& aComponents) : m_aRep(aComponents) { init(); }
+ RelativePath() SAL_THROW(()) : m_aRep() { init(); }
- /// build the Path that results from appending <var>aPath</var> to this
- RelativePath compose(RelativePath const& aPath) const;
+ /// construct a relative path having <var>aRep</var> as representation
+ explicit RelativePath(Path::Rep const& _aRep)
+ : m_aRep(_aRep) { init(); }
- /// construct a path to the child of this path named by <var>aName</var>
- RelativePath child(Name const& aName) const;
+ /// CONVERSION: construct a relative path having <var>aName</var> as single component
+ RelativePath(Path::Component const& _aName) SAL_THROW(());
- /// build the path that results from dropping the last component off this
- RelativePath parent() const;
+ /// build the Path that results from appending <var>aPath</var> to this
+ RelativePath compose(RelativePath const& _aPath) const SAL_THROW(());
/// check if this is an empty path
- bool isEmpty() const { return m_aRep.isEmpty(); }
+ bool isEmpty() const SAL_THROW(()) { return m_aRep.isEmpty(); }
/// Count the components of this
- Components::size_type getDepth() const { return m_aRep.countComponents(); }
+ Path::size_type getDepth() const SAL_THROW(()) { return m_aRep.countComponents(); }
/// get the local name (the last component of this path)
- Name getLocalName() const { return m_aRep.getLocalName(); }
+ Path::Component const& getLocalName() const { return m_aRep.getLocalName(); }
+
+ /// get the local name (the first component of this path)
+ Path::Component const& getFirstName() const { return m_aRep.getFirstName(); }
+
+ /// set this to the remainder of this path after the first name (drop the first component of this path)
+ void dropFirstName() { m_aRep.dropFirstName(); }
/// get a /-separated string representation of this
- OUString toString() const;
+ OUString toString() const SAL_THROW(());
public:
// Iteration support
/// get a STL style iterator to the first component
- Iterator begin() const { return m_aRep.begin(); }
+ Iterator begin() const SAL_THROW(()) { return m_aRep.begin(); }
/// get a STL style iterator to after the last component
- Iterator end() const { return m_aRep.end(); }
+ Iterator end() const SAL_THROW(()) { return m_aRep.end(); }
/// get a STL style iterator to the first component
- MutatingIterator begin_mutate() { return m_aRep.begin_mutate(); }
+ MutatingIterator begin_mutate() SAL_THROW(()) { return m_aRep.begin_mutate(); }
/// get a STL style iterator to after the last component
- MutatingIterator end_mutate() { return m_aRep.end_mutate(); }
-
- // Decomposed access
- /// Get a collection of all components of this
- Components components() const { return m_aRep.components(); }
+ MutatingIterator end_mutate() SAL_THROW(()) { return m_aRep.end_mutate(); }
// Direct access - 'package' visible
/// Get a reference to (or copy of) the internal PathRep of this
- PathRep const& rep() const { return m_aRep; }
- public:
- // comparison operators
- // equality (== is primary)
- friend bool operator==(RelativePath const& lhs, RelativePath const& rhs)
- { return lhs.m_aRep == rhs.m_aRep; }
-
- // ordering (< is primary)
- friend bool operator< (RelativePath const& lhs, RelativePath const& rhs)
- { return lhs.m_aRep.before(rhs. m_aRep); }
+ Path::Rep const& rep() const SAL_THROW(()) { return m_aRep; }
- // hashing
- size_t hashCode() const { return m_aRep.hashCode(); }
private:
void init();
};
+ /// compare taking type wildcards into account
+ inline bool matches(RelativePath const& lhs,RelativePath const& rhs) SAL_THROW(())
+ { return Path::matches(lhs.rep(),rhs.rep()); }
+
//------------------------------------------------------------------------
class AbsolutePath
{
- PathRep m_aRep; enum { REP_OFF = 1 };
+ Path::Rep m_aRep;
public:
/// A dummy parameter for disabling validity checking on arguments
typedef argument::NoValidate NoValidate;
- /// a sequence of element names which make up a path
- typedef PathRep::Components Components;
/// a (read-only) iterator to the element names which make up a path
- typedef PathRep::Iterator Iterator;
+ typedef Path::Iterator Iterator;
/// a (mutating) iterator to the element names which make up a path
- typedef PathRep::MutatingIterator MutatingIterator;
+ typedef Path::MutatingIterator MutatingIterator;
public:
// Construction
- /// construct a absolute path from <var>aString</var> ignoring any parse errors
- explicit AbsolutePath(OUString const& aString, NoValidate);
- /// construct a absolute path having <var>aRep</var> as representation
- explicit AbsolutePath(PathRep const& aRep) : m_aRep(aRep) { init(); }
- /// construct a absolute path consisting of the components of <var>aComponents</var>
- explicit AbsolutePath(Components const& aComponents) : m_aRep(aComponents) { init(); }
+ /// construct a absolute path from <var>aString</var> throwing InvalidName for parse errors
+ static AbsolutePath parse(OUString const& _aString);
+
+ /// construct a absolute path to a whole module (toplevel)
+ static AbsolutePath makeModulePath(Name const& _aModuleName)
+ { return AbsolutePath( Path::Rep( Path::wrapSimpleName(_aModuleName) ) ); }
+
+ /// construct a absolute path to a whole module (toplevel)
+ static AbsolutePath makeModulePath(Name const& _aModuleName, NoValidate) SAL_THROW(());
+
+ /// construct a absolute path to a whole module (toplevel) without error checking
+ static AbsolutePath makeModulePath(OUString const& _aString, NoValidate) SAL_THROW(());
/// construct an absolute path to the (virtual) hierarchy root
- static AbsolutePath root();
+ static AbsolutePath root() SAL_THROW(());
/// construct an (otherwise invalid) substitute path for the root of a free-floating node
- static AbsolutePath detachedRoot();
+ static AbsolutePath detachedRoot() SAL_THROW(());
+
+ /// construct a absolute path having <var>aRep</var> as representation
+ explicit AbsolutePath(Path::Rep const& _aRep) SAL_THROW(())
+ : m_aRep(_aRep) { init(); }
/// build the absolute path that results from appending <var>aPath</var> to this
- AbsolutePath compose(RelativePath const& aPath) const;
+ AbsolutePath compose(RelativePath const& _aPath) const SAL_THROW(());
- /// construct a path to the child of this path named by <var>aName</var>
- AbsolutePath child(Name const& aName) const;
+ /// build the absolute path that results from removing the last component of this
+ AbsolutePath getParentPath() const;
- /// build the path that results from dropping the last component off this
- AbsolutePath parent() const;
+ /// check if this is the path to the (imaginary) root node
+ bool isRoot() const SAL_THROW(()) { return m_aRep.isEmpty(); }
- /// check if this is the path to the root node
- bool isRoot() const;
+ /// check if this is a path to a detached node
+ bool isDetached() const SAL_THROW(());
/// get the local name (the last component of this path)
- Name getLocalName() const { return m_aRep.getLocalName(); }
+ Path::Component const& getLocalName() const { return m_aRep.getLocalName(); }
- Name getModuleName() const { return isRoot() ? Name() : *begin(); }
+ Name const & getModuleName() const { return m_aRep.getFirstName().getInternalName(); }
/// get a /-separated string representation of this
- OUString toString() const;
+ OUString toString() const SAL_THROW(());
/// Count the components of this
- Components::size_type getDepth() const { return m_aRep.countComponents() - REP_OFF; }
+ Path::size_type getDepth() const SAL_THROW(()) { return m_aRep.countComponents(); }
public:
// Iteration support
/// get a STL style iterator to the first component
- Iterator begin() const { return m_aRep.begin() + REP_OFF; }
+ Iterator begin() const SAL_THROW(()) { return m_aRep.begin(); }
/// get a STL style iterator to after the last component
- Iterator end() const { return m_aRep.end(); }
+ Iterator end() const SAL_THROW(()) { return m_aRep.end(); }
/// get a STL style iterator to the first component
- MutatingIterator begin_mutate() { return m_aRep.begin_mutate() + REP_OFF; }
+ MutatingIterator begin_mutate() SAL_THROW(()) { return m_aRep.begin_mutate(); }
/// get a STL style iterator to after the last component
- MutatingIterator end_mutate() { return m_aRep.end_mutate(); }
-
- // Decomposed access
- /// Get a collection of all components of this
- Components components() const { return Components(begin(),end()); }
+ MutatingIterator end_mutate() SAL_THROW(()) { return m_aRep.end_mutate(); }
// Direct access - 'package' visible
/// Get a reference to (or copy of) the internal PathRep of this
- PathRep const& rep() const { return m_aRep; }
- public:
- // comparison operators
- // equality (== is primary)
- friend bool operator==(AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return lhs.m_aRep == rhs.m_aRep; }
-
- // ordering (< is primary)
- friend bool operator< (AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return lhs.m_aRep.before(rhs. m_aRep); }
-
- // hashing
- size_t hashCode() const { return m_aRep.hashCode(); }
+ Path::Rep const& rep() const SAL_THROW(()) { return m_aRep; }
private:
- void init();
+ void init() SAL_THROW(());
};
- /// distinguishes which kind of path is held in a <type>Path</type> object
- namespace PathType { enum Type { eNAME = 0, eRELATIVE = 1, eABSOLUTE = 2, ePATH = 3 }; }
- //------------------------------------------------------------------------
- class Path
- {
- public:
- /// A dummy parameter for disabling validity checking on arguments
- typedef argument::NoValidate NoValidate;
-
- /// distinguishes which kind of path is held in this object
- typedef PathType::Type Type;
-
- /// a sequence of element names which make up a path
- typedef PathRep::Components Components;
- /// a (read-only) iterator to the element names which make up a path
- typedef PathRep::Iterator Iterator;
- /// a (mutating) iterator to the element names which make up a path
- typedef PathRep::MutatingIterator MutatingIterator;
- public:
- /// Parse a /-separated string into a collection of path components (best try, no exceptions)
- static Components parse(OUString const& aString, Type eType = PathType::ePATH);
- public:
- /// construct a path (of type <var>eType</var>) from <var>aString</var> ignoring any parse errors
- explicit Path(OUString const& aString, NoValidate, Type eType = PathType::ePATH);
-
- /// construct a path (of type <var>eType</var>) having <var>aRep</var> as representation
- explicit Path(PathRep const& aRep, Type eType = PathType::ePATH);
-
- /// construct a path (of type <constant>Path::NAME</constant>) containing <var>aName</var>
- explicit Path(Name const& aName);
-
- /// construct a path (of type <constant>Path::ABSOLUTE</constant>) equal to <var>aPath</var>
- Path(AbsolutePath const& aPath);
-
- /// construct a path (of type <constant>Path::RELATIVE</constant>) equal to <var>aPath</var>
- Path(RelativePath const& aPath);
-
- /// build the path (of the same type as this) that results from appending <var>aPath</var> to this
- Path compose(RelativePath const& aPath) const;
-
- /// construct a path to the child of this path named by <var>aName</var>
- Path child(Name const& aName) const;
-
- /// build the path that results from dropping the last component off this
- Path parent() const;
-
- /// tell the type of this (as known)
- Type getType() const { return m_eType; }
-
- /// get the local name (the last component of this path)
- Name getLocalName() const { return m_aRep.getLocalName(); }
-
- /// get a /-separated string representation of this
- OUString toString() const;
- public:
- // Iteration support
- /// get a STL style iterator to the first component
- Iterator begin() const { return m_aRep.begin(); }
- /// get a STL style iterator to after the last component
- Iterator end() const { return m_aRep.end(); }
-
- /// get a STL style iterator to the first component
- MutatingIterator begin_mutate() { return m_aRep.begin_mutate(); }
- /// get a STL style iterator to after the last component
- MutatingIterator end_mutate() { return m_aRep.end_mutate(); }
-
- // Decomposed access
- /// Get a collection of all components of this
- Components components() const { return m_aRep.components(); }
-
- // Direct access - 'package' visible
- /// Get a reference to (or copy of) the internal PathRep of this
- PathRep const& rep() const { return m_aRep; }
- public:
- // comparison operators
- // equality (== is primary)
- friend bool operator==(Path const& lhs, Path const& rhs)
- { return lhs.m_aRep == rhs.m_aRep; }
- // hashing
- size_t hashCode() const { return m_aRep.hashCode(); }
- private:
- PathRep m_aRep;
- Type m_eType;
-
- void init();
- };
-
-
+ /// compare taking type wildcards into account
+ inline bool matches(AbsolutePath const& lhs,AbsolutePath const& rhs) SAL_THROW(())
+ { return Path::matches(lhs.rep(),rhs.rep()); }
//------------------------------------------------------------------------
// Derived comparison operator implementations
//------------------------------------------------------------------------
- inline bool operator!=(Name const& lhs, Name const& rhs)
+ inline bool operator!=(Name const& lhs, Name const& rhs) SAL_THROW(())
{ return !(lhs == rhs); }
//--------------------------------------------------------------------
- inline bool operator<=(Name const& lhs, Name const& rhs)
+ inline bool operator<=(Name const& lhs, Name const& rhs) SAL_THROW(())
{ return !(rhs < lhs); }
- inline bool operator> (Name const& lhs, Name const& rhs)
+ inline bool operator> (Name const& lhs, Name const& rhs) SAL_THROW(())
{ return rhs < lhs; }
- inline bool operator>=(Name const& lhs, Name const& rhs)
+ inline bool operator>=(Name const& lhs, Name const& rhs) SAL_THROW(())
{ return !(lhs < rhs); }
//------------------------------------------------------------------------
- inline bool operator!=(AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return !(lhs == rhs); }
- //--------------------------------------------------------------------
- inline bool operator<=(AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return !(rhs < lhs); }
- inline bool operator> (AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return rhs < lhs; }
- inline bool operator>=(AbsolutePath const& lhs, AbsolutePath const& rhs)
- { return !(lhs < rhs); }
+ namespace Path
+ {
//------------------------------------------------------------------------
- inline bool operator!=(RelativePath const& lhs, RelativePath const& rhs)
- { return !(lhs == rhs); }
- //--------------------------------------------------------------------
- inline bool operator<=(RelativePath const& lhs, RelativePath const& rhs)
- { return !(rhs < lhs); }
- inline bool operator> (RelativePath const& lhs, RelativePath const& rhs)
- { return rhs < lhs; }
- inline bool operator>=(RelativePath const& lhs, RelativePath const& rhs)
- { return !(lhs < rhs); }
+ template <class PathClass>
+ bool hasPrefix(PathClass const& _aPath, PathClass const& _aPrefix) SAL_THROW(())
+ {
+ return hasMatchingPrefix(_aPath.rep(),_aPrefix.rep() );
+ }
//------------------------------------------------------------------------
- inline bool operator!=(Path const& lhs, Path const& rhs)
- { return !(lhs == rhs); }
+
+ template <class PathClass>
+ RelativePath stripPrefix(PathClass const& _aPath, PathClass const& _aPrefix)
+ {
+ return RelativePath( stripMatchingPrefix(_aPath.rep(),_aPrefix.rep()) );
+ }
+ //------------------------------------------------------------------------
+
+ // STL Helpers
+ //------------------------------------------------------------------------
+
+ /// a weak strict ordering considering only the name part
+ struct Before
+ {
+ bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
+ { return before(lhs,rhs); }
+ bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
+ { return before(lhs,rhs); }
+ bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
+ { return before(lhs.rep(),rhs.rep()); }
+ bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
+ { return before(lhs.rep(),rhs.rep()); }
+ };
+ //------------------------------------------------------------------------
+
+ /// an equality relation considering only the name part (compatible to Before)
+ struct Equiv
+ {
+ bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
+ { return equiv(lhs,rhs); }
+ bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
+ { return equiv(lhs,rhs); }
+ bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
+ { return equiv(lhs.rep(),rhs.rep()); }
+ bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
+ { return equiv(lhs.rep(),rhs.rep()); }
+ };
+ //------------------------------------------------------------------------
+
+ /// a hash generator (compatible to Equiv and Before)
+ struct Hash
+ {
+ size_t operator()(Component const& _aObject) const SAL_THROW(())
+ { return _aObject.hashCode(); }
+ size_t operator()(Rep const& _aObject) const SAL_THROW(())
+ { return _aObject.hashCode(); }
+ size_t operator()(AbsolutePath const& _aObject) const SAL_THROW(())
+ { return _aObject.rep().hashCode(); }
+ size_t operator()(RelativePath const& _aObject) const SAL_THROW(())
+ { return _aObject.rep().hashCode(); }
+ };
+ //------------------------------------------------------------------------
+ /// a binary predicate that is not (!) an equivalence relation
+
+ struct Matches
+ {
+ bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
+ { return matches(lhs,rhs); }
+ bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
+ { return matches(lhs,rhs); }
+ bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
+ { return matches(lhs.rep(),rhs.rep()); }
+ bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
+ { return matches(lhs.rep(),rhs.rep()); }
+ };
+ //------------------------------------------------------------------------
+ }
//------------------------------------------------------------------------
}
}
diff --git a/configmgr/source/inc/configset.hxx b/configmgr/source/inc/configset.hxx
index b2f27a4bc6b8..8b44436559ac 100644
--- a/configmgr/source/inc/configset.hxx
+++ b/configmgr/source/inc/configset.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configset.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:27:17 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,6 +87,7 @@ namespace configmgr
//---------------------------------------------------------------------
class Name;
class AbsolutePath;
+ namespace Path { class Component; }
//---------------------------------------------------------------------
typedef com::sun::star::uno::Type UnoType;
@@ -113,7 +114,8 @@ namespace configmgr
bool isValid() const;
- Name getName() const;
+ Path::Component getFullName() const;
+ Name getName() const;
ElementTree getElementTree() const;
};
@@ -168,7 +170,7 @@ namespace configmgr
UnoType getElementType() const;
Name getTemplateName() const;
Name getTemplatePackage() const;
- RelativePath getTemplatePath() const;
+ OUString getTemplatePathString() const;
static TemplateHolder extractElementInfo(Tree const& aTree, NodeRef const& aNode);
};
@@ -206,9 +208,9 @@ namespace configmgr
NodeChange validateRemoveElement (ElementRef const& aElement);
private:
- void implValidateSet();
- Name implValidateElement(ElementRef const& aElement);
- void implValidateTree(ElementTree const& aElementTree);
+ void implValidateSet();
+ Path::Component implValidateElement(ElementRef const& aElement);
+ void implValidateTree(ElementTree const& aElementTree);
};
//-----------------------------------------------------------------------------
/// allows to insert,remove and replace an element of a <type>Node</type> that is a Container ("set") of simple values.
@@ -230,7 +232,7 @@ namespace configmgr
private:
typedef Tree ElementNodeRef;
void implValidateSet();
- Name implValidateElement(ElementRef const& aElement);
+ Path::Component implValidateElement(ElementRef const& aElement);
UnoAny implValidateValue(ElementNodeRef const& aElementTree, UnoAny const& aValue);
UnoAny implValidateValue(UnoAny const& aValue);
diff --git a/configmgr/source/inc/mergechange.hxx b/configmgr/source/inc/mergechange.hxx
index e83b5b4beb7d..5cc5fbd91d83 100644
--- a/configmgr/source/inc/mergechange.hxx
+++ b/configmgr/source/inc/mergechange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: lla $ $Date: 2001-01-17 15:02:30 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,64 +59,42 @@
*
************************************************************************/
+#ifndef INCLUDED_CONFIGMGR_MERGECHANGE_HXX
+#define INCLUDED_CONFIGMGR_MERGECHANGE_HXX
+
+#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX
+#include "namecreator.hxx"
+#endif
+
+#ifndef CONFIGMGR_CHANGE_HXX
#include "change.hxx"
-#include "treeprovider.hxx"
+#endif
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#include "treechangelist.hxx"
+#endif
namespace configmgr
{
-
- class ONameCreator
- {
- std::vector<rtl::OUString> m_aNameList;
- public:
- ONameCreator(){}
- void init(const ConfigurationName &_aName);
- rtl::OUString createName(const rtl::OUString &aPlusName);
- void pushName(const rtl::OUString &aName);
- void popName();
- };
-
// -----------------------------------------------------------------------------
- // Helperclass to search a change in a given changetree
- class OMergeSearchChange : private ChangeTreeModification, public ONameCreator
- {
- rtl::OUString m_aSearchName;
- bool m_bFound;
- Change* m_pFoundChange;
-
- protected:
- bool isFound() { return m_bFound; }
- virtual void handle(ValueChange& _rValueNode);
- virtual void handle(AddNode& _rAddNode);
- virtual void handle(RemoveNode& _rRemoveNode);
- virtual void handle(SubtreeChange& _rSubtree);
-
- public:
- OMergeSearchChange(const rtl::OUString &_aName);
- Change* searchForChange(Change &aChange);
- };
-
- // -----------------------------------------------------------------------------
- class OMergeTreeChangeList : private ChangeTreeAction, public ONameCreator
+ class OMergeTreeChangeList : private ChangeTreeAction, private OPathCreator<AbsolutePath>
{
TreeChangeList &m_aTreeChangeList; // ChangeList, which will be grown
SubtreeChange *m_pCurrentParent; // our current position
- vector<SubtreeChange*> m_aTreePathStack; // how the name says, a stack for the given path
-
// ------- Helper for Path stack -------
- void pushTree(SubtreeChange* _pTree);
- void popTree();
+ SubtreeChange* pushTree(SubtreeChange& _rTree);
+ void popTree(SubtreeChange* _pSaveTree);
public:
// CTor
OMergeTreeChangeList(TreeChangeList& _aTree);
- SubtreeChange* check(const ConfigurationName &_aName);
// start function, with the Change we want to do.
// WARNING this could be a big tree, because a change can contain subtreechanges!
- void handleChange(TreeChangeList &_rList);
+ void mergeChanges(TreeChangeList const&_rList);
+ private:
+ void initRoot(TreeChangeList const& _aChanges);
private:
virtual void handle(ValueChange const& _rValueNode);
@@ -126,27 +104,28 @@ namespace configmgr
};
// -----------------------------------------------------------------------------
- class OMergeChanges : private ChangeTreeAction, public ONameCreator
+ class OMergeChanges : private ChangeTreeAction, private OPathCreator<RelativePath>
{
- SubtreeChange &m_aSubtreeChange; // ChangeList, which will be grown
+ SubtreeChange &m_rSubtreeChange; // ChangeList, which will be grown
SubtreeChange *m_pCurrentParent; // our current position
- vector<SubtreeChange*> m_aTreePathStack; // how the name says, a stack for the given path
+ typedef configuration::RelativePath RelativePath;
// ------- Helper for Path stack -------
- void pushTree(SubtreeChange* _pTree);
- void popTree();
+ SubtreeChange* pushTree(SubtreeChange& _rTree);
+ void popTree(SubtreeChange* _pSaveTree);
public:
// CTor
- OMergeChanges(SubtreeChange& _aTree);
-
- SubtreeChange* check(const ConfigurationName &_aName);
+ OMergeChanges(SubtreeChange& _rTree);
// start function, with the Change we want to do.
// WARNING this could be a big tree, because a change can contain subtreechanges!
- void handleChange(const SubtreeChange &_rList, const rtl::OUString &_aPathToRoot);
+ void mergeChanges(const SubtreeChange &_rChange, const RelativePath& _aPathToChange);
+ void mergeChanges(const SubtreeChange &_rChange);
private:
+ void initRoot(const RelativePath& _aPathToChange);
+ private:
virtual void handle(ValueChange const& _rValueNode);
virtual void handle(AddNode const& _rAddNode);
virtual void handle(RemoveNode const& _rRemoveNode);
@@ -154,3 +133,6 @@ namespace configmgr
};
} // namespace configmgr
+
+#endif
+
diff --git a/configmgr/source/inc/namecreator.hxx b/configmgr/source/inc/namecreator.hxx
new file mode 100644
index 000000000000..6b9d13e8a426
--- /dev/null
+++ b/configmgr/source/inc/namecreator.hxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * $RCSfile: namecreator.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX
+#define INCLUDED_CONFIGMGR_NAMECREATOR_HXX
+
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
+#include "configpath.hxx"
+#endif
+
+namespace configmgr
+{
+ // -----------------------------------------------------------------------------
+ class Change;
+ class SubtreeChange;
+ // -----------------------------------------------------------------------------
+ using configuration::Name;
+ using configuration::AbsolutePath;
+ using configuration::RelativePath;
+ // -----------------------------------------------------------------------------
+
+ class ONameCreator
+ {
+ public:
+ typedef configuration::Path::Component FullName;
+ typedef configuration::Path::Rep PathRep;
+ typedef std::vector< FullName > NameList;
+ public:
+ ONameCreator() {}
+
+ void pushName(const FullName &_aName) { m_aNameList.push_back(_aName); }
+ void popName() { m_aNameList.pop_back(); }
+
+ void clear() { m_aNameList.clear(); }
+
+ RelativePath buildPath() const;
+ RelativePath buildPath(const FullName &_aPlusName) const;
+
+ static FullName createName(Change const& _rChange, SubtreeChange const* _pParent);
+ private:
+ NameList m_aNameList;
+ };
+
+ template <class PathClass>
+ class OPathCreator : public ONameCreator
+ {
+ public:
+ typedef PathClass PathType;
+ public:
+ OPathCreator() : m_aBasePath( PathRep() ) {}
+ OPathCreator(PathClass const & _aBasePath) : m_aBasePath(_aBasePath) {}
+
+ void init(PathClass const & _aBasePath)
+ { clear(); m_aBasePath = _aBasePath; }
+
+ PathClass createPath() const
+ { return m_aBasePath.compose( ONameCreator::buildPath() ); }
+
+ PathClass createPath(const FullName & _aPlusName) const
+ { return m_aBasePath.compose( ONameCreator::buildPath(_aPlusName) ); }
+ private:
+ PathClass m_aBasePath;
+ };
+ // -----------------------------------------------------------------------------
+
+} // namespace configmgr
+
+#endif
+
diff --git a/configmgr/source/inc/noderef.hxx b/configmgr/source/inc/noderef.hxx
index afcc5b69cec8..2d0d01880a8d 100644
--- a/configmgr/source/inc/noderef.hxx
+++ b/configmgr/source/inc/noderef.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: noderef.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:19:26 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,15 +62,25 @@
#ifndef CONFIGMGR_CONFIGNODE_HXX_
#define CONFIGMGR_CONFIGNODE_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
#include "configexcept.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
#include "configpath.hxx"
-#include <vector>
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#define INCLUDED_VECTOR
+#endif
+
namespace configmgr
{
class INode;
@@ -83,6 +93,7 @@ namespace configmgr
class Name;
class AbsolutePath;
class RelativePath;
+ namespace Path { class Component; }
struct Attributes;
@@ -203,6 +214,9 @@ namespace configmgr
/// checks whether the node <var>aNode</var> has a element node named <var>aName</var>.
bool hasElement(NodeRef const& aNode, Name const& aName) const;
+ /// checks whether the node <var>aNode</var> has a element node named <var>aName</var>.
+ bool hasElement(NodeRef const& aNode, Path::Component const& aName) const;
+
/** gets the element named <var>aName</var> of node <var>aNode</var>.
<p>PRE: <code>hasElement(aNode,aName) == true</code></p>
<p>If there is no such element, may return an empty node or raise an exception (?)</p>
@@ -268,7 +282,7 @@ namespace configmgr
AnyNodeRef getAnyChild(NodeRef const& aNode, Name const& aName) const;
/// return the local <type>Name</type> of the root node of this tree
- Name getRootName() const;
+ Path::Component getRootName() const;
/// return the local <type>Name</type> of node <var>aNode</var> in this tree
Name getName(NodeRef const& aNode) const;
@@ -302,11 +316,11 @@ namespace configmgr
/// return the parent <type>NodeRef</type> of <var>aValue</var> (or an empty node, if it is the tree root)
NodeRef getParent(ValueRef const& aValue) const;
- /// return the <type>Path</type> of <var>aNode</var>, relative to the tree root (or an empty path if it is empty)
- RelativePath getLocalPath(NodeRef const& aNode) const;
+ /// return the <type>AbsolutePath</type> of <var>aNode</var>
+ AbsolutePath getAbsolutePath(NodeRef const& aNode) const;
- /// return the <type>Path</type> of <var>aNode</var>
- RelativePath getLocalPath(ValueRef const& aNode) const;
+ /// gets the <type>AbsolutePath</type> of the root node of this tree
+ AbsolutePath getRootPath() const;
/// gets the root node of this tree
NodeRef getRootNode() const;
@@ -349,8 +363,6 @@ namespace configmgr
Tree getContextTree() const;
/// gets the parent node of this tree ('s root node), if available
NodeRef getContextNode() const;
- /// gets the path of the (possibly fictitious) parent node of this tree
- AbsolutePath getContextPath() const;
// Update handling
public:
@@ -445,20 +457,54 @@ namespace configmgr
/** make a <type>Name</type> out of <var>sName</var>.
@throws InvalidName
- if <var>sName is not a valid name for a <var>aNode</var> within <var>aTree</var>
+ if <var>sName</var> is not a valid name for a member of group <var>aNode</var> within <var>aTree</var>
+
+ */
+ Name validateChildName(OUString const& sName, Tree const& aTree, NodeRef const& aNode );
+
+ /** make a <type>Name</type> out of <var>sName</var>.
+ @throws InvalidName
+ if <var>sName</var> is not a valid name for an element of set <var>aNode</var> within <var>aTree</var>
+
+ */
+ Name validateElementName(OUString const& sName, Tree const& aTree, NodeRef const& aNode );
+
+ /** make a <type>Name</type> out of <var>sName</var>.
+ @throws InvalidName
+ if <var>sName</var> is not a valid name for a child of <var>aNode</var> within <var>aTree</var>
+
+ */
+ Name validateChildOrElementName(OUString const& sName, Tree const& aTree, NodeRef const& aNode );
+
+ /** make one path component out of <var>sName</var>.
+ @throws InvalidName
+ if <var>sName</var> is not a valid name for an element of set <var>aNode</var> within <var>aTree</var>
+
+ */
+ Path::Component validateElementPathComponent(OUString const& sName, Tree const& aTree, NodeRef const& aNode );
+
+ /** parse <var>aPath</var> into a relative path,
+ valid in the context of node <var>aNode<var/> in <var>aTree<var/>.
+ @returns
+ <var>aPath<var/> parsed as a relative path
+ @throws InvalidName
+ if <var>aPath<var/> is not a relative path or not valid in the context of <var>aNode<var/>
*/
- Name validateNodeName(OUString const& sName, Tree const& aTree, NodeRef const& aNode );
+ RelativePath validateRelativePath(OUString const& aPath, Tree const& aTree, NodeRef const& aNode);
- /** reduce <var>aPath</var> to be a path relative to (<var>aTree<var/>,<var>aNode<var/>)
+ /** parse <var>aPath</var> as a configuration path
+ and reduce it to be relative to node <var>aNode<var/> in <var>aTree<var/>.
@returns
- <var>aPath<var/> if it already is a relative path or the part of it relative to <var>aNode<var/>
- if it is an absolute path that to a descendant of <var>aNode<var/>
+ the result of parsing <var>aPath<var/>, if that results in a relative path, or
+ the part of it relative to <var>aNode<var/>,
+ if it is an absolute path to a descendant of <var>aNode<var/>
@throws InvalidName
- if <var>aPath<var/> is an absolute path that is not to a descendant of <var>aNode<var/>
+ if <var>aPath<var/> is not awell-formed path or
+ if it is an absolute path that is not to a descendant of <var>aNode<var/>
*/
- RelativePath reduceRelativePath(OUString const& aPath, Tree const& aTree, NodeRef const& aBaseNode);
+ RelativePath validateAndReducePath(OUString const& aPath, Tree const& aTree, NodeRef const& aNode);
/** checks whether there are any immediate children of <var>aNode</var> (which is in <var>aTree</var>)
@@ -477,18 +523,14 @@ namespace configmgr
*/
bool hasChildOrElement(Tree const& aTree, NodeRef const& aNode, Name const& aName);
- /** tries to find the immediate child of <var>aNode</var> (which is in <var>aTree</var>)
+ /** checks whether there is an immediate child of <var>aNode</var> (which is in <var>aTree</var>)
specified by <var>aName</var>
- <p> On return <var>aNode</var> is modified to refer to the node found and
- <var>aTree</var> will then refer to the tree that node is in.
- <p/>
@return
<TRUE/> if the child node exists
- (so <var>aNode</var> and <var>aTree</var> refer to the desired node),
<FALSE/> otherwise
*/
- bool findInnerChildNode(Tree& aTree, NodeRef& aNode, Name const& aName);
+ bool hasChildOrElement(Tree const& aTree, NodeRef const& aNode, Path::Component const& aName);
/** tries to find the immediate child of <var>aNode</var> (which is in <var>aTree</var>)
specified by <var>aName</var>
@@ -504,42 +546,7 @@ namespace configmgr
@see NodeRef::getAvailableChild
*/
- bool findInnerAvailableChildNode(Tree& aTree, NodeRef& aNode, Name const& aName);
-
- /** tries to find the descendant of <var>aNode</var> (which is in <var>aTree</var>) specified by <var>aPath</var>
- <p> This function follows the given path stepwise, until a requested node is missing in the tree.</p>
- <p> On return <var>aNode</var> is modified to refer to the last node found and
- <var>aTree</var> will then refer to the tree that node is in.
- <p/>
- <p> Also, <var>aPath</var> is modified to contain the unresolved part of the original path.
- </p>
-
- @return
- <TRUE/> if the path could be resolved completely
- (so <var>aNode</var> and <var>aTree</var> refer to the desired node,
- <var>aPath</var> is empty)<BR/>
- <FALSE/> otherwise
- */
- bool findInnerDescendantNode(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
-
- /** tries to find the descendant of <var>aNode</var> (which is in <var>aTree</var>) specified by <var>aPath</var>
- <p> This function follows the given path stepwise, until a requested node is miss in the tree,
- or is not availbale in a set node.
- </p>
- <p> On return <var>aNode</var> is modified to refer to the last node found and
- <var>aTree</var> will then refer to the tree that node is in.
- <p/>
- <p> Also, <var>aPath</var> is modified to contain the unresolved part of the original path.
- </p>
- <p>Caution: May miss existing descendants unless the node has been accessed before.</p>
-
- @return
- <TRUE/> if the path could be resolved completely
- (so <var>aNode</var> and <var>aTree</var> refer to the desired node,
- <var>aPath</var> is empty)<BR/>
- <FALSE/> otherwise
- */
- bool findInnerDescendantAvailable(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
+ bool findInnerChildOrAvailableElement(Tree& aTree, NodeRef& aNode, Name const& aName);
/// test whether the given node is a structural (inner) node
bool isStructuralNode(Tree const& aTree, NodeRef const& aNode);
diff --git a/configmgr/source/inc/roottree.hxx b/configmgr/source/inc/roottree.hxx
index ce99bc42c960..103601490336 100644
--- a/configmgr/source/inc/roottree.hxx
+++ b/configmgr/source/inc/roottree.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottree.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:26:39 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,11 +84,11 @@ namespace configmgr
//-----------------------------------------------------------------------------
- RootTree createReadOnlyTree( AbsolutePath const& aContextPath,
+ RootTree createReadOnlyTree( AbsolutePath const& aRootPath,
ISubtree& rCacheNode, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider);
- RootTree createUpdatableTree( AbsolutePath const& aContextPath,
+ RootTree createUpdatableTree( AbsolutePath const& aRootPath,
ISubtree& rCacheNode, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider);
diff --git a/configmgr/source/inc/template.hxx b/configmgr/source/inc/template.hxx
index 13c8aeadecd6..fd0c8a8a54e9 100644
--- a/configmgr/source/inc/template.hxx
+++ b/configmgr/source/inc/template.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: template.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-04-19 15:13:33 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -153,7 +153,7 @@ namespace configmgr
UnoType getInstanceType() const;
/// get the path where the template is located
- RelativePath getPath() const;
+ OUString getPathString() const;
/// get the local name of the template
Name getName() const { return m_aName; }
diff --git a/configmgr/source/inc/treechangelist.hxx b/configmgr/source/inc/treechangelist.hxx
new file mode 100644
index 000000000000..62311af2a0ea
--- /dev/null
+++ b/configmgr/source/inc/treechangelist.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: treechangelist.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */
+
+
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#define CONFIGMGR_TREECHANGELIST_HXX
+
+#ifndef CONFIGMGR_CHANGE_HXX
+#include "change.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_
+#include "attributes.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
+#include "configpath.hxx"
+#endif
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
+#include <options.hxx>
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+namespace configmgr
+{
+
+////////////////////////////////////////////////////////////////////////////////
+ struct Chg {};
+
+ //==========================================================================
+ //= TreeChangeList
+ //==========================================================================
+ struct TreeChangeList
+ {
+ typedef configuration::AbsolutePath AbsolutePath;
+ typedef configuration::Name Name;
+ typedef configuration::Attributes NodeAttributes;
+
+ TreeChangeList(const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rRootPath, Chg,
+ const SubtreeChange& _aSubtree)
+ : m_xOptions(_xOptions),
+ m_aLocation(_rRootPath),
+ root(_aSubtree) /* EXPENSIVE!!! (deep copy) */
+ {}
+
+ /** ctor
+ @param _rRootPath path to the root of the whole to-be-updated subtree
+ */
+ TreeChangeList( const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rRootPath, Chg,
+ const NodeAttributes& _rAttr = NodeAttributes())
+ : m_xOptions(_xOptions)
+ , m_aLocation(_rRootPath)
+ , root(_rRootPath.getLocalName().getName().toString(), _rAttr)
+ {}
+
+ /** ctor
+ @param _rLocalName relative path within the to-be-updated subtree
+ */
+ TreeChangeList( const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rRootPath, Chg,
+ const Name& _rChildTemplateName,
+ const Name& _rChildTemplateModule,
+ const NodeAttributes& _rAttr = NodeAttributes())
+ : m_xOptions(_xOptions)
+ , m_aLocation(_rRootPath)
+ , root(_rRootPath.getLocalName().getName().toString(), _rChildTemplateName.toString(), _rChildTemplateModule.toString(), _rAttr)
+ {}
+ /** ctor
+ @param _rPathToRoot path to parent of the the root of the whole to-be-updated subtree
+ @param _rLocalName relative path within the to-be-updated subtree
+ * /
+ TreeChangeList( const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rPathToRoot, Chg,
+ const Name& _rLocalName,
+ const NodeAttributes& _rAttr)
+ : m_xOptions(_xOptions)
+ , m_aLocation(_rPathToRoot.compose(_rLocalName))
+ , root(_rLocalName.getName().toString(), _rAttr)
+ {}
+ */
+
+ /** ctor
+ @param _rPathToRoot path to the root of the whole to-be-updated subtree
+ @param _rLocalName relative path within the to-be-updated subtree
+ * /
+ TreeChangeList( const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rPathToRoot, Chg,
+ const Name& _rLocalName,
+ const Name& _rChildTemplateName,
+ const Name& _rChildTemplateModule,
+ const NodeAttributes& _rAttr)
+ : m_xOptions(_xOptions)
+ , m_aLocation(_rPathToRoot)
+ , root(_rLocalName.toString(), _rChildTemplateName.toString(), _rChildTemplateModule.toString(), _rAttr)
+ {}
+ */
+
+ /** ctor
+ @param _rPathToRoot path to the root of the whole to-be-updated subtree
+ @param _rLocalName relative path within the to-be-updated subtree
+ */
+ TreeChangeList( const vos::ORef < OOptions >& _xOptions,
+ const AbsolutePath& _rRootPath, Chg,
+ const ISubtree& _rTree)
+ : m_xOptions(_xOptions)
+ , m_aLocation(_rRootPath)
+ , root(_rTree)
+ {
+ OSL_ENSURE(false, "Test only, because deep copy of subtreechange is very expensive.");
+ }
+
+ /** ctor
+ @param _rTreeList list to initialize the path, no childs are copied
+ */
+ TreeChangeList( const TreeChangeList& _rTree, SubtreeChange::NoChildCopy _rNoCopy)
+ : m_xOptions(_rTree.m_xOptions)
+ , m_aLocation(_rTree.m_aLocation)
+ , root(_rTree.root, _rNoCopy)
+ {}
+
+ /// is root a change for the module root
+ bool isModuleRootChange() const { return m_aLocation.getDepth() <= 1; }
+
+ /// get the module these changes belong to
+ Name getModuleName() const { return m_aLocation.getModuleName(); }
+
+ /// get the full path to the root (location + root-name)
+ void setRootPath(const AbsolutePath& _rRootPath)
+ { m_aLocation = _rRootPath; }
+
+ /// get the full path to the root (location + root-name)
+ AbsolutePath const& getRootNodePath() const { return m_aLocation; }
+
+ /// get the full path to the root (location)
+ AbsolutePath getRootContextPath(Chg) const { return m_aLocation.getParentPath(); }
+
+ vos::ORef < OOptions > getOptions() const { return m_xOptions; }
+
+ public:
+ SubtreeChange root; // the root of the whole tree of updates
+ private:
+ AbsolutePath m_aLocation; // absolute path to the parent of the node corresponding to this->root
+ vos::ORef < OOptions > m_xOptions; // options for the tree that is concerned by these changes
+ };
+//----------------------------------------------------------------------------
+
+} // namespace configmgr
+
+#endif
+
diff --git a/configmgr/source/inc/treeprovider.hxx b/configmgr/source/inc/treeprovider.hxx
index 780146df922f..94e2cefb91e6 100644
--- a/configmgr/source/inc/treeprovider.hxx
+++ b/configmgr/source/inc/treeprovider.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeprovider.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-06-11 09:22:47 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,11 +65,6 @@
#ifndef CONFIGMGR_TREEPROVIDER_HXX
#define CONFIGMGR_TREEPROVIDER_HXX
-#include "change.hxx"
-
-#ifndef _SAL_TYPES_H_
-#include <sal/types.h>
-#endif
#ifndef _CONFIGMGR_COMMONTYPES_HXX_
#include "commontypes.hxx"
#endif
@@ -77,123 +72,45 @@
#include "synchronize.hxx"
#endif
-#ifndef _COM_SUN_STAR_UNO_ANY_H_
-#include <com/sun/star/uno/Any.hxx>
-#endif
-#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
-#include <com/sun/star/uno/Type.hxx>
-#endif
-#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
-#include <com/sun/star/uno/Sequence.hxx>
-#endif
-#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_
-#include <com/sun/star/lang/WrappedTargetException.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
-#include <com/sun/star/container/NoSuchElementException.hpp>
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
+#include "valuenode.hxx"
#endif
#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
#include <options.hxx>
#endif
-#ifndef _OSL_DIAGNOSE_H_
-#include <osl/diagnose.h>
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
#endif
-#ifndef _RTL_USTRING_HXX_
-#include <rtl/ustring.hxx>
+#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
+#include <com/sun/star/uno/RuntimeException.hpp>
#endif
+
#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
#endif
-#ifndef CONFIGMGR_CONFNAME_HXX_
-#include "confname.hxx"
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
#endif
+
namespace configmgr
{
namespace uno = com::sun::star::uno;
- namespace lang = com::sun::star::lang;
- namespace container = com::sun::star::container;
using ::rtl::OUString;
////////////////////////////////////////////////////////////////////////////////
-
-
- //==========================================================================
- //= TreeChangeList
- //==========================================================================
- struct TreeChangeList
+ namespace configuration
{
- vos::ORef < OOptions > m_xOptions; // options for the tree that is concerned by these changes
- ConfigurationName pathToRoot; // absolute path to the root of the whole to-be-updated subtree
- SubtreeChange root; // changes made within this sub tree
- // TreeChangeList(): root(::rtl::OUString(), configuration::Attributes()){}
-
- TreeChangeList(const vos::ORef < OOptions >& _xOptions, const rtl::OUString& _rPathToRoot, const SubtreeChange& _aSubtree)
- : m_xOptions(_xOptions),
- pathToRoot(_rPathToRoot, ConfigurationName::Absolute()),
- root(_aSubtree) /* EXPENSIVE!!! (deep copy) */
- {}
-
- // TreeChangeList(const vos::ORef < OOptions >& _xOptions, const rtl::OUString& _rPathToRoot, auto_ptr<SubtreeChange> _pSubtreeChange)
- // : m_xOptions(_xOptions),
- // pathToRoot(_rPathToRoot),
- // root(*_pSubtreeChange.release()) /* EXPENSIVE!!! (deep copy) */
- // {}
- /** ctor
- @param _rPathToRoot path to the root of the whole to-be-updated subtree
- @param _rLocalName relative path within the to-be-updated subtree
- */
- TreeChangeList( const vos::ORef < OOptions >& _xOptions,
- const rtl::OUString& _rPathToRoot,
- const rtl::OUString& _rLocalName,
- const configuration::Attributes& _rAttr)
- : m_xOptions(_xOptions)
- , pathToRoot(_rPathToRoot, ConfigurationName::Absolute())
- , root(_rLocalName, _rAttr)
- {}
-
- /** ctor
- @param _rPathToRoot path to the root of the whole to-be-updated subtree
- @param _rLocalName relative path within the to-be-updated subtree
- */
- TreeChangeList( const vos::ORef < OOptions >& _xOptions,
- const rtl::OUString& _rPathToRoot,
- const rtl::OUString& _rLocalName,
- const rtl::OUString& _rChildTemplateName,
- const rtl::OUString& _rChildTemplateModule,
- const configuration::Attributes& _rAttr)
- : m_xOptions(_xOptions)
- , pathToRoot(_rPathToRoot, ConfigurationName::Absolute())
- , root(_rLocalName, _rChildTemplateName, _rChildTemplateModule, _rAttr)
- {}
-
- /** ctor
- @param _rPathToRoot path to the root of the whole to-be-updated subtree
- @param _rLocalName relative path within the to-be-updated subtree
- */
- TreeChangeList( const vos::ORef < OOptions >& _xOptions,
- const rtl::OUString& _rPathToRoot,
- const ISubtree& _rTree)
- : m_xOptions(_xOptions)
- , pathToRoot(_rPathToRoot, ConfigurationName::Absolute())
- , root(_rTree)
- {
- OSL_ENSURE(false, "Test only, because deep copy of subtreechange is very expensive.");
- }
-
- /** ctor
- @param _rTreeList list to initialize the path, no childs are copied
- */
- TreeChangeList( const TreeChangeList& _rTree, SubtreeChange::NoChildCopy _rNoCopy)
- : m_xOptions(_rTree.m_xOptions)
- , pathToRoot(_rTree.pathToRoot)
- , root(_rTree.root, _rNoCopy)
- {}
-
- /// get the module these changes belong to
- OUString getModuleName() const;
- };
+ class Name;
+ class AbsolutePath;
+ }
+ //-------------------------
+ class ISubtree;
+ struct TreeChangeList;
//==========================================================================
//= ITreeProvider
@@ -201,10 +118,12 @@ namespace configmgr
class ITreeProvider
{
public:
+ typedef configuration::AbsolutePath AbsolutePath;
+
enum { ALL_LEVELS = -1 };
/// load the tree named by a path using certain options and requiring a specific loading depth - return it yielding ownership
- virtual std::auto_ptr<ISubtree> loadSubtree(OUString const& aSubtreePath,
+ virtual std::auto_ptr<ISubtree> loadSubtree(AbsolutePath const& aSubtreePath,
const vos::ORef < OOptions >& _xOptions,
sal_Int16 nMinLevels = ALL_LEVELS) throw (uno::Exception) = 0;
@@ -221,6 +140,8 @@ namespace configmgr
class ITreeManager : public ISynchronizedData
{
public:
+ typedef configuration::AbsolutePath AbsolutePath;
+
enum { ALL_LEVELS = ITreeProvider::ALL_LEVELS };
/** request that the tree named by a path is added to the collection of managed trees
@@ -228,14 +149,14 @@ namespace configmgr
Return a reference to that managed tree.
The reference must later be released by calling releaseSubtree with the same path and options.
*/
- virtual ISubtree * requestSubtree(OUString const& aSubtreePath,
+ virtual ISubtree * requestSubtree(AbsolutePath const& aSubtreePath,
const vos::ORef < OOptions >& _xOptions,
sal_Int16 nMinLevels = ALL_LEVELS) throw (uno::Exception) = 0;
/** request that the tree named by a path is added to the collection of managed trees
respecting certain options and requiring a specific loading depth.
*/
- virtual void fetchSubtree(OUString const& aSubtreePath,
+ virtual void fetchSubtree(AbsolutePath const& aSubtreePath,
const vos::ORef < OOptions >& _xOptions,
sal_Int16 nMinLevels = ALL_LEVELS) throw() = 0;
@@ -246,7 +167,7 @@ namespace configmgr
virtual void notifyUpdate(TreeChangeList const& aChanges ) throw (uno::RuntimeException) = 0;
// bookkeeping support
- virtual void releaseSubtree(OUString const& aSubtreePath,
+ virtual void releaseSubtree(AbsolutePath const& aSubtreePath,
const vos::ORef < OOptions >& _xOptions ) throw () = 0;
/** data for the given options may not be used any more
@@ -265,8 +186,12 @@ namespace configmgr
class ITemplateProvider
{
public:
- virtual ::std::auto_ptr<INode> requestTemplateInstance(::rtl::OUString const& aName, ::rtl::OUString const& aModule,
- const vos::ORef < OOptions >& _xOptions) throw (uno::Exception) = 0;
+ typedef configuration::Name Name;
+
+ virtual ::std::auto_ptr<INode> requestTemplateInstance(
+ Name const& aName, Name const& aModule,
+ const vos::ORef < OOptions >& _xOptions
+ ) throw (uno::Exception) = 0;
};
diff --git a/configmgr/source/misc/anypair.cxx b/configmgr/source/misc/anypair.cxx
index a200d5d69550..8fe657547216 100644
--- a/configmgr/source/misc/anypair.cxx
+++ b/configmgr/source/misc/anypair.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: anypair.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:16:02 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -255,7 +255,7 @@ namespace configmgr
else if ( typelib_typedescriptionreference_equals(_ppType,_pUnoAny->pType) )
return true;
- else if (_pUnoAny->pData == NULL && _pUnoAny->pType->eTypeClass == typelib_TypeClass_VOID)
+ else if (_pUnoAny->pType->eTypeClass == typelib_TypeClass_VOID)
return true;
else
@@ -269,7 +269,7 @@ namespace configmgr
return false;
bool bOldNull = (*_ppData == NULL);
- bool bNewNull = (_pUnoAny->pData == NULL);
+ bool bNewNull = (_pUnoAny->pType->eTypeClass == typelib_TypeClass_VOID);
if (bOldNull)
{
@@ -295,14 +295,15 @@ namespace configmgr
uno_type_any_assign(&aTmp,_pUnoAny->pData, _pUnoAny->pType, uno::cpp_acquire, uno::cpp_release);
- *_ppData = aTmp.pData;
if (bNewNull)
{
OSL_ASSERT(aTmp.pData == NULL);
+ *_ppData = NULL;
typelib_typedescriptionreference_release(aTmp.pType);
}
else
{
+ *_ppData = aTmp.pData;
*_ppType = aTmp.pType;
}
}
diff --git a/configmgr/source/misc/mergechange.cxx b/configmgr/source/misc/mergechange.cxx
index 79191d72d738..ba96213c09c5 100644
--- a/configmgr/source/misc/mergechange.cxx
+++ b/configmgr/source/misc/mergechange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-05-28 15:25:34 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,20 +61,23 @@
#include <stdio.h>
-#ifndef CONFIGMGR_CONFNAME_HXX_
-#include "confname.hxx"
-#endif
-
-
#include "mergechange.hxx"
+#ifndef CONFIGMGR_CHANGE_HXX
#include "change.hxx"
-#include "treeprovider.hxx"
+#endif
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#include "treechangelist.hxx"
+#endif
+#ifndef _CONFIGMGR_TREEACTIONS_HXX_
#include "treeactions.hxx"
-#include "tracer.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
+#include "configexcept.hxx"
+#endif
-#ifndef _COM_SUN_STAR_UNO_ANY_H_
-#include <com/sun/star/uno/Any.h>
+#ifndef _CONFIGMGR_TRACER_HXX_
+#include "tracer.hxx"
#endif
#define ASCII(x) rtl::OUString::createFromAscii(x)
@@ -82,121 +85,61 @@
namespace configmgr
{
using namespace com::sun::star::uno;
+ using namespace configuration;
+ using namespace std;
- void ONameCreator::init(const ConfigurationName &_aName)
+ RelativePath ONameCreator::buildPath() const
{
- // HACK!
- if (!(_aName.fullName().equals(ASCII("/"))))
- {
- // initial Name
- for(ConfigurationName::Iterator it = _aName.begin();
- it != _aName.end();
- ++it)
- {
- m_aNameList.push_back(*it);
- }
- }
- }
+ Path::Rep aAdded;
- rtl::OUString ONameCreator::createName(const rtl::OUString &aPlusName)
- {
- // create a name
- static rtl::OUString aNameDelimiter = OUString::createFromAscii("/");
- OUString aName;
- for (vector<OUString>::const_iterator it = m_aNameList.begin();
- it != m_aNameList.end();
- it++)
- {
- aName += *it;
- aName += aNameDelimiter;
- }
- if (aPlusName.getLength() == 0)
+ for(NameList::const_reverse_iterator it = m_aNameList.rbegin(),
+ stop = m_aNameList.rend();
+ it != stop;
+ ++it)
{
- aName = aName.copy(0, aName.getLength() - 1);
- }
- else
- {
- aName += aPlusName;
- }
- if (aName[0] == sal_Unicode('/'))
- {
- aName = aName.copy(1);
+ aAdded.prepend(*it);
}
- return aName;
- }
- void ONameCreator::pushName(const rtl::OUString &aName)
- {
- m_aNameList.push_back(aName);
- }
- void ONameCreator::popName()
- {
- m_aNameList.pop_back();
+ return RelativePath(aAdded);
}
+ RelativePath ONameCreator::buildPath(const FullName &aPlusName) const
+ {
+ OSL_ENSURE( !aPlusName.isEmpty(), "To create the base name use the parameterless overload" );
- // -----------------------------------------------------------------------------
-
- // Helperclass to search a change in a given changetree
- OMergeSearchChange::OMergeSearchChange(const rtl::OUString &_aName)
- : m_aSearchName(_aName), m_bFound(false), m_pFoundChange(NULL) {}
+ Path::Rep aAdded(aPlusName);
- void OMergeSearchChange::handle(ValueChange& _rValueNode)
- {
- rtl::OUString aName = createName(_rValueNode.getNodeName());
- if (aName.equals(m_aSearchName))
+ for(NameList::const_reverse_iterator it = m_aNameList.rbegin(),
+ stop = m_aNameList.rend();
+ it != stop;
+ ++it)
{
- m_bFound = true;
- m_pFoundChange = &_rValueNode;
+ aAdded.prepend(*it);
}
- }
- void OMergeSearchChange::handle(AddNode& _rAddNode)
- {
- rtl::OUString aName = createName(_rAddNode.getNodeName());
- if (aName.equals(m_aSearchName))
- {
- m_bFound = true;
- m_pFoundChange = &_rAddNode;
- }
+ return RelativePath(aAdded);
}
- void OMergeSearchChange::handle(RemoveNode& _rRemoveNode)
+ Path::Component ONameCreator::createName(Change const& _rChange, SubtreeChange const* _pParent)
{
- rtl::OUString aName = createName(_rRemoveNode.getNodeName());
- if (aName.equals(m_aSearchName))
+ OSL_ENSURE(_pParent, "ONameCreator: Cannot create proper name without a parent");
+ if (_pParent && _pParent->isSetNodeChange())
{
- m_bFound = true;
- m_pFoundChange = &_rRemoveNode;
- }
- }
+ OUString sElementName = _rChange.getNodeName();
+ OUString sTypeName = _pParent->getElementTemplateName();
- void OMergeSearchChange::handle(SubtreeChange& _rSubtree)
- {
- rtl::OUString aName = createName(_rSubtree.getNodeName());
- if (aName.equals(m_aSearchName))
- {
- m_bFound = true;
- m_pFoundChange = &_rSubtree;
+ return Path::makeCompositeName(sElementName, sTypeName);
}
- if (!m_bFound)
+ else
{
- // recursive descent
- pushName(_rSubtree.getNodeName());
- _rSubtree.forEachChange(*this);
- popName();
- }
- }
+ OUString sElementName = _rChange.getNodeName();
- Change* OMergeSearchChange::searchForChange(Change &aChange)
- {
- applyToChange(aChange);
- if (isFound())
- {
- return m_pFoundChange;
+ OSL_ENSURE(isSimpleName(sElementName),"Unexpected: Non-simple name in non-set node");
+
+ return Path::wrapSafeName(sElementName);
}
- return NULL;
}
+
// -----------------------------------------------------------------------------
class OMergeValueChange : private ChangeTreeModification
{
@@ -367,66 +310,101 @@ namespace configmgr
// -----------------------------------------------------------------------------
// Main class for merging treechangelists
- // ------- Helper for Path stack -------
- void OMergeTreeChangeList::pushTree(SubtreeChange* _pTree)
+ // CTor
+ OMergeTreeChangeList::OMergeTreeChangeList(TreeChangeList& _aTree)
+ :m_aTreeChangeList(_aTree), m_pCurrentParent(NULL)
{
- m_pCurrentParent = _pTree;
- OSL_ENSURE(m_pCurrentParent, "OMergeTreeChangeList::pushTree: must not be NULL!");
- m_aTreePathStack.push_back(_pTree);
}
- void OMergeTreeChangeList::popTree()
+
+ static
+ inline
+ Change* findExistingChange(SubtreeChange* pCurrentParent, Path::Component const & _aName)
{
- m_aTreePathStack.pop_back();
- m_pCurrentParent = m_aTreePathStack.back();
+ OSL_ASSERT(pCurrentParent);
+
+ Change *pChange = pCurrentParent->getChange(_aName.getName().toString());
+
+ if (!pChange && !_aName.isSimpleName())
+ {
+ pChange = pCurrentParent->getChange(_aName.toPathString());
+ OSL_ENSURE(!pChange, "Update trouble: Existing node found only by composite name while merging");
+ }
+
+ return pChange;
}
- // CTor
- OMergeTreeChangeList::OMergeTreeChangeList(TreeChangeList& _aTree)
- :m_aTreeChangeList(_aTree), m_pCurrentParent(NULL)
+ static
+ inline
+ Change* findExistingChange(SubtreeChange* pCurrentParent, OUString const & _aName)
{
+ OSL_ASSERT(pCurrentParent);
+
+ Change *pChange = pCurrentParent->getChange(_aName);
+
+ return pChange;
}
- SubtreeChange* OMergeTreeChangeList::check(const ConfigurationName &_aName)
+ void OMergeTreeChangeList::initRoot(TreeChangeList const& _aChanges)
{
- // First check, if the aName is in the treechangelist
- ONameCreator aNameCreator;
+ AbsolutePath aThisRootPath = m_aTreeChangeList.getRootNodePath();
+ AbsolutePath aStartPath = _aChanges.getRootNodePath();
+
+ RelativePath aEnsurePath = Path::stripPrefix(aStartPath,aThisRootPath);
SubtreeChange* pCurrentParent = &m_aTreeChangeList.root;
- if (!(_aName.fullName().equals(ASCII("/"))))
+ for(RelativePath::Iterator it = aEnsurePath.begin(), stop = aEnsurePath.end();
+ it != stop;
+ ++it)
{
- for(ConfigurationName::Iterator it = _aName.begin();
- it != _aName.end();
- ++it)
+ Change *pChange = findExistingChange(pCurrentParent,*it);
+
+ if (!pChange)
{
- aNameCreator.pushName(*it);
- rtl::OUString aSearchName = aNameCreator.createName(OUString());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aTreeChangeList.root);
+ // create a correspondens for the name, we did not find.
+ auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(it->getName().toString(), configuration::Attributes()));
+ pChange = pNewChange.get();
- if (!pChange)
- {
- // create a correspondens for the name, we not found.
- auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(*it, configuration::Attributes()));
- pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
+ pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
- pChange = a.searchForChange(m_aTreeChangeList.root);
- }
- pCurrentParent = SAL_STATIC_CAST(SubtreeChange*, pChange);
+ OSL_ENSURE(pChange == findExistingChange(pCurrentParent,*it),
+ "ERROR: Newly added change cannot be found in parent change");
}
+
+ if (!pChange->ISA(SubtreeChange))
+ 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);
}
- return pCurrentParent;
+
+ this->init(aStartPath);
+
+ m_pCurrentParent = pCurrentParent;
+ }
+
+ // ------- Helper for Path stack -------
+ SubtreeChange* OMergeTreeChangeList::pushTree(SubtreeChange& _rTree)
+ {
+ pushName( ONameCreator::createName(_rTree,m_pCurrentParent) );
+
+ SubtreeChange* pSave = m_pCurrentParent;
+ m_pCurrentParent = &_rTree;
+ return pSave;
+ }
+ void OMergeTreeChangeList::popTree(SubtreeChange* _pSaveTree)
+ {
+ m_pCurrentParent = _pSaveTree;
+
+ popName();
}
// start function, with the Change we want to do.
// WARNING this could be a big tree, because a change can contain subtreechanges!
- void OMergeTreeChangeList::handleChange(TreeChangeList &_rList)
+ void OMergeTreeChangeList::mergeChanges(TreeChangeList const&_rList)
{
- ConfigurationName aName = _rList.pathToRoot;
- init(aName); // our Name start with pathToRoot
- m_pCurrentParent = check(aName); // pathToRoot must exist or will be created
+ initRoot(_rList ); // path location being merged must exist
- applyToChange(_rList.root);
+ this->applyToChildren(_rList.root);
}
// Algorithm: search the actual path in the out m_aTreeChangeList
@@ -441,14 +419,13 @@ namespace configmgr
void OMergeTreeChangeList::handle(ValueChange const& _rValueNode)
{
// Handle a ValueChange,
- rtl::OUString aSearchName = createName(_rValueNode.getNodeName()); // this construct is only for better debugging
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aTreeChangeList.root);
- if (pChange)
+ OUString aNodeName = _rValueNode.getNodeName();
+
+ if (Change *pChange = findExistingChange(m_pCurrentParent,aNodeName))
{
// Value found, merge content
- OMergeValueChange a(*m_pCurrentParent,_rValueNode);
- a.handleChange(*pChange);
+ OMergeValueChange aMergeValue(*m_pCurrentParent,_rValueNode);
+ aMergeValue.handleChange(*pChange);
}
else
{
@@ -461,13 +438,11 @@ namespace configmgr
void OMergeTreeChangeList::handle(AddNode const& _rAddNode)
{
// Handle an AddNode
- rtl::OUString aSearchName = createName(_rAddNode.getNodeName());
+ bool bReplacing = _rAddNode.isReplacing();
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aTreeChangeList.root);
+ OUString aNodeName = _rAddNode.getNodeName();
- bool bReplacing = _rAddNode.isReplacing();
- if (pChange)
+ if (Change *pChange = findExistingChange(m_pCurrentParent,aNodeName))
{
OSL_ENSURE(pChange->ISA(RemoveNode) || bReplacing, "OMergeTreeChangeList::handle(AddNode): the changes tree given already contains a change for this!");
@@ -490,11 +465,11 @@ namespace configmgr
void OMergeTreeChangeList::handle(RemoveNode const& _rRemoveNode)
{
// Handle a RemoveNode
- rtl::OUString aSearchName = createName(_rRemoveNode.getNodeName());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aTreeChangeList.root);
+ OUString aNodeName = _rRemoveNode.getNodeName();
+
+ Change *pChange = findExistingChange(m_pCurrentParent,aNodeName);
- // examine what to do with this change
+ // examine what to do with this change
OMergeRemoveNode aExaminer;
aExaminer.handleChange(pChange);
@@ -502,7 +477,7 @@ namespace configmgr
if (pChange)
m_pCurrentParent->removeChange(pChange->getNodeName());
- // insert a new change if necessary
+ // insert a new change if necessary
switch (aExaminer.getAction())
{
case OMergeRemoveNode::RemoveCompletely:
@@ -533,9 +508,9 @@ namespace configmgr
// with the pointer m_pCurrentParent we remember our SubtreeChange in witch we
// add all other Changes.
- rtl::OUString aSearchName = createName(_rSubtree.getNodeName());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aTreeChangeList.root);
+ OUString aNodeName = _rSubtree.getNodeName();
+
+ Change *pChange = findExistingChange(m_pCurrentParent,aNodeName);
// const sal_Char* pType = pChange ? pChange->getType() : NULL;
SubtreeChange* pSubtreeChange = NULL;
@@ -546,34 +521,36 @@ namespace configmgr
{
// create a new SubtreeChange
auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(_rSubtree, SubtreeChange::NoChildCopy()));
+ pSubtreeChange = pNewChange.get();
+
// add the new SubtreeChange in m_aTreeChangeList
m_pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
- // check list and get this new SubtreeChange
- pChange = a.searchForChange(m_aTreeChangeList.root);
+ // check list for this new SubtreeChange
+ OSL_ASSERT(pSubtreeChange == findExistingChange(m_pCurrentParent,aNodeName));
}
- // hard cast(!) to SubtreeChange because we are a SubtreeChange
- pSubtreeChange = SAL_STATIC_CAST(SubtreeChange*, pChange);
+ else // hard cast(!) to SubtreeChange because we are a SubtreeChange
+ pSubtreeChange = static_cast<SubtreeChange*>(pChange);
// save this SubtreeChange so we allways have the last Subtree
- pushTree(pSubtreeChange); // remember the SubtreeChange Pointer
- pushName(_rSubtree.getNodeName()); // pathstack
- _rSubtree.forEachChange(*this);
- popName();
- popTree();
+ SubtreeChange* pSaveParent = pushTree(*pSubtreeChange);
+ this->applyToChildren(_rSubtree);
+ popTree( pSaveParent );
}
else if (pChange->ISA(AddNode))
{
// in this AddNode should be a subtree, NOT a subtreechange
- AddNode* pAddNode = SAL_STATIC_CAST(AddNode*, pChange);
+ AddNode* pAddNode = static_cast<AddNode*>(pChange);
INode* pNode = pAddNode->getAddedNode();
ISubtree* pSubtree = pNode ? pNode->asISubtree() : 0;
if (pSubtree)
{
// pSubtree = pSubtree + _rSubtree;
+ AbsolutePath aSubtreePath = this->createPath( ONameCreator::createName(_rSubtree,m_pCurrentParent) );
+ OSL_ASSERT( aSubtreePath.getLocalName().getName().toString() == pSubtree->getName() );
// Now apply _rSubtree to the subtree
- TreeChangeList aChangeList(m_aTreeChangeList.m_xOptions, aSearchName, _rSubtree); // expensive!
+ TreeChangeList aChangeList(m_aTreeChangeList.getOptions(), aSubtreePath, Chg(), _rSubtree); // expensive!
apply(aChangeList, *pSubtree);
// This isn't correct today because _rSubtree is const and this construct require that _rSubtree isn't const
@@ -582,86 +559,97 @@ namespace configmgr
}
else
{
- OSL_ENSURE(false, "OMergeTreeChangeList: There is a wrong subtree type node found.");
+ OSL_ENSURE(false, "OMergeTreeChangeList: Unexpected node type found in an AddNode.");
/* wrong type of node found: bse ASSERTEN/WERFEN */;
}
}
else
{
- OSL_ENSURE(false, "OMergeTreeChangeList: There is a wrong type node found.");
+ OSL_ENSURE(false, "OMergeTreeChangeList: Unexpected change type found for a subtree.");
/* wrong type of node found: bse ASSERTEN/WERFEN */;
}
}
// -----------------------------------------------------------------------------
- // ------- Helper for Path stack -------
- void OMergeChanges::pushTree(SubtreeChange* _pTree)
- {
- m_pCurrentParent = _pTree;
- OSL_ENSURE(m_pCurrentParent, "OMergeChanges::pushTree: must not be NULL!");
- m_aTreePathStack.push_back(_pTree);
- }
- void OMergeChanges::popTree()
- {
- m_aTreePathStack.pop_back();
- m_pCurrentParent = m_aTreePathStack.back();
- }
-
// CTor
- OMergeChanges::OMergeChanges(SubtreeChange& _aTree)
- :m_aSubtreeChange(_aTree), m_pCurrentParent(NULL)
+ OMergeChanges::OMergeChanges(SubtreeChange& _rTree)
+ : m_rSubtreeChange(_rTree), m_pCurrentParent(NULL)
{
}
- SubtreeChange* OMergeChanges::check(const ConfigurationName &_aName)
+ void OMergeChanges::initRoot(const RelativePath& _aPathToChange)
{
- // First check, if the aName is in the subtreechange
- ONameCreator aNameCreator;
-
- SubtreeChange* pCurrentParent = &m_aSubtreeChange;
+ SubtreeChange* pCurrentParent = &m_rSubtreeChange;
- if (!(_aName.fullName().equals(ASCII("/"))))
+ for(RelativePath::Iterator it = _aPathToChange.begin(), stop = _aPathToChange.end();
+ it != stop;
+ ++it)
{
- for(ConfigurationName::Iterator it = _aName.begin();
- it != _aName.end();
- ++it)
- {
- aNameCreator.pushName(*it);
- rtl::OUString aSearchName = aNameCreator.createName(OUString());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aSubtreeChange);
+ Change *pChange = findExistingChange(pCurrentParent,*it);
- if (!pChange)
- {
- // create a correspondens for the name, we not found.
- auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(*it, configuration::Attributes()));
- pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
+ if (!pChange)
+ {
+ // create a correspondens for the name, we did not find.
+ auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(it->getName().toString(), configuration::Attributes()));
+ pChange = pNewChange.get();
- pChange = a.searchForChange(m_aSubtreeChange);
- }
- pCurrentParent = SAL_STATIC_CAST(SubtreeChange*, pChange);
+ pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
- // HACK!
- // no descent to anything, we are flat!
- break;
+ OSL_ENSURE(pChange == 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);
}
- return pCurrentParent;
+
+ this->init(_aPathToChange);
+
+ m_pCurrentParent = pCurrentParent;
}
+ // -----------------------------------------------------------------------------
+
+ // ------- Helper for Path stack -------
+ SubtreeChange* OMergeChanges::pushTree(SubtreeChange& _rTree)
+ {
+ pushName( ONameCreator::createName(_rTree,m_pCurrentParent) );
+
+ SubtreeChange* pSave = m_pCurrentParent;
+ m_pCurrentParent = &_rTree;
+ return pSave;
+ }
+ void OMergeChanges::popTree(SubtreeChange* _pSaveTree)
+ {
+ m_pCurrentParent = _pSaveTree;
+
+ popName();
+ }
+ // -----------------------------------------------------------------------------
+
+ // start function, with the Change we want to do.
+ // 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);
+ }
+ // -----------------------------------------------------------------------------
// start function, with the Change we want to do.
// WARNING this could be a big tree, because a change can contain subtreechanges!
- void OMergeChanges::handleChange(const SubtreeChange &_rList, const rtl::OUString &_aPathToRoot)
+ void OMergeChanges::mergeChanges(const SubtreeChange &_rChange, const RelativePath& _aPathToChange)
{
- rtl::OUString aPath = _aPathToRoot;
- ConfigurationName aName(aPath, ConfigurationName::Absolute());
- // try to use an empty List.
- // init(aName); // our Name start with pathToRoot
- m_pCurrentParent = check(aName); // pathToRoot must exist or will be created
+ initRoot( _aPathToChange); // path location being merged must exist
- applyToChange(_rList);
+ this->applyToChildren(_rChange); //- semantics ?
+ //this->applyToChange(_rChange);
}
+ // -----------------------------------------------------------------------------
// Algorithm: search the actual path in the out m_aSubtreeChange
// if we found something, we must merge/convert the Node with our Node
@@ -675,14 +663,13 @@ namespace configmgr
void OMergeChanges::handle(ValueChange const& _rValueNode)
{
// Handle a ValueChange,
- rtl::OUString aSearchName = createName(_rValueNode.getNodeName()); // this construct is only for better debugging
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aSubtreeChange);
- if (pChange)
+ OUString aNodeName = _rValueNode.getNodeName();
+
+ if (Change *pChange = findExistingChange(m_pCurrentParent,aNodeName))
{
// Value found, merge content
- OMergeValueChange a(*m_pCurrentParent,_rValueNode);
- a.handleChange(*pChange);
+ OMergeValueChange aMergeValue(*m_pCurrentParent,_rValueNode);
+ aMergeValue.handleChange(*pChange);
}
else
{
@@ -691,22 +678,24 @@ namespace configmgr
m_pCurrentParent->addChange(pNewChange);
}
}
+ // -----------------------------------------------------------------------------
void OMergeChanges::handle(AddNode const& _rAddNode)
{
// Handle an AddNode
- rtl::OUString aSearchName = createName(_rAddNode.getNodeName());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aSubtreeChange);
-
bool bReplacing = _rAddNode.isReplacing();
- if (pChange)
+
+ OUString aNodeName = _rAddNode.getNodeName();
+
+ if (Change *pChange = findExistingChange(m_pCurrentParent,aNodeName))
{
- OSL_ENSURE(pChange->ISA(RemoveNode) || bReplacing, "OMergeTreeChangeList::handle(AddNode): the changes tree given already contains a change for this!");
+ OSL_ENSURE(pChange->ISA(RemoveNode) || bReplacing, "OMergeChanges::handle(AddNode): the changes tree given already contains a change for this!");
m_pCurrentParent->removeChange(pChange->getNodeName());
+
bReplacing = true;
}
+
// insert manually
auto_ptr<INode> pNode = auto_ptr<INode>(_rAddNode.getAddedNode()->clone());
@@ -717,15 +706,16 @@ namespace configmgr
auto_ptr<Change> pNewChange( pNewAdd.release() );
m_pCurrentParent->addChange(pNewChange);
}
+ // -----------------------------------------------------------------------------
void OMergeChanges::handle(RemoveNode const& _rRemoveNode)
{
// Handle a RemoveNode
- rtl::OUString aSearchName = createName(_rRemoveNode.getNodeName());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aSubtreeChange);
+ OUString aNodeName = _rRemoveNode.getNodeName();
- // examine what to do with this change
+ Change *pChange = findExistingChange(m_pCurrentParent,aNodeName);
+
+ // examine what to do with this change
OMergeRemoveNode aExaminer;
aExaminer.handleChange(pChange);
@@ -733,7 +723,7 @@ namespace configmgr
if (pChange)
m_pCurrentParent->removeChange(pChange->getNodeName());
- // insert a new change if necessary
+ // insert a new change if necessary
switch (aExaminer.getAction())
{
case OMergeRemoveNode::RemoveCompletely:
@@ -752,9 +742,12 @@ namespace configmgr
}
}
+// -----------------------------------------------------------------------------
+
+
// -----------------------------------------------------------------------------
- class TreeUpdater : public ChangeTreeModification
+ class TreeUpdater : public ChangeTreeAction
{
ISubtree* m_pCurrentSubtree;
#if DEBUG
@@ -764,16 +757,15 @@ namespace configmgr
public:
TreeUpdater(ISubtree* pSubtree):m_pCurrentSubtree(pSubtree){}
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
+ void handle(ValueChange const& aValueNode);
+ void handle(AddNode const& aAddNode);
+ void handle(RemoveNode const& aRemoveNode);
+ void handle(SubtreeChange const& aSubtree);
};
// -----------------------------------------------------------------------------
-
- void OMergeChanges::handle(SubtreeChange const& _rSubtreeChange)
+ void OMergeChanges::handle(SubtreeChange const& _rSubtree)
{
// Handle a SubtreeChange
// we must check if exact this SubtreeChange is in the TreeChangeList, if not,
@@ -781,94 +773,62 @@ namespace configmgr
// with the pointer m_pCurrentParent we remember our SubtreeChange in witch we
// add all other Changes.
- rtl::OUString aSearchName = createName(_rSubtreeChange.getNodeName());
- OMergeSearchChange a(aSearchName);
- Change *pChange = a.searchForChange(m_aSubtreeChange);
+ OUString aNodeName = _rSubtree.getNodeName();
+ Change *pChange = findExistingChange(m_pCurrentParent,aNodeName);
+
+ // const sal_Char* pType = pChange ? pChange->getType() : NULL;
SubtreeChange* pSubtreeChange = NULL;
if (pChange == NULL || pChange->ISA(SubtreeChange))
{
- // hard cast(!) to SubtreeChange because we are a SubtreeChange
- pSubtreeChange = SAL_STATIC_CAST(SubtreeChange*, pChange);
- if (pSubtreeChange)
- {
- // Value found, nothing to be done, because we are a SubtreeChange
- // we only must go downstairs
- }
- else
+ // need to create a new Subtreechange
+ if (!pChange)
{
// create a new SubtreeChange
- auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(_rSubtreeChange, SubtreeChange::NoChildCopy()));
+ auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(_rSubtree, SubtreeChange::NoChildCopy()));
+ pSubtreeChange = pNewChange.get();
+
// add the new SubtreeChange in m_aTreeChangeList
m_pCurrentParent->addChange(auto_ptr<Change>(pNewChange.release()));
- // check list and get this new SubtreeChange
- pChange = a.searchForChange(m_aSubtreeChange);
- pSubtreeChange = SAL_STATIC_CAST(SubtreeChange*, pChange);
+ // check list for this new SubtreeChange
+ OSL_ASSERT(pSubtreeChange == findExistingChange(m_pCurrentParent,aNodeName));
}
+ else // hard cast(!) to SubtreeChange because we are a SubtreeChange
+ pSubtreeChange = static_cast<SubtreeChange*>(pChange);
+
// save this SubtreeChange so we allways have the last Subtree
- pushTree(pSubtreeChange); // remember the SubtreeChange Pointer
- pushName(_rSubtreeChange.getNodeName()); // pathstack
- _rSubtreeChange.forEachChange(*this);
- popName();
- popTree();
+ SubtreeChange* pSaveParent = pushTree(*pSubtreeChange);
+ this->applyToChildren(_rSubtree);
+ popTree( pSaveParent );
}
else if (pChange->ISA(AddNode))
{
- // OSL_ENSURE(false, "sorry, no addnode in subtreechange! can't supported yet.");
-
- AddNode* pAddNode = SAL_STATIC_CAST(AddNode*, pChange);
+ AddNode* pAddNode = static_cast<AddNode*>(pChange);
INode* pNode = pAddNode->getAddedNode();
- ISubtree* pISubtree = pNode ? pNode->asISubtree() : 0;
-
- OSL_ENSURE(pISubtree, "Warning: there is no Subtree in the AddNode");
- if (pISubtree)
+ ISubtree* pSubtree = pNode ? pNode->asISubtree() : 0;
+ if (pSubtree)
{
- // ----------------------------
- // pISubtree += _rSubtreeChange
- // ----------------------------
-
- // Merge _rSubtreeChange into pSubtree using a TreeUpdate object
- SubtreeChange *pSubtreeChange = SAL_STATIC_CAST(SubtreeChange*, _rSubtreeChange.clone());
- TreeUpdater aTreeUpdate(pISubtree);
- pSubtreeChange->forEachChange(aTreeUpdate);
-
-//
-// // auto_ptr<SubtreeChange> pNewChange(new SubtreeChange(_rSubtreeChange, SubtreeChange::NoChildCopy()));
-// // OMergeTreeAction aChangeHandler(*pNewChange.get(), pISubtree);
-// // pNewChange.get()->forEachChange(aChangeHandler);
-//
-// TreeChangeList aMergeChangeList(NULL, _rSubtreeChange.getNodeName(), _rSubtreeChange);
-//
-// OMergeTreeAction aChangeHandler(aMergeChangeList.root, pISubtree);
-// m_aSubtreeChange.forEachChange(aChangeHandler);
-//
-// // now check the real modifications
-// OChangeActionCounter aChangeCounter;
-// // aChangeCounter.handle(*pNewChange.get());
-// aChangeCounter.handle(aMergeChangeList.root);
-//
-// CFG_TRACE_INFO("cache manager: counted changes from notification : additions: %i , removes: %i, value changes: %i", aChangeCounter.nAdds, aChangeCounter.nRemoves, aChangeCounter.nValues);
-// if (aChangeCounter.hasChanges())
-// {
-// // pNewChange.get()->forEachChange(aTreeUpdate);
-// aMergeChangeList.root.forEachChange(aTreeUpdate);
-// }
+ // Now apply _rSubtree to the subtree
+ TreeUpdater aTreeUpdate(pSubtree);
+ aTreeUpdate.applyToChildren(_rSubtree);
}
else
{
- // wrong type of node found: bse ASSERTEN/WERFEN
+ OSL_ENSURE(false, "OMergeChanges: Unexpected node type found in an AddNode.");
+ /* wrong type of node found: bse ASSERTEN/WERFEN */;
}
}
else
{
- // wrong type of node found: bse ASSERTEN/WERFEN
+ OSL_ENSURE(false, "OMergeChanges: Unexpected change type found for a subtree.");
+ /* wrong type of node found: bse ASSERTEN/WERFEN */;
}
}
// --------------------------------- updateTree ---------------------------------
- void TreeUpdater::handle(ValueChange& aValueNode)
+ void TreeUpdater::handle(ValueChange const& aValueNode)
{
// Change a Value
OSL_ENSURE(m_pCurrentSubtree,"Cannot apply ValueChange without subtree");
@@ -880,7 +840,7 @@ namespace configmgr
OSL_ENSURE(pValue,"Cannot apply ValueChange: Node is not a value");
if (pValue)
- aValueNode.applyTo(*pValue);
+ aValueNode.applyChangeNoRecover(*pValue);
#ifdef DEBUG
else
{
@@ -892,7 +852,7 @@ namespace configmgr
#endif
}
- void TreeUpdater::handle(AddNode& aAddNode)
+ void TreeUpdater::handle(AddNode const& aAddNode)
{
// Add a new Value
if (m_pCurrentSubtree)
@@ -906,15 +866,11 @@ namespace configmgr
if (aOldNode.get() == NULL)
aLog.push_back(rtl::OString("TreeUpdater: can't recover node being replaced (for AddNode)"));
#endif
- if (aOldNode.get() != NULL)
- {
- OIdRemover::removeIds(*aOldNode);
- }
-
- aAddNode.takeReplacedNode( aOldNode );
}
- m_pCurrentSubtree->addChild(aAddNode.releaseAddedNode());
+ auto_ptr<INode> pNode = auto_ptr<INode>(aAddNode.getAddedNode()->clone());
+
+ m_pCurrentSubtree->addChild(pNode);
OIdPropagator::propagateIdToChildren(*m_pCurrentSubtree);
}
@@ -925,49 +881,47 @@ namespace configmgr
}
- void TreeUpdater::handle(RemoveNode& aRemoveNode)
+ void TreeUpdater::handle(RemoveNode const& aRemoveNode)
{
// remove a Value
if (m_pCurrentSubtree)
{
std::auto_ptr<INode> aOldNode = m_pCurrentSubtree->removeChild(aRemoveNode.getNodeName());
- sal_Bool bOk = (NULL != aOldNode.get());
- if (bOk)
- {
- OIdRemover::removeIds(*aOldNode);
- }
- aRemoveNode.takeRemovedNode( aOldNode );
-
#ifdef DEBUG
- if (!bOk)
+ if (NULL == aOldNode.get())
{
::rtl::OString aStr("TreeUpdater: Can't remove child with name:=");
aStr += rtl::OUStringToOString(aRemoveNode.getNodeName(),RTL_TEXTENCODING_ASCII_US);
- OSL_ENSURE(bOk, aStr.getStr());
+ OSL_ENSURE(false, aStr.getStr());
aLog.push_back(aStr);
}
#endif
}
}
- void TreeUpdater::handle(SubtreeChange& _aSubtree)
+ void TreeUpdater::handle(SubtreeChange const& _aSubtree)
{
// handle traversion
ISubtree *pOldSubtree = m_pCurrentSubtree;
rtl::OUString aNodeName = _aSubtree.getNodeName();
- OSL_ENSURE(m_pCurrentSubtree->getChild(aNodeName), "TreeUpdater::handle : invalid subtree change ... this will crash !");
- m_pCurrentSubtree = m_pCurrentSubtree->getChild(aNodeName)->asISubtree();
+
+ INode* pChild = m_pCurrentSubtree->getChild(aNodeName);
+ OSL_ENSURE(pChild, "TreeUpdater::handle : invalid subtree change ... no child for change !");
+ m_pCurrentSubtree = pChild ? pChild->asISubtree() : NULL;
#if DEBUG
- ::rtl::OString aStr("TreeUpdater: there is no Subtree for name:=");
- aStr += rtl::OUStringToOString(_aSubtree.getNodeName(),RTL_TEXTENCODING_ASCII_US);
- OSL_ENSURE(m_pCurrentSubtree, aStr.getStr());
if (!m_pCurrentSubtree)
+ {
+ ::rtl::OString aStr("TreeUpdater: there is no Subtree for name:=");
+ aStr += rtl::OUStringToOString(_aSubtree.getNodeName(),RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSURE(false, aStr.getStr());
aLog.push_back(aStr);
+ }
#endif
+ // recurse
+ if (m_pCurrentSubtree) _aSubtree.forEachChange(*this);
- _aSubtree.forEachChange(*this);
m_pCurrentSubtree = pOldSubtree;
}
diff --git a/configmgr/source/registry/cfgregistrykey.cxx b/configmgr/source/registry/cfgregistrykey.cxx
index 63dc4fb20bb9..d98fb6c1caee 100644
--- a/configmgr/source/registry/cfgregistrykey.cxx
+++ b/configmgr/source/registry/cfgregistrykey.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cfgregistrykey.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: obo $ $Date: 2001-03-02 15:52:25 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -103,6 +103,9 @@
#ifndef _COM_SUN_STAR_BEANS_XPROPERTY_HPP_
#include <com/sun/star/beans/XProperty.hpp>
#endif
+#ifndef _COM_SUN_STAR_UTIL_XSTRINGESCAPE_HPP_
+#include <com/sun/star/util/XStringEscape.hpp>
+#endif
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
@@ -111,7 +114,11 @@
#include <typelib/typedescription.hxx>
#endif
+#ifndef INCLUDED_LIMITS
#include <limits>
+#define INCLUDED_LIMITS
+#endif
+
#define THISREF() static_cast< ::cppu::OWeakObject* >(this)
#define UNISTRING(c) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(c) )
@@ -123,6 +130,7 @@ namespace configmgr
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::container;
@@ -179,16 +187,14 @@ OUString getNodeName(const Reference< XNameAccess >& _xNode)
if (xName.is())
return xName->getName();
- // fallback
- Reference< XHierarchicalName > xPath( _xNode, UNO_QUERY );
- if (xPath.is())
- return xPath->getHierarchicalName();
-
OSL_ENSURE( !_xNode.is(), "Cannot get name of node");
return OUString();
}
//--------------------------------------------------------------------------
+static bool splitPath(const OUString& _sPath, OUString& _rsParentPath, OUString& _rsLocalName);
+//--------------------------------------------------------------------------
+
OConfigurationRegistryKey::OConfigurationRegistryKey
(const Reference< XNameAccess >& _rxRootNode
,sal_Bool _bWriteable
@@ -212,7 +218,7 @@ OConfigurationRegistryKey::OConfigurationRegistryKey
,m_bReadOnly(!_bWriteable)
,m_xNode(_rxNode)
,m_xParentNode()
- ,m_sLocalName( getNodeName(_rxNode) ) // this will be treated as root
+ ,m_sLocalName( getNodeName(_rxNode) ) // this will not be treated as root
{
OSL_ENSURE(m_xNode.is(), "OConfigurationRegistryKey::OConfigurationRegistryKey : invalid config node param !");
}
@@ -627,27 +633,31 @@ Any OConfigurationRegistryKey::implGetDescendant(const OUString& _rDescendantNam
try
{
- if (-1 != _rDescendantName.indexOf('/'))
+ if (!m_xNode.is())
{
- Reference< XHierarchicalNameAccess > xDeepAccess( m_xNode, UNO_QUERY );
- if (xDeepAccess.is())
- aElementReturn = xDeepAccess->getByHierarchicalName(_rDescendantName);
- else
- throw InvalidRegistryException(UNISTRING("Nested element access not supported by this node."), THISREF());
+ // implEnsureNode should have been called before this method
+ OSL_ENSURE(sal_False, "OConfigurationRegistryKey::getDescendant : invalid call !");
+
+ // this method should not be called if the object does not represent a container node ...
+ throw InvalidRegistryException(UNISTRING("invalid object."), THISREF());
}
- else
+
+ try
{
- if (m_xNode.is())
- aElementReturn = m_xNode->getByName(_rDescendantName);
+ // look for a local member first
+ aElementReturn = m_xNode->getByName(_rDescendantName);
+ }
+ catch(NoSuchElementException&)
+ {
+ // is it a (possibly) hierarchical name ?
+ if ( _rDescendantName.indexOf('/') <0 ) throw;
- else
- {
- // implEnsureNode should have been called before this method
- OSL_ENSURE(sal_False, "OConfigurationRegistryKey::getDescendant : invalid call !");
+ // Yes, so try deep access
+ Reference< XHierarchicalNameAccess > xDeepAccess( m_xNode, UNO_QUERY );
+ if (!xDeepAccess.is())
+ throw InvalidRegistryException(UNISTRING("Nested element access not supported by this node."), THISREF());
- // this method should not be called if the object does not represent a container node ...
- throw InvalidRegistryException(UNISTRING("invalid object."), THISREF());
- }
+ aElementReturn = xDeepAccess->getByHierarchicalName(_rDescendantName);
}
}
catch(NoSuchElementException&)
@@ -1193,36 +1203,27 @@ Reference< XRegistryKey > OConfigurationRegistryKey::implGetKey( const ::rtl::OU
}
#endif
- Reference< XNameAccess > xDescParent(m_xNode); // the parent config node of the descandent
-
- OUString sDescRelativeName(_rKeyName);
- sal_Int32 nSeparatorPos = _rKeyName.lastIndexOf('/');
-
- if ( (nSeparatorPos > 0) && (nSeparatorPos == (_rKeyName.getLength() - 1)) )
- {
- // recognize a trailing slash
- sDescRelativeName = sDescRelativeName.copy(0, nSeparatorPos);
- OSL_ASSERT(sDescRelativeName.getLength() == nSeparatorPos);
+ OSL_ASSERT(m_xNode.is());
- nSeparatorPos = sDescRelativeName.lastIndexOf('/');
- OSL_ASSERT(sDescRelativeName.getLength() > nSeparatorPos);
- }
+ Reference< XNameAccess > xDescParent(m_xNode); // the parent config node of the descandent
+ OUString sDescRelativeName( _rKeyName ); // local name of the descendant within xDescParent
- if (nSeparatorPos >= 1)
+ if (!m_xNode->hasByName(_rKeyName)) // it is a hierarchical Path -> more work
{
- Any aDescParent = implGetDescendant(_rKeyName.copy(0, nSeparatorPos));
- ::cppu::extractInterface(xDescParent, aDescParent);
- if (!xDescParent.is())
- throw InvalidRegistryException(UNISTRING("The internal registry structure seems to be corrupt."), THISREF());
+ OUString sParentLocation;
- // will be the name of the new key relative to it's parent
- sDescRelativeName = sDescRelativeName.copy(nSeparatorPos + 1);
- }
- else if (nSeparatorPos == 0)
- {
- OSL_ENSURE(false, "Component root path specified for value ?");
- throw InvalidRegistryException(UNISTRING("Component root path found for value. The internal registry structure seems to be corrupt."), THISREF());
+ if ( !splitPath(_rKeyName, sParentLocation, sDescRelativeName) )
+ {
+ throw InvalidRegistryException(UNISTRING("Cannot split path for value. The internal registry structure seems to be corrupt."), THISREF());
+ }
+ if (sParentLocation.getLength())
+ {
+ Any aDescParent = implGetDescendant(sParentLocation);
+ ::cppu::extractInterface(xDescParent, aDescParent);
+ if (!xDescParent.is())
+ throw InvalidRegistryException(UNISTRING("The internal registry structure seems to be corrupt."), THISREF());
+ }
}
OSL_ENSURE(xDescParent.is(), "No Parent Node found for value ?");
@@ -1240,25 +1241,71 @@ Reference< XRegistryKey > SAL_CALL OConfigurationRegistryKey::openKey( const ::r
return implGetKey(_rKeyName);
}
-
//--------------------------------------------------------------------------
-void OConfigurationRegistryKey::checkRelativeKeyName(OUString& _rKeyName) throw(InvalidRegistryException, RuntimeException)
+bool OConfigurationRegistryKey::checkRelativeKeyName(OUString& _rKeyName) throw(InvalidRegistryException, RuntimeException)
{
// no empty names allowed
if (!_rKeyName.getLength())
throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
- // no absolute names ("/...") allowed
- if (_rKeyName.getStr()[0] == '/')
- throw InvalidRegistryException(UNISTRING("The key name is invalid. It must be a relative, not an absolute name."), THISREF());
+ bool bCleanPath = true;
// cut trailing slashes
- while (_rKeyName.getLength() && (_rKeyName.getStr()[_rKeyName.getLength() - 1] == '/'))
- _rKeyName = _rKeyName.copy(0, _rKeyName.getLength() - 1);
+ sal_Int32 nCleanEnd = _rKeyName.getLength();
+ while (nCleanEnd > 0 && _rKeyName[nCleanEnd - 1] == '/' )
+ --nCleanEnd;
- if (!_rKeyName.getLength())
- // the original name consists of slashes only
- throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
+ if (m_xNode.is())
+ {
+ if (m_xNode-> hasByName(_rKeyName))
+ {
+ bCleanPath = false;
+ }
+
+ else
+ {
+ Reference< XStringEscape > xSE(m_xNode, UNO_QUERY);
+
+ sal_Bool bPreferLocal = xSE.is();
+
+ if (!bPreferLocal)
+ {
+ Reference< XServiceInfo > xSI(m_xNode, UNO_QUERY);
+ if (xSI.is() && xSI->supportsService(OUString::createFromAscii("com.sun.star.configuration.SetAccess")))
+ bPreferLocal = true;
+ }
+
+ if (bPreferLocal)
+ {
+ Reference< XHierarchicalNameAccess > xHA(m_xNode, UNO_QUERY);
+ OUString sCleanName = _rKeyName.copy(0, nCleanEnd);
+
+ if (xHA.is() && xHA->hasByHierarchicalName(sCleanName))
+ bPreferLocal = false;
+ }
+
+ if (bPreferLocal && xSE.is())
+ {
+ _rKeyName = xSE->escapeString(_rKeyName);
+ }
+ bCleanPath = !bPreferLocal;
+ }
+ }
+
+ if (bCleanPath)
+ {
+ // no absolute names ("/...") allowed
+ if (_rKeyName.getStr()[0] == '/')
+ throw InvalidRegistryException(UNISTRING("The key name is invalid. It must be a relative, not an absolute name."), THISREF());
+
+ if (nCleanEnd <= 0)
+ // the original name consists of slashes only
+ throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
+
+
+ _rKeyName = _rKeyName.copy(0, nCleanEnd);
+ }
+ return bCleanPath;
}
//--------------------------------------------------------------------------
@@ -1273,30 +1320,34 @@ Reference< XRegistryKey > SAL_CALL OConfigurationRegistryKey::createKey( const :
OSL_ENSURE(m_xNode.is(), "OConfigurationRegistryKey::createKey : somebody changed the checkValid(KAT_CHILD) behaviour !");
OUString sKeyName(_rKeyName);
- checkRelativeKeyName(sKeyName);
-
- sal_Int32 nSeparatorPos = sKeyName.lastIndexOf('/');
- if (-1 != nSeparatorPos)
+ if (checkRelativeKeyName(sKeyName))
{
- // check if we have the key already
- Reference< XHierarchicalNameAccess > xDeepAccess(m_xNode, UNO_QUERY);
- if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(sKeyName))
- {
- // already there - just open it
- return implGetKey(sKeyName);
- }
+ OUString sParentName, sLocalName;
- // deep access, but not found. delegate it to a registry key which is one level above the to-be-created one
- OUString sSetNodeName = sKeyName.copy(0, nSeparatorPos);
- sKeyName = sKeyName.copy(nSeparatorPos + 1);
+ if (!splitPath(sKeyName,sParentName, sLocalName))
+ throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
- Reference< XRegistryKey > xSetNode = implGetKey(sSetNodeName);
- if (!xSetNode.is())
+ if (sParentName.getLength()) // it's a nested key name
{
- OSL_ENSURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
- throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ // check if we have the key already
+ Reference< XHierarchicalNameAccess > xDeepAccess(m_xNode, UNO_QUERY);
+ if (xDeepAccess.is() && xDeepAccess->hasByHierarchicalName(sKeyName))
+ {
+ // already there - just open it
+ return implGetKey(sKeyName);
+ }
+
+ // deep access, but not found. delegate it to a registry key which is one level above the to-be-created one
+ Reference< XRegistryKey > xSetNode = implGetKey(sParentName);
+ if (!xSetNode.is())
+ {
+ OSL_ENSURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
+ throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ }
+ return xSetNode->createKey(sLocalName); // problem: request for a/['b/c'] might find a/b/c
}
- return xSetNode->createKey(sKeyName);
+ else
+ sKeyName = sLocalName;
}
// The requested new key is one level below ourself. Can't delegate the creation.
@@ -1404,23 +1455,26 @@ void SAL_CALL OConfigurationRegistryKey::deleteKey( const OUString& _rKeyName )
throw InvalidRegistryException(UNISTRING("The key is read only."), THISREF());
OUString sKeyName(_rKeyName);
- checkRelativeKeyName(sKeyName);
-
- sal_Int32 nSeparatorPos = sKeyName.lastIndexOf('/');
- if (-1 != nSeparatorPos)
+ if (checkRelativeKeyName(sKeyName))
{
- // deep access. delegate it to a registry key which is one level above the to-be-created one
- ::rtl::OUString sSetNodeName = sKeyName.copy(0, nSeparatorPos);
- sKeyName = sKeyName.copy(nSeparatorPos + 1);
+ OUString sParentName, sLocalName;
+
+ if (!splitPath(sKeyName,sParentName, sLocalName))
+ throw InvalidRegistryException(UNISTRING("The key name is invalid."), THISREF());
- Reference< XRegistryKey > xSetNode = implGetKey(sSetNodeName);
- if (!xSetNode.is())
+ if (sParentName.getLength()) // it's a nested key name
{
- OSL_ENSURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
- throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ Reference< XRegistryKey > xSetNode = implGetKey(sParentName);
+ if (!xSetNode.is())
+ {
+ OSL_ENSURE(sal_False, "OConfigurationRegistryKey::createKey : somebody changed the implGetKey behaviour !");
+ throw InvalidRegistryException(UNISTRING("An internal error occured."), THISREF());
+ }
+ xSetNode->deleteKey(sLocalName);
+ return;
}
- xSetNode->deleteKey(sKeyName);
- return;
+ else
+ sKeyName = sLocalName;
}
// The requested new key is one level below ourself. Can't delegate the creation.
@@ -1503,5 +1557,39 @@ void SAL_CALL OConfigurationRegistryKey::deleteLink( const ::rtl::OUString& rLin
//..........................................................................
} // namespace configmgr
//..........................................................................
+// split path
+#include "configpath.hxx"
+#include "configexcept.hxx"
+
+bool configmgr::splitPath(const OUString& _sPath, OUString& _rsParentPath, OUString& _rsLocalName)
+{
+ using namespace ::configmgr::configuration;
+
+ bool bResult = false;
+ try
+ {
+ bool bAbsolute = Path::isAbsolutePath(_sPath);
+ Path::Rep aPath = bAbsolute ? AbsolutePath::parse(_sPath).rep() : RelativePath::parse(_sPath).rep();
+
+ OSL_ENSURE(!aPath.isEmpty(), "Trying to split an empty or root path");
+ Path::Iterator aFirst = aPath.begin(), aLast = aPath.end();
+
+ if (aFirst != aLast)
+ {
+ --aLast;
+
+ _rsLocalName = aLast->getName().toString();
+ _rsParentPath = Path::Rep(aFirst,aLast).toString(bAbsolute);
+
+ bResult = true;
+ }
+ // else go on to fail
+ }
+ catch (configuration::Exception&)
+ {
+ }
+ return bResult;
+}
+//..........................................................................
diff --git a/configmgr/source/registry/cfgregistrykey.hxx b/configmgr/source/registry/cfgregistrykey.hxx
index 8446a6e319da..6a45c837ae02 100644
--- a/configmgr/source/registry/cfgregistrykey.hxx
+++ b/configmgr/source/registry/cfgregistrykey.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cfgregistrykey.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-02-27 10:27:47 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -274,12 +274,13 @@ protected:
that ...<br/>
In addition, the given name will be normalized. Basically, this means that it does not contain trailing slashes.
</p>
+ @returns
+ <TRUE/> if the name is a valid relative path
+ <FALSE/> if the name is a local name only
@throws InvalidRegistryException
- if the name is not relative (i.e. if it starts with an slash)
- @throws InvalidRegistryException
- if the name is empty or consists of slashes only
+ if the name is invalid or not relative (i.e. if it starts with an slash)
*/
- void checkRelativeKeyName(::rtl::OUString& _rKeyName)
+ bool checkRelativeKeyName(::rtl::OUString& _rKeyName)
throw(::com::sun::star::registry::InvalidRegistryException, ::com::sun::star::uno::RuntimeException);
/** get a default value for a value of a given type
diff --git a/configmgr/source/tree/changes.cxx b/configmgr/source/tree/changes.cxx
index 680fe359140c..47d422e2d975 100644
--- a/configmgr/source/tree/changes.cxx
+++ b/configmgr/source/tree/changes.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: changes.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jl $ $Date: 2001-03-21 12:26:09 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -154,6 +154,31 @@ void ValueChange::applyTo(ValueNode& aValue)
}
// -------------------------------------------------------------------------
+void ValueChange::applyChangeNoRecover(ValueNode& aValue) const
+{
+ switch (getMode())
+ {
+ case wasDefault:
+ OSL_ASSERT(aValue.isDefault());
+ case changeValue:
+ aValue.setValue(getNewValue());
+ break;
+
+ case setToDefault:
+ aValue.setDefault();
+ break;
+
+ case changeDefault:
+ aValue.changeDefault(getNewValue());
+ break;
+
+ default:
+ OSL_ENSURE(0, "Unknown mode found for ValueChange");
+ break;
+ }
+}
+
+// -------------------------------------------------------------------------
::rtl::OUString ValueChange::getModeAsString() const
{
::rtl::OUString aRet;
diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx
index 9a78253be962..19c914326bb9 100644
--- a/configmgr/source/tree/cmtree.cxx
+++ b/configmgr/source/tree/cmtree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtree.cxx,v $
*
- * $Revision: 1.21 $
+ * $Revision: 1.22 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:16:03 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,28 +60,53 @@
************************************************************************/
#include <stdio.h>
-/* PLEASE DON'T DELETE ANY COMMENT LINES, ALSO IT'S UNNECESSARY. */
#include "subtree.hxx"
+#ifndef CONFIGMGR_CHANGE_HXX
+#include "change.hxx"
+#endif
+#ifndef CONFIGMGR_TREECHANGELIST_HXX
+#include "treechangelist.hxx"
+#endif
+
+#ifndef CONFIGMGR_TREEPROVIDER_HXX
+#include "treeprovider.hxx"
+#endif
+#ifndef _CONFIGMGR_TREEACTIONS_HXX_
+#include "treeactions.hxx"
+#endif
+
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+#ifndef INCLUDED_DEQUE
#include <deque>
+#define INCLUDED_DEQUE
+#endif
+#ifndef INCLUDED_VECTOR
#include <vector>
+#define INCLUDED_VECTOR
+#endif
+#ifndef INCLUDED_IOSTREAM
#include <iostream>
+#define INCLUDED_IOSTREAM
+#endif
+#ifndef INCLUDED_EXCEPTION
#include <exception>
-#include <sal/types.h>
+#define INCLUDED_EXCEPTION
+#endif
+#ifndef INCLUDED_SET
#include <set>
-#include <rtl/string.hxx>
-#include <rtl/ustring.hxx>
-#include <osl/diagnose.h>
-
-#include "confname.hxx" // Iterator for PathName scans
-#include "cmtreemodel.hxx"
-#include "treeactions.hxx"
-
-#include <com/sun/star/uno/Any.hxx>
-
-// WISDOM
-// !!Never write same code twice!!
+#define INCLUDED_SET
+#endif
using namespace std;
using namespace rtl;
diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx
index 3fb0e44391cd..764af77bc229 100644
--- a/configmgr/source/tree/cmtreemodel.cxx
+++ b/configmgr/source/tree/cmtreemodel.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtreemodel.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-05-31 11:49:31 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,16 +60,27 @@
************************************************************************/
#include <stdio.h>
-#ifndef CONFIGMGR_CMTREEMODEL_HXX
+
#include "cmtreemodel.hxx"
+
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
+#include "configexcept.hxx"
+#endif
+#ifndef INCLUDED_CONFIGMGR_NAMECREATOR_HXX
+#include "namecreator.hxx"
#endif
+#ifndef _CONFIGMGR_STRDECL_HXX_
+#include "strdecl.hxx"
+#endif
+
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
-#include "configexcept.hxx"
-#include "strdecl.hxx"
+#ifndef INCLUDED_ALGORITHM
+#define INCLUDED_ALGORITHM
#include <algorithm>
+#endif
//..........................................................................
namespace configmgr
@@ -94,21 +105,7 @@ bool isLocalizedValueSet(SubtreeChange const& _aSubtree)
}
//==========================================================================
-// -----------------------------------------------------------------------------
-//= TreeChangeList
-//==========================================================================
-OUString TreeChangeList::getModuleName() const
-{
- OUString sRet;
- if (this->pathToRoot.depth() == 0)
- sRet = root.getNodeName();
-
- else
- sRet = pathToRoot.moduleName();
- OSL_ENSURE(sRet.getLength(), "WARNING: TreeChangeList has no module name");
- return sRet;
-}
-//..........................................................................
+
//==========================================================================
//= Change
//==========================================================================
diff --git a/configmgr/source/tree/treeactions.cxx b/configmgr/source/tree/treeactions.cxx
index 98c875d761a8..2bb946f119d9 100644
--- a/configmgr/source/tree/treeactions.cxx
+++ b/configmgr/source/tree/treeactions.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeactions.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-06-11 08:28:01 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,8 +62,13 @@
#include <stdio.h>
#include "treeactions.hxx"
+
+#ifndef CONFIGMGR_TREE_NODEFACTORY_HXX
#include "treenodefactory.hxx"
+#endif
+#ifndef CONFIGMGR_TREEPROVIDER_HXX
#include "treeprovider.hxx"
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
diff --git a/configmgr/source/treecache/invalidatetree.cxx b/configmgr/source/treecache/invalidatetree.cxx
index 40f4b869e1bc..b7912449c283 100644
--- a/configmgr/source/treecache/invalidatetree.cxx
+++ b/configmgr/source/treecache/invalidatetree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: invalidatetree.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dg $ $Date: 2001-05-03 16:09:46 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,27 +59,56 @@
*
************************************************************************/
-#include <algorithm>
+#include "treecache.hxx"
+
+#ifndef _CONFIGMGR_SESSION_CONFIGSESSION_HXX_
#include "configsession.hxx"
+#endif
+#ifndef CONFIGMGR_CHANGE_HXX
#include "change.hxx"
+#endif
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
#include "valuenode.hxx"
+#endif
+#ifndef _CONFIGMGR_TREEACTIONS_HXX_
#include "treeactions.hxx"
+#endif
+#ifndef CONFIGMGR_TREEPROVIDER_HXX
#include "treeprovider.hxx"
-#include "treecache.hxx"
-#include "tracer.hxx"
+#endif
+#ifndef CONFIGMGR_TREEDATA_HXX
#include "treedata.hxx"
-#include "treeloader.hxx"
+#endif
+#ifndef CONFIGMGR_LOADER_HXX
+#include "loader.hxx"
+#endif
+#ifndef _CONFIGMGR_TRACER_HXX_
+#include "tracer.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
#include <com/sun/star/uno/Any.hxx>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HPP_
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#endif
#ifndef _VOS_THREAD_HXX_
#include <vos/thread.hxx>
#endif
+#ifndef INCLUDED_ALGORITHM
+#include <algorithm>
+#define INCLUDED_ALGORITHM
+#endif
+
namespace configmgr
{
using namespace com::sun::star::uno;
+ using namespace configuration;
+ namespace container = com::sun::star::container;
// -----------------------------------------------------------------------------
// ------------------------------- invalidateTree -------------------------------
// -----------------------------------------------------------------------------
@@ -184,64 +213,16 @@ namespace configmgr
}
};
-/*
- class MyAction : public NodeAction
- {
- vector< OUString > m_aNameList;
- OUString getPath();
- public:
- virtual void handle(ValueNode const&);
- virtual void handle(ISubtree const&);
- };
-
- // -----------------------------------------------------------------------------
-
- OUString MyAction::getPath()
- {
- OUString aName;
- for (vector<OUString>::const_iterator it = m_aNameList.begin();
- it != m_aNameList.end();
- it++)
- {
- aName += *it;
- aName += OUString::createFromAscii("/");
- }
- return aName;
- }
-
- void MyAction::handle(ValueNode const& aValueNode)
- {
- OUString aName = getPath() + aValueNode.getName();
- Any anAny = aValueNode.getValue();
-
- // double aDouble;
- // anAny >>= aDouble;
- // volatile int dummy = 0;
-
- }
-
- void MyAction::handle(ISubtree const& aSubtree)
- {
- m_aNameList.push_back(aSubtree.getName());
- aSubtree.forEachChild(*this);
- m_aNameList.pop_back();
- }
-*/
-
// -----------------------------------------------------------------------------
auto_ptr<TreeChangeList> createDiffs(ISubtree* _pCachedTree, ISubtree * _pLoadedSubtree,
- const vos::ORef<OOptions>& _rOptions, rtl::OUString const& _aAbsoluteSubtreePath)
+ const vos::ORef<OOptions>& _rOptions,
+ AbsolutePath const& _aAbsoluteSubtreePath)
{
// a new TreeChangeList, will filled with the changes between the cached tree and the new loaded tree
// Create a TreeChangeList with the right name, parentname and ConfigurationProperties
- ConfigurationName aName(_aAbsoluteSubtreePath, ConfigurationName::Absolute());
- OUString aParentName = aName.getParentName().fullName();
- OUString aLocalName = aName.localName();
-
- std::auto_ptr<TreeChangeList>
- aNewChangeList(
- new TreeChangeList(_rOptions, aParentName, aLocalName, configuration::Attributes()));
+ std::auto_ptr<TreeChangeList> aNewChangeList(
+ new TreeChangeList(_rOptions, _aAbsoluteSubtreePath,Chg()) );
// create the differences
OBuildChangeTree aNewChangeTree(aNewChangeList.get()->root, _pCachedTree, 1);
@@ -281,7 +262,7 @@ void concatSubtreeWithChanges(ISubtree* _pSubtree, TreeChangeList &_aChangeList)
}
// -----------------------------------------------------------------------------
-auto_ptr<ISubtree> TreeManager::loadNodeFromSession( IConfigSession *_pSession, rtl::OUString const& _aAbsoluteSubtreePath,
+auto_ptr<ISubtree> TreeManager::loadNodeFromSession( IConfigSession *_pSession, AbsolutePath const& _aAbsoluteSubtreePath,
const vos::ORef < OOptions >& _xOptions,
sal_Int16 _nMinLevels) throw (uno::Exception)
{
@@ -321,11 +302,11 @@ class OInvalidateTreeThread: public vos::OThread
{
vos::ORef<OOptions> m_aOptions;
TreeManager& m_rTreeManager;
- OUString m_aAbsoluteSubtreePath;
+ AbsolutePath m_aAbsoluteSubtreePath;
virtual void SAL_CALL run();
public:
- OInvalidateTreeThread(TreeManager& _pTreeManager, const rtl::OUString &_aAbsoluteSubtreePath,
+ OInvalidateTreeThread(TreeManager& _pTreeManager, const AbsolutePath &_aAbsoluteSubtreePath,
const vos::ORef<OOptions>& _rOptions)
:m_rTreeManager(_pTreeManager),
m_aAbsoluteSubtreePath(_aAbsoluteSubtreePath),
@@ -340,7 +321,7 @@ public:
};
// -----------------------------------------------------------------------------
-void TreeManager::invalidateTreeAsync(const rtl::OUString &_aAbsoluteSubtreePath, const vos::ORef<OOptions>& _rOptions) throw (uno::Exception)
+void TreeManager::invalidateTreeAsync(const AbsolutePath &_aAbsoluteSubtreePath, const vos::ORef<OOptions>& _rOptions) throw (uno::Exception)
{
if (m_bDisposeMode == false)
{
@@ -358,7 +339,7 @@ void TreeManager::invalidateTreeAsync(const rtl::OUString &_aAbsoluteSubtreePath
// -----------------------------------------------------------------------------
-void TreeManager::refreshSubtree(const rtl::OUString &_aAbsoluteSubtreePath, const vos::ORef<OOptions>& _aOptions) throw (uno::Exception)
+void TreeManager::refreshSubtree(const AbsolutePath &_aAbsoluteSubtreePath, const vos::ORef<OOptions>& _aOptions) throw (uno::Exception)
{
// load the Node direct from the session, without using the cache
auto_ptr<ISubtree> aLoadedSubtree( this->loadNodeFromSession(m_pSession, _aAbsoluteSubtreePath, _aOptions, -1) );
diff --git a/configmgr/source/treemgr/collectchanges.cxx b/configmgr/source/treemgr/collectchanges.cxx
index 476775cdc3e0..a18dd60ca489 100644
--- a/configmgr/source/treemgr/collectchanges.cxx
+++ b/configmgr/source/treemgr/collectchanges.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: collectchanges.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:35:06 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -126,19 +126,24 @@ bool convertNodeChange(NodeChangeData& aData_, RemoveNode const& aChange_)
CollectChanges::CollectChanges( NodeChangesInformation& rTargetList_,
TreeImpl& rStartTree_, NodeOffset nStartNode_,
+ TemplateHolder aElementTemplate_,
TreeDepth nMaxDepth)
: m_rTargetList(rTargetList_)
, m_aAccessor()
+, m_aContextTypeName()
, m_pBaseTree(&rStartTree_)
, m_nBaseNode(nStartNode_)
, m_nDepthLeft( nMaxDepth )
{
+ if (aElementTemplate_.isValid())
+ m_aContextTypeName = aElementTemplate_->getName();
}
//-----------------------------------------------------------------------------
-CollectChanges::CollectChanges( CollectChanges const& rBase, Name const& rChildName)
+CollectChanges::CollectChanges( CollectChanges const& rBase, Path::Component const& rChildName, Name const& aSubTypeName_)
: m_rTargetList(rBase.m_rTargetList)
-, m_aAccessor(rBase.m_aAccessor.child(rChildName))
+, m_aAccessor(rBase.m_aAccessor.compose(rChildName))
+, m_aContextTypeName(aSubTypeName_)
, m_pBaseTree(rBase.m_pBaseTree)
, m_nBaseNode(rBase.m_nBaseNode)
, m_nDepthLeft(childDepth(rBase.m_nDepthLeft))
@@ -147,6 +152,21 @@ CollectChanges::CollectChanges( CollectChanges const& rBase, Name const& rChildN
}
//-----------------------------------------------------------------------------
+inline
+Path::Component CollectChanges::implGetNodeName(Change const& aChange_) const
+{
+ Name aSimpleNodeName = makeName( aChange_.getNodeName(), Name::NoValidate() );
+
+ if (m_aContextTypeName.isEmpty())
+ {
+ OSL_ENSURE(isSimpleName(aSimpleNodeName),"Unexpected: Found non-simple name without a type");
+ return Path::wrapSafeName(aSimpleNodeName);
+ }
+ else
+ return Path::makeCompositeName(aSimpleNodeName, m_aContextTypeName);
+}
+
+//-----------------------------------------------------------------------------
void CollectChanges::collectFrom(ValueChange const& aChange_)
{
NodeChangeInformation aInfo;
@@ -187,9 +207,9 @@ void CollectChanges::collectFrom(SubtreeChange const& aChanges_)
{
if (m_nDepthLeft > 0)
{
- Name aNodeName( aChanges_.getNodeName(), Name::NoValidate() );
+ Name aSubTypeName = makeName( aChanges_.getElementTemplateName(), Name::NoValidate() );
- CollectChanges aSubcollector( *this, aNodeName );
+ CollectChanges aSubcollector( *this, implGetNodeName(aChanges_), aSubTypeName );
aSubcollector.applyToChildren(aChanges_);
}
@@ -213,8 +233,8 @@ bool CollectChanges::implSetLocation(NodeChangeLocation& rLocation_, Change cons
if (bSet_ && m_aAccessor.isEmpty()) // It is a set change affecting the base ...
rLocation_.setAffected( aBaseID );
- Name aChangeName( aOriginal_.getNodeName(), Name::NoValidate() );
- rLocation_.setAccessor( m_aAccessor.child( aChangeName ) );
+ Path::Component aChangeName = implGetNodeName( aOriginal_ );
+ rLocation_.setAccessor( m_aAccessor.compose( aChangeName ) );
return true;
}
diff --git a/configmgr/source/treemgr/collectchanges.hxx b/configmgr/source/treemgr/collectchanges.hxx
index 3c4cefb71487..d01f1f37071d 100644
--- a/configmgr/source/treemgr/collectchanges.hxx
+++ b/configmgr/source/treemgr/collectchanges.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: collectchanges.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-02-13 17:22:35 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,7 @@ namespace configmgr
{
NodeChangesInformation& m_rTargetList;
RelativePath m_aAccessor;
+ Name m_aContextTypeName;
TreeImpl* m_pBaseTree;
NodeOffset m_nBaseNode;
TreeDepth m_nDepthLeft;
@@ -105,6 +106,7 @@ namespace configmgr
/// Constructs a Visitor object, sets the output target list and context
CollectChanges( NodeChangesInformation& rTargetList_,
TreeImpl& rStartTree_, NodeOffset nStartNode_,
+ TemplateHolder aElementTemplate_,
TreeDepth nMaxDepth = c_TreeDepthAll);
/// Adds a (translated) ValueChange to the target list
@@ -127,7 +129,7 @@ namespace configmgr
protected:
/// Constructs a Visitor object for a child of another one's context
- CollectChanges( CollectChanges const& rBase, Name const& rChildName);
+ CollectChanges( CollectChanges const& rBase, Path::Component const& rChildName, Name const& aSubTypeName );
private:
// ChangeTreeAction implementations
@@ -138,6 +140,7 @@ namespace configmgr
bool implSetLocation(NodeChangeLocation& rLocation_, Change const& aOriginal_, bool bSet_) const;
void implAdd(NodeChangeInformation const& aChangeInfo_);
+ Path::Component implGetNodeName(Change const& _aChange_) const;
};
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/treemgr/configpath.cxx b/configmgr/source/treemgr/configpath.cxx
index faffb93c9cd4..9ee667647922 100644
--- a/configmgr/source/treemgr/configpath.cxx
+++ b/configmgr/source/treemgr/configpath.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configpath.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: fs $ $Date: 2001-04-03 14:56:27 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,9 +60,18 @@
************************************************************************/
#include "configpath.hxx"
+
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
#include "configexcept.hxx"
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#ifndef INCLUDED_ALGORITHM
#include <algorithm>
+#define INCLUDED_ALGORITHM
+#endif
#define OLD_SETELEMENT_NAMES 1
@@ -71,517 +80,1007 @@ namespace configmgr
namespace configuration
{
-//-----------------------------------------------------------------------------
- const sal_Unicode c_cDelimiter = '/';
- const sal_Unicode c_quot = '\"';
- const sal_Unicode c_apos = '\'';
-
- const sal_Unicode c_lBracket = '[', c_rBracket = ']';
-
- const sal_Size c_nBraLen = 2;
- const sal_Unicode c_lBraQuot[c_nBraLen] = { c_lBracket, c_quot };
- const sal_Unicode c_rBraQuot[c_nBraLen] = { c_quot, c_rBracket };
- const sal_Unicode c_lBraApos[c_nBraLen] = { c_lBracket, c_apos };
- const sal_Unicode c_rBraApos[c_nBraLen] = { c_apos, c_rBracket };
+ //-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+// Name validation
+//-----------------------------------------------------------------------------
namespace
{
//-------------------------------------------------------------------------
- // Helper functions for name validation
- //-------------------------------------------------------------------------
- bool isBracketed(OUString const& sName)
+ inline
+ bool isValidNameStart(sal_Unicode ch) SAL_THROW(())
+ {
+ return (sal_Unicode('A') <= ch && ch <= sal_Unicode('Z')) ||
+ (sal_Unicode('a') <= ch && ch <= sal_Unicode('z')) ||
+ sal_Unicode('_') == ch;
+ }
+ inline
+ bool isValidNameCont(sal_Unicode ch) SAL_THROW(())
{
-#if OLD_SETELEMENT_NAMES
+ return ( (sal_Unicode('0') <= ch && ch <= sal_Unicode('9'))
+ || (sal_Unicode('.') == ch) // eg for module names
+ || (sal_Unicode('-') == ch) // eg for locale names
+ || (sal_Unicode(':') == ch) // support special namespaced names
+ );
+ }
+
+ //-------------------------------------------------------------------------
+}
+//-----------------------------------------------------------------------------
+
+bool isSimpleName(OUString const& sName) SAL_THROW(())
+{
+ sal_Unicode const* const pStr = sName.getStr();
+ sal_Unicode const* const pEnd = pStr + sName.getLength();
+ if (pStr == pEnd)
return false;
-#endif
- sal_Int32 nLen = sName.getLength();
- return sName.getLength() > 2*c_nBraLen &&
- sName[0] == c_lBracket &&
- sName[nLen-1] == c_rBracket &&
- ((sName[1] == c_quot && sName[nLen-2] == c_quot) ||
- (sName[1] == c_apos && sName[nLen-2] == c_apos) );
+ for (sal_Unicode const* pValidate = pStr; pValidate != pEnd; ++pValidate)
+ {
+ if (!isValidNameStart(*pValidate))
+ {
+ if (pValidate == pStr) // first char - then this means failure
+ return false;
+ else if (!isValidNameCont(*pValidate))
+ return false;
+ }
}
- //-------------------------------------------------------------------------
- inline OUString makeBrace(sal_Unicode const (&chars)[c_nBraLen])
- { return OUString(chars,c_nBraLen); }
+ return true;
+}
+//-----------------------------------------------------------------------------
+// class configuration::Name
+//-----------------------------------------------------------------------------
- OUString bracket(OUString const& sName)
- {
-#if OLD_SETELEMENT_NAMES
- return OUString();
-#endif
- if (sName.indexOf(c_cDelimiter) >= 0)
- return OUString();
+// tag struct to ensure construction is routed through our helpers
+struct Path::PackageOnly {};
- else if (isBracketed(sName))
- return sName;
+//-----------------------------------------------------------------------------
- else if (sName.indexOf(c_quot) < 0)
- return makeBrace(c_lBraQuot) += OUString(sName) += makeBrace(c_rBraQuot);
+// Performance: Could optimize memory usage by using a string pool
+inline
+Name::Name(OUString const& aString, Path::PackageOnly) SAL_THROW(())
+: m_sRep(aString)
+{
- else if (sName.indexOf(c_quot) < 0)
- return makeBrace(c_lBraQuot) += OUString(sName) += makeBrace(c_rBraQuot);
+}
+//-----------------------------------------------------------------------------
- else
- return OUString();
- }
+Name makeName(OUString const& sName, Name::NoValidate) SAL_THROW(())
+{
+ return Name( sName, Path::PackageOnly() );
+}
+//-----------------------------------------------------------------------------
- //-------------------------------------------------------------------------
- OUString unbracket(OUString const& sName)
- {
- if (sName.indexOf(c_cDelimiter) >= 0)
- return OUString();
+Name makeNodeName(OUString const& sName, Name::NoValidate) SAL_THROW(())
+{
+ OSL_ENSURE( isSimpleName(sName), "Creating a Name that is invalid as member node name");
+ return Name( sName, Path::PackageOnly() );
+}
+//-----------------------------------------------------------------------------
+
+Name makeElementName(OUString const& sName, Name::NoValidate) SAL_THROW(())
+{
+ return Name( sName, Path::PackageOnly() );
+}
+//-----------------------------------------------------------------------------
- else if (isBracketed(sName))
- return sName.copy(c_nBraLen,sName.getLength()-c_nBraLen);
+Name validateNodeName(OUString const& sName)
+{
+ if (!isSimpleName(sName))
+ throw InvalidName(sName, "is not a valid name for a configuration node");
- else
- return sName;
+ return Name( sName, Path::PackageOnly() );
+}
+//-----------------------------------------------------------------------------
+
+Name validateElementName(OUString const& sName)
+{
+ return Name( sName, Path::PackageOnly() );
+}
+//-----------------------------------------------------------------------------
+
+namespace // path helpers I
+{
+//-----------------------------------------------------------------------------
+ const sal_Unicode c_cDelimiter = '/';
+
+ const sal_Unicode c_lBracket = '[', c_rBracket = ']';
+
+ const sal_Unicode c_cAnytype = '*';
+//-----------------------------------------------------------------------------
+
+ // Textually an Absolute path starts with a slash
+ static
+ inline
+ bool detectAbsolutePath(sal_Unicode const* _pPath) SAL_THROW(())
+ {
+ OSL_ASSERT( _pPath != NULL );
+ return *_pPath == c_cDelimiter;
}
+//-----------------------------------------------------------------------------
- //-------------------------------------------------------------------------
+ static
inline
- bool isValidNameStart(sal_Unicode ch)
+ OUString makeWildcardType() SAL_THROW(())
{
- return (sal_Unicode('A') <= ch && ch <= sal_Unicode('Z')) ||
- (sal_Unicode('a') <= ch && ch <= sal_Unicode('z')) ||
- sal_Unicode('_') == ch;
+ return OUString(&c_cAnytype,1);
}
+//-----------------------------------------------------------------------------
+
+ // even handles empty strings (if NUL-terminated)
+ static
inline
- bool isValidNameCont(sal_Unicode ch)
+ bool isWildcardType(sal_Unicode const* _sType) SAL_THROW(())
{
- return ( (sal_Unicode('0') <= ch && ch <= sal_Unicode('9'))
- || (sal_Unicode('-') == ch)
- || (sal_Unicode('.') == ch)
- );
+ return _sType[0] == c_cAnytype &&
+ _sType[1] == 0;
}
+//-----------------------------------------------------------------------------
- //-------------------------------------------------------------------------
- bool isValidName(OUString const& sName)
+ static
+ inline
+ bool isEmptyString(sal_Unicode const* _sType) SAL_THROW(())
+ {
+ return _sType[0] == 0;
+ }
+//-----------------------------------------------------------------------------
+ static
+ inline
+ sal_Unicode lastChar(OUString const& _sString) SAL_THROW(())
{
- sal_Unicode const* const pStr = sName.getStr();
- sal_Unicode const* const pEnd = pStr + sName.getLength();
- if (pStr == pEnd)
- return false;
+ sal_Int32 const nLen = _sString.getLength();
- for (sal_Unicode const* pValidate = pStr; pValidate != pEnd; ++pValidate)
- {
- if (!isValidNameStart(*pValidate))
- {
- if (pValidate == pStr)
- return isBracketed(sName) && sName.indexOf(c_cDelimiter) < 0;
- else if (!isValidNameCont(*pValidate))
- return false;
- }
- }
+ OSL_PRECOND( nLen > 0, "Non-empty string expected");
- return true;
+ return _sString[nLen-1];
}
- //-------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+ Name implMakeCompositeName(OUString const& _sBaseName, OUString const& _sPredicate) SAL_THROW((InvalidName));
+ void implSplitCompositeName(Name const& _aCompositeName, OUString& _rBaseName, OUString& _rPredicate) SAL_THROW(());
+//-----------------------------------------------------------------------------
}
+//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-// class configuration::Name
+namespace Path
+{
+//-----------------------------------------------------------------------------
+// class configuration::Path::Component
//-----------------------------------------------------------------------------
-// Performance: Could optimize memory usage by using a string pool
-Name::Name(OUString const& aString, NoValidate)
-: m_sRep(aString)
+inline // though public, this method is not available outside this translation unit
+Component::Component(OUString const& _sName, Path::PackageOnly _tag) SAL_THROW(())
+: m_aName(_sName, _tag)
{
+}
+//-----------------------------------------------------------------------------
+inline // though public, this method is not available outside this translation unit
+Component::Component(Name const& _aName, Path::PackageOnly) SAL_THROW(())
+: m_aName(_aName)
+{
}
//-----------------------------------------------------------------------------
-Name makeName(OUString const& sName)
+bool Component::isSimpleName() const SAL_THROW(())
{
- return Name( unbracket(sName), Name::NoValidate() );
+ return !m_aName.isEmpty() && lastChar(m_aName.toString()) != c_rBracket;
}
//-----------------------------------------------------------------------------
-Name validateNodeName(OUString const& sName)
+Name Component::getName() const SAL_THROW(())
{
- if (!isValidName(sName))
- throw InvalidName(sName, "is not a valid configuration name");
- if (isBracketed(sName))
- throw InvalidName(sName, "is not a valid name for an configuration Node (bracketed names are not allowed");
+ if (isSimpleName()) return m_aName;
+
+ OUString sName, sType;
+ implSplitCompositeName(m_aName,sType,sName);
- return Name( sName, Name::NoValidate() );
+ return Name(sName,PackageOnly());
}
//-----------------------------------------------------------------------------
-Name validateElementName(OUString const& sName)
+Name Component::getTypeName() const SAL_THROW(())
{
- if (!isValidName(sName))
- throw InvalidName(sName, "is not a valid configuration name");
+ if (isSimpleName()) return Name();
+
+ OUString sName, sType;
+ implSplitCompositeName(m_aName,sType,sName);
- return Name( unbracket(sName), Name::NoValidate() );
+ return Name(sType,PackageOnly());
}
//-----------------------------------------------------------------------------
+bool Component::splitCompositeName(Name& _rName, Name& _rType) const SAL_THROW(())
+{
+ if (isSimpleName())
+ {
+ _rName = m_aName;
+ _rType = Name();
+ return false;
+ }
+ else
+ {
+ OUString sName, sType;
+ implSplitCompositeName(m_aName,sType,sName);
+ _rName = Name(sName, PackageOnly());
+ _rType = Name(sType, PackageOnly());
+ return true;
+ }
+}
//-----------------------------------------------------------------------------
-// class configuration::PathRep
+
+bool Component::splitCompositeName(OUString& _rName, OUString& _rType) const SAL_THROW(())
+{
+ if (isSimpleName())
+ {
+ _rName = m_aName.toString();
+ _rType = OUString();
+ return false;
+ }
+ else
+ {
+ implSplitCompositeName(m_aName,_rType,_rName);
+ return true;
+ }
+}
//-----------------------------------------------------------------------------
-PathRep::PathRep(Components const& aComponents)
-: m_aComponents(aComponents)
+Component makeEmptyComponent() SAL_THROW(())
{
+ return Component( OUString(), PackageOnly() );
}
//-----------------------------------------------------------------------------
-PathRep PathRep::compose(PathRep const& aRelativePath) const
+Component wrapSimpleName(OUString const& _sName)
{
- Components aResult( components() );
- aResult.insert(aResult.end(), aRelativePath.begin(), aRelativePath.end());
- return PathRep( aResult );
+ OSL_ENSURE( isSimpleName(_sName), "Simple Name expected creating path component");
+ if (!isSimpleName(_sName))
+ throw InvalidName(_sName, "is not a simple name. Cannot convert to path component");
+
+ return Component( _sName, PackageOnly() );
}
//-----------------------------------------------------------------------------
-Name PathRep::getLocalName() const
+Component wrapSimpleName(Name const& _aName)
{
- if (isEmpty())
- return Name();
- else
- return components().back();
+ return wrapSimpleName( _aName.toString() );
}
+//-----------------------------------------------------------------------------
+
+Component makeCompositeName(Name const& _aElementName, Name const& _aTypeName)
+{
+ OUString const sElementName = _aElementName.toString();
+ OUString const sTypeName = _aTypeName.toString();
+ return Component( implMakeCompositeName(sTypeName,sElementName), PackageOnly() );
+}
//-----------------------------------------------------------------------------
-PathRep PathRep::child(Name const& aChild) const
+Component makeCompositeName(OUString const& _sElementName, OUString const& _sTypeName)
{
- Components aResult( components() );
- aResult.push_back(aChild);
- return PathRep( aResult );
+ return Component( implMakeCompositeName(_sTypeName,_sElementName), PackageOnly() );
}
//-----------------------------------------------------------------------------
-PathRep PathRep::parent() const
+
+bool matches(Component const& lhs,Component const& rhs) SAL_THROW(())
{
- Components aResult( components() );
- OSL_ENSURE( !aResult.empty(), "ERROR: Getting parent path of empty path" );
- if (aResult.empty())
- throw InvalidName(OUString(RTL_CONSTASCII_USTRINGPARAM("<empty>")), " - is empty. Cannot construct parent path");
+ // this extra preflight check might be left out (is it good for performance ?)
+ if (lhs.getInternalName() == rhs.getInternalName())
+ return true;
+
+ if (lhs.getName() != rhs.getName())
+ return false;
+
+ // simple names are considered equivalent to wildcard namess
+ if (lhs.isSimpleName() || rhs.isSimpleName())
+ return true;
+
+ Name aTypeLHS = lhs.getTypeName();
+ Name aTypeRHS = rhs.getTypeName();
+
+ // this would need an extra test without our preflight check
+ OSL_ASSERT(aTypeLHS != aTypeRHS); // would have been dicovered by first check
- aResult.pop_back();
- return PathRep( aResult );
+ if ( isWildcardType(aTypeLHS.toString()) || isWildcardType(aTypeRHS.toString()) )
+ return true;
+
+ return false;
}
//-----------------------------------------------------------------------------
-OUString PathRep::toString() const
+//-----------------------------------------------------------------------------
+// weak comparison of components
+//-----------------------------------------------------------------------------
+bool before(Component const& lhs, Component const& rhs) SAL_THROW(())
+{ return lhs.getName() < rhs.getName(); }
+
+//-----------------------------------------------------------------------------
+bool equiv(Component const& lhs, Component const& rhs) SAL_THROW(())
+{ return lhs.getName() == rhs.getName(); }
+
+//-----------------------------------------------------------------------------
+size_t hashCode(Component const& comp) SAL_THROW(())
+{ return comp.getName().hashCode(); }
+
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// class configuration::Path::Rep
+//-----------------------------------------------------------------------------
+void Rep::check_not_empty() const
{
- OUString const sDelimiter(&c_cDelimiter, 1);
+ if (m_aComponents.empty())
+ {
+ OSL_ENSURE(!m_aComponents.empty(),"Trying to access components of an empty path");
+ throw Exception("Trying to access components of an empty path");
+ }
+}
+//-----------------------------------------------------------------------------
+
+void Rep::prepend(Rep const& _aOther) SAL_THROW(())
+{
+ // to prepend the other path append its components
+ m_aComponents.insert( m_aComponents.end(),
+ _aOther.m_aComponents.begin(),
+ _aOther.m_aComponents.end());
+
+}
+//-----------------------------------------------------------------------------
+OUString Rep::toString(bool _bAbsolute) const SAL_THROW(())
+{
Iterator cur = begin();
Iterator const stop = end();
- OUString sRet;
- if (cur != stop)
- {
- sRet = cur->toString();
+ rtl::OUStringBuffer sRet;
- while(++cur != stop)
- sRet += sDelimiter.concat( cur->toString() );
+ if (!_bAbsolute && cur != stop)
+ sRet = cur++->toPathString();
- if ((--cur)->isEmpty()) // special behavior for root & friends
- sRet += sDelimiter;
- }
- return sRet;
+ for ( ;cur != stop; ++cur)
+ sRet.append( c_cDelimiter ).append( cur->toPathString() );
+
+ return sRet.makeStringAndClear();
}
//-----------------------------------------------------------------------------
-size_t PathRep::hashCode() const
+size_t Rep::hashCode() const SAL_THROW(())
{
const unsigned long mangle_factor = 11; // 1011 (2)
unsigned long nHash = 0;
for (Iterator it = begin(), stop = end(); it != stop; ++it)
{
- nHash = mangle_factor*nHash + it->hashCode();
+ nHash = mangle_factor*nHash + Path::hashCode(*it);
}
return nHash;
}
//-----------------------------------------------------------------------------
-bool PathRep::before(PathRep const& rhs) const
+bool before(Rep const& lhs, Rep const& rhs) SAL_THROW(())
+{
+ return std::lexicographical_compare(lhs.begin(),lhs.end(),rhs.begin(),rhs.end(), Before());
+}
+//-----------------------------------------------------------------------------
+
+bool equiv(Rep const& lhs, Rep const& rhs) SAL_THROW(())
+{
+ return (lhs.countComponents() == rhs.countComponents()) &&
+ std::equal(lhs.begin(),lhs.end(),rhs.begin(),Equiv());
+}
+//-----------------------------------------------------------------------------
+
+bool matches(Rep const& lhs, Rep const& rhs) SAL_THROW(())
+{
+ return (lhs.countComponents() == rhs.countComponents()) &&
+ std::equal(lhs.begin(),lhs.end(),rhs.begin(),Matches());
+}
+//-----------------------------------------------------------------------------
+
+bool isAbsolutePath(OUString const& _sPath) SAL_THROW(())
{
- return std::lexicographical_compare(this->begin(),this->end(),rhs.begin(),rhs.end());
+ return detectAbsolutePath(_sPath);
}
//-----------------------------------------------------------------------------
-bool operator==(PathRep const& lhs, PathRep const& rhs)
+bool hasMatchingPrefix(Rep const& _aPath, Rep const& _aPrefix) SAL_THROW(())
{
- return (lhs.m_aComponents.size() != rhs.m_aComponents.size()) &&
- std::equal(lhs.begin(),lhs.end(),rhs.begin());
+ return (_aPath.countComponents() >= _aPrefix.countComponents()) &&
+ std::equal( _aPrefix.begin(), _aPrefix.end(), _aPath.begin(), Matches());
}
//-----------------------------------------------------------------------------
+Rep stripMatchingPrefix(Rep const& _aPath,Rep const& _aPrefix) // SAL_THROW((InvalidName))
+{
+ Rep aResult(_aPath);
+
+ for (Iterator it = _aPrefix.begin(); it != _aPrefix.end(); ++it)
+ {
+ if (aResult.isEmpty() || !matches(*it,aResult.getFirstName()))
+ throw InvalidName(aResult.getFirstName().toPathString(), "does not match the expected location.");
+
+ aResult.dropFirstName();
+ }
+
+ return aResult;
+}
+//-----------------------------------------------------------------------------
+} // namespace Path
+//-----------------------------------------------------------------------------
+
namespace
{
- // Absolute path starts its rep with an empty name
- bool isAbsolute(PathRep const& aRep)
+//-----------------------------------------------------------------------------
+ const sal_Unicode c_quot = '\"';
+ const sal_Unicode c_apos = '\'';
+ const sal_Unicode c_amp = '&';
+
+ const sal_Unicode c_end_escape = ';';
+
+ const sal_Unicode c_normal_quot = c_apos;
+ //-------------------------------------------
+ static sal_Char const c_amp_name[] = "&amp;";
+ static sal_Char const c_apos_name[] = "&apos;";
+ static sal_Char const c_quot_name[] = "&quot;";
+
+//-------------------------------------------------------------------------
+ /// distinguishes which kind of path is held in a path object
+ enum PathType { eRELATIVE = 1, eABSOLUTE = 2 };
+
+ // path parsing iterator type
+ typedef sal_Unicode const * StrPos;
+
+//-----------------------------------------------------------------------------
+
+ /** find the char being escaped by the escape sequence in the given string range
+ @return
+ the char being escaped or zero, if the range is no known escape
+ */
+ sal_Unicode implParseEscape(StrPos pBegin, StrPos pEnd) SAL_THROW(())
{
- return !aRep.isEmpty() &&
- aRep.begin()->isEmpty();
+ OSL_PRECOND( pBegin < pEnd, "Nonempty string range expected" );
+ OSL_PRECOND( pBegin[0] == c_amp, "String range is not a possible escape: missing start marker" );
+ OSL_PRECOND( pEnd[-1] == c_end_escape, "String range is not a possible escape: missing end marker" );
+
+ sal_Int32 const nLen = pEnd - pBegin;
+
+ sal_Unicode chResult;
+
+ if ( 2 > nLen || nLen > 4) // quick check, if there is no possible match
+ chResult = 0;
+ // the standard escapes
+ else if (0 == rtl_ustr_ascii_compare_WithLength(pBegin,nLen,c_amp_name)) chResult = c_amp;
+ else if (0 == rtl_ustr_ascii_compare_WithLength(pBegin,nLen,c_apos_name)) chResult = c_apos;
+ else if (0 == rtl_ustr_ascii_compare_WithLength(pBegin,nLen,c_quot_name)) chResult = c_quot;
+ // extra escapes for XML compatibility
+ else if (0 == rtl_ustr_ascii_compare_WithLength(pBegin,nLen,"&lt;")) chResult = sal_Unicode('<');
+ else if (0 == rtl_ustr_ascii_compare_WithLength(pBegin,nLen,"&gt;")) chResult = sal_Unicode('>');
+ else chResult = 0;
+
+ return chResult;
}
- // Textually Absolute path starts with a slash
- bool isAbsolute(OUString const& sPath)
+
+//-----------------------------------------------------------------------------
+
+ /** find the escape sequence to use for the given char
+ @return
+ an escape sequence, or NULL, if the char should not be escaped
+ */
+ inline
+ sal_Char const* implGetEscape(sal_Unicode ch ) SAL_THROW(())
{
- return sPath.getLength() != 0 &&
- sPath.getStr()[0] == c_cDelimiter;
+ switch (ch)
+ {
+ case c_amp: return c_amp_name;
+ case c_apos: return c_apos_name;
+ case c_quot: return c_quot_name;
+
+ default: return NULL;
+ }
+ }
+
+//-----------------------------------------------------------------------------
+
+ /** find the start of the path component ending before pEnd in the string starting at pBegin
+ @return
+ a pointer to the last character before pEnd that is not a name delimiter
+ */
+ StrPos implFindNameStart(StrPos pBegin, StrPos pEnd) SAL_THROW(())
+ {
+ OSL_PRECOND(pBegin <= pEnd, "Invalid string range");
+
+ sal_Int32 const nLen = pEnd-pBegin;
+ sal_Int32 const nPos = rtl_ustr_lastIndexOfChar_WithLength(pBegin, nLen, c_cDelimiter) + 1;
+
+ OSL_ASSERT(0 <= nPos && nPos <= nLen);
+
+ return pBegin + nPos;
}
- PathRep::Components implParsePath(OUString const& aString, Path::Type eType)
+//-----------------------------------------------------------------------------
+
+ /** find the start of the bracketed & quoted predicate ending before pEnd in the string starting at pBegin
+ @return
+ a pointer to the opening bracket matching the closing bracket at pEnd[-1], if found
+ <var>pEnd</var>, if no bracketed string was found
+ NULL, if there was a closing bracket, but the beginning could not be discovered
+ */
+ StrPos implFindPredicateStart(StrPos pBegin, StrPos pEnd) SAL_THROW(())
{
- PathRep::Components aRet;
+ OSL_PRECOND(pBegin < pEnd, "Nonempty string range required");
- sal_Int32 nPos = 0;
- sal_Int32 const nEnd = aString.getLength();
+ if (pEnd == pBegin || pEnd[-1] != c_rBracket) return pEnd;
- if (isAbsolute(aString))
+ if (--pEnd == pBegin)
{
- OSL_ENSURE(eType == PathType::eABSOLUTE || eType == PathType::ePATH,"Configuration: PARSE WARNING: Absolute Path String provided in an inapplicable context");
- eType = PathType::eABSOLUTE;
- ++nPos;
+ OSL_ENSURE(false, "Invalid path component: single ']'");
+ return NULL; // string was only "]"
}
- if (eType == PathType::eABSOLUTE)
- aRet.push_back(Name());
+ sal_Unicode chQuote = *--pEnd;
- while(nPos < nEnd)
+ if (chQuote != c_quot && chQuote != c_apos)
{
- sal_Int32 nCut = aString.indexOf(c_cDelimiter, nPos);
- if (nCut < 0) nCut = nEnd;
+ // should we support empty brackets ?
+ if (chQuote == c_lBracket)
+ {
+ OSL_ENSURE(false, "Empty predicate brackets found");
+ return NULL; // for now we don't
- OSL_ENSURE(nPos < nCut, "Configuration: PARSE WARNING: Invalid Path containing empty component");
+ }
+
+ // should we support brackets with non-quoted strings ?
+ chQuote = c_lBracket; // for now we do
+ }
- aRet.push_back(makeName(aString.copy(nPos,nCut-nPos)));
- nPos = nCut + 1;
+ sal_Int32 nStart = rtl_ustr_lastIndexOfChar_WithLength(pBegin, pEnd-pBegin, chQuote);
+
+ if (chQuote != c_lBracket) // needed to support non-quoted strings
+ --nStart;
+
+ if (nStart < 0)
+ {
+ OSL_ENSURE(false, "Could not find opening quote or bracket for bracketed predicate");
+ return NULL;
}
- return aRet;
+ if (pBegin[nStart] != c_lBracket)
+ {
+ OSL_ENSURE(false, "Illegal quote character in string");
+ return NULL; // for now we don't
+ }
+
+ return pBegin + nStart;
}
-}
+//-----------------------------------------------------------------------------
+ /// find the position of the given char in the range given.
+ inline
+ sal_Int32 indexOfCharInRange(StrPos pBegin, StrPos pEnd, sal_Unicode ch) SAL_THROW(())
+ {
+ return rtl_ustr_indexOfChar_WithLength(pBegin, pEnd-pBegin, ch);
+ }
//-----------------------------------------------------------------------------
-// class RelativePath
+
+ /// find the position of the given char in the range given.
+ inline
+ bool containsChar(sal_Unicode const * pString, sal_Unicode ch) SAL_THROW(())
+ {
+ return rtl_ustr_indexOfChar(pString, ch) >= 0;
+ }
//-----------------------------------------------------------------------------
-// Absolute path starts its rep with an empty name
-// we must ensure that there is no empty name for a relative path
-// see AbsolutePath::init
-void RelativePath::init()
-{
- if (!m_aRep.isEmpty())
+ /** validate and normalize a bracketed & quoted predicate from content the string range [pBegin,pEnd)
+ @param pRequiredEscapes
+ contains a list of characters that must be preescaped or are otherwise invalid
+ if NULL is passed, the source range is presumed to contain no escaped data
+ otherwise the ampersand (&) and all characters in the list are required to be escaped
+ @return
+ the normalized, bracketed and quoted predicate
+ @throw
+ InvalidName, if the predicate data is not valid
+ */
+ OUString implMakeNormalizedPredicate(StrPos pBeginContent, StrPos pEndContent, sal_Unicode const* pRequiredEscapes) SAL_THROW((InvalidName))
{
- OSL_ENSURE(!m_aRep.begin()->isEmpty(), "WARNING: Wrong representation passed to RelativePath");
- while(begin()->isEmpty()) // but now correcting this condition
+ OSL_PRECOND(pBeginContent <= pEndContent, "Invalid string range");
+ if (pBeginContent == pEndContent)
+ return OUString();
+
+ rtl::OUStringBuffer aNormalized(pEndContent-pBeginContent + 4); // reserve approximate size initially
+
+ // prefix: opening bracket and quote
+ aNormalized.append(c_lBracket).append(c_normal_quot);
+
+ // content: copy over each char and handle escaping
+ for(StrPos pCur = pBeginContent; pCur != pEndContent; ++pCur)
{
- m_aRep.removeComponent(m_aRep.begin_mutate());
+ sal_Unicode ch = *pCur;
+
+ // maybe parse contained escaping
+ if (pRequiredEscapes)
+ {
+ if (ch == c_amp)
+ {
+ // find an escape end marker (after pCur). Result is pCur, if the end marker is not there
+ StrPos pEndEscape = pCur + indexOfCharInRange(pCur+1,pEndContent,c_end_escape);
+ sal_Unicode ch2 = pCur != pEndEscape ? implParseEscape(pCur,pEndEscape+1) : 0;
+
+ if (ch2 != 0) // found and read a valid escape sequence
+ {
+ ch = ch2;
+ pCur = pEndEscape;
+ OSL_ASSERT(*pCur == c_end_escape);
+ }
+ else
+ {
+ OSL_ENSURE(false, "Character '&' must be escaped in this context");
+ #if 0
+ throw InvalidName(OUString(pBeginContent,pEndContent-pBeginContent),
+ "is not a valid element name string. "
+ "Character '&' must be escaped in this context");
+ #endif
+ }
+ }
+ else if ( containsChar(pRequiredEscapes, ch) )
+ {
+ throw InvalidName(OUString(pBeginContent,pEndContent-pBeginContent),
+ "is not a valid element name string. "
+ "Some characters must be escaped in this context");
+ }
+ }
+
+ // now append (escape if normal)
+ if (sal_Char const * pEscape = implGetEscape(ch))
+ aNormalized.appendAscii( pEscape );
+
+ else
+ aNormalized.append( ch );
}
+
+ // suffix: closing quote and bracket
+ aNormalized.append(c_normal_quot).append(c_rBracket);
+
+ return aNormalized.makeStringAndClear();
}
- OSL_ASSERT( !isAbsolute(m_aRep) );
-}
//-----------------------------------------------------------------------------
-RelativePath::RelativePath()
-: m_aRep( Components() )
-{
-}
-//-----------------------------------------------------------------------------
+ /** extract and unescape the normalized predicate content in the string range [pBegin,pEnd)
+ @return
+ the denormalized predicate content
+ */
+ OUString implReadPredicate(StrPos pBegin, StrPos pEnd) SAL_THROW(())
+ {
+ OSL_PRECOND(pBegin <= pEnd, "Invalid string range");
-RelativePath::RelativePath(OUString const& aString, NoValidate)
-: m_aRep(implParsePath(aString, PathType::eRELATIVE))
-{
- init();
-}
-//-----------------------------------------------------------------------------
+ rtl::OUStringBuffer aContent(pEnd-pBegin); // reserve approximate size initially
-RelativePath::RelativePath(Name const& aName)
-: m_aRep( Components(1,aName) )
-{
- if (aName.isEmpty()) m_aRep.clearComponents();
- OSL_ASSERT( !isAbsolute(m_aRep) );
-}
-//-----------------------------------------------------------------------------
+ StrPos pReadPos = pBegin;
-RelativePath RelativePath::compose(RelativePath const& aPath) const
-{
- return RelativePath( m_aRep.compose(aPath.rep()) );
-}
-//-----------------------------------------------------------------------------
+ // content: copy data, handling escapes
+ for(StrPos pCur = pReadPos; pCur != pEnd; ++pCur)
+ {
+ if (*pCur != c_amp) continue; // no escape here
-RelativePath RelativePath::child(Name const& aChild) const
-{
- return RelativePath( m_aRep.child(aChild) );
-}
-//-----------------------------------------------------------------------------
+ // handle an escape
+ // find an escape end marker (after pCur). Result is pCur, if the end marker is not there
+ StrPos pEndEscape = pCur + indexOfCharInRange(pCur+1,pEnd,c_end_escape);
-RelativePath RelativePath::parent() const
-{
- return RelativePath( m_aRep.parent() );
-}
-//-----------------------------------------------------------------------------
+ OSL_ENSURE(pEndEscape != pCur, "Found dangling ampersand in normalized data");
-OUString RelativePath::toString() const
-{
- return m_aRep.toString();
-}
+ sal_Unicode ch = implParseEscape(pCur,pEndEscape+1);
+
+ OSL_ENSURE(ch != 0, "Found unreckognized escape in normalized data");
+
+ if (ch != 0) // found and read a valid escape sequence
+ {
+ // do copy of preceding data
+ aContent.append(pReadPos, pCur-pReadPos).append(ch);
+ pCur = pReadPos = pEndEscape;
+ ++pReadPos;
+
+ OSL_ASSERT(*pCur == c_end_escape);
+ }
+ // otherwise just treat the ampersand as a mormal character
+ }
+
+ // do copy of remaining data
+ if (pReadPos != pEnd)
+ aContent.append(pReadPos, pEnd-pReadPos);
+
+ return aContent.makeStringAndClear();
+ }
//-----------------------------------------------------------------------------
-// class AbsolutePath
+
+ /** validate and normalize the bracketed & quoted predicate in the string range [pBegin,pEnd)
+ @return
+ the normalized predicate
+ @throw
+ InvalidName, if the predicate is not valid
+ */
+ OUString implNormalizePredicate(StrPos pBegin, StrPos pEnd) SAL_THROW((InvalidName))
+ {
+ sal_Unicode sStopCharBuf[2];
+ sal_Unicode const * pStopChars;
+
+ OSL_PRECOND(pBegin < pEnd, "Nonempty string range expected");
+ OSL_PRECOND(pEnd-pBegin >= 2, "Bracketed string range expected");
+ OSL_PRECOND(pBegin[0] == c_lBracket,"Bracketed string range expected");
+ OSL_PRECOND(pEnd[-1] == c_rBracket, "Bracketed string range expected");
+
+ ++pBegin; --pEnd; // skip brackets
+
+ sal_Unicode const chUsedQuot = *pBegin;
+ if (chUsedQuot == c_apos || chUsedQuot == c_quot)
+ {
+ OSL_PRECOND(pBegin < pEnd && pEnd-pBegin >= 2, "Bracketed quoted string range expected");
+ OSL_PRECOND(pEnd[-1] == chUsedQuot, "Non-matching quotes in bracketed quoted string");
+
+ if (pEnd-pBegin <= 1 || pEnd[-1] != chUsedQuot)
+ throw InvalidName( OUString(pBegin, pEnd-pBegin), "is not a valid element predicate: quotes do not match");
+
+ ++pBegin; --pEnd; // skip quotes
+
+ sStopCharBuf[0] = chUsedQuot;
+ sStopCharBuf[1] = 0;
+
+ pStopChars = sStopCharBuf;
+ }
+
+ // non-quoted strings are not really valid, but we tolerate them
+ else
+ {
+ OSL_ENSURE(false, "Warning: Invalid path - non-quoted data in bracketed predicate");
+
+ static sal_Unicode const sGeneralStoppers[] = { c_quot, c_apos, c_rBracket, c_lBracket, 0 };
+
+ pStopChars = sGeneralStoppers;
+ }
+
+ if (pBegin == pEnd)
+ throw InvalidName(OUString(pBegin-1,2),"Empty element name in predicate");
+
+ return implMakeNormalizedPredicate(pBegin, pEnd, pStopChars);
+ }
//-----------------------------------------------------------------------------
+ /// parse a path into a sequence of components
+ Path::Rep implParsePath(OUString const& _aPathString, PathType eType) SAL_THROW((InvalidName))
+ {
+ Path::Rep aResult;
-// Starts the rep with an empty name
-// - this also ensures correct toString() behavior
-// - skipping this extra element is done using REP_OFF
-void AbsolutePath::init()
-{
- if (!isAbsolute(m_aRep))
- m_aRep.insertComponent(m_aRep.begin_mutate());
- OSL_ASSERT( isAbsolute(m_aRep) );
-}
+ StrPos pBegin = _aPathString.getStr();
+ StrPos pEnd = pBegin + _aPathString.getLength();
+
+ if (eType == eABSOLUTE)
+ {
+ if ( detectAbsolutePath(_aPathString) )
+ ++pBegin; // skip the leading slash
+
+ else
+ OSL_ENSURE(false, "Warning: trying to parse relative path as absolute");
+ }
+ else
+ OSL_ENSURE(!detectAbsolutePath(_aPathString), "ERROR: trying to parse absolute path as relative one");
+
+ if (detectAbsolutePath(pBegin))
+ throw InvalidName(_aPathString, "is not a valid path. Illegal empty first component");
+
+ else if (pBegin != pEnd && pEnd[-1] == '/')
+ {
+ OSL_ENSURE(false, "Illegal configuration path. Terminating '/' found.");
+ --pEnd;
+ }
+
+ while (pEnd != pBegin)
+ {
+ // check for predicate
+ StrPos pQuoteStart = implFindPredicateStart(pBegin, pEnd);
+ if (pQuoteStart == NULL)
+ throw InvalidName(_aPathString, "is not a valid path. Invalid name or predicate syntax");
+
+ StrPos pNameStart = implFindNameStart(pBegin, pQuoteStart);
+
+ OUString aElementName(pNameStart, pQuoteStart-pNameStart);
+
+ if (!isSimpleName(aElementName))
+ {
+ // this is OK only for few cases WITH predicate
+ if (pQuoteStart == pEnd)
+ throw InvalidName(_aPathString, "is not a valid path. Invalid name");
+
+ if (isEmptyString(aElementName))
+ aElementName = makeWildcardType();
+
+ else if ( !isWildcardType(aElementName))
+ throw InvalidName(_aPathString, "is not a valid path. Invalid type tag for predicate");
+ }
+ if (pQuoteStart != pEnd)
+ aElementName += implNormalizePredicate(pQuoteStart,pEnd);
+
+ aResult.prepend( Path::Component(aElementName, Path::PackageOnly()) );
+
+ pEnd = pNameStart;
+ if (pNameStart != pBegin) --pEnd;
+ }
+
+ return aResult;
+ }
//-----------------------------------------------------------------------------
-AbsolutePath::AbsolutePath(OUString const& aString, NoValidate)
-: m_aRep(implParsePath(aString, PathType::eABSOLUTE))
-{
- init();
-}
+ /// build a composite path component from a base name (type) and a (somewhat optional) predicate
+ Name implMakeCompositeName(OUString const& _sBaseName, OUString const& _sPredicate) SAL_THROW((InvalidName))
+ {
+ OUString sComposite(_sBaseName);
+
+ if (isEmptyString(_sBaseName))
+ sComposite = makeWildcardType();
+
+ else if (!isWildcardType(_sBaseName) && !isSimpleName(_sBaseName))
+ throw InvalidName(_sBaseName, "The base-name (type) part of a composite node name must be a simple word");
+
+ StrPos pPredStart = _sPredicate.getStr();
+ StrPos pPredEnd = pPredStart + _sPredicate.getLength();
+
+ if (pPredStart != pPredEnd)
+ sComposite += implMakeNormalizedPredicate(pPredStart, pPredEnd, NULL);
+
+ return Name( sComposite, Path::PackageOnly() );
+ }
//-----------------------------------------------------------------------------
-AbsolutePath AbsolutePath::root()
-{
- Components aRep(1);
- return AbsolutePath(aRep);
+ /// split a composite path component into a base name (type) and a predicate (if present)
+ void implSplitCompositeName(Name const& _aCompositeName, OUString& _rBaseName, OUString& _rPredicate) SAL_THROW(())
+ {
+ OUString sComposite = _aCompositeName.toString();
+ sal_Int32 nPos = sComposite.indexOf(c_lBracket);
+
+ if (nPos >= 0)
+ {
+ OSL_ENSURE( nPos > 0, "Invalid name: Only predicate, no base type");
+
+ _rBaseName = sComposite.copy(0,nPos);
+
+ StrPos pBeginPred = sComposite.getStr() + nPos;
+ StrPos pEndPred = sComposite.getStr() + sComposite.getLength();
+
+ OSL_ASSERT(pBeginPred[0] == c_lBracket);
+ OSL_ENSURE(pBeginPred[1] == c_normal_quot, "Missing or unexpected quote mark");
+ OSL_ENSURE(pEndPred[-1] == c_rBracket, "Invalid name: Predicate brackets not closed");
+ OSL_ENSURE(pEndPred[-2] == c_normal_quot, "Missing or unexpected quote mark");
+
+ // skip brackets and quotes - then read data
+ _rPredicate = implReadPredicate(pBeginPred+2, pEndPred-2);
+ }
+ else
+ {
+ OSL_ENSURE( sComposite.indexOf(c_rBracket) < 0, "Invalid name: Predicate brackets not opened");
+ _rBaseName = sComposite;
+ _rPredicate = OUString();
+ }
+ }
+//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
-AbsolutePath AbsolutePath::detachedRoot()
-{
- Components aRep(2);
- return AbsolutePath(aRep);
-}
+//-----------------------------------------------------------------------------
+// class RelativePath
//-----------------------------------------------------------------------------
-AbsolutePath AbsolutePath::compose(RelativePath const& aPath) const
+// Currently unused method to check/ensure validity
+void RelativePath::init() SAL_THROW(())
{
- return AbsolutePath( m_aRep.compose(aPath.rep()));
}
//-----------------------------------------------------------------------------
-AbsolutePath AbsolutePath::child(Name const& aChild) const
+RelativePath RelativePath::parse(OUString const& aString)
{
- return AbsolutePath( m_aRep.child(aChild) );
+ return RelativePath( implParsePath(aString, eRELATIVE) );
}
//-----------------------------------------------------------------------------
-AbsolutePath AbsolutePath::parent() const
+RelativePath::RelativePath(Path::Component const& aName) SAL_THROW(())
+: m_aRep(aName)
{
- return AbsolutePath( m_aRep.parent() );
+ if (aName.isEmpty()) m_aRep.clearComponents();
}
//-----------------------------------------------------------------------------
-bool AbsolutePath::isRoot() const
+RelativePath RelativePath::compose(RelativePath const& aPath) const SAL_THROW(())
{
- return m_aRep.countComponents() == REP_OFF;
+ Path::Rep aResult = aPath.rep();
+ aResult.prepend( this->m_aRep );
+ return RelativePath( aResult );
}
//-----------------------------------------------------------------------------
-
-OUString AbsolutePath::toString() const
+OUString RelativePath::toString() const SAL_THROW(())
{
- return m_aRep.toString();
+ return m_aRep.toString(false);
}
-//-----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
-// class Path
+// class AbsolutePath
//-----------------------------------------------------------------------------
-PathRep::Components Path::parse(OUString const& aString, Type eType)
+// Currently unused method to check/ensure validity
+void AbsolutePath::init() SAL_THROW(())
{
- return implParsePath(aString, eType);
}
//-----------------------------------------------------------------------------
-void Path::init()
+AbsolutePath AbsolutePath::parse(OUString const& aString)
{
- using namespace PathType;
- if (m_eType == ePATH)
- {
- m_eType = isAbsolute(m_aRep) ? eABSOLUTE
- :m_aRep.countComponents() == 1 ? eNAME
- : eRELATIVE;
- }
-
- OSL_ASSERT( isAbsolute(m_aRep) == (m_eType == eABSOLUTE) );
+ return AbsolutePath( implParsePath(aString, eABSOLUTE) );
}
//-----------------------------------------------------------------------------
-Path::Path(OUString const& aString, NoValidate, Type eType)
-: m_aRep(implParsePath(aString,eType))
-, m_eType(eType)
+AbsolutePath AbsolutePath::root() SAL_THROW(())
{
- init();
+ return AbsolutePath( Path::Rep() );
}
//-----------------------------------------------------------------------------
-Path::Path(PathRep const& aRep, Type eType)
-: m_aRep(aRep)
-, m_eType(eType)
+AbsolutePath AbsolutePath::detachedRoot() SAL_THROW(())
{
- init();
+ Path::Rep aRep( Path::makeEmptyComponent() ); // use 1 empty component here, to start detached names
+ return AbsolutePath( aRep );
}
//-----------------------------------------------------------------------------
-Path::Path(Name const& aName)
-: m_aRep( Components(1,aName) )
-, m_eType(PathType::eNAME)
+static inline Path::Component implMakeSafeModuleName(OUString const& _sModuleName) SAL_THROW(())
{
- OSL_ASSERT( !isAbsolute(m_aRep) );
+ OSL_ENSURE( isSimpleName(_sModuleName), "A module name must be a simple name");
+
+ // if (isSimpleName(_sModuleName)) sModuleName = escape_name( _sModuleName );
+
+ return Path::Component(_sModuleName, Path::PackageOnly());
}
//-----------------------------------------------------------------------------
-Path::Path(AbsolutePath const& aPath)
-: m_aRep(aPath.rep())
-, m_eType(PathType::eABSOLUTE)
+AbsolutePath AbsolutePath::makeModulePath(Name const& _aModuleName, NoValidate) SAL_THROW(())
{
- OSL_ASSERT( isAbsolute(m_aRep) );
+ return AbsolutePath( Path::Rep( implMakeSafeModuleName(_aModuleName.toString()) ) );
}
//-----------------------------------------------------------------------------
-Path::Path(RelativePath const& aPath)
-: m_aRep(aPath.rep())
-, m_eType(PathType::eRELATIVE)
+AbsolutePath AbsolutePath::makeModulePath(OUString const& _sModuleName, NoValidate) SAL_THROW(())
{
- OSL_ASSERT( !isAbsolute(m_aRep) );
+ return AbsolutePath( Path::Rep( implMakeSafeModuleName(_sModuleName) ) );
}
//-----------------------------------------------------------------------------
-Path Path::compose(RelativePath const& aPath) const
+AbsolutePath AbsolutePath::compose(RelativePath const& aPath) const SAL_THROW(())
{
- return Path( m_aRep.compose(aPath.rep()), m_eType);
+ Path::Rep aResult = aPath.rep();
+ aResult.prepend( this->m_aRep );
+ return AbsolutePath( aResult );
}
//-----------------------------------------------------------------------------
-Path Path::child(Name const& aChild) const
+AbsolutePath AbsolutePath::getParentPath() const
{
- return Path( m_aRep.child(aChild), m_eType );
+ // or: m_aRep.check_not_empty();
+ OSL_ENSURE(!isRoot(), "ERROR: Requesting the parent of a root path");
+ if (isRoot()) return *this;
+
+ OSL_ENSURE(!isDetached(), "ERROR: Requesting the parent of a detached path");
+
+ return AbsolutePath( Path::Rep(begin(),end()-1) );
}
//-----------------------------------------------------------------------------
-Path Path::parent() const
+bool AbsolutePath::isDetached() const SAL_THROW(())
{
- return Path( m_aRep.parent(), m_eType);
+ return !m_aRep.isEmpty() && begin()->isEmpty();
}
//-----------------------------------------------------------------------------
-OUString Path::toString() const
+OUString AbsolutePath::toString() const SAL_THROW(())
{
- return m_aRep.toString();
+ return m_aRep.toString(true);
}
-
//-----------------------------------------------------------------------------
}
}
diff --git a/configmgr/source/treemgr/configset.cxx b/configmgr/source/treemgr/configset.cxx
index 56bfe20eba26..7697295ff9a4 100644
--- a/configmgr/source/treemgr/configset.cxx
+++ b/configmgr/source/treemgr/configset.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configset.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,11 +122,19 @@ ElementTree ElementRef::getElementTree() const
}
//-----------------------------------------------------------------------------
+Path::Component ElementRef::getFullName() const
+{
+ if (!isValid()) return Path::makeEmptyComponent();
+
+ return m_aTreeHolder->getExtendedRootName();
+}
+//-----------------------------------------------------------------------------
+
Name ElementRef::getName() const
{
if (!isValid()) return Name();
- return m_aTreeHolder->getRootName();
+ return m_aTreeHolder->getSimpleRootName();
}
//-----------------------------------------------------------------------------
// class ElementTree
@@ -286,9 +294,9 @@ Name SetElementInfo::getTemplatePackage() const
}
//-----------------------------------------------------------------------------
-RelativePath SetElementInfo::getTemplatePath() const
+OUString SetElementInfo::getTemplatePathString() const
{
- return m_aTemplate->getPath();
+ return m_aTemplate->getPathString();
}
//-----------------------------------------------------------------------------
@@ -514,7 +522,7 @@ static void doValidateElement(ElementRef const& aElement)
//-----------------------------------------------------------------------------
/// validates that the given element is valid in this context and returns its name
-Name TreeSetUpdater::implValidateElement(ElementRef const& aElement)
+Path::Component TreeSetUpdater::implValidateElement(ElementRef const& aElement)
{
doValidateElement(aElement);
@@ -523,12 +531,12 @@ Name TreeSetUpdater::implValidateElement(ElementRef const& aElement)
// OSL_ENSURE( !pElement || pElement->isTemplateInstance(), "INTERNAL ERROR: Set Element without associated template found");
// OSL_ENSURE( !pElement || pElement->isInstanceOf(m_aTemplate), "INTERNAL ERROR: Set Update: existing element does not match template");
- return aElement.getName();
+ return aElement.getFullName();
}
//-----------------------------------------------------------------------------
/// validates that the given element is valid and can be replaced in this context and returns its name
-Name ValueSetUpdater::implValidateElement(ElementRef const& aElement)
+Path::Component ValueSetUpdater::implValidateElement(ElementRef const& aElement)
{
doValidateElement(aElement);
@@ -543,7 +551,7 @@ Name ValueSetUpdater::implValidateElement(ElementRef const& aElement)
"INTERNAL ERROR: Set Update: existing element does not match template type");
#endif
- return aElement.getName();
+ return aElement.getFullName();
}
//-----------------------------------------------------------------------------
static void checkEligibleChild(ElementTree const& aElementTree, Tree const& aParentTree)
@@ -581,8 +589,8 @@ void TreeSetUpdater::implValidateTree(ElementTree const& aElementTree)
if (!aElementTree->isInstanceOf(m_aTemplate))
{
- throw TypeMismatch( aElementTree->getTemplate()->getPath().toString(),
- m_aTemplate->getPath().toString(), " - new element without template in Set Update");
+ throw TypeMismatch( aElementTree->getTemplate()->getPathString(),
+ m_aTemplate->getPathString(), " - new element without template in Set Update");
}
}
//-----------------------------------------------------------------------------
@@ -639,7 +647,7 @@ NodeChange TreeSetUpdater::validateInsertElement (Name const& aName, ElementTree
implValidateTree(aNewElement);
- std::auto_ptr<SetChangeImpl> pChange( new SetInsertTreeImpl(aName, aNewElement.get()) );
+ std::auto_ptr<SetChangeImpl> pChange( new SetInsertTreeImpl(aNewElement->makeExtendedName(aName), aNewElement.get()) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -655,7 +663,9 @@ NodeChange ValueSetUpdater::validateInsertElement (Name const& aName, UnoAny con
UnoAny aValidValue = implValidateValue(aNewValue);
- std::auto_ptr<SetChangeImpl> pChange( new SetInsertValueImpl(aName, makeValueElement(aName, aValidValue)) );
+ ElementTreeHolder aNewElement = makeValueElement(aName, aValidValue);
+
+ std::auto_ptr<SetChangeImpl> pChange( new SetInsertValueImpl(aNewElement->makeExtendedName(aName), aNewElement) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -665,7 +675,7 @@ NodeChange ValueSetUpdater::validateInsertElement (Name const& aName, UnoAny con
NodeChange TreeSetUpdater::validateReplaceElement(ElementRef const& aElement, ElementTree const& aNewElement)
{
- Name aName = implValidateElement(aElement);
+ Path::Component aName = implValidateElement(aElement);
implValidateTree(aNewElement);
@@ -679,13 +689,15 @@ NodeChange TreeSetUpdater::validateReplaceElement(ElementRef const& aElement, El
NodeChange ValueSetUpdater::validateReplaceElement(ElementRef const& aElement, UnoAny const& aNewValue)
{
- Name aName = implValidateElement(aElement);
+ Path::Component aName = implValidateElement(aElement);
ElementNodeRef aElementNode = extractElementNode(aElement);
UnoAny aValidValue = implValidateValue(aElementNode, aNewValue);
- std::auto_ptr<SetChangeImpl> pChange( new SetReplaceValueImpl(aName, makeValueElement(aName, aElementNode,aValidValue)) );
+ ElementTreeHolder aNewElement = makeValueElement(aName.getName(), aElementNode, aValidValue);
+
+ std::auto_ptr<SetChangeImpl> pChange( new SetReplaceValueImpl(aName, aNewElement) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -695,7 +707,7 @@ NodeChange ValueSetUpdater::validateReplaceElement(ElementRef const& aElement, U
NodeChange TreeSetUpdater::validateRemoveElement (ElementRef const& aElement)
{
- Name aName = implValidateElement(aElement);
+ Path::Component aName = implValidateElement(aElement);
std::auto_ptr<SetChangeImpl> pChange( new SetRemoveTreeImpl(aName) );
@@ -708,7 +720,7 @@ NodeChange TreeSetUpdater::validateRemoveElement (ElementRef const& aElement)
NodeChange ValueSetUpdater::validateRemoveElement (ElementRef const& aElement)
{
- Name aName = implValidateElement(aElement);
+ Path::Component aName = implValidateElement(aElement);
std::auto_ptr<SetChangeImpl> pChange( new SetRemoveValueImpl(aName) );
@@ -763,11 +775,7 @@ Name ElementHelper::getElementName(ElementRef const& aElement)
{
OSL_PRECOND( aElement.isValid(), "ERROR: Configuration: ElementRef operation requires valid node" );
- Tree aElementTree = impl_extractElementTree(aElement);
-
- OSL_ASSERT( aElementTree.isEmpty() == !aElement.isValid() );
-
- return aElementTree.getRootName();
+ return aElement.getName();
}
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/treemgr/nodechangeimpl.cxx b/configmgr/source/treemgr/nodechangeimpl.cxx
index f9fad1e51a75..2e6885e6848e 100644
--- a/configmgr/source/treemgr/nodechangeimpl.cxx
+++ b/configmgr/source/treemgr/nodechangeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeimpl.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -315,14 +315,14 @@ void ValueChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nPar
{
OSL_ENSURE(false, "ValueChangeTarget is being set without a name");
NodeChangeImpl::setAffected(aAffectedTree,aAffectedTree->parent(nParentNode));
- m_aName = aAffectedTree->getNodeName(nParentNode);
+ m_aName = aAffectedTree->getSimpleNodeName(nParentNode);
}
}
//-----------------------------------------------------------------------------
RelativePath ValueChangeImpl::doGetChangingNodePath() const
{
- return RelativePath( m_aName );
+ return RelativePath( Path::wrapSimpleName(m_aName) );
}
//-----------------------------------------------------------------------------
@@ -504,7 +504,7 @@ NodeOffset DeepValueReplaceImpl::doGetBaseNode() const // use your own
// All Sets: SetChangeImpl - common base
//-----------------------------------------------------------------------------
-SetChangeImpl::SetChangeImpl(Name const& aName, bool bNoCheck)
+SetChangeImpl::SetChangeImpl(Path::Component const& aName, bool bNoCheck)
: NodeChangeImpl(bNoCheck)
, m_aName(aName)
{
@@ -519,7 +519,7 @@ void SetChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nAffec
RelativePath SetChangeImpl::doGetChangingNodePath() const
{
- return RelativePath(getElementName());
+ return RelativePath(getFullElementName());
}
//-----------------------------------------------------------------------------
@@ -544,7 +544,7 @@ void SetChangeImpl::doApply( Node& rTarget)
// Full Sets: SetInsertTreeImpl
//-----------------------------------------------------------------------------
-SetInsertTreeImpl::SetInsertTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck)
+SetInsertTreeImpl::SetInsertTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck)
: SetChangeImpl(aName,bNoCheck)
, m_aNewTree(aNewTree)
{
@@ -587,7 +587,7 @@ void SetInsertTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
// Full Sets: SetReplaceTreeImpl
//-----------------------------------------------------------------------------
-SetReplaceTreeImpl::SetReplaceTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree)
+SetReplaceTreeImpl::SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree)
: SetChangeImpl(aName)
, m_aNewTree(aNewTree)
, m_aOldTree()
@@ -595,7 +595,7 @@ SetReplaceTreeImpl::SetReplaceTreeImpl(Name const& aName, ElementTreeHolder cons
}
//-----------------------------------------------------------------------------
-SetReplaceTreeImpl::SetReplaceTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree)
+SetReplaceTreeImpl::SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree)
: SetChangeImpl(aName,true)
, m_aNewTree(aNewTree)
, m_aOldTree(aOldTree)
@@ -657,14 +657,14 @@ void SetReplaceTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName
// Full Sets: SetRemoveTreeImpl
//-----------------------------------------------------------------------------
-SetRemoveTreeImpl::SetRemoveTreeImpl(Name const& aName)
+SetRemoveTreeImpl::SetRemoveTreeImpl(Path::Component const& aName)
: SetChangeImpl(aName)
, m_aOldTree()
{
}
//-----------------------------------------------------------------------------
-SetRemoveTreeImpl::SetRemoveTreeImpl(Name const& aName, ElementTreeHolder const& aOldTree)
+SetRemoveTreeImpl::SetRemoveTreeImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree)
: SetChangeImpl(aName,true)
, m_aOldTree(aOldTree)
{
diff --git a/configmgr/source/treemgr/nodechangeimpl.hxx b/configmgr/source/treemgr/nodechangeimpl.hxx
index b4542cc5abad..11a7f69f4dae 100644
--- a/configmgr/source/treemgr/nodechangeimpl.hxx
+++ b/configmgr/source/treemgr/nodechangeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeimpl.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:35:59 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -304,12 +304,15 @@ namespace configmgr
class SetChangeImpl
: public NodeChangeImpl
{
- Name m_aName;
+ Path::Component m_aName;
public:
- explicit SetChangeImpl(Name const& aName, bool bNoCheck = false);
+ explicit SetChangeImpl(Path::Component const& aName, bool bNoCheck = false);
/// the name of the element being changed
- Name getElementName() const { return m_aName; }
+ Path::Component getFullElementName() const { return m_aName; }
+
+ /// the name of the element being changed
+ Name getElementName() const { return m_aName.getName(); }
/// setup the 'target' node that is to be affected or changed
void setTarget(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode);
@@ -340,7 +343,7 @@ namespace configmgr
{
ElementTreeHolder m_aNewTree;
public:
- explicit SetInsertTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck = false);
+ explicit SetInsertTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck = false);
protected:
/// checks, if this represents an actual change (given whether the change has been applied or not)
@@ -362,8 +365,8 @@ namespace configmgr
ElementTreeHolder m_aNewTree;
ElementTreeHolder m_aOldTree;
public:
- explicit SetReplaceTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree);
- explicit SetReplaceTreeImpl(Name const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree);
+ explicit SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree);
+ explicit SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree);
protected:
/// checks, if this represents an actual change (given whether the change has been applied or not)
@@ -384,8 +387,8 @@ namespace configmgr
{
ElementTreeHolder m_aOldTree;
public:
- explicit SetRemoveTreeImpl(Name const& aName);
- explicit SetRemoveTreeImpl(Name const& aName, ElementTreeHolder const& aOldTree);
+ explicit SetRemoveTreeImpl(Path::Component const& aName);
+ explicit SetRemoveTreeImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree);
protected:
/// checks, if this represents an actual change (given whether the change has been applied or not)
diff --git a/configmgr/source/treemgr/nodechangeinfo.cxx b/configmgr/source/treemgr/nodechangeinfo.cxx
index 3b80fea5f8db..2c7f49c33da2 100644
--- a/configmgr/source/treemgr/nodechangeinfo.cxx
+++ b/configmgr/source/treemgr/nodechangeinfo.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeinfo.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:31:32 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -188,7 +188,7 @@ bool NodeChangeLocation::isValidLocation() const
: ( m_affected.isValidNode() &&
(! m_bSubNodeChanging ||
(!m_path.isEmpty() &&
- SubNodeID(m_affected,m_path.getLocalName()).isValidNode()
+ SubNodeID(m_affected,m_path.getLocalName().getName()).isValidNode()
) ) ) );
}
//-----------------------------------------------------------------------------
@@ -265,7 +265,7 @@ SubNodeID NodeChangeLocation::getChangingValueID() const
OSL_ENSURE(!m_affected.isEmpty() && m_affected.isValidNode(), "Invalid target location set in NodeChangeLocation with subnode");
OSL_ENSURE(!m_path.isEmpty(), "No target accessor set in NodeChangeLocation with subnode");
- SubNodeID aResult( m_affected, m_path.getLocalName() );
+ SubNodeID aResult( m_affected, m_path.getLocalName().getName() );
OSL_ENSURE(aResult.isValidNode(), "Invalid change location set in NodeChangeLocation");
diff --git a/configmgr/source/treemgr/nodeimpl.cxx b/configmgr/source/treemgr/nodeimpl.cxx
index 01d02eb59a6f..7367cfffaf90 100644
--- a/configmgr/source/treemgr/nodeimpl.cxx
+++ b/configmgr/source/treemgr/nodeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimpl.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:43:00 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -116,7 +116,7 @@ namespace
bool GroupMemberDispatch::test_value(INode const& _rNode) const
{
- Name aName( _rNode.getName(), Name::NoValidate() );
+ Name aName = makeName( _rNode.getName(), Name::NoValidate() );
return m_rGroup.hasValue( aName );
}
@@ -126,7 +126,7 @@ namespace
OSL_ENSURE( test_value(_rValue), "ERROR: GroupMemberDispatch:Did not find a ValueMember for a value child.");
if ( !done() )
{
- Name aValueName( _rValue.getName(), Name::NoValidate() );
+ Name aValueName( makeNodeName(_rValue.getName(), Name::NoValidate()) );
m_aResult = m_rVisitor.visit( m_rGroup.getValue(aValueName) );
}
@@ -641,7 +641,7 @@ void SetNodeImpl::implCollectChanges(NodeChangesInformation& rLocalChanges, Subt
OSL_ENSURE(pParentTree->isValidNode(nNode), "Invalid context node in Set");
OSL_ENSURE(&pParentTree->node(nNode)->setImpl() == this, "Wrong context node in Set");
- CollectChanges aCollector(rLocalChanges, *pParentTree, nNode, nDepth);
+ CollectChanges aCollector(rLocalChanges, *pParentTree, nNode, getElementTemplate(), nDepth);
aCollector.collectFrom(rExternalChange);
}
@@ -699,7 +699,7 @@ void GroupNodeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, Subtr
{
ValueChange const& rValueChange = static_cast<ValueChange const&>(*it);
- Name aValueName( rValueChange.getNodeName(), Name::NoValidate() );
+ Name aValueName = makeNodeName( rValueChange.getNodeName(), Name::NoValidate() );
if (ValueChangeImpl* pThisChange = doAdjustToValueChange(aValueName, rValueChange))
{
diff --git a/configmgr/source/treemgr/nodeimplobj.cxx b/configmgr/source/treemgr/nodeimplobj.cxx
index af785b7afbaa..3b239b569d36 100644
--- a/configmgr/source/treemgr/nodeimplobj.cxx
+++ b/configmgr/source/treemgr/nodeimplobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimplobj.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:43:00 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -458,7 +458,7 @@ void DeferredGroupNodeImpl::doFinishCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aValueName(it->getNodeName(), Name::NoValidate());
+ Name aValueName = makeNodeName(it->getNodeName(), Name::NoValidate());
ValueChanges::iterator itStoredChange = m_aChanges.find(aValueName);
@@ -500,7 +500,7 @@ void DeferredGroupNodeImpl::doRevertCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aValueName(it->getNodeName(), Name::NoValidate());
+ Name aValueName = makeNodeName(it->getNodeName(), Name::NoValidate());
ValueChanges::iterator itStoredChange = m_aChanges.find(aValueName);
@@ -535,7 +535,7 @@ void DeferredGroupNodeImpl::doFailedCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aValueName(it->getNodeName(), Name::NoValidate());
+ Name aValueName = makeNodeName(it->getNodeName(), Name::NoValidate());
ValueChanges::iterator itStoredChange = m_aChanges.find(aValueName);
@@ -949,7 +949,7 @@ SetNodeVisitor::Result DeferredTreeSetNodeImpl::doDispatchToElements(SetNodeVisi
if (m_aChangedData.getElement(it->first) == 0)
{
OSL_ASSERT(it->second.isValid());
- aVisitor.visit(SetEntry(it->second.getBodyPtr()));
+ eRet = aVisitor.visit(SetEntry(it->second.getBodyPtr()));
}
}}
@@ -1209,7 +1209,7 @@ void DeferredTreeSetNodeImpl::doFinishCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
@@ -1300,7 +1300,7 @@ void DeferredTreeSetNodeImpl::doRevertCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
@@ -1374,7 +1374,7 @@ void DeferredTreeSetNodeImpl::doFailedCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
@@ -1977,7 +1977,7 @@ void DeferredValueSetNodeImpl::doFinishCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
@@ -2064,7 +2064,7 @@ void DeferredValueSetNodeImpl::doRevertCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
@@ -2134,7 +2134,7 @@ void DeferredValueSetNodeImpl::doFailedCommit(SubtreeChange& rChanges)
it != stop;
++it)
{
- Name aElementName = Name(it->getNodeName(), Name::NoValidate());
+ Name aElementName = makeElementName(it->getNodeName(), Name::NoValidate());
Element* pOriginal = getStoredElement(aElementName);
diff --git a/configmgr/source/treemgr/noderef.cxx b/configmgr/source/treemgr/noderef.cxx
index df47b48eacb8..80b387207ac1 100644
--- a/configmgr/source/treemgr/noderef.cxx
+++ b/configmgr/source/treemgr/noderef.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: noderef.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -408,6 +408,32 @@ bool Tree::hasElement(NodeRef const& aNode, Name const& aName) const
}
//-----------------------------------------------------------------------------
+bool Tree::hasElement(NodeRef const& aNode, Path::Component const& aName) const
+{
+ OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" );
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: NodeRef operation requires valid node" );
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" );
+
+ if (aNode.m_nDepth == 0)
+ {
+ CFG_TRACE_WARNING( "configuration: Querying node beyond available depth" );
+ }
+
+ bool bFound = false;
+
+ if (aNode.m_pImpl && aNode.m_pImpl->isSetNode())
+ {
+ SetEntry aChildEntry = aNode.m_pImpl->setImpl().findElement(aName.getName());
+
+ // do check if types do match as well
+ bFound = aChildEntry.isValid() &&
+ Path::matches(aChildEntry.tree()->getExtendedRootName(),aName);
+ }
+
+ return bFound; // even if nothing found
+}
+//-----------------------------------------------------------------------------
+
ElementRef Tree::getElement(NodeRef const& aNode, Name const& aName) const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" );
@@ -469,7 +495,7 @@ Name Tree::getName(NodeRef const& aNode) const
if (isEmpty()) return Name();
- return m_pImpl->getNodeName(aNode.m_nPos);
+ return m_pImpl->getSimpleNodeName(aNode.m_nPos);
}
//-----------------------------------------------------------------------------
// class ValueRef
@@ -716,7 +742,7 @@ Name Tree::getName(AnyNodeRef const& aNode) const
if (isEmpty() || !aNode.isValid()) return Name();
if (aNode.isNode())
- return m_pImpl->getNodeName(aNode.m_nUsedPos);
+ return m_pImpl->getSimpleNodeName(aNode.m_nUsedPos);
else
return aNode.m_sNodeName;
@@ -1037,17 +1063,21 @@ UnoAny Tree::getNodeValue(ValueRef const& aNode) const
}
//-----------------------------------------------------------------------------
-RelativePath Tree::getLocalPath(NodeRef const& aNode) const
+AbsolutePath Tree::getAbsolutePath(NodeRef const& aNode) const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
OSL_PRECOND( !aNode.isValid() || isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
- Path::Components aNames;
+ Path::Rep aNames;
- // Case of invalid node is handled properly (as they (should) have m_nPos == 0)
- m_pImpl->appendPathTo( aNode.m_nPos, aNames );
+ if (!this->isEmpty())
+ {
+ if ( aNode.isValid() )
+ m_pImpl->prependLocalPathTo( aNode.m_nPos, aNames );
- return RelativePath(aNames);
+ aNames.prepend( m_pImpl->getRootPath().rep() );
+ }
+ return AbsolutePath(aNames);
}
//-----------------------------------------------------------------------------
@@ -1061,12 +1091,12 @@ NodeRef Tree::getRootNode() const
}
//-----------------------------------------------------------------------------
-Name Tree::getRootName() const
+Path::Component Tree::getRootName() const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
- if (isEmpty()) return Name();
+ if (isEmpty()) return Path::makeEmptyComponent();
- return m_pImpl->getRootName();
+ return m_pImpl->getExtendedRootName();
}
//-----------------------------------------------------------------------------
@@ -1169,11 +1199,11 @@ NodeRef Tree::getContextNode() const
}
//-----------------------------------------------------------------------------
-AbsolutePath Tree::getContextPath() const
+AbsolutePath Tree::getRootPath() const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
- return isEmpty() ? AbsolutePath::root() : m_pImpl->getContextPath();
+ return isEmpty() ? AbsolutePath::root() : m_pImpl->getRootPath();
}
//-----------------------------------------------------------------------------
@@ -1458,15 +1488,39 @@ bool operator < (SubNodeID const& lhs, SubNodeID const& rhs)
// Free functions
//-----------------------------------------------------------------------------
-Name validateNodeName(OUString const& sName, Tree const& aTree, NodeRef const& aNode )
+Name validateElementName(OUString const& sName, Tree const& aTree, NodeRef const& aNode )
+{
+ OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid NodeRef");
+ OSL_PRECOND( aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
+
+ OSL_PRECOND( TreeImplHelper::isSet(aNode), "ERROR: Configuration: Set node expected.");
+
+ return validateElementName(sName);
+}
+//-----------------------------------------------------------------------------
+
+Name validateChildName(OUString const& sName, Tree const& aTree, NodeRef const& aNode )
+{
+ OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid NodeRef");
+ OSL_PRECOND( aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
+
+ OSL_PRECOND( TreeImplHelper::isGroup(aNode), "ERROR: Configuration: Group node expected.");
+
+ return validateNodeName(sName);
+}
+//-----------------------------------------------------------------------------
+
+Name validateChildOrElementName(OUString const& sName, Tree const& aTree, NodeRef const& aNode )
{
OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid NodeRef");
OSL_PRECOND( aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
- if (!aNode.isValid()) // no node - any name
- return makeName(sName);
+ OSL_PRECOND( isStructuralNode(aTree,aNode), "ERROR: Configuration: Inner node expected.");
- else if (TreeImplHelper::isSet(aNode))
+ if (TreeImplHelper::isSet(aNode))
return validateElementName(sName);
else
@@ -1474,61 +1528,75 @@ Name validateNodeName(OUString const& sName, Tree const& aTree, NodeRef const& a
}
//-----------------------------------------------------------------------------
-RelativePath reduceRelativePath(OUString const& sPath, Tree const& aTree, NodeRef const& aBaseNode)
+Path::Component validateElementPathComponent(OUString const& sName, Tree const& aTree, NodeRef const& aNode )
{
- OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
- OSL_PRECOND( !aBaseNode.isValid() || aTree.isValidNode(aBaseNode), "WARNING: Configuration: NodeRef does not match Tree");
+ Name aElementName = validateElementName(sName,aTree,aNode);
+
+ TemplateHolder aTemplate = SetElementInfo::extractElementInfo(aTree,aNode);
+ if (aTemplate.isValid())
+ {
+ return Path::makeCompositeName( aElementName, aTemplate->getName() );
+ }
+ else
+ {
+ OSL_ENSURE(false, "WARNING: Cannot find element type information for building an element name");
+ return Path::wrapElementName(aElementName);
+ }
+}
+//-----------------------------------------------------------------------------
- // TODO: Evaluate aTree's ancestors as node context for path parsing (?)
- Path aPath( sPath, Path::NoValidate() );
+static void implValidateLocalPath(RelativePath& _rPath, Tree const& , NodeRef const& aNode)
+{
+ if (_rPath.isEmpty())
+ throw InvalidName(_rPath.toString(), "is an empty path.");
+
+ // FOR NOW: validate only the first component
+ if (aNode.isValid() && !TreeImplHelper::isSet(aNode))
+ if (!_rPath.getFirstName().isSimpleName())
+ throw InvalidName(_rPath.toString(), "is not valid in this context. Predicate expression used to select group member.");
+}
+//-----------------------------------------------------------------------------
+
+RelativePath validateRelativePath(OUString const& _sPath, Tree const& aTree, NodeRef const& aNode)
+{
+ OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid NodeRef");
+ OSL_PRECOND( aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
- Path::Type eType = aPath.getType();
+ OSL_PRECOND( isStructuralNode(aTree,aNode), "ERROR: Configuration: Inner node expected.");
- if (eType != PathType::eABSOLUTE)
+ if ( Path::isAbsolutePath(_sPath) )
{
- // TODO: Validate path components based on node context
- return RelativePath(aPath.rep());
+ OSL_ENSURE(false, "Absolute pathes are not allowed here (compatibility support enabled");
+ return validateAndReducePath(_sPath,aTree,aNode);
}
- // handle absolute path prefix removal now
- typedef Path::Iterator Iter;
+ RelativePath aResult = RelativePath::parse(_sPath);
- Iter itPath = aPath.begin();
- Iter const itPathEnd = aPath.end();
+ implValidateLocalPath(aResult,aTree,aNode);
- if (itPath != itPathEnd && itPath->isEmpty()) // absolute pathes may use a dummy empty first component
- ++itPath;
+ return aResult;
+}
+//-----------------------------------------------------------------------------
- // Tree context resolution
- {
- AbsolutePath aContextPath( aTree.getContextPath() );
- Iter itCtx = aContextPath.begin();
- Iter const itCtxEnd = aContextPath.end();
+RelativePath validateAndReducePath(OUString const& _sPath, Tree const& aTree, NodeRef const& aNode)
+{
+ OSL_PRECOND( !aTree.isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid NodeRef");
+ OSL_PRECOND( aTree.isValidNode(aNode), "ERROR: Configuration: NodeRef does not match Tree");
- for ( ; itCtx != itCtxEnd; ++itPath, ++itCtx)
- {
- if (itPath == itPathEnd || *itPath != *itCtx )
- throw InvalidName(sPath, " does not point into the current node's tree context.");
- }
- }
- // now resolve the path within the tree
- {
- RelativePath aLocalPath( aTree.getLocalPath(aBaseNode) );
- // could be optimized by just building the reverse list
+ OSL_PRECOND( isStructuralNode(aTree,aNode), "ERROR: Configuration: Inner node expected.");
- Iter itLocal = aLocalPath.begin();
- Iter const itLocalEnd = aLocalPath.end();
+ if ( !Path::isAbsolutePath(_sPath) )
+ return validateRelativePath(_sPath,aTree,aNode);
- for ( ; itLocal != itLocalEnd; ++itPath, ++itLocal)
- {
- if (itPath == itPathEnd || *itPath != *itLocal )
- throw InvalidName(sPath, " does not point into the current context node.");
- }
- }
- // TODO: Validate subsequent path components based on node context
+ AbsolutePath aInputPath = AbsolutePath::parse(_sPath);
- // now return the valid remainder
- return RelativePath(Path::Components(itPath, itPathEnd));
+ RelativePath aStrippedPath = Path::stripPrefix( aInputPath, aTree.getAbsolutePath(aNode) );
+
+ implValidateLocalPath(aStrippedPath,aTree,aNode);
+
+ return aStrippedPath;
}
//-----------------------------------------------------------------------------
@@ -1544,11 +1612,17 @@ bool hasChildOrElement(Tree const& aTree, NodeRef const& aNode, Name const& aNam
}
//-----------------------------------------------------------------------------
-bool findInnerChildNode(Tree& aTree, NodeRef& aNode, Name const& aName)
+bool hasChildOrElement(Tree const& aTree, NodeRef const& aNode, Path::Component const& aName)
+{
+ return TreeImplHelper::isSet(aNode) ? aTree.hasElement(aNode,aName) : aTree.hasChild(aNode,aName.getName());
+}
+//-----------------------------------------------------------------------------
+
+bool findInnerChildOrAvailableElement(Tree& aTree, NodeRef& aNode, Name const& aName)
{
if ( TreeImplHelper::isSet(aNode) )
{
- ElementRef aElement = aTree.getElement(aNode,aName);
+ ElementRef aElement = aTree.getAvailableElement(aNode,aName);
if (aElement.isValid())
{
aTree = aElement.getElementTree().getTree();
@@ -1571,138 +1645,171 @@ bool findInnerChildNode(Tree& aTree, NodeRef& aNode, Name const& aName)
}
//-----------------------------------------------------------------------------
-bool findInnerAvailableChildNode(Tree& aTree, NodeRef& aNode, Name const& aName)
+AnyNodeRef getChildOrElement(Tree& aTree, NodeRef const& aParentNode, Name const& aName)
{
- if ( TreeImplHelper::isSet(aNode) )
+ if (aTree.hasChildValue(aParentNode,aName))
{
- ElementRef aElement = aTree.getAvailableElement(aNode,aName);
+ return AnyNodeRef(aTree.getChildValue(aParentNode,aName));
+ }
+
+ else if ( TreeImplHelper::isSet(aParentNode) )
+ {
+ ElementRef aElement = aTree.getElement(aParentNode,aName);
if (aElement.isValid())
{
aTree = aElement.getElementTree().getTree();
- aNode = aTree.getRootNode();
- return true;
+ return AnyNodeRef(aTree.getRootNode());
}
}
+
else
{
- NodeRef aChild = aTree.getChildNode(aNode,aName);
+ NodeRef aChild = aTree.getChildNode(aParentNode,aName);
if ( aChild.isValid() )
{
- aNode = aChild;
- return true;
+ return AnyNodeRef(aChild);
}
}
- return false;
+ return AnyNodeRef();
}
//-----------------------------------------------------------------------------
-bool findInnerDescendantNode(Tree& aTree, NodeRef& aNode, RelativePath& aPath)
+static
+inline
+bool findLocalInnerChild(Tree const& aTree, NodeRef& aNode, Path::Component const& aName)
{
- // requires: findChildNode leaves node and tree unchanged when returning false
- typedef Path::Iterator Iter;
+ NodeRef aChild = aTree.getChildNode(aNode,aName.getName());
+
+ if ( !aChild.isValid() ) return false;
- Iter itPath = aPath.begin();
- Iter const itPathEnd = aPath.end();
+ OSL_ENSURE( aName.isSimpleName(), "Child of group was found by request using element name format -failing");
+ if ( !aName.isSimpleName()) return false;
- for ( ; itPath != itPathEnd; ++itPath)
- if (!findInnerChildNode(aTree,aNode,*itPath))
- break;
+ aNode = aChild;
- aPath = RelativePath(Path::Components(itPath, itPathEnd));
- return itPath == itPathEnd;
+ return true;
}
//-----------------------------------------------------------------------------
-// NOT exported through noderef.hxx, but through treeimpl.hxx
-bool findInnerDescendantAvailable(Tree& aTree, NodeRef& aNode, RelativePath& aPath)
+static
+inline
+bool findElement(Tree& aTree, NodeRef& aNode, Path::Component const& aName)
{
- // requires: findChildNode leaves node and tree unchanged when returning false
- typedef Path::Iterator Iter;
+ ElementRef aElement = aTree.getElement(aNode,aName.getName());
- Iter itPath = aPath.begin();
- Iter const itPathEnd = aPath.end();
+ if (!aElement.isValid()) return false;
- for ( ; itPath != itPathEnd; ++itPath)
- {
- if (!findInnerAvailableChildNode(aTree,aNode,*itPath))
- break;
- }
+ Tree aFoundTree = aElement.getElementTree().getTree();
+
+ OSL_ENSURE(matches(aFoundTree.getRootName(),aName), "Element found, but type prefix does not match - failing");
+ if ( !matches(aFoundTree.getRootName(),aName) ) return false;
+
+ aTree = aFoundTree;
+ aNode = aTree.getRootNode();
- aPath = RelativePath(Path::Components(itPath, itPathEnd));
- return itPath == itPathEnd;
+ return true;
}
//-----------------------------------------------------------------------------
-AnyNodeRef getChildOrElement(Tree& aTree, NodeRef const& aParentNode, Name const& aName)
+static
+bool findLocalInnerDescendant(Tree const& aTree, NodeRef& aNode, RelativePath& rPath)
{
- if (aTree.hasChildValue(aParentNode,aName))
+ while ( !rPath.isEmpty() )
{
- return AnyNodeRef(aTree.getChildValue(aParentNode,aName));
- }
+ if ( TreeImplHelper::isSet(aNode) ) return false;
- NodeRef aNode(aParentNode);
- if ( findInnerChildNode(aTree,aNode,aName) )
- {
- return AnyNodeRef(aNode);
+ if ( ! findLocalInnerChild(aTree,aNode,rPath.getFirstName()) ) return false;
+
+ rPath.dropFirstName();
}
- return AnyNodeRef();
+ return true;
}
//-----------------------------------------------------------------------------
-AnyNodeRef getAvailableChildOrElement(Tree& aTree, NodeRef const& aParentNode, Name const& aName)
+static
+bool findDeepInnerDescendant(Tree& aTree, NodeRef& aNode, RelativePath& rPath)
{
- if (aTree.hasChildValue(aParentNode,aName))
+ while ( !rPath.isEmpty() )
{
- return AnyNodeRef(aTree.getChildValue(aParentNode,aName));
+ if ( TreeImplHelper::isSet(aNode) )
+ {
+ if ( ! findElement(aTree,aNode,rPath.getFirstName()) ) return false;
+ }
+ else
+ {
+ if ( ! findLocalInnerChild(aTree,aNode,rPath.getFirstName()) ) return false;
+ }
+
+ rPath.dropFirstName();
}
- NodeRef aNode(aParentNode);
- if ( findInnerAvailableChildNode(aTree,aNode,aName) )
+ return true;
+}
+//-----------------------------------------------------------------------------
+
+static
+inline
+bool identifiesLocalValue(Tree const& aTree, NodeRef const& aNode, RelativePath const& aPath)
+{
+ if ( aPath.getDepth() == 1 )
{
- return AnyNodeRef(aNode);
- }
+ Path::Component const & aLocalName = aPath.getLocalName();
+ Name aName = aLocalName.getName();
- return AnyNodeRef();
+ if (aTree.hasChildValue(aNode,aName))
+ {
+ OSL_ENSURE( aLocalName.isSimpleName(), "Value in group was found by request using element name format");
+ if ( aLocalName.isSimpleName())
+ return true;
+ }
+ }
+ return false;
}
//-----------------------------------------------------------------------------
-AnyNodeRef getDescendant(Tree& aTree, NodeRef& aNode, RelativePath& aPath)
+AnyNodeRef getLocalDescendant(Tree /*const*/& aTree, NodeRef& aNode, RelativePath& rPath)
{
- if ( findInnerDescendantNode(aTree,aNode,aPath) )
+ if ( findLocalInnerDescendant(aTree,aNode,rPath) )
{
+ OSL_ASSERT(aTree.isValidNode(aNode));
return AnyNodeRef(aNode);
}
- if ( aPath.getDepth() == 1 )
+ if ( identifiesLocalValue(aTree,aNode,rPath) )
{
- Name aName = aPath.getLocalName();
- if (aTree.hasChildValue(aNode,aName))
- {
- return AnyNodeRef(aTree.getChildValue(aNode,aName));
- }
+ ValueRef aValue = aTree.getChildValue(aNode,rPath.getLocalName().getName());
+ OSL_ASSERT(aTree.isValidNode(aValue));
+ return AnyNodeRef(aValue);
+ }
+
+ // compatibility hack
+ if (aTree.hasElement(aNode,rPath.getFirstName()))
+ {
+ OSL_ENSURE(false, "WARNING: Hierarchical Access to set elements is not specified for this interface. This usage is deprecated");
+ // compatibility access only
+ return getDeepDescendant(aTree,aNode,rPath);
}
return AnyNodeRef();
}
//-----------------------------------------------------------------------------
-AnyNodeRef getDescendantAvailable(Tree& aTree, NodeRef& aNode, RelativePath& aPath)
+AnyNodeRef getDeepDescendant(Tree& aTree, NodeRef& aNode, RelativePath& rPath)
{
- if ( findInnerDescendantAvailable(aTree,aNode,aPath) )
+ if ( findDeepInnerDescendant(aTree,aNode,rPath) )
{
+ OSL_ASSERT(aTree.isValidNode(aNode));
return AnyNodeRef(aNode);
}
- if ( aPath.getDepth() == 1 )
+ if ( identifiesLocalValue(aTree,aNode,rPath) )
{
- Name aName = aPath.getLocalName();
- if (aTree.hasChildValue(aNode,aName))
- {
- return AnyNodeRef(aTree.getChildValue(aNode,aName));
- }
+ ValueRef aValue = aTree.getChildValue(aNode,rPath.getLocalName().getName());
+ OSL_ASSERT(aTree.isValidNode(aValue));
+ return AnyNodeRef(aValue);
}
return AnyNodeRef();
@@ -1759,7 +1866,7 @@ void getAllChildrenHelper(NodeID const& aNode, SubNodeIDList& aList)
nOffset = pTreeImpl->findNextChild(nParent,nOffset))
{
OSL_ASSERT( pTreeImpl->isValidNode(nOffset) );
- aList.push_back( SubNodeID( aNode, pTreeImpl->getNodeName(nOffset)) );
+ aList.push_back( SubNodeID( aNode, pTreeImpl->getSimpleNodeName(nOffset)) );
}
}
}
diff --git a/configmgr/source/treemgr/roottree.cxx b/configmgr/source/treemgr/roottree.cxx
index bef4a09a61c4..653b367400a2 100644
--- a/configmgr/source/treemgr/roottree.cxx
+++ b/configmgr/source/treemgr/roottree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottree.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,23 +75,23 @@ namespace configmgr
// factory methods
//-----------------------------------------------------------------------------
-RootTree createReadOnlyTree( AbsolutePath const& aContextPath,
+RootTree createReadOnlyTree( AbsolutePath const& aRootPath,
ISubtree& rCacheNode, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider)
{
return RootTree( new RootTreeImpl( NodeType::getReadAccessFactory(),
- aContextPath, rCacheNode, nDepth,
+ aRootPath, rCacheNode, nDepth,
aTemplateProvider
));
}
//-----------------------------------------------------------------------------
-RootTree createUpdatableTree( AbsolutePath const& aContextPath,
+RootTree createUpdatableTree( AbsolutePath const& aRootPath,
ISubtree& rCacheNode, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider)
{
return RootTree( new RootTreeImpl( NodeType::getDeferredChangeFactory(),
- aContextPath, rCacheNode, nDepth,
+ aRootPath, rCacheNode, nDepth,
aTemplateProvider
));
}
@@ -142,13 +142,10 @@ bool CommitHelper::prepareCommit(TreeChangeList& rChangeList)
return false;
// find the name and path of the change
- Name aRootName(m_pTree->getRootName());
- AbsolutePath aPath = m_pTree->getContextPath();
-
- OSL_ENSURE(aRootName.toString() == pTreeChange->getNodeName(), "ERROR in Commit: Change Name Mismatch");
+ OSL_ENSURE(m_pTree->getSimpleRootName().toString() == pTreeChange->getNodeName(), "ERROR in Commit: Change Name Mismatch");
// now fill the TreeChangeList
- rChangeList.pathToRoot = ConfigurationName(aPath.toString());
+ rChangeList.setRootPath( m_pTree->getRootPath() );
rChangeList.root.swap( *pTreeChange );
return true;
@@ -160,11 +157,10 @@ void CommitHelper::finishCommit(TreeChangeList& rChangeList)
OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree");
// find the name and path of the change
- Name aRootName(m_pTree->getRootName());
- AbsolutePath aPath = m_pTree->getContextPath();
+ AbsolutePath aPath = m_pTree->getRootPath();
- OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: FinishCommit cannot handle rebased changes trees");
- if (rChangeList.pathToRoot.fullName() != aPath.toString())
+ OSL_ENSURE( rChangeList.getRootNodePath().toString() == aPath.toString(), "ERROR: FinishCommit cannot handle rebased changes trees");
+ if ( !matches(rChangeList.getRootNodePath(), aPath) )
throw configuration::Exception("INTERNAL ERROR: FinishCommit cannot handle rebased changes trees");
m_pTree->finishCommit(rChangeList.root);
@@ -175,12 +171,11 @@ void CommitHelper::revertCommit(TreeChangeList& rChangeList)
{
OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree");
- Name aRootName(m_pTree->getRootName());
- AbsolutePath aPath = m_pTree->getContextPath();
+ AbsolutePath aPath = m_pTree->getRootPath();
- OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: cannot handle rebased changes trees");
- if (rChangeList.pathToRoot.fullName() != aPath.toString())
- throw configuration::Exception("INTERNAL ERROR: RevertCommit cannot handle rebased changes trees");
+ OSL_ENSURE( rChangeList.getRootNodePath().toString() == aPath.toString(), "ERROR: FinishCommit cannot handle rebased changes trees");
+ if ( !matches(rChangeList.getRootNodePath(), aPath) )
+ throw configuration::Exception("INTERNAL ERROR: FinishCommit cannot handle rebased changes trees");
m_pTree->revertCommit(rChangeList.root);
}
@@ -190,12 +185,11 @@ void CommitHelper::failedCommit(TreeChangeList& rChangeList)
{
OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree");
- Name aRootName(m_pTree->getRootName());
- AbsolutePath aPath = m_pTree->getContextPath();
+ AbsolutePath aPath = m_pTree->getRootPath();
- OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: cannot handle rebased changes trees");
- if (rChangeList.pathToRoot.fullName() != aPath.toString())
- throw configuration::Exception("INTERNAL ERROR: FailedCommit cannot handle rebased changes trees");
+ OSL_ENSURE( rChangeList.getRootNodePath().toString() == aPath.toString(), "ERROR: FinishCommit cannot handle rebased changes trees");
+ if ( !matches(rChangeList.getRootNodePath(), aPath) )
+ throw configuration::Exception("INTERNAL ERROR: FinishCommit cannot handle rebased changes trees");
m_pTree->recoverFailedCommit(rChangeList.root);
}
diff --git a/configmgr/source/treemgr/roottreeimpl.hxx b/configmgr/source/treemgr/roottreeimpl.hxx
index 9b733700e9fe..b8f4e2f09961 100644
--- a/configmgr/source/treemgr/roottreeimpl.hxx
+++ b/configmgr/source/treemgr/roottreeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottreeimpl.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2000-11-20 01:38:19 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,7 @@ namespace configmgr
// Construction
/// creates a TreeImpl without a parent tree
RootTreeImpl( NodeFactory& rNodeFactory,
- AbsolutePath const& aContextPath,
+ AbsolutePath const& aRootPath,
ISubtree& rCacheTree, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider);
@@ -93,9 +93,11 @@ namespace configmgr
private:
virtual RootTreeImpl const* doCastToRootTree() const;
virtual ElementTreeImpl const* doCastToElementTree() const;
- virtual void doGetPathRoot(Path::Components& rPath) const;
- AbsolutePath m_aContextPath;
+ virtual Path::Component doGetRootName() const;
+ virtual void doFinishRootPath(Path::Rep& rPath) const;
+
+ AbsolutePath m_aRootPath;
};
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/treemgr/setnodeimpl.cxx b/configmgr/source/treemgr/setnodeimpl.cxx
index 73dbc5a2eba2..9ae5083d9ace 100644
--- a/configmgr/source/treemgr/setnodeimpl.cxx
+++ b/configmgr/source/treemgr/setnodeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setnodeimpl.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -166,7 +166,7 @@ namespace
OSL_ENSURE(aTree->nodeCount(), "INTERNAL ERROR: Unexpected empty (!) tree constructed in set node");
OSL_ENSURE(aTree->isValidNode(aTree->root()), "INTERNAL ERROR: Corrupt tree constructed in set node");
- return aTree->getRootName();
+ return aTree->getSimpleRootName();
}
void CollectElementTrees::handle(ValueNode& rValue)
{
@@ -378,7 +378,7 @@ void AbstractSetNodeImpl::implAdjustToElementChange(NodeChangesInformation& rLoc
{
OSL_ENSURE( implHasLoadedElements() , "Unexpected call: Processing element change in uninitialized set");
- Name aName( aChange.getNodeName(), Name::NoValidate() );
+ Name aName = makeElementName( aChange.getNodeName(), Name::NoValidate() );
NodeChangeImpl* pThisChange = 0;
if (aChange.ISA(AddNode))
@@ -466,7 +466,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doCreateInsert(Name const& aName, Element c
typedef SetInsertTreeImpl SetInsertImpl;
typedef SetInsertValueImpl SetInsertImpl;
- SetChangeImpl* pRet = new SetInsertImpl(aName, aNewElement, true);
+ Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
+
+ SetChangeImpl* pRet = new SetInsertImpl(aFullName, aNewElement, true);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -478,7 +480,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doCreateReplace(Name const& aName, Element
typedef SetReplaceTreeImpl SetReplaceImpl;
typedef SetReplaceValueImpl SetReplaceImpl;
- SetChangeImpl* pRet = new SetReplaceImpl(aName, aNewElement, aOldElement);
+ Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
+
+ SetChangeImpl* pRet = new SetReplaceImpl(aFullName, aNewElement, aOldElement);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -490,7 +494,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doCreateRemove(Name const& aName, Element c
typedef SetRemoveTreeImpl SetRemoveImpl;
typedef SetRemoveValueImpl SetRemoveImpl;
- SetChangeImpl* pRet = new SetRemoveImpl(aName, aOldElement);
+ Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
+
+ SetChangeImpl* pRet = new SetRemoveImpl(aFullName, aOldElement);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -809,8 +815,8 @@ ElementTreeHolder TreeSetNodeImpl::implMakeElement(ElementTreeHolder const& aNew
}
if (!aNewElement->isInstanceOf(aTemplate))
{
- throw TypeMismatch( aNewElement->getTemplate()->getPath().toString(),
- aTemplate->getPath().toString(),
+ throw TypeMismatch( aNewElement->getTemplate()->getPathString(),
+ aTemplate->getPathString(),
" - Trying to insert element with wrong template into set");
}
}
diff --git a/configmgr/source/treemgr/template.cxx b/configmgr/source/treemgr/template.cxx
index 64b78ef79eb4..ceb4ea89c58a 100644
--- a/configmgr/source/treemgr/template.cxx
+++ b/configmgr/source/treemgr/template.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: template.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:33:42 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -166,10 +166,10 @@ UnoType Template::getInstanceType() const
//-----------------------------------------------------------------------------
/// get the path where the template is located
-RelativePath Template::getPath() const
+OUString Template::getPathString() const
{
TemplateName aNames(m_aName,m_aModule);
- return aNames.makePath( );
+ return aNames.makePathString( );
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/templateimpl.cxx b/configmgr/source/treemgr/templateimpl.cxx
index 647f81f9b336..e6ac7ef69d03 100644
--- a/configmgr/source/treemgr/templateimpl.cxx
+++ b/configmgr/source/treemgr/templateimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:33:42 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -78,7 +78,7 @@ namespace configmgr
Name TemplateName::makeSimpleTypeName(UnoType const& aType)
{
OUString sTypeName = toTemplateName(aType);
- return Name(sTypeName, Name::NoValidate());
+ return makeName(sTypeName, Name::NoValidate());
}
//-----------------------------------------------------------------------------
@@ -92,13 +92,13 @@ UnoType TemplateName::resolveSimpleTypeName(Name const& aName)
Name TemplateName::makeNativeTypeModuleName()
{
OUString aModuleName = TEMPLATE_MODULE_NATIVE_VALUE;
- return Name(aModuleName, Name::NoValidate());
+ return makeName(aModuleName, Name::NoValidate());
}
//-----------------------------------------------------------------------------
Name TemplateName::makeLocalizedTypeModuleName()
{
OUString aModuleName = TEMPLATE_MODULE_LOCALIZED_VALUE;
- return Name(aModuleName, Name::NoValidate());
+ return makeName(aModuleName, Name::NoValidate());
}
//-----------------------------------------------------------------------------
bool TemplateName::isSimpleTypeName() const
@@ -222,7 +222,7 @@ std::auto_ptr<INode> TemplateProvider_Impl::instantiate(TemplateHolder const& aT
std::auto_ptr<INode> pRet;
if (aTemplate.isValid())
{
- pRet = m_rProvider.requestTemplateInstance(aTemplate->getName().toString(), aTemplate->getModule().toString(), m_xOptions);
+ pRet = m_rProvider.requestTemplateInstance(aTemplate->getName(), aTemplate->getModule(), m_xOptions);
}
return pRet;
}
@@ -332,9 +332,7 @@ TemplateHolder TemplateProvider_Impl::makeElementTemplateWithType(TemplateName c
OSL_ASSERT(aNames.aName.toString() == aSet.getElementTemplateName());
OSL_ASSERT(aNames.aModule.toString() == aSet.getElementTemplateModule());
- OUString sPath = aNames.makePath().toString(); // could also be extracted from aSet
-
- pTemplateInstance = m_rProvider.requestTemplateInstance(aNames.aName.toString(), aNames.aModule.toString(), m_xOptions);
+ pTemplateInstance = m_rProvider.requestTemplateInstance(aNames.aName, aNames.aModule, m_xOptions);
aType = detectNodeType(pTemplateInstance.get()); // throws if necessary
}
diff --git a/configmgr/source/treemgr/templateimpl.hxx b/configmgr/source/treemgr/templateimpl.hxx
index 423bbfbb43c0..c7efb1eda85c 100644
--- a/configmgr/source/treemgr/templateimpl.hxx
+++ b/configmgr/source/treemgr/templateimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: templateimpl.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:33:42 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,16 +62,34 @@
#ifndef CONFIGMGR_TEMPLATEIMPL_HXX_
#define CONFIGMGR_TEMPLATEIMPL_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
-
+#endif
+#ifndef CONFIGMGR_CONFIGTEMPLATE_HXX_
#include "template.hxx"
-
+#endif
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
#include "configpath.hxx"
+#endif
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
#include "options.hxx"
+#endif
+#ifndef _VOS_REFERNCE_HXX_
#include <vos/refernce.hxx>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+#ifndef INCLUDED_MAP
#include <map>
+#define INCLUDED_MAP
+#endif
+#ifndef INCLUDED_MEMORY
#include <memory>
+#define INCLUDED_MEMORY
+#endif
namespace configmgr
{
@@ -120,18 +138,22 @@ namespace configmgr
{}
TemplateName(OUString const& sName_, OUString const& sModule_)
- : aName(sName_, Name::NoValidate())
- , aModule(sModule_, Name::NoValidate())
+ : aName( makeName(sName_, Name::NoValidate()) )
+ , aModule( makeName(sModule_, Name::NoValidate()) )
{}
//-----------------------------------------------------------------
/// compose the path where the template is located
- RelativePath makePath() const
+ OUString makePathString() const
{
- Path::Components aPath;
- if (!aModule.isEmpty()) aPath.push_back(aModule);
- aPath.push_back(aName);
- return RelativePath( aPath );
+ rtl::OUStringBuffer aBuffer;
+
+ if (!aModule.isEmpty())
+ aBuffer.append( this->aModule.toString() ).append(sal_Unicode('/'));
+
+ aBuffer.append( this->aName.toString() );
+
+ return aBuffer.makeStringAndClear();
}
//-----------------------------------------------------------------
bool isEmpty() const
diff --git a/configmgr/source/treemgr/treeimpl.cxx b/configmgr/source/treemgr/treeimpl.cxx
index 732a1d7b66b8..f75266d87130 100644
--- a/configmgr/source/treemgr/treeimpl.cxx
+++ b/configmgr/source/treemgr/treeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,7 +86,7 @@ inline
static
Name nodeName(INode const& aNode)
{
- return Name(aNode.getName(),Name::NoValidate());
+ return makeName(aNode.getName(),Name::NoValidate());
}
//-----------------------------------------------------------------------------
// class TreeImplBuilder - friend of TreeImpl
@@ -284,35 +284,40 @@ void TreeImpl::disposeData()
}
//-----------------------------------------------------------------------------
-void ElementTreeImpl::doGetPathRoot(Path::Components& rPath) const
+void ElementTreeImpl::doFinishRootPath(Path::Rep& rPath) const
{
- rPath = AbsolutePath::detachedRoot().components();
+ rPath.prepend( doGetRootName() );
+ rPath.prepend( AbsolutePath::detachedRoot().rep() );
}
//-----------------------------------------------------------------------------
-void RootTreeImpl::doGetPathRoot(Path::Components& rPath) const
+void RootTreeImpl::doFinishRootPath(Path::Rep& rPath) const
{
- rPath = m_aContextPath.components();
+ rPath.prepend( m_aRootPath.rep() );
}
//-----------------------------------------------------------------------------
-void TreeImpl::implGetContextPath(Path::Components& rPath) const
+
+void TreeImpl::implPrependRootPath(Path::Rep& rPath) const
{
if (m_pParentTree)
{
+ rPath.prepend( doGetRootName() );
OSL_ASSERT(m_nParentNode);
- m_pParentTree->implGetContextPath(rPath);
- m_pParentTree->appendPathTo(m_nParentNode,rPath);
+ m_pParentTree->prependLocalPathTo(m_nParentNode,rPath);
+ m_pParentTree->implPrependRootPath(rPath);
}
else
- doGetPathRoot(rPath);
+ {
+ doFinishRootPath( rPath );
+ }
}
//-----------------------------------------------------------------------------
-AbsolutePath TreeImpl::getContextPath() const
+AbsolutePath TreeImpl::getRootPath() const
{
- Path::Components aPath;
- implGetContextPath(aPath);
+ Path::Rep aPath;
+ implPrependRootPath(aPath);
return AbsolutePath(aPath);
}
//-----------------------------------------------------------------------------
@@ -473,7 +478,7 @@ void TreeImpl::recoverFailedCommit(SubtreeChange& rRootChange)
void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeChange const& aExternalChange)
{
- OSL_PRECOND( getRootName().toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" );
+ OSL_PRECOND( getSimpleRootName().toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" );
TreeDepth nDepth = getAvailableDepth();
@@ -484,7 +489,7 @@ void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeCha
void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, NodeOffset nNode, SubtreeChange const& aExternalChange)
{
OSL_PRECOND( isValidNode(nNode), "ERROR: Valid node required for adjusting to changes" );
- OSL_PRECOND( getNodeName(nNode).toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" );
+ OSL_PRECOND( getSimpleNodeName(nNode).toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" );
TreeDepth nDepth = remainingDepth(getAvailableDepth(),depthTo(nNode));
@@ -531,7 +536,7 @@ void TreeImpl::doFinishCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode)
OSL_ASSERT(isValidNode(nNode));
Node* pNode = node(nNode);
- OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node");
+ OSL_ENSURE(rSubtreeChange.getNodeName() == getSimpleNodeName(nNode).toString(), "ERROR: Change name does not match node");
if (pNode->isSetNode())
{
OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set");
@@ -555,7 +560,7 @@ void TreeImpl::doRevertCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode)
OSL_ASSERT(isValidNode(nNode));
Node* pNode = node(nNode);
- OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node");
+ OSL_ENSURE(rSubtreeChange.getNodeName() == getSimpleNodeName(nNode).toString(), "ERROR: Change name does not match node");
if (pNode->isSetNode())
{
OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set");
@@ -579,7 +584,7 @@ void TreeImpl::doFailedCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode)
OSL_ASSERT(isValidNode(nNode));
Node* pNode = node(nNode);
- OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node");
+ OSL_ENSURE(rSubtreeChange.getNodeName() == getSimpleNodeName(nNode).toString(), "ERROR: Change name does not match node");
if (pNode->isSetNode())
{
OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set");
@@ -603,7 +608,7 @@ void TreeImpl::doAdjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeC
OSL_ASSERT(isValidNode(nNode));
Node* pNode = node(nNode);
- OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node");
+ OSL_ENSURE(rSubtreeChange.getNodeName() == getSimpleNodeName(nNode).toString(), "ERROR: Change name does not match node");
if (pNode->isSetNode())
{
@@ -653,7 +658,7 @@ void TreeImpl::doFinishSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
{
if ( it->ISA(SubtreeChange) )
{
- NodeOffset nNode = findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate()) );
+ NodeOffset nNode = findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate()) );
OSL_ENSURE( nNode != 0, "Changed sub-node not found in tree");
doFinishCommit(static_cast<SubtreeChange&>(*it),nNode);
@@ -661,7 +666,7 @@ void TreeImpl::doFinishSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
else
{
OSL_ENSURE(it->ISA(ValueChange), "Unexpected change type for child of group node; change is ignored");
- OSL_ENSURE(0 == findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate())),
+ OSL_ENSURE(0 == findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate())),
"Found sub(tree) node where a value was expected");
}
}
@@ -678,7 +683,7 @@ void TreeImpl::doRevertSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
{
if ( it->ISA(SubtreeChange) )
{
- NodeOffset nNode = findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate()) );
+ NodeOffset nNode = findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate()) );
OSL_ENSURE( nNode != 0, "Changed sub-node not found in tree");
doRevertCommit(static_cast<SubtreeChange&>(*it),nNode);
@@ -686,7 +691,7 @@ void TreeImpl::doRevertSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
else
{
OSL_ENSURE(it->ISA(ValueChange), "Unexpected change type for child of group node; change is ignored");
- OSL_ENSURE(0 == findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate())),
+ OSL_ENSURE(0 == findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate())),
"Found sub(tree) node where a value was expected");
}
}
@@ -703,7 +708,7 @@ void TreeImpl::doFailedSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
{
if ( it->ISA(SubtreeChange) )
{
- NodeOffset nNode = findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate()) );
+ NodeOffset nNode = findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate()) );
OSL_ENSURE( nNode != 0, "Changed node not found in tree");
doFailedCommit(static_cast<SubtreeChange&>(*it),nNode);
@@ -711,7 +716,7 @@ void TreeImpl::doFailedSubCommitted(SubtreeChange& aChangesParent, NodeOffset nP
else
{
OSL_ENSURE(it->ISA(ValueChange), "Unexpected change type for child of group node; change is ignored");
- OSL_ENSURE(0 == findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate())),
+ OSL_ENSURE(0 == findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate())),
"Found sub(tree) node where a value was expected");
}
}
@@ -729,7 +734,7 @@ void TreeImpl::doAdjustToSubChanges(NodeChangesInformation& rLocalChanges, Subtr
{
if ( it->ISA(SubtreeChange) )
{
- NodeOffset nNode = findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate()) );
+ NodeOffset nNode = findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate()) );
OSL_ENSURE( nNode != 0 || depthTo(nParentNode) >= getAvailableDepth(), "Changed node not found in tree");
if (nNode != 0)
@@ -741,7 +746,7 @@ void TreeImpl::doAdjustToSubChanges(NodeChangesInformation& rLocalChanges, Subtr
else
{
OSL_ENSURE(it->ISA(ValueChange), "Unexpected change type for child of group node; change is ignored");
- OSL_ENSURE(0 == findChild(nParentNode, Name(it->getNodeName(), Name::NoValidate())),
+ OSL_ENSURE(0 == findChild(nParentNode, makeNodeName(it->getNodeName(), Name::NoValidate())),
"Found sub(tree) node where a value was expected");
}
}
@@ -757,7 +762,7 @@ NodeOffset TreeImpl::parent(NodeOffset nNode) const
return node(nNode)->parent();
}
//-----------------------------------------------------------------------------
-inline // is private
+inline // is protected and should be used only here
Name TreeImpl::implGetOriginalName(NodeOffset nNode) const
{
OSL_ASSERT(isValidNode(nNode));
@@ -766,18 +771,37 @@ Name TreeImpl::implGetOriginalName(NodeOffset nNode) const
}
//-----------------------------------------------------------------------------
+Path::Component ElementTreeImpl::doGetRootName() const
+{
+ return makeExtendedName( implGetOriginalName( root() ) );
+}
+
+//-----------------------------------------------------------------------------
-Name TreeImpl::getNodeName(NodeOffset nNode) const
+Path::Component RootTreeImpl::doGetRootName() const
{
- if (nNode == root()) return getRootName();
+ return m_aRootPath.getLocalName();
+}
+//-----------------------------------------------------------------------------
+
+
+Name TreeImpl::getSimpleNodeName(NodeOffset nNode) const
+{
+ if (nNode == root()) return getSimpleRootName();
return implGetOriginalName(nNode);
}
//-----------------------------------------------------------------------------
-Name TreeImpl::getRootName() const
+Name TreeImpl::getSimpleRootName() const
+{
+ return doGetRootName().getName();
+}
+//-----------------------------------------------------------------------------
+
+Path::Component TreeImpl::getExtendedRootName() const
{
- return implGetOriginalName(root());
+ return doGetRootName();
}
//-----------------------------------------------------------------------------
@@ -795,19 +819,17 @@ TreeDepth TreeImpl::depthTo(NodeOffset nNode) const
}
//-----------------------------------------------------------------------------
-void TreeImpl::appendPathTo(NodeOffset nNode, Path::Components& rNames)
+void TreeImpl::prependLocalPathTo(NodeOffset nNode, Path::Rep& rNames)
{
- // nNode == 0 is handled correctly ...
- OSL_ASSERT(nNode == 0 || isValidNode(nNode));
-
- Path::Components::size_type nStart = rNames.size();
+ OSL_ASSERT(isValidNode(nNode));
- for (; nNode != 0; nNode = parent(nNode) )
+ for (; nNode != root(); nNode = parent(nNode) )
{
OSL_ENSURE( isValidNode(nNode), "ERROR: Configuration: node has invalid parent");
- rNames.push_back( getNodeName(nNode) );
+ rNames.prepend( Path::wrapSimpleName( implGetOriginalName(nNode) ) );
}
- std::reverse(rNames.begin() + nStart, rNames.end());
+
+ OSL_ASSERT(nNode == root());
}
//-----------------------------------------------------------------------------
@@ -847,7 +869,7 @@ NodeOffset TreeImpl::findChild(NodeOffset nParent, Name const& aName) const
NodeOffset const nAfterLast = nodeCount() + root();
while (++nPos < nAfterLast)
{
- if(parent(nPos) == nParent && getNodeName(nPos) == aName)
+ if(parent(nPos) == nParent && implGetOriginalName(nPos) == aName)
return nPos;
}
return 0;
@@ -961,12 +983,15 @@ ElementTreeImpl const* RootTreeImpl::doCastToElementTree() const
//-----------------------------------------------------------------------------
RootTreeImpl::RootTreeImpl( NodeFactory& rNodeFactory,
- AbsolutePath const& aContextPath,
+ AbsolutePath const& aRootPath,
ISubtree& rCacheNode, TreeDepth nDepth,
TemplateProvider const& aTemplateProvider)
: TreeImpl()
-, m_aContextPath(aContextPath)
+, m_aRootPath(aRootPath)
{
+ OSL_ENSURE( aRootPath.getLocalName().getName().toString() == rCacheNode.getName(),
+ "Constructing root node: Path does not match node name");
+
TreeImpl::build(rNodeFactory,rCacheNode,nDepth,aTemplateProvider);
}
//-----------------------------------------------------------------------------
@@ -1029,6 +1054,16 @@ void ElementTreeImpl::disposeData()
}
//-----------------------------------------------------------------------------
+Path::Component ElementTreeImpl::makeExtendedName(Name const& _aSimpleName) const
+{
+ OSL_ENSURE(this->isTemplateInstance(), "ElementTree: Cannot discover the type this instantiatiates");
+
+ Name aTypeName = this->isTemplateInstance() ? this->getTemplate()->getName() : Name();
+
+ return Path::makeCompositeName(_aSimpleName, aTypeName);
+}
+//-----------------------------------------------------------------------------
+
// ownership handling
//-----------------------------------------------------------------------------
@@ -1039,7 +1074,7 @@ void ElementTreeImpl::attachTo(ISubtree& rOwningSet, Name const& aElementName)
if (m_pOwnedNode)
{
- OSL_ENSURE(this->getRootName() == aElementName,"ElementTree: Attaching with unexpected element name");
+ OSL_ENSURE(this->getSimpleRootName() == aElementName,"ElementTree: Attaching with unexpected element name");
m_pOwnedNode->setName(aElementName.toString());
std::auto_ptr<INode> aNode(m_pOwnedNode);
@@ -1056,7 +1091,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->getRootName() == aElementName,"ElementTree: Detaching with unexpected element name");
+ OSL_ENSURE(this->getSimpleRootName() == 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");
@@ -1083,7 +1118,7 @@ void ElementTreeImpl::releaseTo(std::auto_ptr<INode>& rNewOwner)
OSL_ENSURE(m_pOwnedNode,"ERROR: Cannot release a non-owned node");
if (m_pOwnedNode)
{
- Name aNodeName = getRootName();
+ Name aNodeName = getSimpleRootName();
m_pOwnedNode->setName( aNodeName.toString() );
}
diff --git a/configmgr/source/treemgr/treeimpl.hxx b/configmgr/source/treemgr/treeimpl.hxx
index 59716e3ad591..f60bcbf0cc9c 100644
--- a/configmgr/source/treemgr/treeimpl.hxx
+++ b/configmgr/source/treemgr/treeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.hxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -244,8 +244,8 @@ namespace configmgr
virtual void disposeData();
// Context Access
- /// gets the path to the parent node of this tree
- AbsolutePath getContextPath() const;
+ /// gets the path to the root node of this tree
+ AbsolutePath getRootPath() const;
/// gets the tree of parent node of this tree
TreeImpl* getContextTree() { return m_pParentTree; }
/// gets the tree of parent node of this tree
@@ -270,15 +270,19 @@ namespace configmgr
*/
NodeOffset parent(NodeOffset nNode) const;
- /** gets the <type>Name</type> of the node <var>nNode</var>
+ /** gets the simple <type>Name</type> of the node <var>nNode</var>
<p>PRE: <code>isValidNode(nNode)</code>
</p>
*/
- Name getNodeName(NodeOffset nNode) const;
+ Name getSimpleNodeName(NodeOffset nNode) const;
- /** gets the <type>Name</type> of the root node (i.e. of the tree)
+ /** gets the simple <type>Name</type> of the root node (i.e. of the tree as a whole)
*/
- Name getRootName() const;
+ Name getSimpleRootName() const;
+
+ /** gets the full name of the root node
+ */
+ Path::Component getExtendedRootName() const;
/** gets the number of hierarchy levels from the root node to node <var>nNode</var>
in this tree
@@ -289,8 +293,8 @@ namespace configmgr
*/
TreeDepth depthTo(NodeOffset nNode) const;
- /// append the local path to a node to a collection of names
- void appendPathTo(NodeOffset nNode, Path::Components& rNames);
+ /// append the local path (relative to root) to a node to a collection of names
+ void prependLocalPathTo(NodeOffset nNode, Path::Rep& rNames);
// Change management
bool hasChanges() const;
@@ -401,6 +405,7 @@ namespace configmgr
/// set no-parent context for this tree
void clearContext();
+ Name implGetOriginalName(NodeOffset nNode) const;
private:
// ISynchronizedData
@@ -412,8 +417,10 @@ namespace configmgr
virtual RootTreeImpl const* doCastToRootTree() const = 0;
virtual ElementTreeImpl const* doCastToElementTree() const = 0;
- Name implGetOriginalName(NodeOffset nNode) const;
- virtual void doGetPathRoot(Path::Components& rPath) const = 0;
+ /// get the full name of the root of this tree
+ virtual Path::Component doGetRootName() const = 0;
+ /// prepend the absolute path to the root of this tree (no context use)
+ virtual void doFinishRootPath(Path::Rep& rPath) const = 0;
mutable OTreeAccessor m_aOwnLock;
@@ -425,7 +432,8 @@ namespace configmgr
enum { m_nRoot = 1 }; /// base of <type>NodeOffset</type>s used in this class
//NodeOffset const m_nRoot; /// base of <type>NodeOffset</type>s used in this class
- void implGetContextPath(Path::Components& rPath) const;
+ /// prepend the absolute path to the root of this tree (using context if present)
+ void implPrependRootPath(Path::Rep& rPath) const;
friend class TreeImplBuilder;
};
@@ -467,6 +475,8 @@ namespace configmgr
bool isInstanceOf(TemplateHolder const& aTemplateInfo) const { return m_aInstanceInfo == aTemplateInfo && aTemplateInfo.isValid(); }
/// retrieves the template that this is an instance of
TemplateHolder getTemplate() const { return m_aInstanceInfo; }
+ /// makes a complete name from a simple name and template information
+ Path::Component makeExtendedName(Name const& aSimpleName) const;
// node control operation
/// check if this is a free-floating tree
@@ -495,7 +505,8 @@ namespace configmgr
virtual RootTreeImpl const* doCastToRootTree() const;
virtual ElementTreeImpl const* doCastToElementTree() const;
- virtual void doGetPathRoot(Path::Components& rPath) const;
+ virtual Path::Component doGetRootName() const;
+ virtual void doFinishRootPath(Path::Rep& rPath) const;
private:
TemplateHolder const m_aInstanceInfo;
INode* m_pOwnedNode;
diff --git a/configmgr/source/treemgr/valuemembernode.cxx b/configmgr/source/treemgr/valuemembernode.cxx
index 93b064016a74..9dcfada7c2e5 100644
--- a/configmgr/source/treemgr/valuemembernode.cxx
+++ b/configmgr/source/treemgr/valuemembernode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: valuemembernode.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:40:28 $
+ * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -214,7 +214,7 @@ bool ValueMemberNode::hasChange() const
Name ValueMemberNode::getNodeName() const
{
- return Name( getOriginalNodeName(m_pOriginal), Name::NoValidate() );
+ return makeNodeName( getOriginalNodeName(m_pOriginal), Name::NoValidate() );
}
//-----------------------------------------------------------------------------