summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-09-28 11:44:40 +0000
committerJörg Barfurth <jb@openoffice.org>2001-09-28 11:44:40 +0000
commite86dc46d7563e6e6399df14f140ef05a7fc7f931 (patch)
tree10ba387cc166901e2046b8c19944929f3be3856a /configmgr
parentde633c67dd2c28af24bd1890bd7470bdbc3d1985 (diff)
#90021# Implement proper support for default-handling
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/api2/accessimpl.cxx63
-rw-r--r--configmgr/source/api2/accessimpl.hxx17
-rw-r--r--configmgr/source/api2/apinodeupdate.cxx16
-rw-r--r--configmgr/source/api2/apinodeupdate.hxx12
-rw-r--r--configmgr/source/api2/apitreeimplobj.cxx47
-rw-r--r--configmgr/source/api2/apitreeimplobj.hxx37
-rw-r--r--configmgr/source/api2/broadcaster.cxx49
-rw-r--r--configmgr/source/api2/committer.cxx5
-rw-r--r--configmgr/source/api2/elementimpl.cxx35
-rw-r--r--configmgr/source/api2/propertyinfohelper.cxx12
-rw-r--r--configmgr/source/api2/propertyinfohelper.hxx13
-rw-r--r--configmgr/source/api2/propertysetaccess.cxx44
-rw-r--r--configmgr/source/api2/propertysetaccess.hxx151
-rw-r--r--configmgr/source/api2/propsetaccessimpl.cxx369
-rw-r--r--configmgr/source/api2/propsetaccessimpl.hxx22
-rw-r--r--configmgr/source/api2/providerimpl.cxx18
-rw-r--r--configmgr/source/api2/providerimpl.hxx30
-rw-r--r--configmgr/source/api2/setupdate.cxx57
-rw-r--r--configmgr/source/api2/setupdate.hxx37
-rw-r--r--configmgr/source/api2/updateimpl.cxx61
-rw-r--r--configmgr/source/api2/updateimpl.hxx23
-rw-r--r--configmgr/source/inc/anynoderef.hxx6
-rw-r--r--configmgr/source/inc/anypair.hxx47
-rw-r--r--configmgr/source/inc/attributes.hxx29
-rw-r--r--configmgr/source/inc/change.hxx131
-rw-r--r--configmgr/source/inc/configdefaultprovider.hxx135
-rw-r--r--configmgr/source/inc/configgroup.hxx67
-rw-r--r--configmgr/source/inc/configset.hxx37
-rw-r--r--configmgr/source/inc/defaultprovider.hxx152
-rw-r--r--configmgr/source/inc/filehelper.hxx8
-rw-r--r--configmgr/source/inc/mergechange.hxx31
-rw-r--r--configmgr/source/inc/nodechange.hxx17
-rw-r--r--configmgr/source/inc/nodechangeinfo.hxx8
-rw-r--r--configmgr/source/inc/noderef.hxx26
-rw-r--r--configmgr/source/inc/treeactions.hxx6
-rw-r--r--configmgr/source/inc/treechangefactory.hxx32
-rw-r--r--configmgr/source/inc/treechangelist.hxx51
-rw-r--r--configmgr/source/inc/valuenode.hxx170
-rw-r--r--configmgr/source/misc/anypair.cxx82
-rw-r--r--configmgr/source/misc/filehelper.cxx10
-rw-r--r--configmgr/source/misc/mergechange.cxx159
-rw-r--r--configmgr/source/tree/changes.cxx56
-rw-r--r--configmgr/source/tree/cmtree.cxx157
-rw-r--r--configmgr/source/tree/cmtreemodel.cxx11
-rw-r--r--configmgr/source/tree/subtree.hxx10
-rw-r--r--configmgr/source/tree/treeactions.cxx215
-rw-r--r--configmgr/source/tree/treechangefactory.cxx49
-rw-r--r--configmgr/source/treecache/invalidatetree.cxx12
-rw-r--r--configmgr/source/treemgr/configdefaultprovider.cxx175
-rw-r--r--configmgr/source/treemgr/configgroup.cxx226
-rw-r--r--configmgr/source/treemgr/configset.cxx71
-rw-r--r--configmgr/source/treemgr/defaultproviderproxy.cxx154
-rw-r--r--configmgr/source/treemgr/defaultproviderproxy.hxx131
-rw-r--r--configmgr/source/treemgr/groupnodeimpl.hxx7
-rw-r--r--configmgr/source/treemgr/makefile.mk6
-rw-r--r--configmgr/source/treemgr/nodechange.cxx69
-rw-r--r--configmgr/source/treemgr/nodechangeimpl.cxx481
-rw-r--r--configmgr/source/treemgr/nodechangeimpl.hxx300
-rw-r--r--configmgr/source/treemgr/nodeimpl.cxx212
-rw-r--r--configmgr/source/treemgr/nodeimplobj.cxx240
-rw-r--r--configmgr/source/treemgr/nodeimplobj.hxx20
-rw-r--r--configmgr/source/treemgr/noderef.cxx155
-rw-r--r--configmgr/source/treemgr/setnodeimpl.cxx95
-rw-r--r--configmgr/source/treemgr/setnodeimpl.hxx42
-rw-r--r--configmgr/source/treemgr/valuemembernode.cxx13
65 files changed, 3714 insertions, 1515 deletions
diff --git a/configmgr/source/api2/accessimpl.cxx b/configmgr/source/api2/accessimpl.cxx
index dfc5d96814d5..71a9b4cbab5c 100644
--- a/configmgr/source/api2/accessimpl.cxx
+++ b/configmgr/source/api2/accessimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessimpl.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: dg $ $Date: 2001-09-18 19:27:13 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -93,6 +93,12 @@
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
#include <com/sun/star/lang/DisposedException.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HPP_
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVETOEXCEPTION_HPP_
+#include <com/sun/star/beans/PropertyVetoException.hpp>
+#endif
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
@@ -549,7 +555,7 @@ beans::Property implGetAsProperty(NodeAccess& rNode)
Attributes aAttributes = aTree.getAttributes(aNode);
uno::Type aApiType = getUnoInterfaceType();
- return helperMakeProperty( aName,aAttributes,aApiType );
+ return helperMakeProperty( aName,aAttributes,aApiType, aTree.hasNodeDefault(aNode) );
}
catch (configuration::Exception& ex)
{
@@ -763,6 +769,57 @@ Any implGetByHierarchicalName(NodeAccess& rNode, const OUString& sHierarchicalNa
return Any();
}
+// XPropertyWithState
+//---------------------------------------------------------------------
+css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode)
+ throw (uno::RuntimeException)
+{
+ using namespace css::beans;
+
+ PropertyState aRet = PropertyState_AMBIGUOUS_VALUE;
+ try
+ {
+ GuardedNodeDataAccess impl( rNode );
+
+ if ( rNode.getTree().isNodeDefault( rNode.getNode() ) )
+ aRet = PropertyState_DEFAULT_VALUE;
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+ return aRet;
+}
+
+void implSetToDefaultAsProperty(NodeAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ GuardedNodeAccess impl( rNode );
+
+ OUString const sMessage( RTL_CONSTASCII_USTRINGPARAM("Cannot set Property object to default: Object or View is read-only"));
+ beans::PropertyVetoException aVeto(sMessage, rNode.getUnoInstance());
+
+ OUString const sWrapMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Operation failed: "));
+ throw lang::WrappedTargetException(sWrapMessage + sMessage, rNode.getUnoInstance(), uno::makeAny(aVeto));
+}
+
+Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ // not really supported
+
+ /* possible, but nor really useful:
+ GuardedNodeAccess impl( rNode );
+ if (implGetStateAsProperty(rNode) == PropertyState_DEFAULT_VALUE)
+ return rNode.getUnoInstance();
+ */
+
+ return Reference< uno::XInterface >();
+}
+
+
// set-specific Interfaces
//-----------------------------------------------------------------------------------
diff --git a/configmgr/source/api2/accessimpl.hxx b/configmgr/source/api2/accessimpl.hxx
index 9b87dc8ee7cd..f1fcd674f037 100644
--- a/configmgr/source/api2/accessimpl.hxx
+++ b/configmgr/source/api2/accessimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: accessimpl.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,6 +87,9 @@
#ifndef _COM_SUN_STAR_BEANS_XPROPERTY_HPP_
#include <com/sun/star/beans/XProperty.hpp>
#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYWITHSTATE_HPP_
+#include <com/sun/star/beans/XPropertyWithState.hpp>
+#endif
#ifndef _COM_SUN_STAR_UTIL_XSTRINGESCAPE_HPP_
#include <com/sun/star/util/XStringEscape.hpp>
#endif
@@ -157,6 +160,16 @@ namespace configmgr
css::beans::Property implGetAsProperty(NodeAccess& rNode)
throw(uno::RuntimeException);
+ // XPropertyWithState
+ css::beans::PropertyState implGetStateAsProperty(NodeAccess& rNode)
+ throw (uno::RuntimeException);
+
+ void implSetToDefaultAsProperty(NodeAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
+ uno::Reference< uno::XInterface > implGetDefaultAsProperty(NodeAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
// set-specific interfaces
// XTemplateContainer
diff --git a/configmgr/source/api2/apinodeupdate.cxx b/configmgr/source/api2/apinodeupdate.cxx
index ce4a25f8233d..1500a277be67 100644
--- a/configmgr/source/api2/apinodeupdate.cxx
+++ b/configmgr/source/api2/apinodeupdate.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apinodeupdate.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-04-19 15:21:10 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,6 +82,12 @@ configuration::GroupUpdater NodeGroupAccess::getNodeUpdater()
}
//-----------------------------------------------------------------------------
+configuration::GroupDefaulter NodeGroupAccess::getNodeDefaulter()
+{
+ return configuration::GroupDefaulter(getTree(),getNode(), getApiTree().getDefaultProvider());
+}
+//-----------------------------------------------------------------------------
+
ISynchronizedData* NodeGroupAccess::getDataLock()
{
return getApiTree().getDataLock();
@@ -102,6 +108,12 @@ configuration::SetElementFactory NodeTreeSetAccess::getElementFactory()
}
//-----------------------------------------------------------------------------
+configuration::SetDefaulter NodeSetAccess::getNodeDefaulter()
+{
+ return configuration::SetDefaulter(getTree(),getNode(), getApiTree().getDefaultProvider());
+}
+//-----------------------------------------------------------------------------
+
configuration::TreeSetUpdater NodeTreeSetAccess::getNodeUpdater()
{
return configuration::TreeSetUpdater(getTree(),getNode(),getElementInfo());
diff --git a/configmgr/source/api2/apinodeupdate.hxx b/configmgr/source/api2/apinodeupdate.hxx
index a77d763e4111..27900da23957 100644
--- a/configmgr/source/api2/apinodeupdate.hxx
+++ b/configmgr/source/api2/apinodeupdate.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apinodeupdate.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2000-11-10 12:22:55 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,8 +70,10 @@ namespace configmgr
namespace configuration
{
class GroupUpdater;
+ class GroupDefaulter;
class TreeSetUpdater;
class ValueSetUpdater;
+ class SetDefaulter;
class SetElementFactory;
class ElementTree;
@@ -91,8 +93,8 @@ namespace configmgr
class NodeGroupAccess : public NodeGroupInfoAccess
{
public:
- // currently only used for tagging group nodes with update capability
- configuration::GroupUpdater getNodeUpdater();
+ configuration::GroupUpdater getNodeUpdater();
+ configuration::GroupDefaulter getNodeDefaulter();
ISynchronizedData* getDataLock();
};
@@ -101,6 +103,8 @@ namespace configmgr
class NodeSetAccess : public NodeSetInfoAccess
{
public:
+ configuration::SetDefaulter getNodeDefaulter();
+
ISynchronizedData* getDataLock();
};
diff --git a/configmgr/source/api2/apitreeimplobj.cxx b/configmgr/source/api2/apitreeimplobj.cxx
index a70895019642..7bdf167a32d1 100644
--- a/configmgr/source/api2/apitreeimplobj.cxx
+++ b/configmgr/source/api2/apitreeimplobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apitreeimplobj.cxx,v $
*
- * $Revision: 1.29 $
+ * $Revision: 1.30 $
*
- * last change: $Author: jb $ $Date: 2001-07-11 14:25:11 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -380,10 +380,35 @@ ISynchronizedData* ApiProvider::getSourceLock() const
return &m_rProviderImpl;
}
//-------------------------------------------------------------------------
+static
+inline
+configuration::DefaultProvider createDefaultProvider(
+ ApiProvider& rProvider,
+ configuration::Tree const& aTree,
+ vos::ORef< OOptions >const& _xOptions
+ )
+{
+ OProviderImpl& rProviderImpl = rProvider.getProviderImpl();
+ IDefaultProvider& rDefaultProvider = rProviderImpl.getDefaultProvider();
+
+ return configuration::DefaultProvider::create(aTree,_xOptions,&rDefaultProvider,&rProviderImpl);
+}
+//-------------------------------------------------------------------------
+static
+inline
+configuration::DefaultProvider extractDefaultProvider(ApiTreeImpl* pParentTree)
+{
+ if (pParentTree)
+ return pParentTree->getDefaultProvider();
+ else
+ return configuration::DefaultProvider::createEmpty();
+}
+//-------------------------------------------------------------------------
ApiTreeImpl::ApiTreeImpl(UnoInterface* pInstance, Tree const& aTree, ApiTreeImpl& rParentTree)
: m_pInstance(pInstance)
, m_aTree(aTree)
+, m_aDefaultProvider(rParentTree.getDefaultProvider())
, m_rProvider(rParentTree.getProvider())
, m_pParentTree(0)
, m_aNotifier(new NotifierImpl(aTree))
@@ -395,15 +420,28 @@ ApiTreeImpl::ApiTreeImpl(UnoInterface* pInstance, Tree const& aTree, ApiTreeImpl
ApiTreeImpl::ApiTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, Tree const& aTree, ApiTreeImpl* pParentTree)
: m_pInstance(pInstance)
, m_aTree(aTree)
+, m_aDefaultProvider(extractDefaultProvider(pParentTree))
, m_rProvider(rProvider)
, m_pParentTree(0)
, m_aNotifier(new NotifierImpl(aTree))
{
- OSL_ENSURE(!pParentTree || &rProvider == &pParentTree->m_rProvider,"WARNING: Parent tree has a different provider - trouble may be ahead");
+ OSL_ENSURE(pParentTree == NULL || &rProvider == &pParentTree->m_rProvider,"WARNING: Parent tree has a different provider - trouble may be ahead");
setNodeInstance(aTree.getRootNode(), pInstance);
init(pParentTree);
}
//-------------------------------------------------------------------------
+ApiTreeImpl::ApiTreeImpl(UnoInterface* _pInstance, ApiProvider& _rProvider, Tree const& _aTree, DefaultProvider const& _aDefaultProvider)
+: m_pInstance(_pInstance)
+, m_aTree(_aTree)
+, m_aDefaultProvider(_aDefaultProvider)
+, m_rProvider(_rProvider)
+, m_pParentTree(0)
+, m_aNotifier(new NotifierImpl(_aTree))
+{
+ setNodeInstance(_aTree.getRootNode(), _pInstance);
+ init(NULL);
+}
+//-------------------------------------------------------------------------
ApiTreeImpl::~ApiTreeImpl()
{
@@ -411,8 +449,9 @@ ApiTreeImpl::~ApiTreeImpl()
deinit();
}
//-------------------------------------------------------------------------
+
ApiRootTreeImpl::ApiRootTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, Tree const& aTree, vos::ORef< OOptions >const& _xOptions)
-: m_aTreeImpl(pInstance, rProvider, aTree, 0)
+: m_aTreeImpl(pInstance, rProvider, aTree, createDefaultProvider(rProvider, aTree, _xOptions))
, m_pNotificationListener(NULL)
, m_xOptions(_xOptions)
, m_aLocationPath( configuration::Path::Rep() )
diff --git a/configmgr/source/api2/apitreeimplobj.hxx b/configmgr/source/api2/apitreeimplobj.hxx
index 79d626758f39..f9c4c1958377 100644
--- a/configmgr/source/api2/apitreeimplobj.hxx
+++ b/configmgr/source/api2/apitreeimplobj.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: apitreeimplobj.hxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: rt $ $Date: 2001-07-16 08:15:45 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,17 +62,37 @@
#ifndef CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
#define CONFIGMGR_API_TREEIMPLOBJECTS_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGSET_HXX_
#include "configset.hxx"
-
+#endif
+#ifndef CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
+#include "configdefaultprovider.hxx"
+#endif
+#ifndef CONFIGMGR_API_EVENTS_HXX_
#include "confevents.hxx"
+#endif
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
#include "options.hxx"
+#endif
-#include <osl/mutex.hxx>
+#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
+#endif
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+
+#ifndef INCLUDED_MEMORY
#include <memory>
+#define INCLUDED_MEMORY
+#endif
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -138,9 +158,11 @@ namespace configmgr
typedef uno::Reference<com::sun::star::lang::XComponent> UnoComponent;
typedef configuration::Tree Tree;
+ typedef configuration::DefaultProvider DefaultProvider;
Tree m_aTree;
NotifierImplHolder m_aNotifier;
+ DefaultProvider m_aDefaultProvider;
ComponentRef m_xProvider;
ApiProvider& m_rProvider;
ApiTreeImpl* m_pParentTree;
@@ -148,7 +170,8 @@ namespace configmgr
public:
explicit ApiTreeImpl(UnoInterface* pInstance, Tree const& aTree, ApiTreeImpl& rParentTree);
- explicit ApiTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, Tree const& aTree, ApiTreeImpl* pParentTree = 0);
+ explicit ApiTreeImpl(UnoInterface* pInstance, ApiProvider& rProvider, Tree const& aTree, ApiTreeImpl* pParentTree);
+ explicit ApiTreeImpl(UnoInterface* _pInstance, ApiProvider& _rProvider, Tree const& _aTree, DefaultProvider const & _aDefaultProvider);
~ApiTreeImpl();
// initialization
@@ -167,6 +190,7 @@ namespace configmgr
// api object handling
Factory& getFactory() const { return m_rProvider.getFactory(); }
Notifier getNotifier() const;
+ DefaultProvider getDefaultProvider() const { return m_aDefaultProvider; }
// needs external locking
ApiTreeImpl const* getRootTreeImpl() const;
@@ -202,6 +226,7 @@ namespace configmgr
{
typedef configuration::Tree Tree;
typedef configuration::AbsolutePath AbsolutePath;
+ typedef configuration::DefaultProvider DefaultProvider;
vos::ORef< OOptions > m_xOptions;
public:
@@ -217,7 +242,7 @@ namespace configmgr
bool disposeTree();
/// toggle whether this object relays notifications from the base provider
- bool enableNotification(bool bEnable);
+ bool enableNotification(bool bEnable);
private:
IConfigBroadcaster* implSetNotificationSource(IConfigBroadcaster* pNew);
void implSetLocation();
diff --git a/configmgr/source/api2/broadcaster.cxx b/configmgr/source/api2/broadcaster.cxx
index 54da080aa145..0b99e71b770f 100644
--- a/configmgr/source/api2/broadcaster.cxx
+++ b/configmgr/source/api2/broadcaster.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: broadcaster.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-09-13 09:14:56 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -488,6 +488,7 @@ namespace configmgr
break;
+ case NodeChangeData::eResetSetDefault:
case NodeChangeData::eRenameElementTree:
case NodeChangeData::eNoChange:
OSL_ASSERT(false);
@@ -966,7 +967,7 @@ namespace configmgr
NotifierData aRootData(rNotifierImpl, pTreeImpl);
NodeChangesInformation aChangeInfos;
- if (aChanges.getChangesInfo(aChangeInfos))
+ if (aChanges.getChangesInfos(aChangeInfos))
{
return create(rNotifierImpl,pTreeImpl,aChangeInfos,bLocal);
}
@@ -1052,42 +1053,44 @@ namespace configmgr
}
// ---------------------------------------------------------------------------------------------------
- bool Broadcaster::Impl::translateChanges(NodeChangesInformation& aInfos, NodeChanges const& aChanges, bool bSingleBase) const
+ bool Broadcaster::Impl::translateChanges(NodeChangesInformation& _rInfos, NodeChanges const& aChanges, bool bSingleBase) const
{
- NodeChangesInformation aNewInfos;
- aNewInfos.reserve( aChanges.getCount() );
-
Tree aBaseTree = m_aNotifierData.second->getTree();
Factory& rFactory = m_aNotifierData.second->getFactory();
- for (NodeChanges::Iterator it = aChanges.begin(); it != aChanges.end(); ++it)
+ NodeChangesInformation aRawInfos;
+
+ sal_uInt32 nChanges = aChanges.getChangesInfos(aRawInfos);
+
+ OSL_ENSURE(nChanges, "Cannot get info(s) for change - skipping for notification");
+ OSL_ENSURE(nChanges == aRawInfos.size(), "Incorrect change count returned");
+
+ NodeChangesInformation aNewInfos;
+ aNewInfos.reserve(nChanges);
+
+ // enabling the Single base optimization requires a base node (not only a base tree) for correct accessors
+ //if (!bSingleBase || !configuration::equalTree(aBaseTree,aNewChange.info.baseTree))
+
+ for (NodeChangesInformation::Iterator pos = aRawInfos.begin(); pos != aRawInfos.end(); ++pos)
{
- NodeChangeInformation aInfo;
- if (!it->getChangeInfo(aInfo))
- {
- OSL_TRACE("Cannot get info for change - skipping for notification");
- continue;
- }
+ NodeChangeInformation aInfo = *pos;
- // enabling the Single base optimization requires a base node (not only a base tree) for correct accessors
- //if (!bSingleBase || !configuration::equalTree(aBaseTree,aNewChange.info.baseTree))
if( !configapi::rebaseChange(aInfo.location,aBaseTree) )
{
OSL_TRACE("Change is not within expected tree - skipping for notification");
continue;
}
- if( !configapi::resolveToUno(aInfo.change,rFactory) )
- {
- // it actually is expected that elements may not be found
- // OSL_TRACE("Cannot find affected elements of Change");
- }
+ OSL_ENSURE(!pos->isEmptyChange(), "Empty Change Found for Notification");
+ // it actually is expected that elements may not be found - thus ignoring result
+ configapi::resolveToUno(aInfo.change,rFactory);
aNewInfos.push_back( aInfo );
}
- aNewInfos.swap(aInfos);
- return !aInfos.empty();
+ aNewInfos.swap(_rInfos);
+
+ return !_rInfos.empty();
}
// ---------------------------------------------------------------------------------------------------
diff --git a/configmgr/source/api2/committer.cxx b/configmgr/source/api2/committer.cxx
index 25e3535dec83..a656a707755e 100644
--- a/configmgr/source/api2/committer.cxx
+++ b/configmgr/source/api2/committer.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: committer.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -124,7 +124,6 @@ void Committer::commit()
OSL_ENSURE(m_rTree.getOptions().isValid(),"INTERNAL ERROR: Invalid Options used.");
TreeChangeList aChangeList(m_rTree.getOptions(),
aTree.getRootPath(),
- Chg(),
aTree.getAttributes(aTree.getRootNode()));
ITreeManager* pUpdateProvider = getUpdateProvider();
diff --git a/configmgr/source/api2/elementimpl.cxx b/configmgr/source/api2/elementimpl.cxx
index 3d346e63db89..5ec42c887c67 100644
--- a/configmgr/source/api2/elementimpl.cxx
+++ b/configmgr/source/api2/elementimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: elementimpl.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -581,6 +581,7 @@ uno::Sequence< css::util::ElementChange > implGetPendingChanges( TreeElement& rE
throw(uno::RuntimeException)
{
using css::util::ElementChange;
+ using configuration::NodeChangesInformation;
std::vector<ElementChange> aResult;
try
@@ -589,24 +590,26 @@ uno::Sequence< css::util::ElementChange > implGetPendingChanges( TreeElement& rE
Tree aTree( aLocked->getTree() );
- NodeChanges aChanges;
- if (aLocked->getTree().collectChanges(aChanges))
- {
- Factory& rFactory = aLocked->getFactory();
+ NodeChangesInformation aInfos;
- for(NodeChanges::Iterator it = aChanges.begin(), stop = aChanges.end();
- it != stop;
- ++it)
+ {
+ NodeChanges aChanges;
+ if (aLocked->getTree().collectChanges(aChanges))
{
- configuration::NodeChangeInformation aInfo;
- if (it->getChangeInfo(aInfo))
- {
- ElementChange aChange;
- fillChange(aChange,aInfo,aTree,rFactory);
- aResult.push_back(aChange);
- }
+ aChanges.getChangesInfos(aInfos);
}
}
+
+ Factory& rFactory = aLocked->getFactory();
+
+ for(NodeChangesInformation::Iterator it = aInfos.begin(), stop = aInfos.end();
+ it != stop;
+ ++it)
+ {
+ ElementChange aChange;
+ fillChange(aChange,*it,aTree,rFactory);
+ aResult.push_back(aChange);
+ }
}
catch (configuration::Exception& ex)
{
diff --git a/configmgr/source/api2/propertyinfohelper.cxx b/configmgr/source/api2/propertyinfohelper.cxx
index 382b1c6fe5fd..6f06c1cabf70 100644
--- a/configmgr/source/api2/propertyinfohelper.cxx
+++ b/configmgr/source/api2/propertyinfohelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertyinfohelper.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -77,7 +77,10 @@ namespace configmgr
namespace configapi
{
//-----------------------------------------------------------------------------
-beans::Property helperMakeProperty( configuration::Name const& aName, configuration::Attributes const aAttributes, uno::Type const& aType )
+beans::Property helperMakeProperty(configuration::Name const& aName,
+ configuration::Attributes const aAttributes,
+ uno::Type const& aType,
+ bool bDefaultable )
throw(uno::RuntimeException)
{
namespace PropertyAttribute = com::sun::star::beans::PropertyAttribute;
@@ -87,7 +90,8 @@ beans::Property helperMakeProperty( configuration::Name const& aName, configurat
if ( aAttributes.bNullable) nPropAttributes |= PropertyAttribute::MAYBEVOID;
if ( aAttributes.bNotified) nPropAttributes |= PropertyAttribute::BOUND;
if ( aAttributes.bConstrained) nPropAttributes |= PropertyAttribute::CONSTRAINED;
- if ( aAttributes.bDefaultable) nPropAttributes |= PropertyAttribute::MAYBEDEFAULT;
+
+ if ( bDefaultable) nPropAttributes |= PropertyAttribute::MAYBEDEFAULT;
return beans::Property(aName.toString(), -1, aType, nPropAttributes);
}
diff --git a/configmgr/source/api2/propertyinfohelper.hxx b/configmgr/source/api2/propertyinfohelper.hxx
index 017385596382..da81eeb1f16a 100644
--- a/configmgr/source/api2/propertyinfohelper.hxx
+++ b/configmgr/source/api2/propertyinfohelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertyinfohelper.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,16 +80,13 @@ namespace configmgr
within the configuration tree.
(read-only operation)
*/
- namespace configuration
- {
- class Name;
- struct Attributes;
- }
+ namespace node { struct Attributes; }
+ namespace configuration { class Name; }
namespace configapi
{
// translation helper
- beans::Property helperMakeProperty( configuration::Name const& aName, configuration::Attributes const aAttributes, uno::Type const& aType )
+ beans::Property helperMakeProperty( configuration::Name const& aName, node::Attributes const aAttributes, uno::Type const& aType, bool bDefaultable )
throw(uno::RuntimeException);
}
diff --git a/configmgr/source/api2/propertysetaccess.cxx b/configmgr/source/api2/propertysetaccess.cxx
index 66f8cbf2b923..56b1a925c6fc 100644
--- a/configmgr/source/api2/propertysetaccess.cxx
+++ b/configmgr/source/api2/propertysetaccess.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertysetaccess.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-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -246,26 +246,52 @@ void SAL_CALL BasicPropertySet::firePropertiesChangeEvent( const uno::Sequence<
}
//////////////////////////////////////////////////////////////////////////////////
-// XPropertyState
+// XPropertyState / XMultiPropertyStates
//////////////////////////////////////////////////////////////////////////////////
-#ifndef CONFIGMGR_NO_PROPERTYSTATE
+
+// getting property states
+//////////////////////////////////////////////////////////////////////////////////
+
beans::PropertyState SAL_CALL BasicPropertySet::getPropertyState( const OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
return implGetPropertyState( getNode(), sPropertyName);
}
+//---------------------------------------------------------------------------------
uno::Sequence< beans::PropertyState > SAL_CALL BasicPropertySet::getPropertyStates( const uno::Sequence< OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
return implGetPropertyStates( getNode(), aPropertyNames );
}
+//---------------------------------------------------------------------------------
+
+// setting to default state
+//////////////////////////////////////////////////////////////////////////////////
void SAL_CALL BasicPropertySet::setPropertyToDefault( const OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException)
{
implSetPropertyToDefault( getGroupNode(), sPropertyName);
}
+//---------------------------------------------------------------------------------
+
+void SAL_CALL BasicPropertySet::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
+ throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ implSetPropertiesToDefault( getGroupNode(), aPropertyNames);
+}
+//---------------------------------------------------------------------------------
+
+void SAL_CALL BasicPropertySet::setAllPropertiesToDefault( )
+ throw (uno::RuntimeException)
+{
+ implSetAllPropertiesToDefault( getGroupNode() );
+}
+//---------------------------------------------------------------------------------
+
+// getting defaults
+//////////////////////////////////////////////////////////////////////////////////
uno::Any SAL_CALL BasicPropertySet::getPropertyDefault( const OUString& sPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
@@ -273,7 +299,15 @@ uno::Any SAL_CALL BasicPropertySet::getPropertyDefault( const OUString& sPropert
{
return implGetPropertyDefault( getNode(), sPropertyName);
}
-#endif
+//---------------------------------------------------------------------------------
+
+uno::Sequence< uno::Any > SAL_CALL BasicPropertySet::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ return implGetPropertyDefaults( getNode(), aPropertyNames);
+}
+//---------------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------------
} // namespace configmgr
diff --git a/configmgr/source/api2/propertysetaccess.hxx b/configmgr/source/api2/propertysetaccess.hxx
index 97630655b139..1ee16a54b9e8 100644
--- a/configmgr/source/api2/propertysetaccess.hxx
+++ b/configmgr/source/api2/propertysetaccess.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propertysetaccess.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,20 +75,15 @@
#include <com/sun/star/beans/XMultiHierarchicalPropertySet.hpp>
#endif
-#ifndef CONFIGMGR_NO_PROPERTYSTATE
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTY_HPP_
-#include <com/sun/star/beans/XProperty.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYWITHSTATE_HPP_
-#include <com/sun/star/beans/XPropertyWithState.hpp>
-#endif
+#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSTATES_HPP_
+#include <com/sun/star/beans/XMultiPropertyStates.hpp>
#endif
-#ifndef _CPPUHELPER_IMPLBASE4_HXX_
-#include <cppuhelper/implbase4.hxx>
+#ifndef _CPPUHELPER_IMPLBASE6_HXX_
+#include <cppuhelper/implbase6.hxx>
#endif
#ifndef CONFIGMGR_APITYPES_HXX_
@@ -116,12 +111,13 @@ namespace configmgr
<p> Is an interface adapter around <type scope='configmgr::configapi'>NodeGroup(Info)Access</type>.</p>
*/
class BasicPropertySet
-: public ::cppu::ImplHelper4
+: public ::cppu::ImplHelper6
< beans::XPropertySet
, beans::XMultiPropertySet
, beans::XHierarchicalPropertySet
, beans::XMultiHierarchicalPropertySet
-// , beans::XPropertyState
+ , beans::XPropertyState
+ , beans::XMultiPropertyStates
>
{
protected:
@@ -224,15 +220,15 @@ public:
firePropertiesChangeEvent( const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
-#ifndef CONFIGMGR_NO_PROPERTYSTATE
// XPropertyState
virtual beans::PropertyState SAL_CALL
getPropertyState( const OUString& PropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
- virtual uno::Sequence< beans::PropertyState > SAL_CALL
- getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
- throw(beans::UnknownPropertyException, uno::RuntimeException);
+ // see below:
+ // virtual uno::Sequence< beans::PropertyState > SAL_CALL
+ // getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
+ // throw(beans::UnknownPropertyException, uno::RuntimeException);
virtual void SAL_CALL
setPropertyToDefault( const OUString& PropertyName )
@@ -242,124 +238,29 @@ public:
getPropertyDefault( const OUString& aPropertyName )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
-#endif
-
-protected:
- virtual configapi::NodeGroupInfoAccess& getNode() = 0;
- configapi::NodeGroupAccess& getGroupNode();
- virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0;
-};
-
-//--------------------------------------------------------------------------
-
-/** implements the interface supported by a node, that is not a group,
- and can't be viewed as property set but which does support children with a default state
- <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeSet(Info)Access</type>.</p>
-*/
-/*
-class BasicPropertyState
-: public ::cppu::ImplHelper1 < beans::XPropertyState >
-{
-public:
-// Constructors & Destructors
- ~BasicPropertyState() {}
-
-public:
- virtual beans::PropertyState SAL_CALL
- getPropertyState( const OUString& PropertyName )
- throw(beans::UnknownPropertyException, uno::RuntimeException);
-
+// XMultiPropertyStates
virtual uno::Sequence< beans::PropertyState > SAL_CALL
getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
- throw(beans::UnknownPropertyException, uno::RuntimeException);
+ throw (beans::UnknownPropertyException, uno::RuntimeException);
virtual void SAL_CALL
- setPropertyToDefault( const OUString& PropertyName )
- throw(beans::UnknownPropertyException, uno::RuntimeException);
-
- virtual uno::Any SAL_CALL
- getPropertyDefault( const OUString& aPropertyName )
- throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
+ setAllPropertiesToDefault( )
+ throw (uno::RuntimeException);
-protected:
- virtual configapi::NodeSetInfoAccess& getNode() = 0;
- configapi::NodeSetAccess& getSetNode();
- virtual configapi::NodeSetAccess* maybeGetUpdateAccess() = 0;
-};
-*/
-/** implements the interface supported by a node, that is contained in a group,
- viewed as property set but which does not support a default state
- <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p>
-*/
-/*
-class BasicPropertySetElement
-: public ::cppu::ImplHelper1 < beans::XProperty >
-{
-public:
-// Constructors & Destructors
- ~BasicPropertySetElement() {}
-
-public:
-// XProperty
- virtual beans::Property SAL_CALL
- getAsProperty( )
- throw(::com::sun::star::uno::RuntimeException);
-
-protected:
- virtual configapi::NodeSetInfoAccess& getNode() = 0;
- configapi::NodeSetAccess& getSetNode();
- virtual configapi::NodeSetAccess* maybeGetUpdateAccess() = 0;
-};
-*/
-/** implements the interface supported by a node, that supports a default state
- <p> Is an interface adapter around <type scope='configmgr::configapi'>NodeAccess</type>.</p>
-*/
-/*class BasicElementWithState
-: public ::cppu::ImplHelper2
- < beans::XProperty
- , beans::XPropertyWithState
- >
-{
-public:
-// Constructors & Destructors
- ~BasicElementWithState() {}
+ virtual void SAL_CALL
+ setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
+ throw (beans::UnknownPropertyException, uno::RuntimeException);
-public:
-// XProperty
- virtual beans::Property SAL_CALL
- getAsProperty( )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual uno::Sequence< uno::Any > SAL_CALL
+ getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
protected:
+ virtual configapi::NodeGroupInfoAccess& getNode() = 0;
+ configapi::NodeGroupAccess& getGroupNode();
+ virtual configapi::NodeGroupAccess* maybeGetUpdateAccess() = 0;
};
-*/
-//--------------------------------------------------------------------------
-/*class BasicPropertySetInfo
-: public cppu::WeakImplHelper1< beans::XPropertySetInfo >
-{
- // class Impl;
- typedef configapi::NodeSetInfoImpl Impl;
- Impl* const m_pImpl;
-public:
-// Constructors & Destructors
- NodePropertySetInfo( Impl* pImpl);
- ~NodePropertySetInfo() {}
-public:
-// XPropertySetInfo
- virtual uno::Sequence< beans::Property > SAL_CALL
- getProperties(void)
- throw(uno::RuntimeException);
-
- virtual beans::Property SAL_CALL
- getPropertyByName(const OUString& sPropertyName)
- throw(beans::UnknownPropertyException, uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- hasPropertyByName(const OUString& sPropertyName)
- throw(uno::RuntimeException);
-};
-*/
//--------------------------------------------------------------------------
}
diff --git a/configmgr/source/api2/propsetaccessimpl.cxx b/configmgr/source/api2/propsetaccessimpl.cxx
index cea23a10a1d5..f66475ad7a04 100644
--- a/configmgr/source/api2/propsetaccessimpl.cxx
+++ b/configmgr/source/api2/propsetaccessimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propsetaccessimpl.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,10 +59,11 @@
*
************************************************************************/
-#ifndef CONFIGMGR_API_PROPERTYSETIMPL_HXX_
#include "propsetaccessimpl.hxx"
-#endif
+#ifndef CONFIGMGR_API_PROPERTYINFOIMPL_HXX_
+#include "propertyinfohelper.hxx"
+#endif
#ifndef CONFIGMGR_API_NODEACCESS_HXX_
#include "apinodeaccess.hxx"
#endif
@@ -184,40 +185,34 @@ public:
}
private:
- typedef sal_Int16 PropAttributes;
+ typedef configuration::Attributes NodeAttributes;
void reset() { m_aProperties.clear(); }
- void setAttributes(PropAttributes& _rPropAttr, configuration::Attributes nNodeAttr);
+
+ NodeAttributes adjustAttributes(NodeAttributes nNodeAttr);
+
Result handle(Tree const& _aTree, NodeRef const& _rValue);
Result handle(Tree const& _aTree, ValueRef const& _rValue);
};
//-----------------------------------------------------------------------------------
-void CollectProperties::setAttributes(PropAttributes& _rPropAttr, configuration::Attributes nNodeAttr)
+CollectProperties::NodeAttributes CollectProperties::adjustAttributes(NodeAttributes nNodeAttr)
{
- if (!nNodeAttr.bWritable) _rPropAttr |= PropertyAttribute::READONLY;
- if (nNodeAttr.bNullable) _rPropAttr |= PropertyAttribute::MAYBEVOID;
- if (nNodeAttr.bNotified) _rPropAttr |= PropertyAttribute::BOUND;
- if (nNodeAttr.bConstrained) _rPropAttr |= PropertyAttribute::CONSTRAINED;
- if (nNodeAttr.bDefaultable) _rPropAttr |= PropertyAttribute::MAYBEDEFAULT;
-
- if (!m_bReadonly)
- _rPropAttr |= PropertyAttribute::READONLY;
+ if (m_bReadonly) nNodeAttr.bWritable = false;
+
+ return nNodeAttr;
}
//-----------------------------------------------------------------------------------
CollectProperties::Result CollectProperties::handle(Tree const& _aTree, ValueRef const& _rValue)
{
// can be default ?
- PropAttributes nAttributes = 0;
- setAttributes(nAttributes, _aTree.getAttributes(_rValue));
-
m_aProperties.push_back(
- Property( _aTree.getName(_rValue).toString(),
- sal_Int32(-1),
- _aTree.getUnoType(_rValue),
- nAttributes
- )
+ helperMakeProperty( _aTree.getName(_rValue),
+ adjustAttributes(_aTree.getAttributes(_rValue)),
+ _aTree.getUnoType(_rValue),
+ _aTree.hasNodeDefault(_rValue)
+ )
);
return CONTINUE;
@@ -227,18 +222,15 @@ CollectProperties::Result CollectProperties::handle(Tree const& _aTree, ValueRef
CollectProperties::Result CollectProperties::handle(Tree const& _aTree, NodeRef const& _rNode)
{
// can be default ?
- PropAttributes nAttributes = 0;
- setAttributes(nAttributes, _aTree.getAttributes(_rNode));
-
OSL_ENSURE( configuration::isStructuralNode(_aTree,_rNode),
"Unexpected value element node. Cannot get proper type for this node as property" );
m_aProperties.push_back(
- Property( _aTree.getName(_rNode).toString(),
- sal_Int32(-1),
- getUnoInterfaceType(),
- nAttributes
- )
+ helperMakeProperty( _aTree.getName(_rNode),
+ adjustAttributes(_aTree.getAttributes(_rNode)),
+ getUnoInterfaceType(),
+ _aTree.hasNodeDefault(_rNode)
+ )
);
return CONTINUE;
@@ -635,18 +627,14 @@ void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& a
RelativePath const aRelPath = validateRelativePath( aPropertyName, aTree, aNode );
- Tree aNestedTree( aTree );
- NodeRef aNestedNode( aNode );
- RelativePath aResolvePath( aRelPath );
-
- AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aResolvePath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aTree, aNode, aRelPath );
if (!aNestedValue.isValid())
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot set Property Value. Property '") );
- sMessage += aResolvePath.toString();
+ sMessage += aRelPath.toString();
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' was not found in ") );
- sMessage += aNestedTree.getAbsolutePath(aNestedNode).toString();
+ sMessage += aTree.getAbsolutePath(aNode).toString();
Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
throw UnknownPropertyException( sMessage, xContext );
@@ -662,7 +650,7 @@ void implSetHierarchicalPropertyValue( NodeGroupAccess& rNode, const OUString& a
}
OSL_ASSERT(aNode.isValid());
- NodeChange aChange = impl->getNodeUpdater().validateSetDeepValue( aNestedTree, aNestedValue.toValue(), aRelPath, aValue );
+ NodeChange aChange = impl->getNodeUpdater().validateSetValue( aNestedValue.toValue(), aValue );
if (aChange.test().isChange())
{
Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChange,false));
@@ -731,11 +719,7 @@ void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const Sequence<
{
RelativePath aRelPath = validateRelativePath( aPropertyNames[i], aTree, aNode );
- Tree aNestedTree( aTree );
- NodeRef aNestedNode( aNode );
- RelativePath aResolvePath( aRelPath );
-
- AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aResolvePath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aTree, aNode, aRelPath );
if (!aNestedValue.isValid())
{
@@ -754,7 +738,7 @@ void implSetHierarchicalPropertyValues( NodeGroupAccess& rNode, const Sequence<
}
OSL_ASSERT(aNode.isValid());
- NodeChange aChange = impl->getNodeUpdater().validateSetDeepValue( aNestedTree, aNestedValue.toValue(), aRelPath, aValues[i] );
+ NodeChange aChange = impl->getNodeUpdater().validateSetValue( aNestedValue.toValue(), aValues[i] );
if (aChange.maybeChange())
{
aChanges.add(aChange);
@@ -917,8 +901,8 @@ Any implGetHierarchicalPropertyValue( NodeGroupInfoAccess& rNode, const OUString
{
GuardedNodeDataAccess impl( rNode );
- Tree aTree( impl->getTree() );
- NodeRef aNode( impl->getNode() );
+ Tree const aTree( impl->getTree() );
+ NodeRef const aNode( impl->getNode() );
RelativePath aRelPath = validateRelativePath( aPropertyName, aTree, aNode );
@@ -979,14 +963,11 @@ Sequence< Any > implGetHierarchicalPropertyValues( NodeGroupInfoAccess& rNode, c
{
RelativePath aRelPath = validateRelativePath( aPropertyNames[i], aTree, aNode );
- Tree aNestedTree( aTree );
- NodeRef aNestedNode( aNode );
-
- AnyNodeRef aNestedValue = getLocalDescendant( aNestedTree, aNestedNode, aRelPath );
+ AnyNodeRef aNestedValue = getLocalDescendant( aTree, aNode, aRelPath );
if (aNestedValue.isValid())
{
- aRet[i] = configapi::makeElement( impl->getFactory(), aNestedTree, aNestedValue );
+ aRet[i] = configapi::makeElement( impl->getFactory(), aTree, aNestedValue );
}
else
{
@@ -1100,8 +1081,9 @@ beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& sP
}
OSL_ASSERT(aNode.isValid());
- //aTree.ensureDefaults();
- return aTree.isNodeDefault(aChild) ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ return aTree.isNodeDefault(aChild) ? beans::PropertyState_DEFAULT_VALUE :
+ aChild.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE :
+ beans::PropertyState_DIRECT_VALUE;
}
catch (configuration::InvalidName& ex)
{
@@ -1162,7 +1144,9 @@ Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const
}
OSL_ASSERT(aChildNode.isValid());
- aRet[i] = aChildTree.isNodeDefault(aChildNode) ? beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
+ aRet[i] = aChildTree.isNodeDefault(aChildNode) ? beans::PropertyState_DEFAULT_VALUE :
+ aChildNode.isNode() ? beans::PropertyState_AMBIGUOUS_VALUE :
+ beans::PropertyState_DIRECT_VALUE;
}
}
@@ -1183,45 +1167,43 @@ Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const
}
//-----------------------------------------------------------------------------------
+static inline NodeChange validateSetToDefaultHelper(configuration::GroupDefaulter& _rDefaulter, AnyNodeRef _aNode)
+{
+ if (!_aNode.isNode())
+ return _rDefaulter.validateSetToDefaultValue( _aNode.toValue() );
+
+ else
+ return _rDefaulter.validateSetToDefaultState( _aNode.toNode() );
+}
+//-----------------------------------------------------------------------------------
void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& sPropertyName )
throw(beans::UnknownPropertyException, RuntimeException)
{
try
{
- using configuration::getChildOrElement;
-
GuardedGroupUpdateAccess impl( rNode );
Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateChildOrElementName(sPropertyName,aTree,aNode);
+ configuration::GroupDefaulter aDefaulter = impl->getNodeDefaulter();
+ aDefaulter.ensureDataAvailable();
- Tree aChildTree( aTree);
+ Name aChildName = validateChildName(sPropertyName,aTree,aNode);
- AnyNodeRef aChildNode = getChildOrElement(aChildTree, aNode, aChildName);
- if (!aChildNode.isValid())
- {
- OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default. Property '") );
- sMessage += sPropertyName;
- sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in NodeRef ") );
- sMessage += aTree.getAbsolutePath(aNode).toString();
+ AnyNodeRef aChild( aTree.getAnyChild(aNode, aChildName) );
- Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
- throw UnknownPropertyException( sMessage, xContext );
- }
- OSL_ASSERT(aChildNode.isValid());
+ NodeChange aChange = validateSetToDefaultHelper( aDefaulter, aChild );
- aChildTree.ensureDefaults();
+ const bool bLocal = !aDefaulter.hasDoneSet();
- NodeChange aChange = impl->getNodeUpdater().validateSetDefault( aChildNode );
- if (aChange.test().isChange())
+ if (aChange.test().isChange() )
{
- Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChange,true));
+ Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChange,bLocal));
aSender.queryConstraints(aChange);
- aTree.integrate(aChange, aNode, true);
+ aTree.integrate(aChange, aNode, bLocal);
impl.clearForBroadcast();
aSender.notifyListeners(aChange);
@@ -1248,27 +1230,172 @@ void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& sProperty
e.unhandled();
}
}
+//-----------------------------------------------------------------------------------
+void implSetPropertiesToDefault( NodeGroupAccess& rNode, const Sequence< OUString >& aPropertyNames )
+ throw(beans::UnknownPropertyException, RuntimeException)
+{
+ try
+ {
+ GuardedGroupUpdateAccess impl( rNode );
+
+ Tree const aTree( impl->getTree() );
+ NodeRef const aNode( impl->getNode() );
+
+ configuration::GroupDefaulter aDefaulter = impl->getNodeDefaulter();
+ aDefaulter.ensureDataAvailable();
+
+ NodeChanges aChanges;
+ for(sal_Int32 i = 0, count= aPropertyNames.getLength(); i < count; ++i)
+ {
+ Name aChildName = validateChildName( aPropertyNames[i], aTree, aNode ); // validated
+
+ AnyNodeRef aChild( aTree.getAnyChild(aNode, aChildName) );
+
+ if (!aChild.isValid())
+ {
+ OSL_ENSURE(!configuration::hasChildOrElement(aTree, aNode, aChildName),"ERROR: Configuration: Existing Property not found by implementation");
+
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") );
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
+ sMessage += aChildName.toString();
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
+ sMessage += aTree.getAbsolutePath(aNode).toString();
+
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage, xContext );
+ }
+ OSL_ASSERT(aNode.isValid());
+
+ if (!aTree.hasNodeDefault(aChild))
+ {
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default.") );
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM(" Property '") );
+ sMessage += aChildName.toString();
+
+ if (aChild.isNode())
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' is not a simple value.") );
+
+ else
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' does not have a default value.") );
+
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage, xContext );
+ }
+
+ NodeChange aChildChange = validateSetToDefaultHelper(aDefaulter, aChild );
+ if (aChildChange.maybeChange())
+ aChanges.add(aChildChange);
+ }
+
+ const bool bLocal = !aDefaulter.hasDoneSet();
+
+ if (!aChanges.test().isEmpty())
+ {
+ Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChanges.compact(),bLocal));
+
+ aSender.queryConstraints(aChanges);
+
+ aTree.integrate(aChanges, aNode, bLocal);
+
+ impl.clearForBroadcast();
+ aSender.notifyListeners(aChanges, bLocal);
+ }
+
+ }
+ catch (configuration::InvalidName& ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage += e.message(), xContext );
+ }
+ catch (configuration::ConstraintViolation & ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage += e.message(), xContext );
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+}
//-----------------------------------------------------------------------------------
-Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
- throw(beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
+void implSetAllPropertiesToDefault( NodeGroupAccess& rNode )
+ throw(RuntimeException)
{
try
{
- using configuration::getChildOrElement;
+ GuardedGroupUpdateAccess impl( rNode );
+
+ Tree const aTree( impl->getTree() );
+ NodeRef const aNode( impl->getNode() );
+
+ configuration::GroupDefaulter aDefaulter = impl->getNodeDefaulter();
+ aDefaulter.ensureDataAvailable();
+
+ NodeChanges aChanges = aDefaulter.validateSetAllToDefault( );
+
+ const bool bLocal = !aDefaulter.hasDoneSet();
+
+ if (!aChanges.test().isEmpty())
+ {
+ Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChanges.compact(),bLocal));
+
+ aSender.queryConstraints(aChanges);
+
+ aTree.integrate(aChanges, aNode, bLocal);
+
+ impl.clearForBroadcast();
+ aSender.notifyListeners(aChanges, bLocal);
+ }
+ }
+ catch (configuration::InvalidName& ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage += e.message(), xContext );
+ }
+ catch (configuration::ConstraintViolation & ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Defaults: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage += e.message(), xContext );
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+}
+
+//-----------------------------------------------------------------------------------
+Any implGetPropertyDefault( NodeGroupInfoAccess& rNode, const OUString& sPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
+{
+ Any aDefault;
+ try
+ {
GuardedNodeDataAccess impl( rNode );
- Tree aTree( impl->getTree() );
+ Tree const aTree( impl->getTree() );
NodeRef const aNode( impl->getNode() );
- Name aChildName = validateChildOrElementName(aPropertyName,aTree,aNode);
+ Name aChildName = validateChildName(sPropertyName,aTree,aNode);
- AnyNodeRef aChildNode = getChildOrElement(aTree, aNode, aChildName);
+ AnyNodeRef aChildNode = aTree.getAnyChild(aNode, aChildName);
if (!aChildNode.isValid())
{
OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") );
- sMessage += aPropertyName;
+ sMessage += sPropertyName;
sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
sMessage += aTree.getAbsolutePath(aNode).toString();
@@ -1277,8 +1404,10 @@ Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
}
OSL_ASSERT(aNode.isValid());
- aTree.ensureDefaults();
- return aTree.getNodeDefault(aChildNode);
+ if (!aChildNode.isNode())
+ {
+ aDefault = aTree.getNodeDefaultValue(aChildNode.toValue());
+ }
}
catch (configuration::InvalidName& ex)
{
@@ -1306,9 +1435,75 @@ Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
e.unhandled();
}
- // unreachable, but still there to make some compilers happy
- OSL_ASSERT(!"Unreachable code");
- return Any();
+ return aDefault;
+}
+
+//-----------------------------------------------------------------------------------
+Sequence< Any > implGetPropertyDefaults( NodeGroupInfoAccess& rNode, const Sequence< OUString >& aPropertyNames )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
+{
+ sal_Int32 const count = aPropertyNames.getLength();
+ Sequence<Any> aDefaults(count);
+
+ try
+ {
+ using configuration::getChildOrElement;
+
+ GuardedNodeDataAccess impl( rNode );
+
+ Tree const aTree( impl->getTree() );
+ NodeRef const aNode( impl->getNode() );
+
+ for(sal_Int32 i = 0; i < count; ++i)
+ {
+ Name aChildName = validateChildName(aPropertyNames[i],aTree,aNode);
+
+ AnyNodeRef aChildNode = aTree.getAnyChild(aNode, aChildName);
+ if (!aChildNode.isValid())
+ {
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default. Property '") );
+ sMessage += aPropertyNames[i];
+ sMessage += OUString( RTL_CONSTASCII_USTRINGPARAM("' not found in ") );
+ sMessage += aTree.getAbsolutePath(aNode).toString();
+
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage, xContext );
+ }
+ OSL_ASSERT(aNode.isValid());
+
+ if (!aChildNode.isNode())
+ {
+ aDefaults[i] = aTree.getNodeDefaultValue(aChildNode.toValue());
+ }
+ }
+ }
+ catch (configuration::InvalidName& ex)
+ {
+ ExceptionMapper e(ex);
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( e.message(), xContext );
+ }
+ catch (configuration::ConstraintViolation & ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ throw UnknownPropertyException( sMessage += e.message(), xContext );
+ }
+ catch (configuration::WrappedUnoException& ex)
+ {
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot get Default: ") );
+ throw WrappedTargetException( sMessage += ex.extractMessage(), xContext, ex.getAnyUnoException() );
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+
+ return aDefaults;
}
//-----------------------------------------------------------------------------------
diff --git a/configmgr/source/api2/propsetaccessimpl.hxx b/configmgr/source/api2/propsetaccessimpl.hxx
index 1f3cc34f3531..5acd712a975d 100644
--- a/configmgr/source/api2/propsetaccessimpl.hxx
+++ b/configmgr/source/api2/propsetaccessimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: propsetaccessimpl.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:28:26 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -154,20 +154,28 @@ namespace configmgr
void implFirePropertiesChangeEvent( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames, const uno::Reference< beans::XPropertiesChangeListener >& xListener )
throw(uno::RuntimeException);
-#ifndef CONFIGMGR_NO_PROPERTYSTATE
// XPropertyState
- beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& PropertyName )
+ beans::PropertyState implGetPropertyState( NodeAccess& rNode, const OUString& sPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException);
+
+ void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& sPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
+ uno::Any implGetPropertyDefault( NodeGroupInfoAccess& rNode, const OUString& sPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XMultiPropertyState
uno::Sequence< beans::PropertyState > implGetPropertyStates( NodeAccess& rNode, const uno::Sequence< OUString >& aPropertyName )
throw(beans::UnknownPropertyException, uno::RuntimeException);
- void implSetPropertyToDefault( NodeGroupAccess& rNode, const OUString& PropertyName )
+ void implSetPropertiesToDefault( NodeGroupAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, uno::RuntimeException);
- uno::Any implGetPropertyDefault( NodeAccess& rNode, const OUString& aPropertyName )
+ void implSetAllPropertiesToDefault( NodeGroupAccess& rNode )
+ throw(uno::RuntimeException);
+
+ uno::Sequence< uno::Any > implGetPropertyDefaults( NodeGroupInfoAccess& rNode, const uno::Sequence< OUString >& aPropertyNames )
throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
-#endif
}
}
diff --git a/configmgr/source/api2/providerimpl.cxx b/configmgr/source/api2/providerimpl.cxx
index df18d0199ce1..b66889b7a6d5 100644
--- a/configmgr/source/api2/providerimpl.cxx
+++ b/configmgr/source/api2/providerimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerimpl.cxx,v $
*
- * $Revision: 1.41 $
+ * $Revision: 1.42 $
*
- * last change: $Author: jb $ $Date: 2001-09-28 09:18:39 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -296,9 +296,15 @@ namespace configmgr
// access to the raw notifications
IConfigBroadcaster* OProviderImpl::getNotifier() { OSL_ASSERT(m_pTreeMgr); return m_pTreeMgr->getBroadcaster(); }
- // TemplateProvider access
+ // DefaultProvider access
//-----------------------------------------------------------------------------
+ IDefaultProvider& OProviderImpl::getDefaultProvider() const
+ {
+ return *m_pTreeMgr;
+ }
+ // TemplateProvider access
+ //-----------------------------------------------------------------------------
ITemplateProvider& OProviderImpl::getTemplateProvider() const
{
return *m_pTreeMgr;
@@ -366,6 +372,12 @@ namespace configmgr
m_pTreeMgr->fetchSubtree(aSubtreePath, _xOptions, nMinLevels);
}
+ //-----------------------------------------------------------------------------
+ sal_Bool OProviderImpl::fetchDefaultData(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels) throw()
+ {
+ return m_pTreeMgr->fetchDefaultData(aSubtreePath, _xOptions, nMinLevels);
+ }
+
// IInterface
//-----------------------------------------------------------------------------
void SAL_CALL OProviderImpl::acquire( ) throw ()
diff --git a/configmgr/source/api2/providerimpl.hxx b/configmgr/source/api2/providerimpl.hxx
index c871fbc8cb47..700bff24e0d1 100644
--- a/configmgr/source/api2/providerimpl.hxx
+++ b/configmgr/source/api2/providerimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: providerimpl.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,24 +62,31 @@
#ifndef CONFIGMGR_API_PROVIDERIMPL_HXX_
#define CONFIGMGR_API_PROVIDERIMPL_HXX_
+#ifndef CONFIGMGR_TREEPROVIDER_HXX
#include "treeprovider.hxx"
+#endif
+#ifndef CONFIGMGR_DEFAULTPROVIDER_HXX
+#include "defaultprovider.hxx"
+#endif
+
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
+#include "options.hxx"
+#endif
#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
#include <com/sun/star/script/XTypeConverter.hpp>
#endif
-
#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
#include <com/sun/star/lang/XEventListener.hpp>
#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
-#include <com/sun/star/lang/XComponent.hpp>
-
-#include "options.hxx"
-
namespace com { namespace sun { namespace star {
namespace uno
{
@@ -107,6 +114,7 @@ namespace configmgr
class ISubtree;
class ITemplateProvider;
+ class IDefaultProvider;
class IConfigSession;
class TreeManager;
class ConnectionSettings;
@@ -121,7 +129,7 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
- class OProviderImpl : public ITreeManager, public IInterface
+ class OProviderImpl : public ITreeManager, public IDefaultableTreeManager, public IInterface
{
friend class OProvider;
OProvider* m_pProvider; /// used for ref counting, uno representation
@@ -203,11 +211,17 @@ namespace configmgr
virtual void notifyUpdate(TreeChangeList const& aChanges) throw (uno::RuntimeException);
virtual void disposeData(const vos::ORef < OOptions >& _xOptions) throw();
virtual void fetchSubtree(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions, sal_Int16 nMinLevels = ALL_LEVELS) throw();
+ /// IDefaultableTreeManager
+ virtual sal_Bool fetchDefaultData(AbsolutePath const& aSubtreePath, const vos::ORef < OOptions >& _xOptions,
+ sal_Int16 nMinLevels) throw (uno::Exception);
// IInterface
virtual void SAL_CALL acquire( ) throw ();
virtual void SAL_CALL release( ) throw ();
+ // DefaultProvider access
+ IDefaultProvider& getDefaultProvider() const;
+
// TemplateProvider access
ITemplateProvider& getTemplateProvider() const;
diff --git a/configmgr/source/api2/setupdate.cxx b/configmgr/source/api2/setupdate.cxx
index 6d9ad9b2e463..275ffff4c683 100644
--- a/configmgr/source/api2/setupdate.cxx
+++ b/configmgr/source/api2/setupdate.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setupdate.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-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,11 +60,24 @@
************************************************************************/
#include "setupdate.hxx"
+
+#ifndef CONFIGMGR_API_BASEACCESSIMPL_HXX_
+#include "accessimpl.hxx"
+#endif
+#ifndef CONFIGMGR_API_BASEUPDATEIMPL_HXX_
#include "updateimpl.hxx"
-#include "apinodeaccess.hxx"
+#endif
+
+#ifndef CONFIGMGR_API_NODEUPDATE_HXX_
+#include "apinodeupdate.hxx"
+#endif
+#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
#include <cppuhelper/queryinterface.hxx>
+#endif
+#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
#include <cppuhelper/typeprovider.hxx>
+#endif
namespace configmgr
{
@@ -216,6 +229,44 @@ void SAL_CALL BasicValueSet::removeByName( const OUString& rName )
implRemoveByName( getSetNode(), rName );
}
+// XPropertyWithState
+//////////////////////////////////////////////////////////////////////////////////
+
+css::beans::PropertyState SAL_CALL BasicSet::getStateAsProperty() throw (uno::RuntimeException)
+{
+ return implGetStateAsProperty( getSetNode() );
+}
+//..............................................................................
+
+css::beans::PropertyState SAL_CALL BasicValueSet::getStateAsProperty() throw (uno::RuntimeException)
+{
+ return implGetStateAsProperty( getSetNode() );
+}
+//-----------------------------------------------------------------------------------
+
+void SAL_CALL BasicSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ implSetToDefaultAsProperty( getSetNode() );
+}
+//..............................................................................
+
+void SAL_CALL BasicValueSet::setToDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ implSetToDefaultAsProperty( getSetNode() );
+}
+//-----------------------------------------------------------------------------------
+
+uno::Reference< uno::XInterface > SAL_CALL BasicSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ return implGetDefaultAsProperty( getSetNode() );
+}
+//..............................................................................
+
+uno::Reference< uno::XInterface > SAL_CALL BasicValueSet::getDefaultAsProperty() throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ return implGetDefaultAsProperty( getSetNode() );
+}
+
// XSingleServiceFactory (not for ValueSet)
//////////////////////////////////////////////////////////////////////////////////
uno::Reference< uno::XInterface > SAL_CALL BasicSet::createInstance( )
diff --git a/configmgr/source/api2/setupdate.hxx b/configmgr/source/api2/setupdate.hxx
index c5f6802a7855..0fa183000dec 100644
--- a/configmgr/source/api2/setupdate.hxx
+++ b/configmgr/source/api2/setupdate.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setupdate.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-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,11 +62,16 @@
#ifndef CONFIGMGR_API_SETUPDATE_HXX_
#define CONFIGMGR_API_SETUPDATE_HXX_
+#ifndef CONFIGMGR_API_SETACCESS_HXX_
#include "setaccess.hxx"
+#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYWITHSTATE_HPP_
+#include <com/sun/star/beans/XPropertyWithState.hpp>
+#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
@@ -90,6 +95,7 @@ namespace configmgr
class BasicSet
: public BasicSetAccess
, public css::container::XNameContainer
+ , public css::beans::XPropertyWithState
, public css::lang::XSingleServiceFactory
{
protected:
@@ -138,6 +144,19 @@ namespace configmgr
removeByName( const OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
+ // XPropertyWithState
+ virtual css::beans::PropertyState SAL_CALL
+ getStateAsProperty( )
+ throw (uno::RuntimeException);
+
+ virtual void SAL_CALL
+ setToDefaultAsProperty( )
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
+ virtual uno::Reference< uno::XInterface > SAL_CALL
+ getDefaultAsProperty( )
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
// XSingleServiceFactory
virtual uno::Reference< uno::XInterface > SAL_CALL
createInstance( )
@@ -160,6 +179,7 @@ namespace configmgr
*/
class BasicValueSet
: public BasicSetAccess
+ , public css::beans::XPropertyWithState
, public css::container::XNameContainer
{
protected:
@@ -208,6 +228,19 @@ namespace configmgr
removeByName( const OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
+ // XPropertyWithState
+ virtual css::beans::PropertyState SAL_CALL
+ getStateAsProperty( )
+ throw (uno::RuntimeException);
+
+ virtual void SAL_CALL
+ setToDefaultAsProperty( )
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
+ virtual uno::Reference< uno::XInterface > SAL_CALL
+ getDefaultAsProperty( )
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
protected:
configapi::NodeValueSetAccess& getSetNode();
virtual configapi::NodeValueSetAccess* maybeGetUpdateAccess() = 0;
diff --git a/configmgr/source/api2/updateimpl.cxx b/configmgr/source/api2/updateimpl.cxx
index 5466cb2e26e3..518b0d5031b3 100644
--- a/configmgr/source/api2/updateimpl.cxx
+++ b/configmgr/source/api2/updateimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: updateimpl.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -674,6 +674,63 @@ void implRemoveByName(NodeValueSetAccess& rNode, const OUString& sName )
}
//-----------------------------------------------------------------------------------
+// XPropertyWithState
+//-----------------------------------------------------------------------------------
+
+void implSetToDefaultAsProperty(NodeSetAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException)
+{
+ try
+ {
+ GuardedSetUpdateAccess impl( rNode );
+
+ Tree const aTree( impl->getTree() );
+ NodeRef const aNode( impl->getNode() );
+
+ configuration::SetDefaulter aDefaulter = impl->getNodeDefaulter();
+
+ NodeChange aChange = aDefaulter.validateSetToDefaultState();
+
+ const bool bLocal = true;
+
+ if (aChange.test().isChange() )
+ {
+ Broadcaster aSender(impl->getNotifier().makeBroadcaster(aChange,bLocal));
+
+ aSender.queryConstraints(aChange);
+
+ aTree.integrate(aChange, aNode, bLocal);
+
+ impl.clearForBroadcast();
+ aSender.notifyListeners(aChange);
+ }
+ }
+ catch (configuration::ConstraintViolation & ex)
+ {
+ ExceptionMapper e(ex);
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+
+ throw lang::WrappedTargetException( sMessage += e.message(), xContext, uno::Any());
+ }
+ catch (configuration::Exception& ex)
+ {
+ ExceptionMapper e(ex);
+ e.setContext( rNode.getUnoInstance() );
+ e.unhandled();
+ }
+ catch (lang::WrappedTargetException& ) { throw;}
+ catch (uno::RuntimeException& ) { throw;}
+ catch (uno::Exception& e)
+ {
+ OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration - Cannot restore Default: ") );
+ Reference<uno::XInterface> xContext( rNode.getUnoInstance() );
+
+ throw lang::WrappedTargetException( sMessage += e.Message, xContext, uno::makeAny(e));
+ }
+}
+//-----------------------------------------------------------------------------------
+
// XSingleServiceFactory
//-----------------------------------------------------------------------------------
Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode )
diff --git a/configmgr/source/api2/updateimpl.hxx b/configmgr/source/api2/updateimpl.hxx
index a6447a0325cb..6baa5eb27b70 100644
--- a/configmgr/source/api2/updateimpl.hxx
+++ b/configmgr/source/api2/updateimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: updateimpl.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-09-28 12:44:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -69,6 +69,12 @@
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYWITHSTATE_HPP_
+#include <com/sun/star/beans/XPropertyWithState.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
namespace configmgr
{
@@ -77,15 +83,17 @@ namespace configmgr
/* implementations of the interfaces supported by a (parent) node
within the configuration tree.
- (read-only operation)
+ (updating operation)
*/
namespace configapi
{
+ class NodeSetAccess;
class NodeTreeSetAccess;
class NodeValueSetAccess;
class NodeGroupAccess;
// XNameReplace
+ //---------------------------------------------------------------------
void implReplaceByName(NodeGroupAccess& rNode, const OUString& rName, const uno::Any& rElement )
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
@@ -96,6 +104,7 @@ namespace configmgr
throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
// XNameContainer
+ //---------------------------------------------------------------------
void implInsertByName(NodeTreeSetAccess& rNode, const OUString& rName, const uno::Any& rElement)
throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, uno::RuntimeException);
@@ -108,12 +117,20 @@ namespace configmgr
void implRemoveByName(NodeValueSetAccess& rNode, const OUString& rName )
throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, uno::RuntimeException);
+ // XPropertyWithState - updating operation only
+ //---------------------------------------------------------------------
+ void implSetToDefaultAsProperty(NodeSetAccess& rNode)
+ throw (css::lang::WrappedTargetException, uno::RuntimeException);
+
// XSingleServiceFactory
+ //---------------------------------------------------------------------
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode )
throw(uno::Exception, uno::RuntimeException);
uno::Reference< uno::XInterface > implCreateElement(NodeTreeSetAccess& rNode, const uno::Sequence< uno::Any >& aArguments )
throw(uno::Exception, uno::RuntimeException);
+
+ //---------------------------------------------------------------------
}
}
diff --git a/configmgr/source/inc/anynoderef.hxx b/configmgr/source/inc/anynoderef.hxx
index 73c042ee70b8..ebd7c2857a30 100644
--- a/configmgr/source/inc/anynoderef.hxx
+++ b/configmgr/source/inc/anynoderef.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: anynoderef.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:45 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -190,7 +190,7 @@ namespace configmgr
and <var>aPath</var> is empty)<BR/>
an invalid node otherwise
*/
- AnyNodeRef getLocalDescendant(Tree& aTree, NodeRef& aNode, RelativePath& aPath);
+ AnyNodeRef getLocalDescendant(Tree const& aTree, NodeRef const& aNode, RelativePath const& 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>
diff --git a/configmgr/source/inc/anypair.hxx b/configmgr/source/inc/anypair.hxx
index daeefc79b977..e3c3aed9c6fe 100644
--- a/configmgr/source/inc/anypair.hxx
+++ b/configmgr/source/inc/anypair.hxx
@@ -75,49 +75,60 @@ namespace configmgr
cfgmgr_AnyPair m_aAnyPair;
public:
+ enum SelectMember
+ {
+ SELECT_FIRST = cfgmgr_SELECT_FIRST,
+ SELECT_SECOND = cfgmgr_SELECT_SECOND,
+ SELECT_BOTH = cfgmgr_SELECT_BOTH
+ };
+ public:
// ctors
AnyPair();
explicit AnyPair(uno::Type const& _aType); // one Type, any's are null
- explicit AnyPair(uno::Any const& _aAny); // one any - to first
+ explicit AnyPair(uno::Any const& _aAny, SelectMember _select); // one selected any
explicit AnyPair(uno::Any const& _aAny, uno::Any const& _aAny2) SAL_THROW((lang::IllegalArgumentException));
- // copy-ctor
+ // copy
AnyPair(AnyPair const& _aAny);
-
- // assign operator
AnyPair& operator=(AnyPair const& _aAny);
// d-tor
~AnyPair();
- // set-types
+ // elementwise setters
sal_Bool setFirst(uno::Any const& _aAny);
sal_Bool setSecond(uno::Any const& _aAny);
+ sal_Bool setValue(uno::Any const& _aAny, SelectMember _select);
+ // clear data (but not type)
+ void clear(SelectMember _select = SELECT_BOTH);
- uno::Any getFirst() const;
- uno::Any getSecond() const;
- uno::Type getValueType() const;
- bool hasFirst() const
+ // checking state and availablity of values
+ bool isEmpty() const { return cfgmgr_AnyPair_isEmpty(&m_aAnyPair.desc); }
+
+ bool isNull () const { return ! hasValue(); }
+
+ bool hasValue(SelectMember _select = SELECT_BOTH) const
{
- return !cfgmgr_AnyPair_isNull(&m_aAnyPair.desc, cfgmgr_SELECT_FIRST);
+ return !cfgmgr_AnyPair_isNull(&m_aAnyPair.desc, _select);
}
- bool hasSecond() const
+ bool hasFirst() const
{
- return !cfgmgr_AnyPair_isNull(&m_aAnyPair.desc, cfgmgr_SELECT_SECOND);
+ return hasValue(SELECT_FIRST);
}
- bool hasValue() const
+ bool hasSecond() const
{
- return !cfgmgr_AnyPair_isNull(&m_aAnyPair.desc, cfgmgr_SELECT_BOTH);
+ return hasValue(SELECT_SECOND);
}
- bool isNull () const { return ! hasValue(); }
- bool isEmpty() const { return cfgmgr_AnyPair_isEmpty(&m_aAnyPair.desc); }
+ // elementwise getters
+ uno::Type getValueType() const;
+ uno::Any getFirst() const;
+ uno::Any getSecond() const;
+ uno::Any getValue(SelectMember _select) const;
- void check_init() {};
- void init() {};
};
diff --git a/configmgr/source/inc/attributes.hxx b/configmgr/source/inc/attributes.hxx
index 9634564a00e5..acae6f8e40f8 100644
--- a/configmgr/source/inc/attributes.hxx
+++ b/configmgr/source/inc/attributes.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: attributes.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-09-25 16:00:39 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,16 +63,16 @@
#define CONFIGMGR_CONFIGURATION_ATTRIBUTES_HXX_
namespace configmgr
{
- namespace configuration
+ namespace node
{
/// holds attributes a node in the schema
struct Attributes
{
bool bWritable : 1; // write-protected, if false
- bool bFinalized : 1; // write-protected, but not here
+ bool bFinalized : 1; // can not be overridden - write protected when merged upwards
- bool bReplacing : 1; // node does not exist in the default layer
- bool bDefaultable : 1; // values only: a default value does exist
+ bool bReplaced : 1; // node not merged: it does not exist in the default layer
+ bool bDefaulted : 1; // node not merged: it exists only in the default layer
bool bNullable : 1; // values only: can be NULL
bool bLocalized : 1; // values only: value may depend on locale
@@ -83,17 +83,26 @@ namespace configmgr
Attributes()
: bWritable(true)
+ , bFinalized(false)
+ , bReplaced(false)
+ , bDefaulted(false)
, bNullable(true)
+ , bLocalized(false)
, bNotified(true)
, bConstrained(false)
- , bReplacing(false)
- , bLocalized(false)
- , bDefaultable(false)
- , bFinalized(false)
{}
+ /* ! IMPORTANT: if these defaults are changed,
+ the handling in CmXMLFormater::handleAttributes()
+ and OValueHandler::startElement() should be reviewed
+ */
};
}
+ // for backward compatibility - this used to be in namespace configuration
+ namespace configuration
+ {
+ using node::Attributes;
+ }
}
#endif
diff --git a/configmgr/source/inc/change.hxx b/configmgr/source/inc/change.hxx
index 1f6ed3bcbb22..06d1c8f062dd 100644
--- a/configmgr/source/inc/change.hxx
+++ b/configmgr/source/inc/change.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: change.hxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: avy $ $Date: 2001-08-08 11:21:36 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,18 +122,24 @@ namespace configmgr
{
protected:
rtl::OUString m_aName;
+ bool m_bIsToDefault;
void swap(Change& aOther);
public:
explicit
- Change(rtl::OUString const& _rName) : m_aName(_rName){}
- Change(Change const& _rChange):m_aName(_rChange.m_aName){}
+ Change(rtl::OUString const& _rName, bool _bToDefault)
+ : m_aName(_rName)
+ , m_bIsToDefault(_bToDefault)
+ {}
+
virtual ~Change() {}
rtl::OUString getNodeName() const { return m_aName; }
void setNodeName(const rtl::OUString &aName) {m_aName = aName;}
+ bool isToDefault() const { return m_bIsToDefault; }
+
Change* getSubChange(rtl::OUString const& _rName) { return doGetChild(_rName); }
Change const* getSubChange(rtl::OUString const& _rName) const { return doGetChild(_rName); }
@@ -157,18 +163,29 @@ namespace configmgr
typedef uno::Any Any;
struct SetToDefault {};
enum Mode { wasDefault, changeValue, setToDefault, changeDefault, typeIsAny };
- configuration::Attributes m_aAttributes;
private:
- uno::Any m_aValue;
- uno::Any m_aOldValue;
- Mode m_eMode;
+ uno::Any m_aValue;
+ uno::Any m_aOldValue;
+ node::Attributes m_aAttributes;
+ Mode m_eMode;
public:
- ValueChange(rtl::OUString const& _rName, uno::Any aNewValue, const configuration::Attributes& _rAttributes,
- Mode aMode = changeValue, uno::Any aOldValue = uno::Any());
+ ValueChange(
+ rtl::OUString const& _rName,
+ const node::Attributes& _rAttributes,
+ uno::Any aNewValue,
+ uno::Any aOldValue = uno::Any());
+
+ ValueChange(
+ rtl::OUString const& _rName,
+ const node::Attributes& _rAttributes,
+ Mode aMode,
+ uno::Any aNewValue,
+ uno::Any aOldValue = uno::Any());
+
ValueChange(uno::Any aNewValue, ValueNode const& aOldValue);
ValueChange(SetToDefault, ValueNode const& aOldValue);
- ValueChange(const ValueChange&);
+
virtual Change* clone() const;
uno::Any getNewValue() const { return m_aValue; }
@@ -178,8 +195,8 @@ namespace configmgr
void setNewValue(const uno::Any& _rNewVal, Mode aMode)
{ setNewValue(_rNewVal); m_eMode = aMode;}
- bool isReplacing() const {return m_aAttributes.bReplacing;}
- bool isLocalized() const {return m_aAttributes.bLocalized;}
+ bool isReplacedValue() const {return m_aAttributes.bReplaced;}
+ bool isLocalizedValue() const {return m_aAttributes.bLocalized;}
Mode getMode() const { return m_eMode; }
@@ -209,13 +226,15 @@ namespace configmgr
INode* m_pOldNode;
bool m_bReplacing;
- // don't create CopyCTor automatically
- void operator=(AddNode const&);
+ private:
+ void operator=(AddNode const&); // not implemented
+ // needed for clone()
+ AddNode(AddNode const&);
public:
- AddNode(std::auto_ptr<INode> aNewNode_,rtl::OUString const& _rName);
+ AddNode(std::auto_ptr<INode> aNewNode_,rtl::OUString const& _rName, bool _bToDefault);
~AddNode();
- AddNode(AddNode const&);
+
virtual Change* clone() const;
/// marks this as not merely adding a node but replacing another
@@ -278,12 +297,17 @@ namespace configmgr
protected:
INode* m_pOldNode;
std::auto_ptr<INode> m_aOwnOldNode;
+ bool m_bIsToDefault;
+ private:
+ RemoveNode& operator=(const RemoveNode&); // not implemented
+ // needed for clone()
+ RemoveNode(const RemoveNode&);
public:
explicit
- RemoveNode(rtl::OUString const& _rName);
+ RemoveNode(rtl::OUString const& _rName, bool _bToDefault);
~RemoveNode();
- RemoveNode(const RemoveNode&);
+
virtual Change* clone() const;
virtual void dispatch(ChangeTreeAction& anAction) const { anAction.handle(*this); }
@@ -325,9 +349,10 @@ namespace configmgr
Children m_aChanges;
::rtl::OUString m_sTemplateName; /// path of the template for child instantiation
::rtl::OUString m_sTemplateModule; /// module of the template for child instantiation
- configuration::Attributes m_aAttributes;
+ node::Attributes m_aAttributes;
- // don't create CopyCTor automatically
+ // don't create copy ops automatically
+ SubtreeChange(const SubtreeChange&);
void operator=(SubtreeChange&);
public:
@@ -343,46 +368,58 @@ namespace configmgr
public:
/// A parameter for disabling copying of children
typedef treeop::NoChildCopy NoChildCopy;
+ typedef treeop::DeepChildCopy DeepChildCopy;
SubtreeChange(const rtl::OUString& _rName,
- const configuration::Attributes& _rAttr)
- :Change(_rName)
- ,m_aAttributes(_rAttr)
- {}
+ const node::Attributes& _rAttr,
+ bool _bToDefault = false)
+ : Change(_rName,_bToDefault)
+ , m_aAttributes(_rAttr)
+ {
+ m_aAttributes.bDefaulted = _bToDefault;
+ }
SubtreeChange(const rtl::OUString& _rName,
const rtl::OUString& _rTemplateName,
const rtl::OUString& _rTemplateModule,
- const configuration::Attributes& _rAttr)
- :Change(_rName)
- ,m_sTemplateName(_rTemplateName)
- ,m_sTemplateModule(_rTemplateModule)
- ,m_aAttributes(_rAttr)
- {}
-
- SubtreeChange(const ISubtree& _rTree)
- :Change(_rTree.getName())
- ,m_aAttributes(_rTree.getAttributes())
- ,m_sTemplateName(_rTree.getElementTemplateName())
- ,m_sTemplateModule(_rTree.getElementTemplateModule())
- {}
+ const node::Attributes& _rAttr,
+ bool _bToDefault = false)
+ : Change(_rName,_bToDefault)
+ , m_sTemplateName(_rTemplateName)
+ , m_sTemplateModule(_rTemplateModule)
+ , m_aAttributes(_rAttr)
+ {
+ m_aAttributes.bDefaulted = _bToDefault;
+ }
+
+ SubtreeChange(const ISubtree& _rTree, bool _bToDefault = false)
+ : Change(_rTree.getName(),_bToDefault)
+ , m_aAttributes(_rTree.getAttributes())
+ , m_sTemplateName(_rTree.getElementTemplateName())
+ , m_sTemplateModule(_rTree.getElementTemplateModule())
+ {
+ m_aAttributes.bDefaulted = _bToDefault;
+ }
SubtreeChange(const SubtreeChange& _rChange, NoChildCopy)
- :Change(_rChange)
- ,m_sTemplateName(_rChange.getElementTemplateName())
- ,m_sTemplateModule(_rChange.getElementTemplateModule())
- ,m_aAttributes(_rChange.getAttributes()){}
+ : Change(_rChange)
+ , m_sTemplateName(_rChange.getElementTemplateName())
+ , m_sTemplateModule(_rChange.getElementTemplateModule())
+ , m_aAttributes(_rChange.getAttributes())
+ {}
~SubtreeChange();
- SubtreeChange(const SubtreeChange&);
+ SubtreeChange(const SubtreeChange&, DeepChildCopy);
+
virtual Change* clone() const;
void swap(SubtreeChange& aOther);
- bool isReplacing() const {return m_aAttributes.bReplacing;}
- bool isLocalized() const {return m_aAttributes.bLocalized;}
- const configuration::Attributes& getAttributes() const {return m_aAttributes;}
+ bool isReplacedNode() const { return m_aAttributes.bReplaced; }
+ bool isLocalizedContainer() const { return m_aAttributes.bLocalized; }
+
+ const node::Attributes& getAttributes() const {return m_aAttributes;}
bool isSetNodeChange() const { return m_sTemplateName.getLength() != 0; }
@@ -392,7 +429,7 @@ namespace configmgr
void setElementTemplate(const rtl::OUString& _rName, const rtl::OUString& _rModule)
{ m_sTemplateName = _rName; m_sTemplateModule = _rModule; }
- sal_Int32 size() const { return m_aChanges.size(); }
+ sal_Int32 size() const { return m_aChanges.size(); }
uno::Sequence< rtl::OUString > elementNames() const;
void addChange(std::auto_ptr<Change> aChange);
diff --git a/configmgr/source/inc/configdefaultprovider.hxx b/configmgr/source/inc/configdefaultprovider.hxx
new file mode 100644
index 000000000000..2f66fc445574
--- /dev/null
+++ b/configmgr/source/inc/configdefaultprovider.hxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * $RCSfile: configdefaultprovider.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
+ *
+ * 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 CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
+#define CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+
+#ifndef _RTL_REF_HXX_
+#include <rtl/ref.hxx>
+#endif
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
+
+namespace configmgr
+{
+//-----------------------------------------------------------------------------
+ class ISubtree;
+ class IDefaultProvider;
+ class IDefaultableTreeManager;
+ class OOptions;
+
+ namespace uno = com::sun::star::uno;
+//-----------------------------------------------------------------------------
+ namespace configuration
+ {
+//-----------------------------------------------------------------------------
+
+ class Tree;
+ class NodeRef;
+//-----------------------------------------------------------------------------
+
+ /// provides access to the default for a given request
+ class DefaultProviderProxy;
+
+ class DefaultProvider
+ {
+ rtl::Reference< DefaultProviderProxy > m_aProxy;
+ public:
+ // factory methods
+ static DefaultProvider createEmpty();
+ static DefaultProvider create(Tree const& _aRootTree, vos::ORef<OOptions> const& _xOptions,
+ IDefaultProvider* _pDefaultProvider,
+ IDefaultableTreeManager* _pFetchProvider);
+
+ // actual c'tor
+ explicit
+ DefaultProvider(rtl::Reference< DefaultProviderProxy > const& _xProviderProxy);
+
+ // standard c/d-tors to make compiler barrier
+ DefaultProvider(DefaultProvider const& _aOther);
+ DefaultProvider& operator=(DefaultProvider const& _aOther);
+ ~DefaultProvider();
+
+ bool isValid() const { return !! m_aProxy.is(); }
+
+ /// tries to load default data into the specified tree
+ bool fetchDefaultData(Tree const& _aTree) const SAL_THROW((uno::Exception));
+
+ /// tries to load a default instance of the specified node
+ std::auto_ptr<ISubtree> getDefaultTree(Tree const& _aTree, NodeRef const& _aNode) const SAL_THROW((uno::Exception));
+
+ };
+
+//-----------------------------------------------------------------------------
+ }
+}
+
+#endif // CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
diff --git a/configmgr/source/inc/configgroup.hxx b/configmgr/source/inc/configgroup.hxx
index 78ee181073fc..183e6b259f3e 100644
--- a/configmgr/source/inc/configgroup.hxx
+++ b/configmgr/source/inc/configgroup.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configgroup.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:27:17 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,9 +62,18 @@
#ifndef CONFIGMGR_CONFIGGROUP_HXX_
#define CONFIGMGR_CONFIGGROUP_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
#include "configexcept.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
+#include "configdefaultprovider.hxx"
+#endif
namespace com { namespace sun { namespace star {
namespace script { class XTypeConverter; }
@@ -86,31 +95,61 @@ namespace configmgr
class RelativePath;
//-----------------------------------------------------------------------------
- /// allows to update values of a simple type within a <type>NodeRef</type> that refers to a Group
- class GroupUpdater
+ /// helper for updating a <type>NodeRef</type> that refers to a Group
+ class GroupUpdateHelper
{
Tree m_aTree;
NodeRef m_aNode;
- UnoTypeConverter m_xTypeConverter;
public:
- GroupUpdater(Tree const& aParentTree, NodeRef const& aGroupNode, UnoTypeConverter const& xConverter);
+ GroupUpdateHelper(Tree const& aParentTree, NodeRef const& aGroupNode);
+ ~GroupUpdateHelper() {}
- NodeChange validateSetDefault(AnyNodeRef const& aNode);
+ void validateNode(ValueRef const& aNode) const;
+ void validateNode(NodeRef const& aNode) const;
- NodeChange validateSetDefault(ValueRef const& aValueNode);
+ Tree const& tree() const { return m_aTree; }
+ NodeRef const& node() const { return m_aNode; }
+ private:
+ void implValidateTree(Tree const& aTree) const;
+ void implValidateNode(Tree const& aTree, NodeRef const& aNode) const;
+ void implValidateNode(Tree const& aTree, ValueRef const& aNode) const;
+ };
+//-----------------------------------------------------------------------------
+ /// allows to update values of a simple type within a <type>NodeRef</type> that refers to a Group
+ class GroupUpdater
+ {
+ GroupUpdateHelper m_aHelper;
+ UnoTypeConverter m_xTypeConverter;
+ public:
+ GroupUpdater(Tree const& aParentTree, NodeRef const& aGroupNode, UnoTypeConverter const& xConverter);
NodeChange validateSetValue(ValueRef const& aValueNode, UnoAny const& newValue );
- NodeChange validateSetDeepValue(Tree const& aNestedTree, ValueRef const& aNestedValueNode,
- RelativePath const& aRelPath,UnoAny const& newValue);
-
private:
- void implValidateTree(Tree const& aTree) const;
- void implValidateGroup(Tree const& aTree, NodeRef const& aNode) const;
- void implValidateNode(Tree const& aTree, ValueRef const& aNode) const;
UnoAny implValidateValue(Tree const& aTree, ValueRef const& aNode, UnoAny const& aValue) const;
};
//-----------------------------------------------------------------------------
+
+ /// allows to reset to default value or state members of a <type>NodeRef</type> that refers to a Group
+ class GroupDefaulter
+ {
+ GroupUpdateHelper m_aHelper;
+ DefaultProvider m_aDefaultProvider;
+ bool m_bHasDoneSet;
+ public:
+ GroupDefaulter(Tree const& _aParentTree, NodeRef const& _aGroupNode, DefaultProvider const& _aProvider);
+
+ bool hasDoneSet() const { return m_bHasDoneSet; }
+
+ bool ensureDataAvailable();
+
+ NodeChange validateSetToDefaultValue(ValueRef const& aValueNode);
+
+ NodeChange validateSetToDefaultState(NodeRef const& aNode);
+
+ NodeChanges validateSetAllToDefault();
+ };
+//-----------------------------------------------------------------------------
bool convertCompatibleValue(UnoTypeConverter const& xConverter, uno::Any& rConverted,
UnoAny const& rNewValue, UnoType const& rTargetType);
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/inc/configset.hxx b/configmgr/source/inc/configset.hxx
index a5506b2e2d01..ff2c2b41ad64 100644
--- a/configmgr/source/inc/configset.hxx
+++ b/configmgr/source/inc/configset.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configset.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-08-06 15:25:20 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,13 +62,30 @@
#ifndef CONFIGMGR_CONFIGSET_HXX_
#define CONFIGMGR_CONFIGSET_HXX_
+#ifndef CONFIGMGR_API_APITYPES_HXX_
#include "apitypes.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGEXCEPT_HXX_
#include "configexcept.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIG_DEFAULTPROVIDER_HXX_
+#include "configdefaultprovider.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGTEMPLATE_HXX_
#include "template.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
#include "noderef.hxx"
+#endif
+#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
+#endif
+
+#ifndef INCLUDED_MEMORY
#include <memory>
+#define INCLUDED_MEMORY
+#endif
namespace com { namespace sun { namespace star {
namespace script { class XTypeConverter; }
@@ -245,6 +262,22 @@ namespace configmgr
static ElementNodeRef extractElementNode(ElementRef const& aElement);
};
//-----------------------------------------------------------------------------
+
+ /// allows to restore to its default state a <type>Node</type> that is a Container ("set") of full-fledged trees.
+ class SetDefaulter
+ {
+ Tree m_aParentTree;
+ NodeRef m_aSetNode;
+ DefaultProvider m_aDefaultProvider;
+ public:
+ SetDefaulter(Tree const& aParentTree, NodeRef const& aSetNode, DefaultProvider const& aDefaultProvider);
+
+ NodeChange validateSetToDefaultState();
+
+ private:
+ void implValidateSet();
+ };
+//-----------------------------------------------------------------------------
}
}
diff --git a/configmgr/source/inc/defaultprovider.hxx b/configmgr/source/inc/defaultprovider.hxx
new file mode 100644
index 000000000000..4da77e792380
--- /dev/null
+++ b/configmgr/source/inc/defaultprovider.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: defaultprovider.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
+ *
+ * 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 CONFIGMGR_DEFAULTPROVIDER_HXX
+#define CONFIGMGR_DEFAULTPROVIDER_HXX
+
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
+#include "valuenode.hxx"
+#endif
+
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
+#include <options.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
+#include <com/sun/star/uno/Exception.hpp>
+#endif
+#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 INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
+
+
+namespace configmgr
+{
+
+ namespace uno = com::sun::star::uno;
+ using ::rtl::OUString;
+
+////////////////////////////////////////////////////////////////////////////////
+ namespace configuration
+ {
+ class AbsolutePath;
+ }
+ //-------------------------
+ class ISubtree;
+
+ //==========================================================================
+ //= IDefaultProvider
+ //==========================================================================
+ /* is an interface that can be implemented by an <type>ITreeProvider</type>
+ or <type>ITreeManager</type>.
+ <p>Supports functionality to fetch only the default data corresponding to a tree</p>
+ */
+ class SAL_NO_VTABLE IDefaultProvider
+ {
+ public:
+ /** load the default version of the tree named by a path
+ using certain options and requiring a specific loading depth
+ @returns
+ the default data tree, yielding ownership of it
+ <NULL/>if no default data is available for the tree
+ */
+ virtual std::auto_ptr<ISubtree> requestDefaultData(configuration::AbsolutePath const& aSubtreePath,
+ const vos::ORef < OOptions >& _xOptions,
+ sal_Int16 nMinLevels) throw (uno::Exception) = 0;
+ };
+
+ //==========================================================================
+ //= IDefaultableTreeManager
+ //==========================================================================
+ /* is a supplementary interface for a <type>ITreeManager</type>.
+ <p>Supports functionality to load default data into the managed tree</p>
+ */
+ class SAL_NO_VTABLE IDefaultableTreeManager
+ {
+ public:
+ /** attempt to load default data into the tree named by a path using certain options
+ and requiring a specific loading depth.
+
+ @returns
+ <TRUE/>, if some default data is available within the tree
+ <FALSE/>, if no default data is available for the tree
+ */
+ virtual sal_Bool fetchDefaultData(configuration::AbsolutePath const& aSubtreePath,
+ const vos::ORef < OOptions >& _xOptions,
+ sal_Int16 nMinLevels) throw (uno::Exception) = 0;
+
+ };
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace configmgr
+
+#endif
+
diff --git a/configmgr/source/inc/filehelper.hxx b/configmgr/source/inc/filehelper.hxx
index 4491af9af990..c50037fbb8bd 100644
--- a/configmgr/source/inc/filehelper.hxx
+++ b/configmgr/source/inc/filehelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: filehelper.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dg $ $Date: 2001-09-18 19:11:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -112,9 +112,9 @@ namespace configmgr
*/
bool mkdirs(rtl::OUString const& _aDirectory);
- /** replaces a file specified by _aFromURL with a file specified by _aToURL.
+ /** replaces a file specified by _aToURL with a file specified by _aFromURL.
*/
- void replaceFile(const rtl::OUString& _aFromURL, const rtl::OUString &_aToURL) throw (io::IOException);
+ void replaceFile(const rtl::OUString& _aToURL, const rtl::OUString &_aFromURL) throw (io::IOException);
/** removes a file specified by _aURL. Ignores the case of a non-existing file.
*/
diff --git a/configmgr/source/inc/mergechange.hxx b/configmgr/source/inc/mergechange.hxx
index f1b641adede4..76fb1b9519f1 100644
--- a/configmgr/source/inc/mergechange.hxx
+++ b/configmgr/source/inc/mergechange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dg $ $Date: 2001-09-18 19:11:44 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,7 +92,6 @@ namespace configmgr
// start function, with the Change we want to do.
// WARNING this could be a big tree, because a change can contain subtreechanges!
void mergeChanges(TreeChangeList const&_rList);
-
private:
void initRoot(TreeChangeList const& _aChanges);
@@ -135,6 +134,32 @@ namespace configmgr
virtual void handle(SubtreeChange const& _rSubtree);
};
+
+ // -----------------------------------------------------------------------------
+ class OStripDefaults : private ChangeTreeModification
+ {
+ SubtreeChange& m_rParent;
+ public:
+ OStripDefaults(SubtreeChange& _rSubtree) : m_rParent(_rSubtree) {}
+
+ bool isEmpty() const { return m_rParent.size() == 0; }
+
+ OStripDefaults& strip();
+
+ static bool strip(SubtreeChange& _rSubtree)
+ {
+ return OStripDefaults(_rSubtree).strip().isEmpty();
+ }
+ private:
+ void stripOne(Change& _rChange);
+
+ virtual void handle(ValueChange& _rValueNode);
+ virtual void handle(AddNode& _rAddNode);
+ virtual void handle(RemoveNode& _rRemoveNode);
+ virtual void handle(SubtreeChange& _rSubtree);
+ };
+
+ // -----------------------------------------------------------------------------
} // namespace configmgr
#endif
diff --git a/configmgr/source/inc/nodechange.hxx b/configmgr/source/inc/nodechange.hxx
index 118ee1d69a29..8235f03f406e 100644
--- a/configmgr/source/inc/nodechange.hxx
+++ b/configmgr/source/inc/nodechange.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechange.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:26:39 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -113,8 +113,8 @@ namespace configmgr
bool maybeChange() const;
/// checks, if this represents an actual change (PRE: must be tested)
bool isChange() const;
- /// retrieve information about the changed data
- bool getChangeInfo(NodeChangeInformation& rInfo) const;
+ /// retrieve information about the changed data, appending to a sequence, returning the count
+ sal_uInt32 getChangeInfos(NodeChangesInformation& rInfo) const;
/// retrieve information about what node is changed
bool getChangeLocation(NodeChangeLocation& rLoc) const;
@@ -173,8 +173,8 @@ namespace configmgr
/// retrieves the total count of changes in this collection
ChangesList::size_type getCount() const { return m_aChanges.size(); }
- /// retrieve information about the changed data
- bool getChangesInfo(NodeChangesInformation& rInfos) const;
+ /// retrieve information about the changed data, appending to a sequence, returning the count
+ sal_uInt32 getChangesInfos(NodeChangesInformation& rInfos) const;
/// test all changes
NodeChanges& test() { implTest(); return *this; }
@@ -188,10 +188,13 @@ namespace configmgr
NodeChanges& compact();
/** insert a change into this collection
- <p>if there is an existing change for this element, they are combine using <method>NodeChange::combine</method>
*/
void add(NodeChange const& aChange);
+ /** insert changes into this collection
+ */
+ void add(NodeChanges const& aChanges);
+
/// returns an STL-style iterator to the first element of the collection
Iterator begin() const { return m_aChanges.begin(); }
MutatingIterator begin() { return m_aChanges.begin(); }
diff --git a/configmgr/source/inc/nodechangeinfo.hxx b/configmgr/source/inc/nodechangeinfo.hxx
index f1be264a8507..f42cbc024aa5 100644
--- a/configmgr/source/inc/nodechangeinfo.hxx
+++ b/configmgr/source/inc/nodechangeinfo.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeinfo.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:26:39 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -128,7 +128,9 @@ namespace configmgr
eReplaceElement,
eRemoveElement,
- eRenameElementTree // not fully supported yet
+ eRenameElementTree, // not fully supported yet
+
+ eResetSetDefault
};
//-------------------------------------------------
diff --git a/configmgr/source/inc/noderef.hxx b/configmgr/source/inc/noderef.hxx
index 2d0d01880a8d..49c253f028d8 100644
--- a/configmgr/source/inc/noderef.hxx
+++ b/configmgr/source/inc/noderef.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: noderef.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -336,26 +336,32 @@ namespace configmgr
UnoAny getNodeValue(ValueRef const& aNode) const; // only works for value nodes
// default value handling
- /// ensure default values are available for nodes where they can be provided at all
- void ensureDefaults() const;
+ /// checks whether <var>aNode</var> has a default value
+ bool hasNodeDefault(ValueRef const& aNode) const; // only works for value nodes
/// checks whether <var>aNode</var> assumes its default value
bool isNodeDefault(ValueRef const& aNode) const; // only works for value nodes
+ /// checks whether <var>aNode</var> has a default state
+ bool hasNodeDefault(NodeRef const& aNode) const;
+
+ /// checks whether <var>aNode</var> assumes its default state
+ bool isNodeDefault(NodeRef const& aNode) const;
+
+ /// checks whether <var>aNode</var> has a default state
+ bool hasNodeDefault(AnyNodeRef const& aNode) const;
+
/// checks whether <var>aNode</var> assumes its default state
bool isNodeDefault(AnyNodeRef const& aNode) const;
- /** retrieves the default value for <var>aNode</var>, provided there is one and it
- is available.
- <p>call <method>Tree::ensureDefaults</method> first to achieve best results</p>
- */
- UnoAny getNodeDefault(ValueRef const& aNode) const; // only works for value nodes
+ /// checks whether the default values are available for the children of <var>aNode</var> (if applicable)
+ bool areValueDefaultsAvailable(NodeRef const& aNode) const;
/** retrieves the default value for <var>aNode</var>, provided there is one and it
is available.
<p>call <method>Tree::ensureDefaults</method> first to achieve best results</p>
*/
- UnoAny getNodeDefault(AnyNodeRef const& aNode) const;
+ UnoAny getNodeDefaultValue(ValueRef const& aNode) const; // only works for value nodes
// Tree context handling
public:
diff --git a/configmgr/source/inc/treeactions.hxx b/configmgr/source/inc/treeactions.hxx
index 064d615e9ad4..d62cb4cd5d9b 100644
--- a/configmgr/source/inc/treeactions.hxx
+++ b/configmgr/source/inc/treeactions.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeactions.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:25:26 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -180,7 +180,7 @@ public:
private:
// ensuring the correct state
- void ensure();
+ bool checkTree() const;
};
//==========================================================================
diff --git a/configmgr/source/inc/treechangefactory.hxx b/configmgr/source/inc/treechangefactory.hxx
index bb9714583d76..4e6b84be56f3 100644
--- a/configmgr/source/inc/treechangefactory.hxx
+++ b/configmgr/source/inc/treechangefactory.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treechangefactory.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-07-16 17:02:18 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,14 +85,22 @@ namespace configmgr
class OTreeChangeFactory
{
public:
- typedef configuration::Name Name;
+ typedef rtl::OUString Name;
public:
//= ValueChanges ============================================================
std::auto_ptr<ValueChange> createValueChange(
Name const& _aName,
+ configuration::Attributes _aAttrs,
+ ValueChange::Mode _eMode,
uno::Any const& _aNewValue,
+ uno::Any _aOldValue = uno::Any()
+ );
+
+ //-----------------------------------------------
+ std::auto_ptr<ValueChange> createValueChange(
+ Name const& _aName,
configuration::Attributes _aAttrs,
- ValueChange::Mode _eMode = ValueChange::changeValue,
+ uno::Any const& _aNewValue,
uno::Any _aOldValue = uno::Any()
);
@@ -111,29 +119,33 @@ namespace configmgr
//= SubtreeChanges ============================================================
std::auto_ptr<SubtreeChange> createGroupNodeChange(
Name const& _aName,
- configuration::Attributes _aAttrs);
+ configuration::Attributes _aAttrs,
+ bool _bToDefault = false);
//-----------------------------------------------
std::auto_ptr<SubtreeChange> createSetNodeChange(
Name const& _aName,
Name const& _aTemplateName,
Name const& _aTemplateModule,
- configuration::Attributes _aAttrs);
+ configuration::Attributes _aAttrs,
+ bool _bToDefault = false);
//-----------------------------------------------
//= Set Changes ============================================================
std::auto_ptr<AddNode> createAddNodeChange(
std::auto_ptr<INode> _aNewNode,
- Name const& _aName);
+ Name const& _aName,
+ bool _bToDefault = false);
//-----------------------------------------------
std::auto_ptr<RemoveNode> createRemoveNodeChange(
- Name const& _aName);
+ Name const& _aName,
+ bool _bToDefault = false);
//= special case: Dummy ISubtree ============================================================
static std::auto_ptr<SubtreeChange> createDummyChange(
- Name const& _aName,
- Name const& _aElementTypeName);
+ configuration::Name const& _aName,
+ configuration::Name const& _aElementTypeName);
//-----------------------------------------------
};
diff --git a/configmgr/source/inc/treechangelist.hxx b/configmgr/source/inc/treechangelist.hxx
index 62311af2a0ea..5424a66b284a 100644
--- a/configmgr/source/inc/treechangelist.hxx
+++ b/configmgr/source/inc/treechangelist.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treechangelist.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,6 @@ namespace configmgr
{
////////////////////////////////////////////////////////////////////////////////
- struct Chg {};
//==========================================================================
//= TreeChangeList
@@ -97,18 +96,19 @@ namespace configmgr
typedef configuration::Attributes NodeAttributes;
TreeChangeList(const vos::ORef < OOptions >& _xOptions,
- const AbsolutePath& _rRootPath, Chg,
- const SubtreeChange& _aSubtree)
+ const AbsolutePath& _rRootPath,
+ const SubtreeChange& _aSubtree,
+ SubtreeChange::DeepChildCopy _doDeepCopy)
: m_xOptions(_xOptions),
m_aLocation(_rRootPath),
- root(_aSubtree) /* EXPENSIVE!!! (deep copy) */
+ root(_aSubtree,_doDeepCopy)
{}
/** 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 AbsolutePath& _rRootPath,
const NodeAttributes& _rAttr = NodeAttributes())
: m_xOptions(_xOptions)
, m_aLocation(_rRootPath)
@@ -119,7 +119,7 @@ namespace configmgr
@param _rLocalName relative path within the to-be-updated subtree
*/
TreeChangeList( const vos::ORef < OOptions >& _xOptions,
- const AbsolutePath& _rRootPath, Chg,
+ const AbsolutePath& _rRootPath,
const Name& _rChildTemplateName,
const Name& _rChildTemplateModule,
const NodeAttributes& _rAttr = NodeAttributes())
@@ -127,42 +127,12 @@ namespace configmgr
, 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 AbsolutePath& _rRootPath,
const ISubtree& _rTree)
: m_xOptions(_xOptions)
, m_aLocation(_rRootPath)
@@ -170,6 +140,7 @@ namespace configmgr
{
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
@@ -194,7 +165,7 @@ namespace configmgr
AbsolutePath const& getRootNodePath() const { return m_aLocation; }
/// get the full path to the root (location)
- AbsolutePath getRootContextPath(Chg) const { return m_aLocation.getParentPath(); }
+ AbsolutePath getRootContextPath() const { return m_aLocation.getParentPath(); }
vos::ORef < OOptions > getOptions() const { return m_xOptions; }
diff --git a/configmgr/source/inc/valuenode.hxx b/configmgr/source/inc/valuenode.hxx
index 129a1ffa6fb0..6c402a798481 100644
--- a/configmgr/source/inc/valuenode.hxx
+++ b/configmgr/source/inc/valuenode.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: valuenode.hxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: jb $ $Date: 2001-09-25 16:02:53 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,24 +62,29 @@
#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
#define _CONFIGMGR_TREE_VALUENODE_HXX
-#include <memory>
+#ifndef CONFIGMGR_RTTIMACROS_HXX
#include "rttimacros.hxx"
-#include <rtl/ustring.hxx>
+#endif
+#ifndef CFGMGR_ANYPAIR_HXX
+#include "anypair.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
+#include "configpath.hxx"
+#endif
#ifndef _COM_SUN_STAR_UNO_ANY_H_
#include <com/sun/star/uno/Any.h>
#endif
-#ifndef CONFIGMGR_CONFIGPATH_HXX_
-#include "configpath.hxx"
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
#endif
-#ifndef _UNO_ANY2_H_
-#include <uno/any2.h>
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
#endif
-#include <anypair.hxx>
-
namespace configmgr
{
@@ -90,8 +95,10 @@ namespace configmgr
class ISubtree;
class ValueNode;
+ using rtl::OUString;
+
// helper (tag) class
- namespace treeop { struct NoChildCopy {}; }
+ namespace treeop { struct NoChildCopy {}; struct DeepChildCopy {}; }
//==========================================================================
//= Visitors
//==========================================================================
@@ -115,29 +122,35 @@ namespace configmgr
class INode
{
- rtl::OUString m_aName;
- configuration::Attributes m_aAttributes;
+ OUString m_aName;
+ node::Attributes m_aAttributes;
protected:
INode(){}
+ bool markAsDefault(bool _bDefault = true) { m_aAttributes.bDefaulted = _bDefault;}
public:
- explicit INode(configuration::Attributes);
- INode(rtl::OUString const& aName, configuration::Attributes);
+ explicit
+ INode(node::Attributes);
+ INode(OUString const& aName, node::Attributes);
+
virtual ~INode();
+
virtual INode* clone() const = 0;
+ public:
- const rtl::OUString& getName() const {return m_aName;}
- configuration::Attributes getAttributes() const {return m_aAttributes;}
+ const OUString& getName() const { return m_aName; }
+ node::Attributes getAttributes() const { return m_aAttributes; }
- bool isLocalized() const {return m_aAttributes.bLocalized;}
- bool isReplacing() const {return m_aAttributes.bReplacing;}
+ bool isDefault() const { return m_aAttributes.bDefaulted; }
+ bool isLocalized() const { return m_aAttributes.bLocalized; }
+ bool isReplaced() const { return m_aAttributes.bReplaced; }
void forceWritableToFinalized(); /// make non-writable nodes writable but finalized
- void setName(const rtl::OUString& _rNewName) { m_aName = _rNewName; }
// to be used with caution. If the node is referenced from somewhere else under it's old name,
// you may have problems with this inconsistence
+ void setName(const OUString& _rNewName) { m_aName = _rNewName; }
virtual ValueNode* asValueNode();
virtual ValueNode const* asValueNode() const;
@@ -153,7 +166,7 @@ namespace configmgr
};
-
+#if 0 // for future redesign
//==========================================================================
//= ISubtree
//==========================================================================
@@ -161,8 +174,8 @@ namespace configmgr
class ASubtree : public INode
{
- sal_Int16 m_nLevel; /// determines if everything is read
- ::rtl::OUString m_sId;
+ sal_Int16 m_nLevel; /// determines if everything is read
+ OUString m_sId;
public:
virtual bool isSetNode() const = 0;
@@ -184,17 +197,12 @@ namespace configmgr
//==========================================================================
class SetTree : public ASubtree
{
- ::rtl::OUString m_sTemplateName; /// path of the template for child instantiation
- ::rtl::OUString m_sTemplateModule; /// module of the template for child instantiation
+ OUString m_sTemplateName; /// path of the template for child instantiation
+ OUString m_sTemplateModule; /// module of the template for child instantiation
public:
virtual bool isSetNode() const; // always true!
};
-
-
-
-
-
-
+#endif
// -----------------------------------------------------------------------------
// ----------------------------------- O L D -----------------------------------
@@ -205,12 +213,13 @@ namespace configmgr
//==========================================================================
class ISubtree : public INode
{
- sal_Int16 m_nLevel; /// determines if everything is read
- ::rtl::OUString m_sId;
- ::rtl::OUString m_sTemplateName; /// path of the template for child instantiation
- ::rtl::OUString m_sTemplateModule; /// module of the template for child instantiation
+ sal_Int16 m_nLevel; /// determines if everything is read
+ sal_Int16 m_nDefaultLevels; /// determines if defaults are read
+ OUString m_sId;
+ OUString m_sTemplateName; /// path of the template for child instantiation
+ OUString m_sTemplateModule; /// module of the template for child instantiation
- virtual INode* doGetChild(rtl::OUString const& name) const = 0;
+ virtual INode* doGetChild(OUString const& name) const = 0;
protected:
ISubtree():m_nLevel(0){}
@@ -218,47 +227,52 @@ namespace configmgr
ISubtree(ISubtree const& other)
:INode(other)
,m_nLevel(other.m_nLevel)
+ ,m_nDefaultLevels(other.m_nDefaultLevels)
,m_sTemplateName(other.m_sTemplateName)
,m_sTemplateModule(other.m_sTemplateModule)
,m_sId() // do not copy ID while cloning !
{}
public:
- // subtree does current not support attributes in the right way
- // ISubtree(const configuration::Attributes& _rAttrs) : INode(_rAttrs), m_nLevel(0) {}
-
// Ctor for group trees
- ISubtree(const rtl::OUString& aName, const configuration::Attributes& _rAttrs)
+ ISubtree(const rtl::OUString& aName, const node::Attributes& _rAttrs)
:INode(aName, _rAttrs)
,m_nLevel(0)
+ ,m_nDefaultLevels(0)
{}
// Ctor for set trees
ISubtree(const rtl::OUString& aName,
const rtl::OUString& _rTemplateName,
const rtl::OUString& _rTemplateModule,
- const configuration::Attributes& _rAttrs)
+ const node::Attributes& _rAttrs)
:INode(aName, _rAttrs)
,m_nLevel(0)
+ ,m_nDefaultLevels(0)
,m_sTemplateName(_rTemplateName)
,m_sTemplateModule(_rTemplateModule){}
- bool hasId() const { return m_sId.getLength() != 0; }
- ::rtl::OUString getId() const { return m_sId; }
- void setId(const ::rtl::OUString& _rId) { m_sId = _rId; }
+ bool hasId() const { return m_sId.getLength() != 0; }
+ OUString getId() const { return m_sId; }
+ void setId(const OUString& _rId) { m_sId = _rId; }
- INode* getChild(rtl::OUString const& name) { return doGetChild(name); }
- INode const* getChild(rtl::OUString const& name) const { return doGetChild(name); }
+ INode* getChild(OUString const& name) { return doGetChild(name); }
+ INode const* getChild(OUString const& name) const { return doGetChild(name); }
ISubtree* asISubtree();
ISubtree const* asISubtree() const;
- sal_Int16 getLevel() const {return m_nLevel;}
- void setLevel(sal_Int16);
+ using INode::markAsDefault;
- bool isSetNode() const { return m_sTemplateName.getLength() != 0; }
- ::rtl::OUString getElementTemplateName() const { return m_sTemplateName; }
- ::rtl::OUString getElementTemplateModule() const { return m_sTemplateModule; }
+ sal_Int16 getLevel() const { return m_nLevel; }
+ sal_Int16 getDefaultsLevel() const { return m_nDefaultLevels; }
+
+ void setLevels(sal_Int16 _nLevel,sal_Int16 _nDefaultsLevel);
+
+ bool isSetNode() const { return m_sTemplateName.getLength() != 0; }
+
+ OUString const& getElementTemplateName() const { return m_sTemplateName; }
+ OUString const& getElementTemplateModule() const { return m_sTemplateModule; }
virtual INode* addChild(std::auto_ptr<INode> node) =0; // takes ownership
virtual ::std::auto_ptr<INode> removeChild(rtl::OUString const& name) =0; // releases ownership
@@ -286,42 +300,46 @@ namespace configmgr
// uno::Any m_aDefaultValue;
public:
- ValueNode(){}
+ //ValueNode(){}
- explicit ValueNode(configuration::Attributes _aAttrs):INode(_aAttrs){}
+ //explicit ValueNode(node::Attributes _aAttrs):INode(_aAttrs){}
- ValueNode(rtl::OUString const& aName, configuration::Attributes _aAttrs)
- :INode(aName, _aAttrs)
+ /*
+ ValueNode(OUString const& aName, node::Attributes _aAttrs)
+ : INode(aName, _aAttrs)
+ , m_aValuePair()
{}
- ValueNode(rtl::OUString const& aName,uno::Type const& aType, configuration::Attributes _aAttrs)
- :INode(aName, _aAttrs), m_aValuePair(aType)
- {
- check_init();
- }
- ValueNode(rtl::OUString const& aName,uno::Any const& anAny, configuration::Attributes _aAttrs)
- :INode(aName, _aAttrs), m_aValuePair(anAny)
+ */
+ ValueNode(OUString const& aName,uno::Type const& aType, node::Attributes _aAttrs)
+ : INode(aName, _aAttrs)
+ , m_aValuePair(aType)
+ {
+ }
+ ValueNode(OUString const& aName,uno::Any const& anAny, node::Attributes _aAttrs)
+ : INode(aName, _aAttrs)
+ , m_aValuePair(anAny, selectMember(_aAttrs.bDefaulted))
{
- init();
}
- ValueNode(rtl::OUString const& aName,uno::Any const& anAny,uno::Any const& aDefault, configuration::Attributes _aAttrs)
- :INode(aName, _aAttrs), m_aValuePair(anAny, aDefault)
+ ValueNode(OUString const& aName,uno::Any const& anAny,uno::Any const& aDefault, node::Attributes _aAttrs)
+ : INode(aName, _aAttrs)
+ , m_aValuePair(anAny, aDefault)
{
- init();
}
+ bool isValid() const {return !m_aValuePair.isEmpty();}
- bool isNull() const {return m_aValuePair.isNull();}
- bool hasDefault() const {return getAttributes().bNullable || m_aValuePair.hasSecond();}
- bool isDefault() const {return !m_aValuePair.hasFirst() && hasDefault();}
+ bool isNull() const {return m_aValuePair.isNull();}
+ bool hasDefault() const {return getAttributes().bNullable || m_aValuePair.hasSecond();}
- uno::Type getValueType() const {return m_aValuePair.getValueType();}
- uno::Any getValue() const {return isDefault() ? m_aValuePair.getSecond() : m_aValuePair.getFirst();}
- uno::Any getDefault() const {return m_aValuePair.getSecond();}
+ uno::Type getValueType() const {return m_aValuePair.getValueType();}
+ uno::Any getValue() const {return m_aValuePair.getValue( selectMember(this->isDefault()) );}
+ uno::Any getDefault() const {return m_aValuePair.getSecond();}
void setValue(uno::Any const& _aValue);
- void changeDefault(uno::Any const& _aValue);
void setDefault();
+ void changeDefault(uno::Any const& _aValue);
+
virtual INode* clone() const;
ValueNode* asValueNode();
@@ -333,8 +351,10 @@ namespace configmgr
// "rtti"
RTTI(ValueNode, INode);
private:
- void init();
- void check_init();
+ static AnyPair::SelectMember selectValue() { return AnyPair::SELECT_FIRST; }
+ static AnyPair::SelectMember selectDeflt() { return AnyPair::SELECT_SECOND; }
+ static AnyPair::SelectMember selectMember(bool bDeflt)
+ { return bDeflt ? AnyPair::SELECT_SECOND : AnyPair::SELECT_FIRST; }
};
//==========================================================================
diff --git a/configmgr/source/misc/anypair.cxx b/configmgr/source/misc/anypair.cxx
index ca5ee575895d..a8e11ac86b92 100644
--- a/configmgr/source/misc/anypair.cxx
+++ b/configmgr/source/misc/anypair.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: anypair.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: rt $ $Date: 2001-07-20 14:32:03 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -550,10 +550,28 @@ namespace configmgr
// -----------------------------------------------------------------------------
sal_Bool anypair_assign_second(cfgmgr_AnyPair* _pAnyPair, uno_Any const * _pUnoAny)
{
+ CFG_PRECOND( _pAnyPair != NULL );
+ CFG_PRECOND( _pUnoAny != NULL );
+
return anypair_any_assign_Data(&_pAnyPair->desc, &_pAnyPair->second, cfgmgr_SELECT_SECOND, _pUnoAny);
}
// -----------------------------------------------------------------------------
+ sal_Bool anypair_assign_both(cfgmgr_AnyPair* _pAnyPair, uno_Any const * _pUnoAny)
+ {
+ CFG_PRECOND( _pAnyPair != NULL );
+ CFG_PRECOND( _pUnoAny != NULL );
+
+ sal_Bool bOK = anypair_assign_first(_pAnyPair,_pUnoAny);
+ if (bOK)
+ {
+ // same type - second assignment must succeed as well
+ OSL_VERIFY( anypair_assign_second(_pAnyPair,_pUnoAny) );
+ }
+ return bOK;
+ }
+
+// -----------------------------------------------------------------------------
void anypair_assign(cfgmgr_AnyPair* _pAnyPair, cfgmgr_AnyPair const * _pAnyPairFrom)
{
if (_pAnyPair != _pAnyPairFrom)
@@ -626,9 +644,17 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
- AnyPair::AnyPair(uno::Any const& _aAny) // one any
+ AnyPair::AnyPair(uno::Any const& _aAny, SelectMember _select)
{
- anypair_construct_first(&m_aAnyPair,&_aAny);
+ switch (_select)
+ {
+ case SELECT_FIRST: anypair_construct_first(&m_aAnyPair,&_aAny); break;
+ case SELECT_SECOND: anypair_construct_second(&m_aAnyPair,&_aAny); break;
+ case SELECT_BOTH: OSL_VERIFY( anypair_construct(&m_aAnyPair,&_aAny,&_aAny) ); break;
+
+ default: OSL_ENSURE(false, "AnyPair: Unknown member selector");
+ anypair_construct_default(&m_aAnyPair); break;
+ }
}
// -----------------------------------------------------------------------------
@@ -636,7 +662,7 @@ namespace configmgr
{
if (!anypair_construct(&m_aAnyPair,&_aAny, &_aAny2))
{
- // throw lang::IllegalArgumentException(rtl::OUString::createFromAscii("Types are not equal."));
+ lang::IllegalArgumentException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AnyPair: Type mismatch in constructor.")),NULL,-1);
}
}
@@ -676,6 +702,40 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
+ sal_Bool AnyPair::setValue(uno::Any const& _aAny, SelectMember _select)
+ {
+ switch (_select)
+ {
+ case SELECT_FIRST: return anypair_assign_first (&m_aAnyPair,&_aAny);
+ case SELECT_SECOND: return anypair_assign_second(&m_aAnyPair,&_aAny);
+ case SELECT_BOTH: return anypair_assign_both (&m_aAnyPair,&_aAny);
+
+ default: OSL_ENSURE(false, "AnyPair: Unknown member selector");
+ return false;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ void AnyPair::clear(SelectMember _select)
+ {
+ switch (_select)
+ {
+ case SELECT_FIRST: anypair_clear_first(&m_aAnyPair); break;
+ case SELECT_SECOND: anypair_clear_second(&m_aAnyPair); break;
+ case SELECT_BOTH: anypair_clear_values(&m_aAnyPair); break;
+
+ default: OSL_ENSURE(false, "AnyPair: Unknown member selector");
+ break;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+ uno::Type AnyPair::getValueType() const
+ {
+ return uno::Type(m_aAnyPair.desc.pType);
+ }
+
+// -----------------------------------------------------------------------------
uno::Any AnyPair::getFirst() const
{
return anypair_Data_toAny( &m_aAnyPair.desc, &m_aAnyPair.first, cfgmgr_SELECT_FIRST );
@@ -687,9 +747,17 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
- uno::Type AnyPair::getValueType() const
+ uno::Any AnyPair::getValue(SelectMember _select) const
{
- return uno::Type(m_aAnyPair.desc.pType);
+ switch (_select)
+ {
+ case SELECT_FIRST: return getFirst();
+ case SELECT_SECOND: return getSecond();
+
+ default: OSL_ENSURE(false, "AnyPair: Unknown member selector");
+ case SELECT_BOTH: OSL_ENSURE(false, "AnyPair: Cannot get value - Invalid selector");
+ return uno::Any();
+ }
}
// -----------------------------------------------------------------------------
diff --git a/configmgr/source/misc/filehelper.cxx b/configmgr/source/misc/filehelper.cxx
index 17169761f67f..9b54d91e53aa 100644
--- a/configmgr/source/misc/filehelper.cxx
+++ b/configmgr/source/misc/filehelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: filehelper.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: rt $ $Date: 2001-09-21 13:59:07 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -111,10 +111,10 @@ namespace configmgr
// -----------------------------------------------------------------------------
void FileHelper::replaceFile(
- const rtl::OUString& _aFromURL, const rtl::OUString &_aToURL) throw (io::IOException)
+ const rtl::OUString& _aToURL, const rtl::OUString &_aFromURL) throw (io::IOException)
{
- FileHelper::removeFile(_aFromURL);
- FileBase::RC eError = File::move(_aToURL, _aFromURL);
+ FileHelper::removeFile(_aToURL);
+ FileBase::RC eError = File::move(_aFromURL, _aToURL);
if (eError != osl_File_E_None)
{
rtl::OUString sError = ASCII("createBackupAndRemove: ") + FileHelper::createOSLErrorString(eError) + ASCII("\n with URL: ") + _aFromURL;
diff --git a/configmgr/source/misc/mergechange.cxx b/configmgr/source/misc/mergechange.cxx
index 74a0acd4fe98..a972c27aac7a 100644
--- a/configmgr/source/misc/mergechange.cxx
+++ b/configmgr/source/misc/mergechange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: mergechange.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: dg $ $Date: 2001-09-18 19:12:17 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -157,7 +157,7 @@ namespace configmgr
}
void handleChange(Change &_rNode)
{
- applyToChange(_rNode);
+ this->applyToChange(_rNode);
}
private:
virtual void handle(ValueChange& _rValueChange)
@@ -172,46 +172,57 @@ namespace configmgr
}
virtual void handle(AddNode& _rAddNode)
{
- // POST: Handle ValueChange in AddNode
- INode* pINode = _rAddNode.getAddedNode();
+ if (m_aValueChange.isToDefault())
+ {
+ std::auto_ptr<Change> aChangeToDefault(m_aValueChange.clone());
+ m_rTargetParent.removeChange(_rAddNode.getNodeName());
+ m_rTargetParent.addChange( aChangeToDefault );
+ }
+ else
+ {
+ // POST: Handle ValueChange in AddNode
+ INode* pINode = _rAddNode.getAddedNode();
- if (ValueNode *pValueNode = pINode->asValueNode())
- pValueNode->setValue( m_aValueChange.getNewValue() );
+ if (ValueNode *pValueNode = pINode->asValueNode())
+ {
+ m_aValueChange.applyChangeNoRecover(*pValueNode);
+ }
- else if (ISubtree* pValueSetNode = pINode->asISubtree() )
- {
- if ( isLocalizedValueSet(*pValueSetNode) )
+ else if (ISubtree* pValueSetNode = pINode->asISubtree() )
{
- std::auto_ptr<ValueNode> pNewValueNode = createNodeFromChange(m_aValueChange);
- if (pNewValueNode.get())
+ if ( isLocalizedValueSet(*pValueSetNode) )
{
- OSL_ENSURE(pNewValueNode->isLocalized(), "OMergeValueChange:handle(AddNode): have a non-localized ValueChange a for a localized node!");
+ std::auto_ptr<ValueNode> pNewValueNode = createNodeFromChange(m_aValueChange);
+ if (pNewValueNode.get())
+ {
+ OSL_ENSURE(pNewValueNode->isLocalized(), "OMergeValueChange:handle(AddNode): have a non-localized ValueChange a for a localized node!");
- std::auto_ptr<INode> pNewNode(pNewValueNode.release());
+ std::auto_ptr<INode> pNewNode(pNewValueNode.release());
- std::auto_ptr<AddNode> pNewAdd( new AddNode(pNewNode,m_aValueChange.getNodeName()) );
- if (_rAddNode.isReplacing())
- pNewAdd->setReplacing();
+ std::auto_ptr<AddNode> pNewAdd( new AddNode(pNewNode,m_aValueChange.getNodeName(), m_aValueChange.isToDefault()) );
+ if (_rAddNode.isReplacing())
+ pNewAdd->setReplacing();
+
+ std::auto_ptr<Change> pNewChange( pNewAdd.release() );
+ replaceExistingEntry(pNewChange);
+ }
+ else
+ OSL_ENSURE(false, "OMergeValueChange:handle(SubtreeChange): Creating a NULL node to replace a localized value set not yet supported");
- std::auto_ptr<Change> pNewChange( pNewAdd.release() );
- replaceExistingEntry(pNewChange);
}
else
- OSL_ENSURE(false, "OMergeValueChange:handle(SubtreeChange): Creating a NULL node to replace a localized value set not yet supported");
-
+ OSL_ENSURE(sal_False, "OMergeValueChange:handle(AddNode): have a ValueChange a for non-value node!");
}
else
- OSL_ENSURE(sal_False, "OMergeValueChange:handle(AddNode): have a ValueChange a for non-value node!");
+ OSL_ENSURE(sal_False, "OMergeValueChange:handle(AddNode): Found unknown node type!");
}
- else
- OSL_ENSURE(sal_False, "OMergeValueChange:handle(AddNode): Found unknown node type!");
}
virtual void handle(SubtreeChange& _rSubtree)
{
if ( isLocalizedValueSet(_rSubtree) )
{
std::auto_ptr<ValueChange> pNewValueChange( new ValueChange(m_aValueChange) );
- OSL_ENSURE(pNewValueChange->isLocalized(), "OMergeValueChange:handle(SubtreeChange): have a non-localized ValueChange a for a localized node!");
+ OSL_ENSURE(pNewValueChange->isLocalizedValue(), "OMergeValueChange:handle(SubtreeChange): have a non-localized ValueChange a for a localized node!");
std::auto_ptr<Change> pNewChange( pNewValueChange.release() );
@@ -532,7 +543,7 @@ namespace configmgr
// insert manually
auto_ptr<INode> pNode = auto_ptr<INode>(_rAddNode.getAddedNode()->clone());
- auto_ptr<AddNode> pNewAdd(new AddNode(pNode, _rAddNode.getNodeName()));
+ auto_ptr<AddNode> pNewAdd(new AddNode(pNode, _rAddNode.getNodeName(), _rAddNode.isToDefault()));
if (bReplacing)
pNewAdd->setReplacing();
@@ -567,7 +578,7 @@ namespace configmgr
// defaulting this so that the node will be marked as deleted
case OMergeRemoveNode::FlagDeleted:
{
- auto_ptr<Change> pNewChange(new RemoveNode(_rRemoveNode.getNodeName()));
+ auto_ptr<Change> pNewChange(new RemoveNode(_rRemoveNode.getNodeName(),_rRemoveNode.isToDefault()));
m_pCurrentParent->addChange(pNewChange);
}
break;
@@ -641,24 +652,35 @@ namespace configmgr
else if (pChange->ISA(AddNode))
{
// in this AddNode should be a subtree, NOT a subtreechange
-
AddNode* pAddNode = static_cast<AddNode*>(pChange);
- INode* pNode = pAddNode->getAddedNode();
- ISubtree* pSubtree = pNode ? pNode->asISubtree() : 0;
- if (pSubtree)
+
+ if (_rSubtree.isToDefault())
{
- // pSubtree = pSubtree + _rSubtree;
- AbsolutePath aSubtreePath = this->createPath( ONameCreator::createName(_rSubtree,m_pCurrentParent) );
- OSL_ASSERT( aSubtreePath.getLocalName().getName().toString() == pSubtree->getName() );
+ std::auto_ptr<Change> aChangeToDefault(_rSubtree.clone());
- // Now apply _rSubtree to the subtree
- TreeChangeList aChangeList(m_aTreeChangeList.getOptions(), aSubtreePath, Chg(), _rSubtree); // expensive!
- applyChanges(aChangeList, *pSubtree);
+ m_pCurrentParent->removeChange(pAddNode->getNodeName());
+ m_pCurrentParent->addChange( aChangeToDefault );
}
else
{
- OSL_ENSURE(false, "OMergeTreeChangeList: Unexpected node type found in an AddNode.");
- /* wrong type of node found: bse ASSERTEN/WERFEN */;
+
+ 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.getOptions(), aSubtreePath, _rSubtree, SubtreeChange::DeepChildCopy()); // expensive!
+ applyChanges(aChangeList, *pSubtree);
+ }
+ else
+ {
+ OSL_ENSURE(false, "OMergeTreeChangeList: Unexpected node type found in an AddNode.");
+ /* wrong type of node found: bse ASSERTEN/WERFEN */;
+ }
}
}
else
@@ -675,6 +697,7 @@ namespace configmgr
: m_rSubtreeChange(_rTree), m_pCurrentParent(NULL)
{
}
+ // -----------------------------------------------------------------------------
void OMergeChanges::initRoot(const SubtreeChange &_rRootChange, const RelativePath& _aPathToChange)
{
@@ -840,7 +863,7 @@ namespace configmgr
// insert manually
auto_ptr<INode> pNode = auto_ptr<INode>(_rAddNode.getAddedNode()->clone());
- auto_ptr<AddNode> pNewAdd(new AddNode(pNode, _rAddNode.getNodeName()));
+ auto_ptr<AddNode> pNewAdd(new AddNode(pNode, _rAddNode.getNodeName(), _rAddNode.isToDefault()));
if (bReplacing)
pNewAdd->setReplacing();
@@ -876,7 +899,7 @@ namespace configmgr
// defaulting this so that the node will be marked as deleted
case OMergeRemoveNode::FlagDeleted:
{
- auto_ptr<Change> pNewChange(new RemoveNode(_rRemoveNode.getNodeName()));
+ auto_ptr<Change> pNewChange(new RemoveNode(_rRemoveNode.getNodeName(),_rRemoveNode.isToDefault()));
m_pCurrentParent->addChange(pNewChange);
}
break;
@@ -884,7 +907,53 @@ namespace configmgr
}
// -----------------------------------------------------------------------------
+ inline
+ void OStripDefaults::stripOne(Change& _rChange)
+ {
+ m_rParent.removeChange(_rChange.getNodeName());
+ }
+ void OStripDefaults::handle(ValueChange& _rValueNode)
+ {
+ if (_rValueNode.isToDefault())
+ stripOne(_rValueNode);
+ }
+ void OStripDefaults::handle(AddNode& _rAddNode)
+ {
+ if (_rAddNode.isToDefault())
+ {
+ INode* pAdded = _rAddNode.getAddedNode();
+ OSL_ENSURE(pAdded,"No Data in AddNode");
+ if (pAdded == NULL || pAdded->getAttributes().bDefaulted)
+ stripOne(_rAddNode);
+
+ // else we should strip the defaults from the added node
+ }
+ }
+ void OStripDefaults::handle(RemoveNode& _rRemoveNode)
+ {
+ if (_rRemoveNode.isToDefault())
+ stripOne(_rRemoveNode);
+ }
+ void OStripDefaults::handle(SubtreeChange& _rSubtree)
+ {
+ if ( strip(_rSubtree) )
+ stripOne(_rSubtree);
+ }
+
+ OStripDefaults& OStripDefaults::strip()
+ {
+ typedef SubtreeChange::MutatingChildIterator Iter;
+
+ Iter it = m_rParent.begin_changes(), stop = m_rParent.end_changes();
+
+ while (it != stop)
+ {
+ this->applyToChange(*it++);
+ }
+
+ return *this;
+ }
// -----------------------------------------------------------------------------
@@ -952,6 +1021,8 @@ namespace configmgr
ISubtree* pSubtree = pNode ? pNode->asISubtree() : 0;
if (pSubtree)
{
+ pSubtree->markAsDefault( _rSubtree.isToDefault() );
+
// Now apply _rSubtree to the subtree
TreeUpdater aTreeUpdate(pSubtree);
aTreeUpdate.applyToChildren(_rSubtree);
@@ -1064,7 +1135,11 @@ namespace configmgr
}
#endif
// recurse
- if (m_pCurrentSubtree) _aSubtree.forEachChange(*this);
+ if (m_pCurrentSubtree)
+ {
+ m_pCurrentSubtree->markAsDefault( _aSubtree.isToDefault() );
+ _aSubtree.forEachChange(*this);
+ }
m_pCurrentSubtree = pOldSubtree;
}
diff --git a/configmgr/source/tree/changes.cxx b/configmgr/source/tree/changes.cxx
index 47d422e2d975..121be48b536a 100644
--- a/configmgr/source/tree/changes.cxx
+++ b/configmgr/source/tree/changes.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: changes.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,7 +61,9 @@
#include <stdio.h>
-#include "cmtreemodel.hxx"
+
+#include "change.hxx"
+
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
@@ -72,42 +74,54 @@ using namespace configmgr;
//= ValueChange
//==========================================================================
// -------------------------------------------------------------------------
-ValueChange::ValueChange(OUString const& _rName,Any aNewValue, const configuration::Attributes& _rAttributes, Mode aMode, Any aOldValue)
- : Change(_rName)
+ValueChange::ValueChange(OUString const& _rName,
+ const node::Attributes& _rAttributes,
+ Any aNewValue, Any aOldValue)
+ : Change(_rName,false)
,m_aValue(aNewValue)
,m_aOldValue(aOldValue)
- ,m_eMode(aMode)
,m_aAttributes(_rAttributes)
{
+ m_eMode = _rAttributes.bDefaulted ? wasDefault : changeValue;
+ m_aAttributes.bDefaulted = false;
+}
+// -------------------------------------------------------------------------
+static inline bool isDefaultMode(ValueChange::Mode _eMode)
+{ return (_eMode == ValueChange::setToDefault) || (_eMode == ValueChange::changeDefault); }
+// -------------------------------------------------------------------------
+ValueChange::ValueChange(OUString const& _rName,
+ const node::Attributes& _rAttributes,
+ Mode _eMode,
+ Any aNewValue, Any aOldValue)
+ : Change(_rName, isDefaultMode(_eMode))
+ ,m_aValue(aNewValue)
+ ,m_aOldValue(aOldValue)
+ ,m_eMode(_eMode)
+ ,m_aAttributes(_rAttributes)
+{
+ m_aAttributes.bDefaulted = Change::isToDefault();
}
// -------------------------------------------------------------------------
ValueChange::ValueChange(Any aNewValue, ValueNode const& aOldValue)
- : Change(aOldValue.getName())
+ : Change(aOldValue.getName(),false)
,m_aValue(aNewValue)
,m_aOldValue(aOldValue.getValue())
,m_aAttributes(aOldValue.getAttributes())
{
m_eMode = aOldValue.isDefault() ? wasDefault : changeValue;
+ m_aAttributes.bDefaulted = false;
}
// -------------------------------------------------------------------------
ValueChange::ValueChange(SetToDefault, ValueNode const& aOldValue)
- : Change(aOldValue.getName())
+ : Change(aOldValue.getName(),true)
,m_aValue(aOldValue.getDefault())
,m_aOldValue(aOldValue.getValue())
,m_eMode(setToDefault)
,m_aAttributes(aOldValue.getAttributes())
{
+ m_aAttributes.bDefaulted = true;
}
-// -------------------------------------------------------------------------
-ValueChange::ValueChange(const ValueChange& _rChange)
- :Change(_rChange.getNodeName())
- ,m_aValue(_rChange.getNewValue())
- ,m_aOldValue(_rChange.getOldValue())
- ,m_eMode(_rChange.getMode())
- ,m_aAttributes(_rChange.getAttributes())
-{}
-
// -----------------------------------------------------------------------------
Change* ValueChange::clone() const
{
@@ -219,8 +233,8 @@ void ValueChange::setModeAsString(const ::rtl::OUString& _rMode)
//= AddNode
//==========================================================================
//--------------------------------------------------------------------------
-AddNode::AddNode(std::auto_ptr<INode> aNewNode_, OUString const& _rName)
- :Change(_rName)
+AddNode::AddNode(std::auto_ptr<INode> aNewNode_, OUString const& _rName, bool _bToDefault)
+ :Change(_rName,_bToDefault)
,m_aOwnNewNode(aNewNode_)
,m_aOwnOldNode()
,m_pOldNode(0)
@@ -275,8 +289,8 @@ void AddNode::takeReplacedNode(std::auto_ptr<INode> aNode)
//==========================================================================
//= RemoveNode
//==========================================================================
-RemoveNode::RemoveNode(OUString const& _rName)
- :Change(_rName)
+RemoveNode::RemoveNode(OUString const& _rName, bool _bToDefault)
+ :Change(_rName,_bToDefault)
,m_aOwnOldNode()
,m_pOldNode(0)
{
diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx
index e93355abe106..70818e6bfd88 100644
--- a/configmgr/source/tree/cmtree.cxx
+++ b/configmgr/source/tree/cmtree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtree.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: jb $ $Date: 2001-09-25 16:34:29 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -116,7 +116,7 @@ namespace configmgr
{
// ------------------------ ChildListSet implementations ------------------------
- ChildListSet::ChildListSet(ChildListSet const& aSet)
+ ChildListSet::ChildListSet(ChildListSet const& aSet, treeop::DeepChildCopy)
{
for(ChildList::iterator it = aSet.GetSet().begin();
it != aSet.GetSet().end();
@@ -173,19 +173,27 @@ namespace configmgr
*/
struct OPropagateLevels : public NodeModification
{
- protected:
- sal_Int32 nChildLevel;
public:
- OPropagateLevels(sal_Int32 _nParentLevel)
+ typedef sal_Int16 Level;
+ OPropagateLevels(Level _nParentLevel, Level _nParentDefaultLevel)
+ : m_nLevel ( childLevel(_nParentLevel) )
+ , m_nDefaultLevel ( childLevel(_nParentDefaultLevel) )
{
- nChildLevel = (ITreeProvider::ALL_LEVELS == _nParentLevel) ? ITreeProvider::ALL_LEVELS : _nParentLevel - 1;
}
virtual void handle(ValueNode&) { /* not interested in value nodes */ }
virtual void handle(ISubtree& _rSubtree)
{
- if ((ITreeProvider::ALL_LEVELS == nChildLevel) || nChildLevel > _rSubtree.getLevel())
- _rSubtree.setLevel(nChildLevel);
+ _rSubtree.setLevels(m_nLevel, m_nDefaultLevel);
+ }
+
+ static Level childLevel(Level _nLevel)
+ {
+ OSL_ASSERT(0 > ITreeProvider::ALL_LEVELS);
+ return (_nLevel > 0) ? _nLevel-1 : _nLevel;
}
+ protected:
+ Level m_nLevel;
+ Level m_nDefaultLevel;
};
@@ -194,20 +202,37 @@ namespace configmgr
ISubtree const* ISubtree::asISubtree() const {return this;}
//--------------------------------------------------------------------------
- void ISubtree::setLevel(sal_Int16 _nLevel)
+ static inline bool adjustLevel(sal_Int16& _rLevel, sal_Int16 _nNewLevel)
{
- m_nLevel = _nLevel;
- if (0 == _nLevel)
- // nothing more to do, this means "nothing known about any children"
- return;
-
- // forward the level number to any child subtrees we have
- OPropagateLevels aDeeperInto(_nLevel);
- aDeeperInto.applyToChildren(*this);
+ if (_rLevel == ITreeProvider::ALL_LEVELS) return false;
+ if (_nNewLevel <= _rLevel &&
+ _nNewLevel != ITreeProvider::ALL_LEVELS) return false;
+
+ _rLevel = _nNewLevel;
+ return true;
+ }
+
+ //--------------------------------------------------------------------------
+ void ISubtree::setLevels(sal_Int16 _nLevel, sal_Int16 _nDefaultLevels)
+ {
+ bool bActive = false;
+
+ if (_nLevel && adjustLevel(m_nLevel, _nLevel))
+ bActive = true;
+
+ if (_nDefaultLevels && adjustLevel(m_nDefaultLevels, _nDefaultLevels))
+ bActive = true;
+
+ // forward the level numbers to any child subtrees we have
+ if (bActive)
+ {
+ OPropagateLevels aPropagate(_nLevel,_nDefaultLevels);
+ aPropagate.applyToChildren(*this);
+ }
}
// --------------------------- Subtree implementation ---------------------------
- INode* Subtree::clone() const {return new Subtree(*this);}
+ INode* Subtree::clone() const {return new Subtree(*this, treeop::DeepChildCopy());}
INode* Subtree::doGetChild(OUString const& aName) const
{
@@ -254,79 +279,8 @@ namespace configmgr
}
return aReturn;
}
+// // -------------------------- ValueNode implementation --------------------------
- //==========================================================================
- //= OBuildChangeTree - historic
- //==========================================================================
- /** generates a change tree by comparing two trees
- */
-/* struct OBuildChangeTree : public NodeModification
- {
- protected:
- SubtreeChange& m_rChangeList;
- INode* m_pCacheNode;
-
- public:
- OBuildChangeTree(SubtreeChange& rList, INode* pNode)
- :m_rChangeList(rList)
- ,m_pCacheNode(pNode)
- {
- }
-
- virtual void handle(ValueNode& _nNode)
- {
- OUString aNodeName = _nNode.getName();
- ISubtree* pTree = m_pCacheNode->asISubtree();
- OSL_ENSURE(pTree, "OBuildChangeTree::handle : node must be a inner node!");
- if (pTree)
- {
- INode* pChild = pTree->getChild(aNodeName);
- ValueNode* pValueNode = pChild ? pChild->asValueNode() : NULL;
- OSL_ENSURE(pValueNode, "OBuildChangeTree::handle : node must be a value node!");
-
- // if the values differ add a new change
- if (pValueNode && _nNode.getValue() != pValueNode->getValue())
- {
- ValueChange* pChange = new ValueChange(_nNode.getValue(), *pValueNode);
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
- }
- }
- }
-
- virtual void handle(ISubtree& _rSubtree)
- {
- OUString aNodeName = _rSubtree.getName();
- ISubtree* pTree = m_pCacheNode->asISubtree();
- OSL_ENSURE(pTree, "OBuildChangeTree::handle : node must be a inner node!");
- if (pTree)
- {
- INode* pChild = pTree->getChild(aNodeName);
- // node not in cache, so ignore it
- // later, when we get additions and removements within on transaction, then we have to care about
- if (pChild)
- {
- ISubtree* pSubTree = pChild->asISubtree();
- OSL_ENSURE(pSubTree, "OBuildChangeTree::handle : node must be a inner node!");
- // generate a new change
-
- SubtreeChange* pChange = new SubtreeChange(_rSubtree);
- OBuildChangeTree aNextLevel(*pChange, pSubTree);
- aNextLevel.applyToChildren(_rSubtree);
-
- // now count if there are any changes
- OChangeCounter aCounter;
- pChange->dispatch(aCounter);
-
- if (aCounter.nCount != 0)
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
- else
- delete pChange;
- }
- }
- }
- };
-
-*/
void Subtree::forEachChild(NodeAction& anAction) const {
for(ChildList::const_iterator it = m_aChildren.GetSet().begin();
it != m_aChildren.GetSet().end();
@@ -342,20 +296,10 @@ namespace configmgr
}
// // -------------------------- ValueNode implementation --------------------------
- void ValueNode::check_init() // may throw in the future
- {
- m_aValuePair.check_init();
- }
-
- void ValueNode::init()
- {
- m_aValuePair.init();
- }
-
-
void ValueNode::setValue(Any const& _aValue)
{
m_aValuePair.setFirst(_aValue);
+ this->markAsDefault(false);
}
void ValueNode::changeDefault(Any const& _aValue)
@@ -365,11 +309,10 @@ namespace configmgr
void ValueNode::setDefault()
{
- // PRE: ????
- // POST: isDefault() == true
- // OSL_ENSURE(false, "ValueNode::setDefault(): this isn't really defined yet.");
- // m_aValue = Any();
- // m_pFirst = NULL;
+ OSL_PRECOND( hasDefault(), "No default value to set for value node");
+ m_aValuePair.clear( selectValue() );
+ this->markAsDefault();
+ OSL_POSTCOND( isDefault(), "Could not set value node to default");
}
INode* ValueNode::clone() const
diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx
index 764af77bc229..07d6bdcd8609 100644
--- a/configmgr/source/tree/cmtreemodel.cxx
+++ b/configmgr/source/tree/cmtreemodel.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cmtreemodel.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,7 +99,7 @@ bool isLocalizedValueSet(ISubtree const& _aSubtree)
bool isLocalizedValueSet(SubtreeChange const& _aSubtree)
{
if ( !_aSubtree.isSetNodeChange()) return false;
- if ( !_aSubtree.isLocalized()) return false;
+ if ( !_aSubtree.isLocalizedContainer()) return false;
if ( !_aSubtree.getElementTemplateModule().equals(TEMPLATE_MODULE_LOCALIZED_VALUE) ) return false;
return true;
}
@@ -112,6 +112,7 @@ bool isLocalizedValueSet(SubtreeChange const& _aSubtree)
void Change::swap(Change& aOther)
{
std::swap(m_aName, aOther.m_aName);
+ std::swap(m_bIsToDefault, aOther.m_bIsToDefault);
}
//==========================================================================
@@ -140,7 +141,7 @@ SubtreeChange::~SubtreeChange()
}
// -----------------------------------------------------------------------------
-SubtreeChange::SubtreeChange(const SubtreeChange& _aObj)
+SubtreeChange::SubtreeChange(const SubtreeChange& _aObj, DeepChildCopy)
:Change(_aObj),
m_sTemplateName(_aObj.m_sTemplateName),
m_sTemplateModule(_aObj.m_sTemplateModule),
@@ -159,7 +160,7 @@ SubtreeChange::SubtreeChange(const SubtreeChange& _aObj)
// -----------------------------------------------------------------------------
Change* SubtreeChange::clone() const
{
- return new SubtreeChange(*this);
+ return new SubtreeChange(*this, DeepChildCopy());
}
//--------------------------------------------------------------------------
void SubtreeChange::addChange(std::auto_ptr<Change> aChange)
diff --git a/configmgr/source/tree/subtree.hxx b/configmgr/source/tree/subtree.hxx
index 50f3436ed6ef..b0fad00fc6f0 100644
--- a/configmgr/source/tree/subtree.hxx
+++ b/configmgr/source/tree/subtree.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: subtree.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: avy $ $Date: 2001-08-08 11:23:48 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,13 +90,14 @@ namespace configmgr
class ChildListSet {
ChildList m_aChildList;
+ ChildListSet(ChildListSet const&);
ChildListSet& operator=(ChildListSet const& aSet);
public:
ChildList& GetSet() {return m_aChildList;}
ChildList const& GetSet() const {return m_aChildList;}
ChildListSet() {}
- ChildListSet(ChildListSet const&);
+ ChildListSet(ChildListSet const&, treeop::DeepChildCopy);
~ChildListSet();
};
@@ -123,6 +124,9 @@ namespace configmgr
const configuration::Attributes& _rAttrs)
:ISubtree(_rName, _rTemplateName, _rTemplateModule, _rAttrs){};
+ Subtree(const Subtree& _rOther, treeop::DeepChildCopy _dc)
+ : ISubtree(_rOther), m_aChildren(_rOther.m_aChildren,_dc){}
+
virtual INode* addChild(std::auto_ptr<INode> node); // takes ownership
virtual ::std::auto_ptr<INode> removeChild(OUString const& name);
diff --git a/configmgr/source/tree/treeactions.cxx b/configmgr/source/tree/treeactions.cxx
index 2bb946f119d9..16c6d371599a 100644
--- a/configmgr/source/tree/treeactions.cxx
+++ b/configmgr/source/tree/treeactions.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeactions.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -159,149 +159,156 @@ void OChangeActionCounter::handle(SubtreeChange const& aSubtree)
//==========================================================================
//= OMergeTreeAction
//==========================================================================
-void OMergeTreeAction::ensure()
+bool OMergeTreeAction::checkTree() const
{
// Change a Value
OSL_ENSURE(m_pRefTree,"OMergeTreeAction::handle: Invalid subtree");
// if we don't have a tree or the tree level is 0 we can leave
- if (!m_pRefTree || 0 == m_pRefTree->getLevel())
- return;
+ return m_pRefTree != NULL;
}
//--------------------------------------------------------------------------
void OMergeTreeAction::handle(ValueChange& _rChange)
{
- ensure();
-
- // We need to find the element in the tree
- const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
-
- // We have a node so we can keep the Change and the values do not differ
- if (pChild)
+ if (checkTree())
{
- const ValueNode* pValueNode = pChild ? pChild->asValueNode() : NULL;
- OSL_ENSURE(pValueNode, "OBuildChangeTree::handle : node must be a value node!");
+ // We need to find the element in the tree
+ const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
- if (pValueNode && _rChange.getNewValue() != pValueNode->getValue())
+ // We have a node so we can keep the Change and the values do not differ
+ if (pChild)
{
- ValueChange* pChange = new ValueChange(_rChange);
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ const ValueNode* pValueNode = pChild ? pChild->asValueNode() : NULL;
+ OSL_ENSURE(pValueNode, "OBuildChangeTree::handle : node must be a value node!");
+
+ // DEFAULT-TODO
+ if (pValueNode && _rChange.getNewValue() != pValueNode->getValue())
+ {
+ ValueChange* pChange = new ValueChange(_rChange);
+ m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ }
}
- }
- else
- {
- std::auto_ptr<ValueNode> pNode = ONodeConverter::createCorrespondingNode(_rChange,m_rNodeFactory);
+ else
+ {
+ std::auto_ptr<ValueNode> pNode = ONodeConverter::createCorrespondingNode(_rChange,m_rNodeFactory);
- // add the tree to the change list
- AddNode* pChange = new AddNode( base_ptr(pNode),_rChange.getNodeName());
- m_rChangeList.addChange(std::auto_ptr<Change>(pChange));
+ // add the tree to the change list
+ AddNode* pChange = new AddNode( base_ptr(pNode),_rChange.getNodeName(), _rChange.isToDefault());
+ m_rChangeList.addChange(std::auto_ptr<Change>(pChange));
+ }
}
}
//--------------------------------------------------------------------------
void OMergeTreeAction::handle(SubtreeChange& _rChange)
{
- ensure();
-
- // We need to find the element in the tree
- const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
-
- // if there is a node we continue
- if (pChild)
+ if (checkTree())
{
- const ISubtree* pSubTree = pChild->asISubtree();
- OSL_ENSURE(pSubTree, "OMergeTreeAction::handle : node must be a inner node!");
+ // We need to find the element in the tree
+ const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
- if (pSubTree)
+ // if there is a node we continue
+ if (pChild)
{
- // generate a new change
- SubtreeChange* pChange = new SubtreeChange(_rChange, SubtreeChange::NoChildCopy());
+ const ISubtree* pSubTree = pChild->asISubtree();
+ OSL_ENSURE(pSubTree, "OMergeTreeAction::handle : node must be a inner node!");
- OMergeTreeAction aNextLevel(*pChange, pSubTree);
- _rChange.forEachChange(aNextLevel);
+ if (pSubTree)
+ {
+ // generate a new change
+ SubtreeChange* pChange = new SubtreeChange(_rChange, SubtreeChange::NoChildCopy());
- // now count if there are any changes
- OChangeActionCounter aCounter;
- aCounter.handle(*pChange);
+ OMergeTreeAction aNextLevel(*pChange, pSubTree);
+ _rChange.forEachChange(aNextLevel);
- if (aCounter.hasChanges())
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ // now count if there are any changes
+ OChangeActionCounter aCounter;
+ aCounter.handle(*pChange);
+
+ if (aCounter.hasChanges())
+ m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ else
+ delete pChange;
+ }
else
- delete pChange;
+ OSL_ENSURE(false, "Inconsistent data: Subtree Change is merged into non-subtree node.");
}
- }
- // otherwise we have to create the node
- else
- {
- std::auto_ptr<ISubtree> pNode = OCreateSubtreeAction::createSubtree(_rChange,m_rNodeFactory);
- OSL_ASSERT(pNode.get() != NULL);
+ // otherwise we have to create the node
+ else
+ {
+ std::auto_ptr<ISubtree> pNode = OCreateSubtreeAction::createSubtree(_rChange,m_rNodeFactory);
+ OSL_ASSERT(pNode.get() != NULL);
- // set the level
- pNode->setLevel(ITreeProvider::ALL_LEVELS);
+ // set the level
+ pNode->setLevels(ITreeProvider::ALL_LEVELS,ITreeProvider::ALL_LEVELS);
- // add the tree to the change list
- std::auto_ptr<Change> pChange( new AddNode(base_ptr(pNode),_rChange.getNodeName()) );
- m_rChangeList.addChange( pChange );
+ // add the tree to the change list
+ std::auto_ptr<Change> pChange( new AddNode(base_ptr(pNode),_rChange.getNodeName(), _rChange.isToDefault()) );
+ m_rChangeList.addChange( pChange );
+ }
}
}
//--------------------------------------------------------------------------
void OMergeTreeAction::handle(RemoveNode& _rChange)
{
- ensure();
-
- // We need to find the element in the tree
- const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
-
- // only if there is a node, we will keep the change
- if (pChild)
+ if (checkTree())
{
- // generate a new change
- RemoveNode* pChange = new RemoveNode(_rChange.getNodeName());
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ // We need to find the element in the tree
+ const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
+
+ // only if there is a node, we will keep the change
+ if (pChild)
+ {
+ // generate a new change
+ RemoveNode* pChange = new RemoveNode(_rChange.getNodeName(),_rChange.isToDefault());
+ m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ }
}
}
//--------------------------------------------------------------------------
void OMergeTreeAction::handle(AddNode& _rChange)
{
- ensure();
-
- // We need to find the element in the tree
- const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
-
- // if the node exists, this must be a ValueNode,
- // otherwise we are not able to clone
- if (pChild && pChild->ISA(ValueNode))
+ if (checkTree())
{
- const ValueNode* pValueNode = pChild->asValueNode();
+ // We need to find the element in the tree
+ const INode* pChild = m_pRefTree->getChild(_rChange.getNodeName());
- std::auto_ptr<INode> aNewNode = _rChange.releaseAddedNode();
- OSL_ENSURE(pValueNode && aNewNode.get() && aNewNode.get()->asValueNode(), "OMergeTreeAction::handle : node must be a value node!");
- if (!pValueNode || !aNewNode.get() || !aNewNode.get()->asValueNode())
- return;
-
- ValueNode* pNewValueNode = aNewNode.get()->asValueNode();
- if (pNewValueNode->getValue() != pValueNode->getValue())
+ // if the node exists, this must be a ValueNode,
+ // otherwise we are not able to clone
+ if (pChild && pChild->ISA(ValueNode))
{
- ValueChange* pChange = new ValueChange(_rChange.getNodeName(),
- pNewValueNode->getValue(),
- pNewValueNode->getAttributes(),
- ValueChange::changeValue,
- pValueNode->getValue());
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ // DEFAULT-TODO
+ const ValueNode* pValueNode = pChild->asValueNode();
+
+ std::auto_ptr<INode> aNewNode = _rChange.releaseAddedNode();
+ OSL_ENSURE(pValueNode && aNewNode.get() && aNewNode.get()->asValueNode(), "OMergeTreeAction::handle : node must be a value node!");
+ if (!pValueNode || !aNewNode.get() || !aNewNode.get()->asValueNode())
+ return;
+
+ ValueNode* pNewValueNode = aNewNode.get()->asValueNode();
+ if (pNewValueNode->getValue() != pValueNode->getValue())
+ {
+ ValueChange* pChange = new ValueChange(_rChange.getNodeName(),
+ pNewValueNode->getAttributes(),
+ pNewValueNode->isDefault() ? ValueChange::setToDefault : ValueChange::changeValue,
+ pNewValueNode->getValue(),
+ pValueNode->getValue());
+ m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
+ }
}
- }
- else
- {
- std::auto_ptr<INode> aNewNode = _rChange.releaseAddedNode();
- AddNode* pChange = new AddNode(aNewNode,_rChange.getNodeName());
- if (pChild != NULL)
+ else
{
- pChange->setReplacing();
+ std::auto_ptr<INode> aNewNode = _rChange.releaseAddedNode();
+ AddNode* pChange = new AddNode(aNewNode,_rChange.getNodeName(),_rChange.isToDefault());
+ if (pChild != NULL)
+ {
+ pChange->setReplacing();
+ }
+ m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
}
- m_rChangeList.addChange(::std::auto_ptr<Change>(pChange));
}
}
@@ -353,14 +360,23 @@ std::auto_ptr<ISubtree> ONodeConverter::createCorrespondingNode(SubtreeChange c
//--------------------------------------------------------------------------
std::auto_ptr<ValueNode> ONodeConverter::createCorrespondingNode(ValueChange const& _rChange, OTreeNodeFactory& _rFactory)
{
- OSL_ENSURE(_rChange.getNewValue().hasValue(), "Losing type information converting change to value");
+ // DEFAULT-TODO
+ OSL_ENSURE(_rChange.getNewValue().hasValue() || _rChange.getOldValue().hasValue(), "Losing type information converting change to value");
+
+ std::auto_ptr<ValueNode> aRet;
+ if (_rChange.getNewValue().hasValue())
+ aRet = _rFactory.createValueNode(_rChange.getNodeName(), _rChange.getNewValue(), _rChange.getAttributes());
+
+ else
+ aRet = _rFactory.createNullValueNode(_rChange.getNodeName(), _rChange.getOldValue().getValueType(), _rChange.getAttributes());
+
+ OSL_ENSURE(aRet.get() && aRet->isValid(), "Could not create corresponding value node");
- std::auto_ptr<ValueNode> aRet = _rFactory.createValueNode(_rChange.getNodeName(), _rChange.getNewValue(), _rChange.getAttributes());
return aRet;
}
//--------------------------------------------------------------------------
-std::auto_ptr<INode>ONodeConverter::extractCorrespondingNode(AddNode& _rChange)
+std::auto_ptr<INode> ONodeConverter::extractCorrespondingNode(AddNode& _rChange)
{
std::auto_ptr<INode> aRet = _rChange.releaseAddedNode();
return aRet;
@@ -543,6 +559,9 @@ void OCreateSubtreeAction::handle(AddNode& _rChange)
aLog.push_back(aStr);
#endif
+ if (m_pCurrentSubtree)
+ m_pCurrentSubtree->markAsDefault( aSubtree.isToDefault() );
+
aSubtree.forEachChange(*this);
m_pCurrentSubtree = pOldSubtree;
}
diff --git a/configmgr/source/tree/treechangefactory.cxx b/configmgr/source/tree/treechangefactory.cxx
index 24a4d7d933fc..7d4c8c6c50db 100644
--- a/configmgr/source/tree/treechangefactory.cxx
+++ b/configmgr/source/tree/treechangefactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treechangefactory.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2001-07-16 17:02:18 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,13 +109,24 @@ OTreeChangeFactory& getDefaultTreeChangeFactory()
//= ValueNodes ============================================================
std::auto_ptr<ValueChange> OTreeChangeFactory::createValueChange(
Name const& _aName,
- uno::Any const& _aNewValue,
configuration::Attributes _aAttrs,
ValueChange::Mode _eMode,
+ uno::Any const& _aNewValue,
+ uno::Any _aOldValue
+ )
+{
+ return std::auto_ptr<ValueChange>(new ValueChange(_aName,_aAttrs,_eMode,_aNewValue,_aOldValue));
+}
+
+//-----------------------------------------------
+std::auto_ptr<ValueChange> OTreeChangeFactory::createValueChange(
+ Name const& _aName,
+ configuration::Attributes _aAttrs,
+ uno::Any const& _aNewValue,
uno::Any _aOldValue
)
{
- return std::auto_ptr<ValueChange>(new ValueChange(_aName.toString(),_aNewValue,_aAttrs,_eMode,_aOldValue));
+ return std::auto_ptr<ValueChange>(new ValueChange(_aName,_aAttrs,_aNewValue,_aOldValue));
}
//-----------------------------------------------
@@ -138,8 +149,8 @@ std::auto_ptr<ValueChange> OTreeChangeFactory::createValueChange(
//= SubtreeChanges ============================================================
std::auto_ptr<SubtreeChange> OTreeChangeFactory::createDummyChange(
- Name const& _aName,
- Name const& _aElementTypeName)
+ configuration::Name const& _aName,
+ configuration::Name const& _aElementTypeName)
{
std::auto_ptr<SubtreeChange> pResult;
@@ -160,9 +171,10 @@ std::auto_ptr<SubtreeChange> OTreeChangeFactory::createDummyChange(
//-----------------------------------------------
std::auto_ptr<SubtreeChange> OTreeChangeFactory::createGroupNodeChange(
Name const& _aName,
- configuration::Attributes _aAttrs)
+ configuration::Attributes _aAttrs,
+ bool _bToDefault)
{
- return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName.toString(),_aAttrs));
+ return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName,_aAttrs,_bToDefault));
}
//-----------------------------------------------
@@ -170,28 +182,31 @@ std::auto_ptr<SubtreeChange> OTreeChangeFactory::createSetNodeChange(
Name const& _aName,
Name const& _aTemplateName,
Name const& _aTemplateModule,
- configuration::Attributes _aAttrs)
+ configuration::Attributes _aAttrs,
+ bool _bToDefault)
{
- return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName.toString(),
- _aTemplateName.toString(),
- _aTemplateModule.toString(),
- _aAttrs));
+ return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName,
+ _aTemplateName,
+ _aTemplateModule,
+ _aAttrs,_bToDefault));
}
//-----------------------------------------------
//= Set Changes ============================================================
std::auto_ptr<AddNode> OTreeChangeFactory::createAddNodeChange(
std::auto_ptr<INode> _aNewNode,
- Name const& _aName)
+ Name const& _aName,
+ bool _bToDefault)
{
- return std::auto_ptr<AddNode>(new AddNode(_aNewNode,_aName.toString()));
+ return std::auto_ptr<AddNode>(new AddNode(_aNewNode,_aName,_bToDefault));
}
//-----------------------------------------------
std::auto_ptr<RemoveNode> OTreeChangeFactory::createRemoveNodeChange(
- Name const& _aName)
+ Name const& _aName,
+ bool _bToDefault)
{
- return std::auto_ptr<RemoveNode>(new RemoveNode(_aName.toString()));
+ return std::auto_ptr<RemoveNode>(new RemoveNode(_aName,_bToDefault));
}
//-----------------------------------------------
diff --git a/configmgr/source/treecache/invalidatetree.cxx b/configmgr/source/treecache/invalidatetree.cxx
index b7912449c283..091e3c758f05 100644
--- a/configmgr/source/treecache/invalidatetree.cxx
+++ b/configmgr/source/treecache/invalidatetree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: invalidatetree.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:50 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -198,14 +198,14 @@ namespace configmgr
// Subtree not in Cache, add in TreeChangeList
// SubtreeChange* pChange = new SubtreeChange(_rSubtree);
INode *pSubtree = _rSubtree.clone();
- auto_ptr<Change> pAdd(new AddNode(auto_ptr<INode>(pSubtree), aNodeName));
+ auto_ptr<Change> pAdd(new AddNode(auto_ptr<INode>(pSubtree), aNodeName, _rSubtree.isDefault()));
m_rChangeList.addChange(::std::auto_ptr<Change>(pAdd));
}
else
{
// Remove Node
- auto_ptr<Change> pRemove(new RemoveNode(aNodeName));
+ auto_ptr<Change> pRemove(new RemoveNode(aNodeName,false));
m_rChangeList.addChange(::std::auto_ptr<Change>(pRemove));
}
}
@@ -222,7 +222,7 @@ auto_ptr<TreeChangeList> createDiffs(ISubtree* _pCachedTree, ISubtree * _pLoaded
// Create a TreeChangeList with the right name, parentname and ConfigurationProperties
std::auto_ptr<TreeChangeList> aNewChangeList(
- new TreeChangeList(_rOptions, _aAbsoluteSubtreePath,Chg()) );
+ new TreeChangeList(_rOptions, _aAbsoluteSubtreePath) );
// create the differences
OBuildChangeTree aNewChangeTree(aNewChangeList.get()->root, _pCachedTree, 1);
@@ -350,7 +350,7 @@ void TreeManager::refreshSubtree(const AbsolutePath &_aAbsoluteSubtreePath, cons
TreeInfo* pTreeInfo = this->requestTreeInfo(_aOptions, false);
if (pTreeInfo != NULL)
{
- ISubtree* pCachedTree = pTreeInfo->acquireSubtreeWithDepth(_aAbsoluteSubtreePath, 0);
+ ISubtree* pCachedTree = pTreeInfo->acquireSubtreeWithDepth(_aAbsoluteSubtreePath, 0, 0);
if (pCachedTree != NULL)
{
auto_ptr<TreeChangeList> aTreeChanges( createDiffs(pCachedTree, aLoadedSubtree.get(), _aOptions, _aAbsoluteSubtreePath) );
diff --git a/configmgr/source/treemgr/configdefaultprovider.cxx b/configmgr/source/treemgr/configdefaultprovider.cxx
new file mode 100644
index 000000000000..4e5cdd28dd89
--- /dev/null
+++ b/configmgr/source/treemgr/configdefaultprovider.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: configdefaultprovider.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "configdefaultprovider.hxx"
+
+#ifndef CONFIGMGR_DEFAULTPROVIDER_PROXY_HXX_
+#include "defaultproviderproxy.hxx"
+#endif
+
+#ifndef CONFIGMGR_CONFIGNODE_HXX_
+#include "noderef.hxx"
+#endif
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
+#include "valuenode.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_
+#include "treeimpl.hxx"
+#endif
+
+namespace configmgr
+{
+//-----------------------------------------------------------------------------
+ namespace configuration
+ {
+//-----------------------------------------------------------------------------
+// class DefaultProvider
+//-----------------------------------------------------------------------------
+
+// standard c/d-tors to make compiler barrier
+DefaultProvider DefaultProvider::createEmpty()
+{
+ return DefaultProvider(NULL);
+}
+//-----------------------------------------------------------------------------
+
+DefaultProvider DefaultProvider::create(Tree const& _aRootTree, vos::ORef<OOptions> const& _xOptions,
+ IDefaultProvider* _pDefaultProvider,
+ IDefaultableTreeManager* _pFetchProvider)
+{
+ OSL_PRECOND( !_aRootTree.isEmpty(), "ERROR: Cannot create DefaultProvider for NULL tree");
+
+ rtl::Reference< DefaultProviderProxy > xNewProxy;
+
+ if (!_aRootTree.isEmpty())
+ {
+ TreeDepth nDepth = TreeImplHelper::impl(_aRootTree)->getAvailableDepth();
+
+ xNewProxy = new DefaultProviderProxy(_pDefaultProvider, _pFetchProvider,
+ _aRootTree.getRootPath(), _xOptions, nDepth );
+ }
+
+ return DefaultProvider( xNewProxy );
+}
+//-----------------------------------------------------------------------------
+
+DefaultProvider::DefaultProvider(DefaultProvider const& _aOther)
+: m_aProxy(_aOther.m_aProxy)
+{
+}
+//-----------------------------------------------------------------------------
+
+DefaultProvider& DefaultProvider::operator=(DefaultProvider const& _aOther)
+{
+ m_aProxy = _aOther.m_aProxy;
+ return *this;
+}
+//-----------------------------------------------------------------------------
+
+DefaultProvider::~DefaultProvider()
+{
+}
+//-----------------------------------------------------------------------------
+
+DefaultProvider::DefaultProvider(rtl::Reference< DefaultProviderProxy > const& _xProviderProxy)
+: m_aProxy(_xProviderProxy)
+{
+}
+//-----------------------------------------------------------------------------
+
+/// tries to load default data into the specified tree
+bool DefaultProvider::fetchDefaultData(Tree const& _aTree) const SAL_THROW((uno::Exception))
+{
+ node::Attributes aAttributes = _aTree.getAttributes(_aTree.getRootNode());
+
+ if (aAttributes.bDefaulted) return true;
+
+ // in replaced/added parts, defaults are considered non-existing
+ if (aAttributes.bReplaced) return false;
+
+ if (!m_aProxy.is()) return false;
+
+ return m_aProxy->fetchDefaultData(_aTree.getRootPath());
+}
+//-----------------------------------------------------------------------------
+
+/// tries to load a default instance of the specified node
+std::auto_ptr<ISubtree> DefaultProvider::getDefaultTree(Tree const& _aTree, NodeRef const& _aNode) const SAL_THROW((uno::Exception))
+{
+ std::auto_ptr<ISubtree> aRet;
+
+ node::Attributes aAttributes = _aTree.getAttributes(_aNode);
+
+// if (aAttributes.bDefaulted)
+// clone the ISubtree (no interface for that) :-(
+
+ if (m_aProxy.is() && !aAttributes.bReplaced)
+ {
+ aRet = m_aProxy->getDefaultTree(_aTree.getAbsolutePath(_aNode));
+ }
+
+ return aRet;
+}
+
+//-----------------------------------------------------------------------------
+ }
+}
+
diff --git a/configmgr/source/treemgr/configgroup.cxx b/configmgr/source/treemgr/configgroup.cxx
index 108fd1285ed0..44cd326e9b58 100644
--- a/configmgr/source/treemgr/configgroup.cxx
+++ b/configmgr/source/treemgr/configgroup.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configgroup.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:34:36 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,15 +60,35 @@
************************************************************************/
#include "configgroup.hxx"
+
+#ifndef CONFIGMGR_CONFIGSET_HXX_
+#include "configset.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGVALUEREF_HXX_
#include "valueref.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGANYNODE_HXX_
#include "anynoderef.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGE_HXX_
#include "nodechange.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEIMPL_HXX_
#include "nodechangeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_
#include "treeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_GROUPNODEBEHAVIOR_HXX_
#include "groupnodeimpl.hxx"
+#endif
+#ifndef _CONFIGMGR_TRACER_HXX_
#include "tracer.hxx"
+#endif
+#ifndef CONFIGMGR_VALUENODEBEHAVIOR_HXX_
#include "valuenodeimpl.hxx"
+#endif
#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_
#include <com/sun/star/script/XTypeConverter.hpp>
@@ -80,22 +100,49 @@ namespace configmgr
{
//-----------------------------------------------------------------------------
-// class GroupUpdater
+// class GroupUpdateHelper
//-----------------------------------------------------------------------------
-GroupUpdater::GroupUpdater(Tree const& aParentTree, NodeRef const& aGroupNode, UnoTypeConverter const& xConverter)
+GroupUpdateHelper::GroupUpdateHelper(Tree const& aParentTree, NodeRef const& aGroupNode)
: m_aTree(aParentTree)
, m_aNode(aGroupNode)
-, m_xTypeConverter(xConverter)
{
- implValidateGroup(m_aTree,m_aNode);
+ implValidateTree(m_aTree);
+ implValidateNode(m_aTree,m_aNode);
if (!TreeImplHelper::isGroup(m_aNode))
throw Exception("INTERNAL ERROR: Group Member Update: node is not a group");
}
//-----------------------------------------------------------------------------
-void GroupUpdater::implValidateNode(Tree const& aTree, ValueRef const& aNode) const
+void GroupUpdateHelper::implValidateTree(Tree const& aTree) const
+{
+ if (aTree.isEmpty())
+ throw Exception("INTERNAL ERROR: Group Member Update: Unexpected NULL tree");
+
+ // check for proper nesting
+ TreeHolder const aParentTree = TreeImplHelper::impl(m_aTree);
+ for(TreeHolder aTestTree = TreeImplHelper::impl(aTree);
+ aTestTree != aParentTree; // search this as ancestor tree
+ aTestTree = aTestTree->getContextTree() )
+ {
+ if (!aTestTree.isValid()) // no more trees to look for
+ throw Exception("INTERNAL ERROR: Group Member Update: improper tree relationship");
+ }
+}
+//-----------------------------------------------------------------------------
+
+void GroupUpdateHelper::implValidateNode(Tree const& aTree, NodeRef const& aNode) const
+{
+ if (!aNode.isValid())
+ throw Exception("INTERNAL ERROR: Group Member Update: Unexpected NULL node");
+
+ if (!aTree.isValidNode(aNode))
+ throw Exception("INTERNAL ERROR: Group Member Update: node does not match tree");
+}
+//-----------------------------------------------------------------------------
+
+void GroupUpdateHelper::implValidateNode(Tree const& aTree, ValueRef const& aNode) const
{
if (!aNode.isValid())
throw Exception("INTERNAL ERROR: Group Member Update: Unexpected NULL node");
@@ -109,6 +156,18 @@ void GroupUpdater::implValidateNode(Tree const& aTree, ValueRef const& aNode) co
}
//-----------------------------------------------------------------------------
+void GroupUpdateHelper::validateNode(ValueRef const& aNode) const
+{
+ implValidateNode(m_aTree,aNode);
+}
+//-----------------------------------------------------------------------------
+
+void GroupUpdateHelper::validateNode(NodeRef const& aNode) const
+{
+ implValidateNode(m_aTree,aNode);
+}
+//-----------------------------------------------------------------------------
+
/** a helper that gets the UNO <type scope='com::sun::star::uno'>Type</type>
for a UNO <type scope='com::sun::star::uno'>Any</type>.
*/
@@ -155,8 +214,17 @@ bool convertCompatibleValue(UnoTypeConverter const& xTypeConverter, uno::Any& rC
return true;
}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+// class GroupUpdater
+//-----------------------------------------------------------------------------
+GroupUpdater::GroupUpdater(Tree const& aParentTree, NodeRef const& aGroupNode, UnoTypeConverter const& xConverter)
+: m_aHelper(aParentTree,aGroupNode)
+, m_xTypeConverter(xConverter)
+{
+}
//-----------------------------------------------------------------------------
UnoAny GroupUpdater::implValidateValue(Tree const& aTree, ValueRef const& aNode, UnoAny const& aValue) const
@@ -198,97 +266,135 @@ UnoAny GroupUpdater::implValidateValue(Tree const& aTree, ValueRef const& aNode,
}
//-----------------------------------------------------------------------------
-void GroupUpdater::implValidateTree(Tree const& aTree) const
+NodeChange GroupUpdater::validateSetValue(ValueRef const& aValueNode, UnoAny const& newValue )
{
- if (aTree.isEmpty())
- throw Exception("INTERNAL ERROR: Group Member Update: Unexpected NULL tree");
+ m_aHelper.validateNode(aValueNode);
- // check for proper nesting
- TreeHolder const aParentTree = TreeImplHelper::impl(m_aTree);
- for(TreeHolder aTestTree = TreeImplHelper::impl(aTree);
- aTestTree != aParentTree; // search this as ancestor tree
- aTestTree = aTestTree->getContextTree() )
+ UnoAny aNewValue = implValidateValue(m_aHelper.tree(), aValueNode, newValue);
+
+ // now build the specific change
+ std::auto_ptr<ValueChangeImpl> pChange( new ValueReplaceImpl(aNewValue) );
+
+ pChange->setTarget(
+ TreeImplHelper::impl(m_aHelper.tree()),
+ TreeImplHelper::parent_offset(aValueNode),
+ m_aHelper.tree().getName(aValueNode)
+ );
+
+ return NodeChange(pChange.release());
+}
+
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// helper class NodeDefaulter
+//-----------------------------------------------------------------------------
+
+namespace
+{
+ struct NodeDefaulter : NodeVisitor
{
- if (!aTestTree.isValid()) // no more trees to look for
- throw Exception("INTERNAL ERROR: Group Member Update: improper tree relationship");
+ GroupDefaulter& updater;
+ NodeChanges result;
+
+ explicit
+ NodeDefaulter(GroupDefaulter& _rUpdater) : updater(_rUpdater), result() {}
+
+ /// do the operation on <var>aNode</var>. needs to be implemented by concrete visitor classes
+ Result handle(Tree const& aTree, NodeRef const& aNode);
+
+ /// do the operation on <var>aValue</var>. needs to be implemented by concrete visitor classes
+ Result handle(Tree const& aTree, ValueRef const& aValue);
+
+ inline void addResult(NodeChange const& aChange)
+ {
+ if (aChange.maybeChange())
+ this->result.add(aChange);
+ }
+ };
+
+ NodeVisitor::Result NodeDefaulter::handle(Tree const& , NodeRef const& aNode)
+ {
+ addResult( updater.validateSetToDefaultState(aNode) );
+ return CONTINUE;
+ }
+
+ NodeVisitor::Result NodeDefaulter::handle(Tree const& , ValueRef const& aValue)
+ {
+ addResult( updater.validateSetToDefaultValue(aValue) );
+ return CONTINUE;
}
}
//-----------------------------------------------------------------------------
-void GroupUpdater::implValidateGroup(Tree const& aTree, NodeRef const& aNode) const
+//-----------------------------------------------------------------------------
+// class GroupDefaulter
+//-----------------------------------------------------------------------------
+
+GroupDefaulter::GroupDefaulter(Tree const& _aParentTree, NodeRef const& _aGroupNode, DefaultProvider const& _aProvider)
+: m_aHelper(_aParentTree,_aGroupNode)
+, m_aDefaultProvider(_aProvider)
+, m_bHasDoneSet(false)
{
- implValidateTree(aTree);
+}
+//-----------------------------------------------------------------------------
- if (!aNode.isValid())
- throw Exception("INTERNAL ERROR: Group Member Update: Unexpected NULL node");
+bool GroupDefaulter::ensureDataAvailable()
+{
+ if ( m_aHelper.tree().areValueDefaultsAvailable(m_aHelper.node()) ) return true;
- if (!aTree.isValidNode(aNode))
- throw Exception("INTERNAL ERROR: Group Member Update: node does not match tree");
+ return m_aDefaultProvider.fetchDefaultData( m_aHelper.tree() );
}
//-----------------------------------------------------------------------------
-NodeChange GroupUpdater::validateSetDefault(ValueRef const& aValueNode)
+NodeChange GroupDefaulter::validateSetToDefaultValue(ValueRef const& aValueNode)
{
- implValidateNode(m_aTree, aValueNode);
-
- if (!m_aTree.getAttributes(aValueNode).bDefaultable)
- throw ConstraintViolation( "Group Member Update: Node may not be default !" );
+ m_aHelper.validateNode(aValueNode);
//if (!TreeImplHelper::member_node(aValueNode).canGetDefaultValue())
// m_aTree.ensureDefaults();
- if (!TreeImplHelper::member_node(aValueNode).canGetDefaultValue())
- throw Exception("INTERNAL ERROR: Group Member Update: default value is not available" );
+ if (!m_aHelper.tree().hasNodeDefault(aValueNode))
+ throw Exception("INTERNAL ERROR: Group Member Update: Node has no default value" );
// now build the specific change
std::auto_ptr<ValueChangeImpl> pChange( new ValueResetImpl() );
- pChange->setTarget(TreeImplHelper::impl(m_aTree), TreeImplHelper::parent_offset(aValueNode), m_aTree.getName(aValueNode));
+ pChange->setTarget(
+ TreeImplHelper::impl(m_aHelper.tree()),
+ TreeImplHelper::parent_offset(aValueNode),
+ m_aHelper.tree().getName(aValueNode)
+ );
return NodeChange(pChange.release());
}
//-----------------------------------------------------------------------------
-NodeChange GroupUpdater::validateSetDefault(AnyNodeRef const& aNode)
+NodeChange GroupDefaulter::validateSetToDefaultState(NodeRef const& aNode)
{
- if ( aNode.isNode() )
- {
- OSL_ENSURE(!m_aTree.getAttributes(aNode).bDefaultable,"Inner Node marked as defaultable");
- throw ConstraintViolation( "Group Member Update: Inner Node may not be set to default !" );
- }
+ m_aHelper.validateNode(aNode);
- return this->validateSetDefault( aNode.toValue() );
-}
-//-----------------------------------------------------------------------------
+ NodeChange aResult;
-NodeChange GroupUpdater::validateSetValue(ValueRef const& aValueNode, UnoAny const& newValue )
-{
- implValidateNode(m_aTree, aValueNode);
- UnoAny aNewValue = implValidateValue(m_aTree, aValueNode, newValue);
-
- // now build the specific change
- std::auto_ptr<ValueChangeImpl> pChange( new ValueReplaceImpl(aNewValue) );
+ // only works for set nodes - groups are left alone
+ if ( TreeImplHelper::isSet(aNode) )
+ {
+ aResult = SetDefaulter( m_aHelper.tree(), aNode, m_aDefaultProvider ).validateSetToDefaultState();
+ }
- pChange->setTarget(TreeImplHelper::impl(m_aTree), TreeImplHelper::parent_offset(aValueNode),m_aTree.getName(aValueNode));
+ m_bHasDoneSet = aResult.maybeChange();
- return NodeChange(pChange.release());
+ return aResult;
}
//-----------------------------------------------------------------------------
-NodeChange GroupUpdater::validateSetDeepValue( Tree const& aNestedTree, ValueRef const& aNestedNode,
- RelativePath const& aRelPath,UnoAny const& newValue)
+NodeChanges GroupDefaulter::validateSetAllToDefault()
{
- implValidateTree(aNestedTree);
- implValidateNode(aNestedTree, aNestedNode);
- UnoAny aNewValue = implValidateValue(aNestedTree, aNestedNode, newValue);
+ NodeDefaulter aDefaulter(*this);
- // now build the specific change
- std::auto_ptr<DeepValueReplaceImpl> pChange( new DeepValueReplaceImpl(aRelPath, aNewValue) );
-
- pChange->setBaseContext(TreeImplHelper::impl(m_aTree), TreeImplHelper::offset(m_aNode));
- pChange->setTarget(TreeImplHelper::impl(aNestedTree), TreeImplHelper::parent_offset(aNestedNode),aNestedTree.getName(aNestedNode));
+ m_aHelper.tree().dispatchToChildren(m_aHelper.node(),aDefaulter);
- return NodeChange(pChange.release());
+ return aDefaulter.result;
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/configset.cxx b/configmgr/source/treemgr/configset.cxx
index ee7b9b360234..d09e0a19a5c2 100644
--- a/configmgr/source/treemgr/configset.cxx
+++ b/configmgr/source/treemgr/configset.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: configset.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: jb $ $Date: 2001-08-06 15:25:20 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,7 +80,12 @@ namespace configmgr
namespace configuration
{
//-----------------------------------------------------------------------------
-
+typedef SetInsertImpl SetInsertTreeImpl;
+typedef SetRemoveImpl SetRemoveTreeImpl;
+typedef SetReplaceImpl SetReplaceTreeImpl;
+typedef SetInsertImpl SetInsertValueImpl;
+typedef SetRemoveImpl SetRemoveValueImpl;
+typedef SetReplaceImpl SetReplaceValueImpl;
//-----------------------------------------------------------------------------
// class ElementRef
//-----------------------------------------------------------------------------
@@ -456,6 +461,16 @@ ValueSetUpdater::ValueSetUpdater(Tree const& aParentTree, NodeRef const& aSetNod
}
//-----------------------------------------------------------------------------
+SetDefaulter::SetDefaulter(Tree const& aParentTree, NodeRef const& aSetNode,
+ DefaultProvider const& aDefaultProvider)
+: m_aParentTree(aParentTree)
+, m_aSetNode(aSetNode)
+, m_aDefaultProvider(aDefaultProvider)
+{
+ implValidateSet();
+}
+//-----------------------------------------------------------------------------
+
/// validates that a actual set and an updater's construction parameters match
static void doValidateSet(Tree const& aParentTree, NodeRef const& aSetNode)
{
@@ -515,6 +530,16 @@ void ValueSetUpdater::implValidateSet()
}
//-----------------------------------------------------------------------------
+/// validates that the actual set and the construction parameters match
+void SetDefaulter::implValidateSet()
+{
+ doValidateSet(m_aParentTree,m_aSetNode);
+
+ if (!m_aDefaultProvider.isValid())
+ throw Exception("INTERNAL ERROR: No default provider available for restoring set default state");
+}
+//-----------------------------------------------------------------------------
+
static void doValidateElement(ElementRef const& aElement)
{
if (!aElement.isValid())
@@ -535,10 +560,12 @@ Path::Component TreeSetUpdater::implValidateElement(ElementRef const& aElement)
{
doValidateElement(aElement);
-// ElementTreeImpl* pElement = TreeImplHelper::elementImpl(aTree)->isTemplateInstance();
-// OSL_ENSURE( pElement, "INTERNAL ERROR: Set Element has wrong type of tree");
-// 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");
+#if 0 // maybe reeanable for DEBUG ?
+ ElementTreeImpl* pElement = TreeImplHelper::elementImpl(aTree)->isTemplateInstance();
+ OSL_ENSURE( pElement, "INTERNAL ERROR: Set Element has wrong type of tree");
+ 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");
+#endif
return aElement.getFullName();
}
@@ -656,7 +683,7 @@ NodeChange TreeSetUpdater::validateInsertElement (Name const& aName, ElementTree
implValidateTree(aNewElement);
- std::auto_ptr<SetChangeImpl> pChange( new SetInsertTreeImpl(aNewElement->makeExtendedName(aName), aNewElement.get()) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetInsertTreeImpl(aNewElement->makeExtendedName(aName), aNewElement.get()) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -674,7 +701,7 @@ NodeChange ValueSetUpdater::validateInsertElement (Name const& aName, UnoAny con
ElementTreeHolder aNewElement = makeValueElement(aName, aValidValue);
- std::auto_ptr<SetChangeImpl> pChange( new SetInsertValueImpl(aNewElement->makeExtendedName(aName), aNewElement) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetInsertValueImpl(aNewElement->makeExtendedName(aName), aNewElement) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -688,7 +715,7 @@ NodeChange TreeSetUpdater::validateReplaceElement(ElementRef const& aElement, El
implValidateTree(aNewElement);
- std::auto_ptr<SetChangeImpl> pChange( new SetReplaceTreeImpl(aName, aNewElement.get()) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetReplaceTreeImpl(aName, aNewElement.get()) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -706,7 +733,7 @@ NodeChange ValueSetUpdater::validateReplaceElement(ElementRef const& aElement, U
ElementTreeHolder aNewElement = makeValueElement(aName.getName(), aElementNode, aValidValue);
- std::auto_ptr<SetChangeImpl> pChange( new SetReplaceValueImpl(aName, aNewElement) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetReplaceValueImpl(aName, aNewElement) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -718,7 +745,7 @@ NodeChange TreeSetUpdater::validateRemoveElement (ElementRef const& aElement)
{
Path::Component aName = implValidateElement(aElement);
- std::auto_ptr<SetChangeImpl> pChange( new SetRemoveTreeImpl(aName) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetRemoveTreeImpl(aName) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -731,7 +758,7 @@ NodeChange ValueSetUpdater::validateRemoveElement (ElementRef const& aElement)
{
Path::Component aName = implValidateElement(aElement);
- std::auto_ptr<SetChangeImpl> pChange( new SetRemoveValueImpl(aName) );
+ std::auto_ptr<SetElementChangeImpl> pChange( new SetRemoveValueImpl(aName) );
pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
@@ -740,6 +767,24 @@ NodeChange ValueSetUpdater::validateRemoveElement (ElementRef const& aElement)
//-----------------------------------------------------------------------------
+NodeChange SetDefaulter::validateSetToDefaultState()
+{
+ std::auto_ptr< ISubtree > aDefault = m_aDefaultProvider.getDefaultTree(m_aParentTree,m_aSetNode);
+
+ // now build the specific change
+ std::auto_ptr<SetChangeImpl> pChange;
+
+ if (aDefault.get())
+ {
+ TemplateProvider aProvider = SetElementFactory::findTemplateProvider(m_aParentTree,m_aSetNode);
+
+ pChange.reset( new SetResetImpl(SetElementFactory(aProvider),aDefault) );
+ pChange->setTarget(TreeImplHelper::impl(m_aParentTree), TreeImplHelper::offset(m_aSetNode));
+ }
+ return NodeChange(pChange.release());
+}
+//-----------------------------------------------------------------------------
+
static inline
Tree impl_extractElementTree (ElementRef const& aElement)
{
diff --git a/configmgr/source/treemgr/defaultproviderproxy.cxx b/configmgr/source/treemgr/defaultproviderproxy.cxx
new file mode 100644
index 000000000000..5c0d4d5a1ff8
--- /dev/null
+++ b/configmgr/source/treemgr/defaultproviderproxy.cxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * $RCSfile: defaultproviderproxy.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "defaultproviderproxy.hxx"
+
+#ifndef CONFIGMGR_DEFAULTPROVIDER_HXX
+#include "defaultprovider.hxx"
+#endif
+#ifndef CONFIGMGR_TREEPROVIDER_HXX
+#include "treeprovider.hxx"
+#endif
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
+#include "valuenode.hxx"
+#endif
+#ifndef CONFIGMGR_MISC_OPTIONS_HXX_
+#include "options.hxx"
+#endif
+
+namespace configmgr
+{
+//-----------------------------------------------------------------------------
+ namespace configuration
+ {
+//-----------------------------------------------------------------------------
+
+DefaultProviderProxy::DefaultProviderProxy(
+ IDefaultProvider * _pDefaultTreeProvider,
+ IDefaultableTreeManager * _pDefaultTreeManager,
+ AbsolutePath const& _aBaseLocation,
+ vos::ORef<OOptions> const& _xOptions,
+ sal_Int16 _nRequestDepth
+ )
+: m_aBaseLocation(_aBaseLocation)
+, m_xOptions(_xOptions)
+, m_nRequestDepth(_nRequestDepth)
+, m_pDefaultTreeProvider(_pDefaultTreeProvider)
+, m_pDefaultTreeManager(_pDefaultTreeManager)
+{
+}
+//-----------------------------------------------------------------------------
+
+DefaultProviderProxy::~DefaultProviderProxy()
+{
+}
+//-----------------------------------------------------------------------------
+
+sal_Int16 DefaultProviderProxy::implGetRemainingDepth(AbsolutePath const& _aLocation) const
+{
+ OSL_ENSURE( Path::hasPrefix(_aLocation,m_aBaseLocation),
+ "ERROR: DefaultProviderProxy called for out-of-scope location" );
+
+ sal_Int16 nDepth = m_nRequestDepth;
+ if (nDepth != ITreeProvider::ALL_LEVELS)
+ {
+ sal_Int16 nLocalDepth = sal_Int16(_aLocation.getDepth()) - sal_Int16(m_aBaseLocation.getDepth());
+
+ OSL_ENSURE( 0 <= nLocalDepth && nLocalDepth < nDepth,
+ "WARNING: DefaultProviderProxy called for tree outside available depth" );
+
+ if (nDepth >= nLocalDepth)
+ nDepth -= nLocalDepth;
+
+ else
+ nDepth = 0;
+ }
+ return nDepth;
+}
+//-----------------------------------------------------------------------------
+
+/// tries to load default data into the specified location (which must be within the request range owned)
+bool DefaultProviderProxy::fetchDefaultData(AbsolutePath const& _aLocation) const SAL_THROW((uno::Exception))
+{
+ sal_Int16 nDepth = implGetRemainingDepth(_aLocation);
+
+ return nDepth != 0 && m_pDefaultTreeManager != NULL &&
+ m_pDefaultTreeManager->fetchDefaultData(_aLocation, m_xOptions, nDepth);
+}
+//-----------------------------------------------------------------------------
+
+/// tries to load a default instance of the specified node (which must be within the request range owned)
+std::auto_ptr<ISubtree> DefaultProviderProxy::getDefaultTree(AbsolutePath const& _aLocation) const SAL_THROW((uno::Exception))
+{
+ sal_Int16 nDepth = implGetRemainingDepth(_aLocation);
+
+ std::auto_ptr<ISubtree> aRet;
+
+ if (nDepth != 0 && m_pDefaultTreeProvider != NULL)
+ aRet = m_pDefaultTreeProvider->requestDefaultData(_aLocation, m_xOptions, nDepth);
+
+ return aRet;
+}
+
+//-----------------------------------------------------------------------------
+ }
+}
+
diff --git a/configmgr/source/treemgr/defaultproviderproxy.hxx b/configmgr/source/treemgr/defaultproviderproxy.hxx
new file mode 100644
index 000000000000..ab0c854592c9
--- /dev/null
+++ b/configmgr/source/treemgr/defaultproviderproxy.hxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * $RCSfile: defaultproviderproxy.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
+ *
+ * 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 CONFIGMGR_DEFAULTPROVIDER_PROXY_HXX_
+#define CONFIGMGR_DEFAULTPROVIDER_PROXY_HXX_
+
+#ifndef CONFIGMGR_CONFIGPATH_HXX_
+#include "configpath.hxx"
+#endif
+
+#ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+#include <salhelper/SimpleReferenceObject.hxx>
+#endif
+
+#ifndef _VOS_REF_HXX_
+#include <vos/ref.hxx>
+#endif
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
+
+namespace configmgr
+{
+//-----------------------------------------------------------------------------
+ class ISubtree;
+ class IDefaultProvider;
+ class IDefaultableTreeManager;
+ class OOptions;
+//-----------------------------------------------------------------------------
+ namespace configuration
+ {
+//-----------------------------------------------------------------------------
+
+ /// provides access to the defaults for a given request
+ class DefaultProviderProxy
+ : public salhelper::SimpleReferenceObject
+ {
+ // the data defining a request
+ AbsolutePath m_aBaseLocation;
+ vos::ORef< OOptions > m_xOptions;
+ sal_Int16 m_nRequestDepth;
+
+ // the object(s) that provide the defaults
+ IDefaultProvider * m_pDefaultTreeProvider;
+ IDefaultableTreeManager * m_pDefaultTreeManager;
+ public:
+ explicit
+ DefaultProviderProxy(
+ IDefaultProvider * _pDefaultTreeProvider,
+ IDefaultableTreeManager * _pDefaultTreeManager,
+ AbsolutePath const& _aBaseLocation,
+ vos::ORef<OOptions> const& _xOptions,
+ sal_Int16 _nRequestDepth
+ );
+
+ ~DefaultProviderProxy();
+
+ /// tries to load default data into the specified location (which must be within the request range owned)
+ bool fetchDefaultData(AbsolutePath const& _aLocation) const SAL_THROW((uno::Exception));
+
+ /// tries to load a default instance of the specified node (which must be within the request range owned)
+ std::auto_ptr<ISubtree> getDefaultTree(AbsolutePath const& _aLocation) const SAL_THROW((uno::Exception));
+
+ private:
+ sal_Int16 implGetRemainingDepth(AbsolutePath const& _aLocation) const;
+ };
+//-----------------------------------------------------------------------------
+ }
+}
+
+#endif // CONFIGMGR_DEFAULTPROVIDER_PROXY_HXX_
diff --git a/configmgr/source/treemgr/groupnodeimpl.hxx b/configmgr/source/treemgr/groupnodeimpl.hxx
index e50a1addfce3..70dce74ce4ed 100644
--- a/configmgr/source/treemgr/groupnodeimpl.hxx
+++ b/configmgr/source/treemgr/groupnodeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: groupnodeimpl.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-07-03 12:55:06 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -116,6 +116,9 @@ namespace configmgr
/// does this hold a child value of the given name
bool hasValue(Name const& aName) const;
+ /// are defaults for this node available ?
+ bool areValueDefaultsAvailable() const;
+
/// retrieve data for the child value of the given name
ValueMemberNode getValue(Name const& aName)
{ return doGetValueMember(aName,false); }
diff --git a/configmgr/source/treemgr/makefile.mk b/configmgr/source/treemgr/makefile.mk
index e1e3270f274d..9bcc137cbe60 100644
--- a/configmgr/source/treemgr/makefile.mk
+++ b/configmgr/source/treemgr/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.5 $
+# $Revision: 1.6 $
#
-# last change: $Author: jb $ $Date: 2001-06-20 20:43:22 $
+# last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -75,10 +75,12 @@ ENABLE_EXCEPTIONS=TRUE
SLOFILES= \
$(SLO)$/collectchanges.obj \
+ $(SLO)$/configdefaultprovider.obj \
$(SLO)$/configexcept.obj \
$(SLO)$/configgroup.obj \
$(SLO)$/configpath.obj \
$(SLO)$/configset.obj \
+ $(SLO)$/defaultproviderproxy.obj \
$(SLO)$/valuemembernode.obj \
$(SLO)$/nodechange.obj \
$(SLO)$/nodechangeimpl.obj \
diff --git a/configmgr/source/treemgr/nodechange.cxx b/configmgr/source/treemgr/nodechange.cxx
index c00001cfb3b7..0c4bc545ef21 100644
--- a/configmgr/source/treemgr/nodechange.cxx
+++ b/configmgr/source/treemgr/nodechange.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechange.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:31:32 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -140,15 +140,29 @@ bool NodeChange::isChange() const
}
//-----------------------------------------------------------------------------
-bool NodeChange::getChangeInfo(NodeChangeInformation& rInfo) const
+sal_uInt32 NodeChange::getChangeInfos(NodeChangesInformation& _rInfos) const
{
- rInfo.change.type = NodeChangeData::eNoChange;
+ sal_uInt32 nCount = 0;
if (m_pImpl)
- m_pImpl->fillChangeInfo(rInfo);
- else
- OSL_ASSERT(rInfo.isEmptyChange());
+ {
+ NodeChangeImpl::ChangeCount nChanges = m_pImpl->getChangeDataCount();
+
+ for (NodeChangeImpl::ChangeCount ix = 0; ix < nChanges; ++ix)
+ {
+ NodeChangeInformation aSingleInfo;
+ aSingleInfo.change.type = NodeChangeData::eNoChange;
+
+ m_pImpl->fillChangeInfo(aSingleInfo,ix);
+
+ if ( !aSingleInfo.isEmptyChange() )
+ {
+ _rInfos.push_back(aSingleInfo);
+ ++nCount;
+ }
+ }
+ }
- return !rInfo.isEmptyChange();
+ return nCount;
}
//-----------------------------------------------------------------------------
@@ -157,23 +171,6 @@ bool NodeChange::getChangeLocation(NodeChangeLocation& rLoc) const
return m_pImpl && m_pImpl->fillChangeLocation(rLoc);
}
//-----------------------------------------------------------------------------
-/*
-bool NodeChange::getChangeInfo(ExtendedNodeChangeInfo& rInfo) const
-{
- if (this->getChangeInfo( rInfo.change))
- {
- rInfo.baseTree = getBaseTree();
- rInfo.baseNode = getBaseNode();
- rInfo.accessor = m_pImpl->getPathToChangingNode();
- return true;
- }
- else
- {
- return false;
- }
-}
-*/
-//-----------------------------------------------------------------------------
Tree NodeChange::getBaseTree() const
{
@@ -316,7 +313,6 @@ void NodeChanges::implApply() const
//Tree getBaseTree() const;
/** insert a change into this collection
- <p>if there is an existing change for this element, they are combine using <method>NodeChange::combine</method>
*/
void NodeChanges::add(NodeChange const& aChange)
{
@@ -324,27 +320,34 @@ void NodeChanges::add(NodeChange const& aChange)
}
//-----------------------------------------------------------------------------
+/** insert multiple changes into this collection
+*/
+void NodeChanges::add(NodeChanges const& aChanges)
+{
+ m_aChanges.insert(m_aChanges.end(),aChanges.begin(),aChanges.end());
+}
+//-----------------------------------------------------------------------------
+
/** removes a change to <var>aNode</var> from this collection (if there is one)
void NodeChanges::reset(Node const& aNode)
{
}
*/
-bool NodeChanges::getChangesInfo(NodeChangesInformation& rInfos) const
+sal_uInt32 NodeChanges::getChangesInfos(NodeChangesInformation& _rInfos) const
{
- if (isEmpty()) return false;
+ if (isEmpty()) return 0;
- rInfos.clear();
- rInfos.reserve(getCount());
+ _rInfos.reserve(_rInfos.size() + this->getCount());
+ sal_Int32 nResult = 0;
for (Iterator it = begin(); it != end(); ++it)
{
NodeChangeInformation aInfo;
- if ( it->getChangeInfo(aInfo) )
- rInfos.push_back(aInfo);
+ nResult += it->getChangeInfos(_rInfos);
}
- return !rInfos.empty();
+ return nResult;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/nodechangeimpl.cxx b/configmgr/source/treemgr/nodechangeimpl.cxx
index face73a050c0..73e913b58eb4 100644
--- a/configmgr/source/treemgr/nodechangeimpl.cxx
+++ b/configmgr/source/treemgr/nodechangeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeimpl.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: hr $ $Date: 2001-09-27 18:51:22 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,12 +61,32 @@
#include "nodechangeimpl.hxx"
+#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
#include "nodechangeinfo.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEBEHAVIOR_HXX_
#include "nodeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_
#include "treeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGSET_HXX_
+#include "configset.hxx"
+#endif
+#ifndef CONFIGMGR_SETNODEBEHAVIOR_HXX_
#include "setnodeimplbase.hxx"
+#endif
+#ifndef CONFIGMGR_GROUPNODEBEHAVIOR_HXX_
#include "groupnodeimpl.hxx"
+#endif
+
+#ifndef _CONFIGMGR_TREE_VALUENODE_HXX
+#include "valuenode.hxx"
+#endif
+#ifndef CONFIGMGR_CHANGE_HXX
+#include "change.hxx"
+#endif
namespace configmgr
{
@@ -93,21 +113,13 @@ NodeChangeImpl::NodeChangeImpl(bool bNoCheck)
TreeHolder NodeChangeImpl::getBaseTree() const
{
- TreeHolder aRet = doGetBaseTree();
- OSL_ENSURE( aRet.isValid(), "ERROR: Configuration Change: Base Tree has not been set up" );
-
- return aRet;
+ return getAffectedTree();
}
//-----------------------------------------------------------------------------
NodeOffset NodeChangeImpl::getBaseNode() const
{
- NodeOffset nRet = doGetBaseNode();
- OSL_ENSURE( nRet != 0, "ERROR: Configuration Change: Base Node has not been set up" );
- OSL_ENSURE( doGetBaseTree().isValid() && doGetBaseTree()->isValidNode(nRet),
- "ERROR: Configuration Change: Base Node does not match tree" );
-
- return nRet;
+ return getAffectedNode();
}
//-----------------------------------------------------------------------------
@@ -131,14 +143,6 @@ NodeOffset NodeChangeImpl::getAffectedNode() const
}
//-----------------------------------------------------------------------------
-RelativePath NodeChangeImpl::getPathToChangingNode() const
-{
- // TODO: Add DEBUG-verification of the result
- return doGetChangingNodePath();
-}
-//-----------------------------------------------------------------------------
-
-
void NodeChangeImpl::setAffected(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode)
{
OSL_ENSURE(m_nState == 0 || (m_aAffectedTree.isEmpty() && m_nState == eNoCheck), "WARNING: Configuration: Retargeting change that already was tested or applied");
@@ -164,24 +168,34 @@ bool NodeChangeImpl::isChange(bool bAllowUntested) const
if (!(m_nState & eTestedChange))
return bAllowUntested;
- return doIsChange(!(m_nState & eAppliedChange));
+ return doIsChange();
+}
+//-----------------------------------------------------------------------------
+
+NodeChangeImpl::ChangeCount NodeChangeImpl::getChangeDataCount() const
+{
+ OSL_PRECOND(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - change data count may be incorrect");
+
+ return doGetChangeCount();
}
//-----------------------------------------------------------------------------
-bool NodeChangeImpl::fillChangeData(NodeChangeData& rChange) const
+bool NodeChangeImpl::fillChangeData(NodeChangeData& rChange, ChangeCount _ix) const
{
- OSL_ENSURE(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - fillChange is partially meaningless");
- return doFillChange(rChange) || rChange.isDataChange(); // force true if the data is signaling change
+ OSL_PRECOND(_ix < doGetChangeCount(), "ERROR: Configuration: Change index out of range");
+ OSL_PRECOND(m_nState & eTestedChange, "WARNING: Configuration: Change was not tested - fillChange is partially meaningless");
+
+ return doFillChange(rChange, _ix) || rChange.isDataChange(); // force true if the data is signaling change
}
//-----------------------------------------------------------------------------
-bool NodeChangeImpl::fillChangeLocation(NodeChangeLocation& rChange) const
+bool NodeChangeImpl::fillChangeLocation(NodeChangeLocation& rChange, ChangeCount _ix) const
{
if (!m_aAffectedTree.isValid()) return false;
rChange.setBase( NodeID(this->getBaseTree().getBodyPtr(), this->getBaseNode()) );
- rChange.setAccessor( this->getPathToChangingNode() );
+ rChange.setAccessor( this->doGetChangingNodePath(_ix) );
rChange.setAffected( NodeID(this->getAffectedTree().getBodyPtr(), this->getAffectedNode()) );
@@ -191,9 +205,9 @@ bool NodeChangeImpl::fillChangeLocation(NodeChangeLocation& rChange) const
}
//-----------------------------------------------------------------------------
-bool NodeChangeImpl::fillChangeInfo(NodeChangeInformation& rChange) const
+bool NodeChangeImpl::fillChangeInfo(NodeChangeInformation& rChange, ChangeCount _ix) const
{
- return fillChangeLocation(rChange.location) & fillChangeData(rChange.change);
+ return fillChangeLocation(rChange.location, _ix) & fillChangeData(rChange.change, _ix);
}
//-----------------------------------------------------------------------------
@@ -226,6 +240,13 @@ void NodeChangeImpl::apply()
}
//-----------------------------------------------------------------------------
+// default count is 1
+NodeChangeImpl::ChangeCount NodeChangeImpl::doGetChangeCount() const
+{
+ return 1;
+}
+//-----------------------------------------------------------------------------
+
/// apply this change to the given node - start state is nState (which is then updated)
void NodeChangeImpl::implApply()
{
@@ -259,20 +280,6 @@ Node* NodeChangeImpl::implGetTarget() const
}
//-----------------------------------------------------------------------------
-// hook method default implementations
-TreeHolder NodeChangeImpl::doGetBaseTree() const
-{
- return m_aAffectedTree;
-}
-//-----------------------------------------------------------------------------
-
-NodeOffset NodeChangeImpl::doGetBaseNode() const
-{
- return m_nAffectedNode;
-}
-//-----------------------------------------------------------------------------
-
-
//-----------------------------------------------------------------------------
// Value operations: ValueChangeImpl = common base
//-----------------------------------------------------------------------------
@@ -320,7 +327,7 @@ void ValueChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nPar
}
//-----------------------------------------------------------------------------
-RelativePath ValueChangeImpl::doGetChangingNodePath() const
+RelativePath ValueChangeImpl::doGetChangingNodePath(ChangeCount ) const
{
return RelativePath( Path::wrapSimpleName(m_aName) );
}
@@ -332,13 +339,13 @@ bool ValueChangeImpl::doIsChangingSubnode() const
}
//-----------------------------------------------------------------------------
-bool ValueChangeImpl::doIsChange(bool ) const
+bool ValueChangeImpl::doIsChange() const
{
return !!(getNewValue() != getOldValue());
}
//-----------------------------------------------------------------------------
-bool ValueChangeImpl::doFillChange(NodeChangeData& rChange) const
+bool ValueChangeImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const
{
rChange.unoData.newValue = getNewValue();
rChange.unoData.oldValue = getOldValue();
@@ -408,10 +415,10 @@ void ValueReplaceImpl::doApplyChange( ValueMemberUpdate& rNode)
}
//-----------------------------------------------------------------------------
-bool ValueReplaceImpl::doFillChange( NodeChangeData& rChange) const
+bool ValueReplaceImpl::doFillChange( NodeChangeData& rChange, ChangeCount _ix) const
{
rChange.type = NodeChangeData::eSetValue;
- return ValueChangeImpl::doFillChange(rChange);
+ return ValueChangeImpl::doFillChange(rChange, _ix);
}
//-----------------------------------------------------------------------------
@@ -436,10 +443,10 @@ void ValueResetImpl::doApplyChange( ValueMemberUpdate& rNode)
}
//-----------------------------------------------------------------------------
-bool ValueResetImpl::doFillChange( NodeChangeData& rChange) const
+bool ValueResetImpl::doFillChange( NodeChangeData& rChange, ChangeCount _ix) const
{
rChange.type = NodeChangeData::eSetDefault;
- ValueChangeImpl::doFillChange(rChange);
+ ValueChangeImpl::doFillChange(rChange,_ix);
return !rChange.isEmptyChange(); // do it defensively here - default (= 'new') may be unknown still
}
//-----------------------------------------------------------------------------
@@ -454,89 +461,197 @@ void ValueResetImpl::preCheckValue(ValueMemberNode& rNode, UnoAny& rOld, UnoAny&
}
//-----------------------------------------------------------------------------
-// Value operations: DeepValueReplaceImpl = set nested value
+// All Set Changes: SetChangeImpl - common base
//-----------------------------------------------------------------------------
-DeepValueReplaceImpl::DeepValueReplaceImpl(RelativePath const& aRelPath, UnoAny const& aNewValue)
-: ValueReplaceImpl(aNewValue)
-, m_aBaseTree()
-, m_nBaseNode(0)
-, m_aNestedPath(aRelPath)
+SetChangeImpl::SetChangeImpl(bool bNoCheck)
+: NodeChangeImpl(bNoCheck)
{
}
//-----------------------------------------------------------------------------
-DeepValueReplaceImpl::DeepValueReplaceImpl(RelativePath const& aRelPath, UnoAny const& aNewValue, UnoAny const& aOldValue)
-: ValueReplaceImpl(aNewValue, aOldValue)
-, m_aBaseTree()
-, m_nBaseNode(0)
-, m_aNestedPath(aRelPath)
+void SetChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode)
{
+ NodeChangeImpl::setAffected(aAffectedTree,nAffectedNode);
}
//-----------------------------------------------------------------------------
-void DeepValueReplaceImpl::setBaseContext(TreeHolder const& aBaseTree, NodeOffset nBaseNode)
+bool SetChangeImpl::doIsChangingSubnode() const
{
- OSL_ENSURE(aBaseTree.isValid() && aBaseTree->isValidNode(nBaseNode), "ERROR: Setting invalid base tree / node for deep change");
+ return false;
+}
- m_aBaseTree = aBaseTree;
- m_nBaseNode = nBaseNode;
+//-----------------------------------------------------------------------------
+// Resetting a set to its default state
+//-----------------------------------------------------------------------------
+
+SetResetImpl::SetResetImpl(
+ SetElementFactory& _rElementFactory,
+ std::auto_ptr<ISubtree> _pDefaultData,
+ bool _bNoCheck
+)
+: SetChangeImpl(_bNoCheck)
+, m_rElementFactory(_rElementFactory)
+, m_aDefaultData(_pDefaultData)
+, m_aTreeChanges()
+{
}
//-----------------------------------------------------------------------------
-RelativePath DeepValueReplaceImpl::doGetChangingNodePath() const
+SetResetImpl::~SetResetImpl()
{
- return m_aNestedPath;
}
//-----------------------------------------------------------------------------
-TreeHolder DeepValueReplaceImpl::doGetBaseTree() const
+RelativePath SetResetImpl::doGetChangingNodePath(ChangeCount _ix) const
{
- return m_aBaseTree;
+ OSL_ENSURE( _ix < m_aTreeChanges.size() || _ix == scCommonBase, "Illegal Change index" );
+ OSL_ASSERT( scCommonBase > m_aTreeChanges.size() );
+
+ if ( _ix < m_aTreeChanges.size() )
+ return RelativePath( m_aTreeChanges[_ix].m_aElementName);
+
+ else
+ return RelativePath();
}
//-----------------------------------------------------------------------------
-NodeOffset DeepValueReplaceImpl::doGetBaseNode() const // use your own
+static NodeChangeData::Type getChangeType(ElementTreeChange const& aChange)
{
- return m_nBaseNode;
+ sal_Bool bHasNew = aChange.m_aAddedElement.isValid();
+ sal_Bool bHasOld = aChange.m_aRemovedElement.isValid();
+
+ NodeChangeData::Type aResult;
+ if (bHasNew)
+ aResult = bHasOld ? NodeChangeData::eReplaceElement : NodeChangeData::eInsertElement;
+ else
+ aResult = bHasOld ? NodeChangeData::eRemoveElement : NodeChangeData::eSetDefault;
+
+ return aResult;
}
+//-----------------------------------------------------------------------------
+bool SetResetImpl::doIsChange() const
+{
+ return !m_aTreeChanges.empty() || m_aDefaultData.get();
+}
//-----------------------------------------------------------------------------
-// All Sets: SetChangeImpl - common base
+
+bool SetResetImpl::doFillChange(NodeChangeData& rChange, ChangeCount _ix) const
+{
+ OSL_ENSURE( _ix < m_aTreeChanges.size() || _ix == scCommonBase, "Illegal Change index" );
+ if (_ix >= m_aTreeChanges.size())
+ {
+ rChange.type = NodeChangeData::eResetSetDefault;
+ return m_aDefaultData.get() != NULL;
+ }
+ ElementTreeChange const& aChange = m_aTreeChanges[_ix];
+
+ rChange.type = getChangeType(aChange);
+
+ rChange.element.newValue = aChange.m_aAddedElement;
+ rChange.element.oldValue = aChange.m_aRemovedElement;
+
+ return true;
+}
//-----------------------------------------------------------------------------
-SetChangeImpl::SetChangeImpl(Path::Component const& aName, bool bNoCheck)
-: NodeChangeImpl(bNoCheck)
-, m_aName(aName)
+void SetResetImpl::doTest( Node& rTarget)
{
+ if ( m_aDefaultData.get() )
+ {
+ SetNodeImpl& rTargetSet = rTarget.setImpl();
+ std::auto_ptr<SubtreeChange> pChanges = rTargetSet.differenceToDefaultState(*m_aDefaultData);
+
+ if (pChanges.get())
+ {
+ for (SubtreeChange::MutatingChildIterator it = pChanges->begin_changes(),
+ stop = pChanges->end_changes();
+ it != stop;
+ ++it)
+ {
+ Name aName = makeElementName(it->getNodeName(), Name::NoValidate());
+
+ SetEntry anExistingEntry = rTargetSet.findElement(aName);
+
+ ElementTreeHolder aOldTree = anExistingEntry.tree();
+ ElementTreeHolder aNewTree;
+
+ if (it->ISA(AddNode))
+ {
+ AddNode& rAddNode = static_cast<AddNode&>(*it);
+ std::auto_ptr<INode> pAddedNode = rAddNode.releaseAddedNode();
+
+ OSL_ENSURE(pAddedNode.get(),"Processing an addNode to default - no node to add");
+
+ aNewTree = m_rElementFactory.instantiateOnDefault(pAddedNode,rTargetSet.getElementTemplate()).get();
+ }
+
+
+ Path::Component aFullName =
+ aNewTree.isValid() ? aFullName = aNewTree->getExtendedRootName() :
+ aOldTree.isValid() ? aFullName = aOldTree->getExtendedRootName() :
+ Path::makeCompositeName(aName,rTargetSet.getElementTemplate()->getName());
+
+ OSL_ENSURE(aOldTree.isValid() || aNewTree.isValid(), "No data for change to default");
+
+ m_aTreeChanges.push_back(ElementTreeChange(aFullName,aNewTree,aOldTree));
+ }
+ }
+
+ m_aDefaultData.reset();
+ }
}
//-----------------------------------------------------------------------------
-void SetChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode)
+void SetResetImpl::doApply( Node& rTarget)
{
- NodeChangeImpl::setAffected(aAffectedTree,nAffectedNode);
+ typedef TreeChanges::iterator Iter;
+
+ SetNodeImpl& rTargetSet = rTarget.setImpl();
+
+ for (Iter it = m_aTreeChanges.begin(); it != m_aTreeChanges.end(); ++it)
+ {
+ Name aElementName = it->m_aElementName.getName();
+
+ if (it->m_aRemovedElement.isValid())
+ rTargetSet.removeElement(aElementName);
+
+ if (it->m_aAddedElement.isValid())
+ {
+ SetEntry aNewEntry( it->m_aAddedElement.getBodyPtr() );
+ rTargetSet.insertElement( aElementName, aNewEntry);
+ }
+
+ OSL_ENSURE(getChangeType(*it) != NodeChangeData::eSetDefault,
+ "Cannot apply change without data");
+ }
}
+
+//-----------------------------------------------------------------------------
+// All Set Changes affecting a single element: SetElementChangeImpl - common base
//-----------------------------------------------------------------------------
-RelativePath SetChangeImpl::doGetChangingNodePath() const
+SetElementChangeImpl::SetElementChangeImpl(Path::Component const& aName, bool bNoCheck)
+: SetChangeImpl(bNoCheck)
+, m_aName(aName)
{
- return RelativePath(getFullElementName());
}
//-----------------------------------------------------------------------------
-bool SetChangeImpl::doIsChangingSubnode() const
+RelativePath SetElementChangeImpl::doGetChangingNodePath(ChangeCount ) const
{
- return false;
+ return RelativePath(getFullElementName());
}
//-----------------------------------------------------------------------------
-void SetChangeImpl::doTest( Node& rTarget)
+void SetElementChangeImpl::doTest( Node& rTarget)
{
doTestElement(rTarget.setImpl(), getElementName() );
}
//-----------------------------------------------------------------------------
-void SetChangeImpl::doApply( Node& rTarget)
+void SetElementChangeImpl::doApply( Node& rTarget)
{
doApplyToElement(rTarget.setImpl(), getElementName() );
}
@@ -545,20 +660,20 @@ void SetChangeImpl::doApply( Node& rTarget)
// Full Sets: SetInsertTreeImpl
//-----------------------------------------------------------------------------
-SetInsertTreeImpl::SetInsertTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck)
-: SetChangeImpl(aName,bNoCheck)
+SetInsertImpl::SetInsertImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck)
+: SetElementChangeImpl(aName,bNoCheck)
, m_aNewTree(aNewTree)
{
}
//-----------------------------------------------------------------------------
-bool SetInsertTreeImpl::doIsChange(bool ) const
+bool SetInsertImpl::doIsChange() const
{
return !!m_aNewTree.isValid();
}
//-----------------------------------------------------------------------------
-bool SetInsertTreeImpl::doFillChange(NodeChangeData& rChange) const
+bool SetInsertImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const
{
rChange.type = NodeChangeData::eInsertElement;
if (m_aNewTree.isValid())
@@ -568,14 +683,14 @@ bool SetInsertTreeImpl::doFillChange(NodeChangeData& rChange) const
}
//-----------------------------------------------------------------------------
-void SetInsertTreeImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
+void SetInsertImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
{
SetEntry anEntry = rNode.findElement(aName); // require loaded children
OSL_ENSURE(!anEntry.isValid(), "ERROR: Configuration: Adding a node that already exists");
}
//-----------------------------------------------------------------------------
-void SetInsertTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
+void SetInsertImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
{
if (m_aNewTree.isValid())
{
@@ -588,16 +703,16 @@ void SetInsertTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
// Full Sets: SetReplaceTreeImpl
//-----------------------------------------------------------------------------
-SetReplaceTreeImpl::SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree)
-: SetChangeImpl(aName)
+SetReplaceImpl::SetReplaceImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree)
+: SetElementChangeImpl(aName)
, m_aNewTree(aNewTree)
, m_aOldTree()
{
}
//-----------------------------------------------------------------------------
-SetReplaceTreeImpl::SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree)
-: SetChangeImpl(aName,true)
+SetReplaceImpl::SetReplaceImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree)
+: SetElementChangeImpl(aName,true)
, m_aNewTree(aNewTree)
, m_aOldTree(aOldTree)
{
@@ -605,14 +720,14 @@ SetReplaceTreeImpl::SetReplaceTreeImpl(Path::Component const& aName, ElementTree
//-----------------------------------------------------------------------------
/// checks, if this represents an actual change
-bool SetReplaceTreeImpl::doIsChange(bool) const
+bool SetReplaceImpl::doIsChange() const
{
- return !!(m_aOldTree != m_aNewTree);
+ return !!(m_aOldTree == m_aNewTree);
}
//-----------------------------------------------------------------------------
/// fills in pre- and post-change values, returns wether they differ
-bool SetReplaceTreeImpl::doFillChange(NodeChangeData& rChange) const
+bool SetReplaceImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const
{
rChange.type = NodeChangeData::eReplaceElement;
if (m_aNewTree.isValid())
@@ -625,7 +740,7 @@ bool SetReplaceTreeImpl::doFillChange(NodeChangeData& rChange) const
}
//-----------------------------------------------------------------------------
-void SetReplaceTreeImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
+void SetReplaceImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
{
OSL_ASSERT(!m_aOldTree.isValid()); // already tested ?
@@ -637,7 +752,7 @@ void SetReplaceTreeImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
}
//-----------------------------------------------------------------------------
-void SetReplaceTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
+void SetReplaceImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
{
if (m_aOldTree != m_aNewTree)
{
@@ -658,29 +773,29 @@ void SetReplaceTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName
// Full Sets: SetRemoveTreeImpl
//-----------------------------------------------------------------------------
-SetRemoveTreeImpl::SetRemoveTreeImpl(Path::Component const& aName)
-: SetChangeImpl(aName)
+SetRemoveImpl::SetRemoveImpl(Path::Component const& aName)
+: SetElementChangeImpl(aName)
, m_aOldTree()
{
}
//-----------------------------------------------------------------------------
-SetRemoveTreeImpl::SetRemoveTreeImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree)
-: SetChangeImpl(aName,true)
+SetRemoveImpl::SetRemoveImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree)
+: SetElementChangeImpl(aName,true)
, m_aOldTree(aOldTree)
{
}
//-----------------------------------------------------------------------------
/// checks, if this represents an actual change
-bool SetRemoveTreeImpl::doIsChange(bool) const
+bool SetRemoveImpl::doIsChange() const
{
return !!m_aOldTree.isValid();
}
//-----------------------------------------------------------------------------
/// fills in pre- and post-change values, returns wether they differ
-bool SetRemoveTreeImpl::doFillChange(NodeChangeData& rChange) const
+bool SetRemoveImpl::doFillChange(NodeChangeData& rChange, ChangeCount) const
{
rChange.type = NodeChangeData::eRemoveElement;
if (m_aOldTree.isValid())
@@ -690,7 +805,7 @@ bool SetRemoveTreeImpl::doFillChange(NodeChangeData& rChange) const
}
//-----------------------------------------------------------------------------
-void SetRemoveTreeImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
+void SetRemoveImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
{
OSL_ASSERT(!m_aOldTree.isValid()); // already tested ?
@@ -702,167 +817,11 @@ void SetRemoveTreeImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
}
//-----------------------------------------------------------------------------
-void SetRemoveTreeImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
+void SetRemoveImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
{
rNode.removeElement(aName);
}
-/*
-//-----------------------------------------------------------------------------
-// Value Sets: Helpers
-//-----------------------------------------------------------------------------
-
-/// provides a wrapper for completely new leaf values (e.g. within value sets)
-ElementTreeHolder makeNewValueTree(Name const& rName, UnoAny const& rValue, UnoType& rType)
-{
- std::auto_ptr<ValueNode> pNode;
- if (rValue.hasValue())
- pNode.reset( new ValueNode(rName.toString(),rValue) );
- else
- pNode.reset( new ValueNode(rName.toString(),rType) );
-
- return new ElementTreeImpl(pNode);
-}
-
-//-----------------------------------------------------------------------------
-// Value Sets: SetInsertValueImpl
-//-----------------------------------------------------------------------------
-
-SetInsertValueImpl::SetInsertValueImpl(Name const& aName, UnoAny const& aNewValue)
-: SetChangeImpl(aName)
-, m_aNewValue(aNewValue)
-{
-}
-//-----------------------------------------------------------------------------
-
-bool SetInsertValueImpl::doIsChange(bool) const
-{
- return true;
-}
-//-----------------------------------------------------------------------------
-
-bool SetInsertValueImpl::doFillChange(DataChange& rChange) const
-{
- rChange.newValue = getNewValue();
-
- return rChange.isChange();
-}
-//-----------------------------------------------------------------------------
-
-void SetInsertValueImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
-{
- OSL_ENSURE(!rNode.findElement(aName).isValid(), "ERROR: Configuration: Adding a node that already exists");
-}
-
-//-----------------------------------------------------------------------------
-void SetInsertValueImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
-{
-// SetEntry aNewEntry ;//= { m_aNewValue.getBodyPtr(), m_aNewValue->rootNode() };
- rNode.insertValue(aName, getNewValue());
-}
-
-//-----------------------------------------------------------------------------
-// Value Sets: SetReplaceValueImpl
-//-----------------------------------------------------------------------------
-
-SetReplaceValueImpl::SetReplaceValueImpl(Name const& aName, UnoAny const& aNewValue)
-: SetChangeImpl(aName)
-, m_aReplacer(aNewValue)
-{
-}
-//-----------------------------------------------------------------------------
-
-bool SetReplaceValueImpl::doIsChange(bool) const
-{
- return m_aReplacer.isChange();
-}
-//-----------------------------------------------------------------------------
-
-bool SetReplaceValueImpl::doFillChange(DataChange& rChange) const
-{
- return m_aReplacer.fillChange(rChange);
-}
-//-----------------------------------------------------------------------------
-
-void SetReplaceValueImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
-{
- Node* pNode = rNode.findElement(aName).pNode;
- OSL_ENSURE( pNode, "ERROR: Configuration: Replacing a node that doesn't exist" );
-
- if (pNode)
- {
- OSL_ENSURE( pNode->isValueNode(), "ERROR: Configuration: Replacing a non value node as value node" );
- m_aReplacer.doTest(*pNode);
- }
-
-}
-//-----------------------------------------------------------------------------
-
-void SetReplaceValueImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
-{
- Node* pNode = rNode.findElement(aName).pNode;
- OSL_ENSURE( pNode, "ERROR: Configuration: Replacing a node that doesn't exist" );
-
- if (pNode)
- {
- OSL_ENSURE( pNode->isValueNode(), "ERROR: Configuration: Replacing a non value node as value node" );
- m_aReplacer.doApply(*pNode);
- }
-}
-
-//-----------------------------------------------------------------------------
-// Value Sets: SetRemoveValueImpl
-//-----------------------------------------------------------------------------
-
-SetRemoveValueImpl::SetRemoveValueImpl(Name const& aName)
-: SetChangeImpl(aName)
-, m_aOldValue()
-, m_bRemove(true)
-{
-}
-//-----------------------------------------------------------------------------
-
-/// checks, if this represents an actual change
-bool SetRemoveValueImpl::doIsChange(bool) const
-{
- return m_bRemove;
-}
-//-----------------------------------------------------------------------------
-
-bool SetRemoveValueImpl::doFillChange(DataChange& rChange) const
-{
- rChange.oldValue = m_aOldValue;
-
- return rChange.isChange();
-}
-//-----------------------------------------------------------------------------
-
-void SetRemoveValueImpl::doTestElement( SetNodeImpl& rNode, Name const& aName)
-{
- OSL_ASSERT(m_bRemove); // test failed before ???
-
- Node* pNode = rNode.findElement(aName).pNode;
- OSL_ENSURE( pNode, "ERROR: Configuration: Removing a node that doesn't exist" );
-
- if (pNode)
- {
- OSL_ENSURE( pNode->isValueNode(), "ERROR: Configuration: Removing a non-value node as value node" );
-
- m_aOldValue = pNode->valueImpl().getValue();
- m_bRemove = true;
- }
- else
- m_bRemove = false;
-}
-//-----------------------------------------------------------------------------
-
-void SetRemoveValueImpl::doApplyToElement( SetNodeImpl& rNode, Name const& aName)
-{
- OSL_ASSERT(m_bRemove); // test failed before ???
-
- rNode.removeElement(aName);
-}
-*/
//-----------------------------------------------------------------------------
}
}
diff --git a/configmgr/source/treemgr/nodechangeimpl.hxx b/configmgr/source/treemgr/nodechangeimpl.hxx
index 11a7f69f4dae..21422e9ae0a7 100644
--- a/configmgr/source/treemgr/nodechangeimpl.hxx
+++ b/configmgr/source/treemgr/nodechangeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodechangeimpl.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,15 +62,37 @@
#ifndef CONFIGMGR_CONFIGCHANGEIMPL_HXX_
#define CONFIGMGR_CONFIGCHANGEIMPL_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"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_
#include "treeimpl.hxx"
+#endif
+#ifndef _VOS_REF_HXX_
#include <vos/ref.hxx>
+#endif
+
+#ifndef INCLUDED_VECTOR
+#include <vector>
+#define INCLUDED_VECTOR
+#endif
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
namespace configmgr
{
+ class ISubtree;
+
namespace configuration
{
//-----------------------------------------------------------------------------
@@ -79,10 +101,6 @@ namespace configmgr
typedef com::sun::star::uno::Any UnoAny;
//-----------------------------------------------------------------------------
- typedef vos::ORef<TreeImpl> TreeHolder;
- typedef vos::ORef<ElementTreeImpl> ElementTreeHolder;
-//-----------------------------------------------------------------------------
-
class Node;
class ValueMemberNode;
class ValueMemberUpdate;
@@ -91,6 +109,33 @@ namespace configmgr
class NodeChangeData;
class NodeChangeLocation;
class NodeChangeInformation;
+//-----------------------------------------------------------------------------
+
+ typedef vos::ORef<TreeImpl> TreeHolder;
+ typedef vos::ORef<ElementTreeImpl> ElementTreeHolder;
+//-----------------------------------------------------------------------------
+ struct ElementTreeChange
+ {
+ Path::Component m_aElementName;
+ ElementTreeHolder m_aAddedElement;
+ ElementTreeHolder m_aRemovedElement;
+
+ ElementTreeChange(
+ Path::Component const& _aElementName,
+ ElementTreeHolder const& _aAddedElement,
+ ElementTreeHolder const& _aRemovedElement
+ )
+ : m_aElementName(_aElementName)
+ , m_aAddedElement(_aAddedElement)
+ , m_aRemovedElement(_aRemovedElement)
+ {}
+
+ bool isChange() const
+ {
+ return !!(m_aAddedElement != m_aRemovedElement);
+ }
+ };
+//-----------------------------------------------------------------------------
/// represents a node position in some tree
@@ -113,26 +158,29 @@ namespace configmgr
/// the node that is affected by the change
NodeOffset getAffectedNode() const;
- /// the path from the base to the changing node
- RelativePath getPathToChangingNode() const;
-
protected:
/// setup the 'target' node that is to be affected or changed
void setAffected(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode);
public:
- // related/affected nodes and trees
+ // getting information
+ typedef sal_uInt32 ChangeCount;
+ /*static const ChangeCount*/ enum { scCommonBase = ~0u };
+
/// checks, if this represents an actual change - with or without requiring a preceding test
bool isChange(bool bAllowUntested) const;
- /// fills in pre- and post-change values, returns whether they may differ
- bool fillChangeData(NodeChangeData& rChange) const;
+ /// return the number of distict changes in this object
+ ChangeCount getChangeDataCount() const;
+
+ /// fills in base change location, returns whether it is set
+ bool fillChangeLocation(NodeChangeLocation& rChange, ChangeCount _ix = scCommonBase) const;
- /// fills in change location, returns whether it is set
- bool fillChangeLocation(NodeChangeLocation& rChange) const;
+ /// fills in pre- and post-change values, returns whether they may differ
+ bool fillChangeData(NodeChangeData& rChange, ChangeCount _ix) const;
/// fills in change location and values, returns whether data may be changed
- bool fillChangeInfo(NodeChangeInformation& rChange) const;
+ bool fillChangeInfo(NodeChangeInformation& rChange, ChangeCount _ix) const;
/// test whether this really is a change to the stored 'changing' node
void test();
@@ -140,31 +188,28 @@ namespace configmgr
/// apply this change to the stored 'changing' node
void apply();
- protected:
+ private:
/// virtual hooks for some of the public methods
- /// the tree on which the operation originated
- virtual TreeHolder doGetBaseTree() const; // default is the same as the target tree
+ /// return the number of distict changes in this object
+ ChangeCount doGetChangeCount() const;
- /// the node thru which the operation originated
- virtual NodeOffset doGetBaseNode() const; // default is the the same as the owning node
- private:
- /// the path from base to 'affected' node
- virtual RelativePath doGetChangingNodePath() const = 0;
+ /// the path from base to 'changing' node
+ virtual RelativePath doGetChangingNodePath(ChangeCount _ix) const = 0;
- /// is the change really affecting a child of the affected node (true for values)
+ /// is the change really affecting a child (or children) of the affected node (true for values)
virtual bool doIsChangingSubnode() const = 0;
- private:
/// checks, if this represents an actual change (given whether the change has been applied or not)
- virtual bool doIsChange(bool bBefore) const = 0;
+ virtual bool doIsChange() const = 0;
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const = 0;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const = 0;
/// dry-check whether this is a change
virtual void doTest( Node& rTarget) = 0;
/// do apply the actual change
virtual void doApply( Node& rTarget) = 0;
+
private:
typedef sal_uInt16 State;
TreeHolder m_aAffectedTree;
@@ -205,7 +250,7 @@ namespace configmgr
protected:
// override information items
/// the path from base to 'affected' node - here is the name of the changing node
- virtual RelativePath doGetChangingNodePath() const;
+ virtual RelativePath doGetChangingNodePath(ChangeCount _ix) const;
/// is the change really affecting a child of the affected node (true here)
virtual bool doIsChangingSubnode() const;
@@ -213,10 +258,10 @@ namespace configmgr
protected:
// override change information items
/// checks, if this represents an actual change (given whether the change has been applied or not)
- virtual bool doIsChange(bool bBefore) const;
+ virtual bool doIsChange() const;
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const = 0;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const = 0;
protected:
// override apply functionality
@@ -249,7 +294,7 @@ namespace configmgr
virtual void doApplyChange( ValueMemberUpdate& rNode);
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
// friend class SetReplaceValueImpl;
};
@@ -271,42 +316,74 @@ namespace configmgr
virtual void doApplyChange( ValueMemberUpdate& rNode);
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
};
//-----------------------------------------------------------------------------
- /// represents setting a deeply nested value node to a given value
- class DeepValueReplaceImpl
- : public ValueReplaceImpl
+
+ /// represents a change to a set (as a container)
+ class SetChangeImpl
+ : public NodeChangeImpl
{
- TreeHolder m_aBaseTree;
- NodeOffset m_nBaseNode;
- RelativePath m_aNestedPath;
public:
- explicit DeepValueReplaceImpl(RelativePath const& aNestedPath, UnoAny const& aNewValue);
- explicit DeepValueReplaceImpl(RelativePath const& aNestedPath, UnoAny const& aNewValue, UnoAny const& aOldValue);
+ explicit SetChangeImpl(bool bNoCheck = false);
- /// set up the node where this is originated
- void setBaseContext(TreeHolder const& aBaseTree, NodeOffset nBaseNode);
+ /// setup the 'target' node that is to be affected or changed
+ void setTarget(TreeHolder const& aAffectedTree, NodeOffset nAffectedNode);
protected:
- /// the path from base to 'affected' node - uses own (explicit) path
- virtual RelativePath doGetChangingNodePath() const;
+ /// virtual hooks for some of the public methods
+ /// is the change really affecting a child of the affected node (false here)
+ virtual bool doIsChangingSubnode() const;
+ };
+//-----------------------------------------------------------------------------
+ class SetElementFactory;
- /// the tree on which the operation originated
- virtual TreeHolder doGetBaseTree() const; // uses own
- /// the node thru which the operation originated
- virtual NodeOffset doGetBaseNode() const; // uses own
+ /// represents setting to its default state a set (as a container)
+ class SetResetImpl
+ : public SetChangeImpl
+ {
+ typedef std::vector< ElementTreeChange > TreeChanges;
+
+ std::auto_ptr<ISubtree> m_aDefaultData;
+ SetElementFactory& m_rElementFactory;
+ TreeChanges m_aTreeChanges;
+ public:
+ explicit SetResetImpl(
+ SetElementFactory& _rElementFactory,
+ std::auto_ptr<ISubtree> _pDefaultData,
+ bool _bNoCheck = false);
+
+ ~SetResetImpl();
+
+ protected:
+ /// virtual hooks for some of the public methods
+ /// retrieve the count of elements affected
+ ChangeCount doGetChangeCount() const;
+
+ /// the path from base to 'affected' node
+ virtual RelativePath doGetChangingNodePath(ChangeCount _ix) const;
+
+ /// checks, if this represents an actual change (given whether the change has been applied or not)
+ virtual bool doIsChange() const;
+ /// fills in pre- and post-change values, returns wether they differ
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
+
+
+ /// retrieve the old value from the given node
+ virtual void doTest( Node& rTarget);
+ /// do apply the actual change
+ virtual void doApply( Node& rTarget);
};
//-----------------------------------------------------------------------------
- /// represents a change to a set (as a container)
- class SetChangeImpl
- : public NodeChangeImpl
+ /// represents a change to an element of a set (as a container)
+ class SetElementChangeImpl
+ : public SetChangeImpl
{
Path::Component m_aName;
public:
- explicit SetChangeImpl(Path::Component const& aName, bool bNoCheck = false);
+ explicit SetElementChangeImpl(Path::Component const& aName, bool bNoCheck = false);
/// the name of the element being changed
Path::Component getFullElementName() const { return m_aName; }
@@ -314,15 +391,10 @@ namespace configmgr
/// 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);
protected:
/// virtual hooks for some of the public methods
/// the path from base to 'affected' node - use element name
- virtual RelativePath doGetChangingNodePath() const;
-
- /// is the change really affecting a child of the affected node (false here)
- virtual bool doIsChangingSubnode() const;
+ virtual RelativePath doGetChangingNodePath(ChangeCount _ix) const;
/// retrieve the old value from the given node
virtual void doTest( Node& rTarget);
@@ -338,18 +410,18 @@ namespace configmgr
//-----------------------------------------------------------------------------
/// represents an insertion into a set of trees
- class SetInsertTreeImpl
- : public SetChangeImpl
+ class SetInsertImpl
+ : public SetElementChangeImpl
{
ElementTreeHolder m_aNewTree;
public:
- explicit SetInsertTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, bool bNoCheck = false);
+ explicit SetInsertImpl(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)
- virtual bool doIsChange(bool bBefore) const;
+ virtual bool doIsChange() const;
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
/// new overridable: retrieve the old value from a properly typed node
virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
@@ -359,20 +431,20 @@ namespace configmgr
//-----------------------------------------------------------------------------
/// represents a substitution within a set of trees
- class SetReplaceTreeImpl
- : public SetChangeImpl
+ class SetReplaceImpl
+ : public SetElementChangeImpl
{
ElementTreeHolder m_aNewTree;
ElementTreeHolder m_aOldTree;
public:
- explicit SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree);
- explicit SetReplaceTreeImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree, ElementTreeHolder const& aOldTree);
+ explicit SetReplaceImpl(Path::Component const& aName, ElementTreeHolder const& aNewTree);
+ explicit SetReplaceImpl(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)
- virtual bool doIsChange(bool bBefore) const;
+ virtual bool doIsChange() const;
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
/// new overridable: retrieve the old value from a properly typed node
virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
@@ -382,46 +454,19 @@ namespace configmgr
//-----------------------------------------------------------------------------
/// represents a removal from of a set of trees
- class SetRemoveTreeImpl
- : public SetChangeImpl
+ class SetRemoveImpl
+ : public SetElementChangeImpl
{
ElementTreeHolder m_aOldTree;
public:
- 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)
- virtual bool doIsChange(bool bBefore) const;
- /// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeData& rChange) const;
-
- /// new overridable: retrieve the old value from a properly typed node
- virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
- /// new overridable: apply the change to a properly typed node
- virtual void doApplyToElement(SetNodeImpl& rNode, Name const& aName);
- };
-//-----------------------------------------------------------------------------
- typedef SetInsertTreeImpl SetInsertValueImpl;
- typedef SetReplaceTreeImpl SetReplaceValueImpl;
- typedef SetRemoveTreeImpl SetRemoveValueImpl;
-/*
- /// represents an insertion into a set of values
- class SetInsertValueImpl
- : public SetChangeImpl
- {
- UnoAny m_aNewValue;
- public:
- explicit SetInsertValueImpl(Name const& aName, UnoAny const& aNewValue);
-
- /// get the post-change value (if known)
- UnoAny getNewValue() const { return m_aNewValue; }
+ explicit SetRemoveImpl(Path::Component const& aName);
+ explicit SetRemoveImpl(Path::Component const& aName, ElementTreeHolder const& aOldTree);
protected:
/// checks, if this represents an actual change (given whether the change has been applied or not)
- virtual bool doIsChange(bool bBefore) const;
+ virtual bool doIsChange() const;
/// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeInfo& rChange) const;
+ virtual bool doFillChange(NodeChangeData& rChange, ChangeCount _ix) const;
/// new overridable: retrieve the old value from a properly typed node
virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
@@ -430,57 +475,6 @@ namespace configmgr
};
//-----------------------------------------------------------------------------
- /// represents a substitution within a set of trees
- class SetReplaceValueImpl
- : public SetChangeImpl
- {
- ElementTreeHolder m_aOldTree;
- UnoAny m_aNewValue;
- public:
- explicit SetReplaceValueImpl(Name const& aName, UnoAny const& aNewValue);
-
- /// get the post-change value (if known)
- UnoAny getNewValue() const { return m_aNewValue; }
- /// get the pre-change value (if known)
- UnoAny getOldValue() const;
-
- protected:
- /// checks, if this represents an actual change (given whether the change has been applied or not)
- virtual bool doIsChange(bool bBefore) const;
- /// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeInfo& rChange) const;
-
- /// new overridable: retrieve the old value from a properly typed node
- virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
- /// new overridable: apply the change to a properly typed node
- virtual void doApplyToElement(SetNodeImpl& rNode, Name const& aName);
- };
-
-//-----------------------------------------------------------------------------
-
- /// represents a removal from of a set of values
- class SetRemoveValueImpl
- : public SetChangeImpl
- {
- ElementTreeHolder m_aOldTree;
- public:
- explicit SetRemoveValueImpl(Name const& aName);
-
- /// get the pre-change value (if known)
- UnoAny getOldValue() const;
-
- protected:
- /// checks, if this represents an actual change (given whether the change has been applied or not)
- virtual bool doIsChange(bool bBefore) const;
- /// fills in pre- and post-change values, returns wether they differ
- virtual bool doFillChange(NodeChangeInfo& rChange) const;
-
- /// new overridable: retrieve the old value from a properly typed node
- virtual void doTestElement(SetNodeImpl& rNode, Name const& aName);
- /// new overridable: apply the change to a properly typed node
- virtual void doApplyToElement(SetNodeImpl& rNode, Name const& aName);
- };
-*/
//-----------------------------------------------------------------------------
}
}
diff --git a/configmgr/source/treemgr/nodeimpl.cxx b/configmgr/source/treemgr/nodeimpl.cxx
index 48e92dc39dbd..fd1cafa0e157 100644
--- a/configmgr/source/treemgr/nodeimpl.cxx
+++ b/configmgr/source/treemgr/nodeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimpl.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: jb $ $Date: 2001-07-20 11:01:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,20 +61,48 @@
#include <stdio.h>
#include "nodeimpl.hxx"
+#ifndef CONFIGMGR_VALUENODEBEHAVIOR_HXX_
#include "valuenodeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_GROUPNODEBEHAVIOR_HXX_
#include "groupnodeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_SETNODEIMPL_HXX_
#include "setnodeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGNODEIMPL_HXX_
#include "treeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGE_HXX_
#include "nodechange.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEIMPL_HXX_
#include "nodechangeimpl.hxx"
+#endif
+#ifndef CONFIGMGR_CONFIGCHANGEINFO_HXX_
#include "nodechangeinfo.hxx"
+#endif
+#ifndef CONFIGMGR_CHANGE_HXX
#include "change.hxx"
+#endif
+#ifndef CONFIGMGR_COLLECTCHANGES_HXX_
#include "collectchanges.hxx"
-
+#endif
+#ifndef _CONFIGMGR_TREEACTIONS_HXX_
+#include "treeactions.hxx"
+#endif
+#ifndef CONFIGMGR_TREE_CHANGEFACTORY_HXX
+#include "treechangefactory.hxx"
+#endif
+
+#ifndef CONFIGMGR_CMTREEMODEL_HXX
#include "cmtreemodel.hxx"
+#endif
+#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
+#endif
namespace configmgr
{
@@ -159,9 +187,7 @@ void NodeImpl::makeIndirect(NodeImplHolder& aThis,bool bIndirect)
void NodeImpl::addLocalChangeHelper( NodeChangesInformation& rLocalChanges_, NodeChange const& aChange_)
{
- NodeChangeInformation aThisInfo;
- if (aChange_.getChangeInfo(aThisInfo))
- rLocalChanges_.push_back( aThisInfo );
+ aChange_.getChangeInfos(rLocalChanges_);
}
@@ -196,6 +222,12 @@ bool GroupNodeImpl::hasValue(Name const& aName) const
}
//-----------------------------------------------------------------------------
+bool GroupNodeImpl::areValueDefaultsAvailable() const
+{
+ return m_rOriginal.getDefaultsLevel() != 0 || m_rOriginal.getAttributes().bDefaulted;
+}
+//-----------------------------------------------------------------------------
+
ValueNode* GroupNodeImpl::getOriginalValueNode(Name const& aName) const
{
OSL_ENSURE( !aName.isEmpty(), "Cannot get nameless child value");
@@ -344,6 +376,33 @@ void SetNodeImpl::removeElement(Name const& aName)
}
//-----------------------------------------------------------------------------
+std::auto_ptr<SubtreeChange> SetNodeImpl::differenceToDefaultState(ISubtree& _rDefaultTree)
+{
+ std::auto_ptr<SubtreeChange> aResult;
+ if (!getOriginalSetNode().isDefault())
+ {
+ aResult.reset( new SubtreeChange( getOriginalSetNode(), true ) );
+
+ if (this->hasChanges())
+ {
+ OSL_ENSURE(implHasLoadedElements(),"Unexpected: Found set with changes but elements are not loaded");
+ this->doDifferenceToDefaultState(*aResult,_rDefaultTree);
+ }
+ else
+ this->implDifferenceToDefaultState(*aResult,_rDefaultTree);
+ }
+ return aResult;
+}
+//-----------------------------------------------------------------------------
+
+void SetNodeImpl::doDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree)
+{
+ OSL_ENSURE(!hasChanges(), "ERROR: SetNodeImpl::doDifferenceToDefaultState does not account for changes");
+
+ implDifferenceToDefaultState(_rChangeToDefault,_rDefaultTree);
+}
+//-----------------------------------------------------------------------------
+
SetNodeVisitor::Result SetNodeImpl::dispatchToElements(SetNodeVisitor& aVisitor)
{
if (implLoadElements())
@@ -364,20 +423,20 @@ NodeType::Enum SetNodeImpl::doGetType() const
{
return NodeType::eSET;
}
-
//-----------------------------------------------------------------------------
+
void SetNodeImpl::doDispatch(INodeHandler& rHandler)
{
rHandler.handle(*this);
}
-
//-----------------------------------------------------------------------------
+
bool SetNodeImpl::implHasLoadedElements() const
{
return m_aInit == 0; // cannot check whether init was called though ...
}
-
//-----------------------------------------------------------------------------
+
bool SetNodeImpl::implLoadElements()
{
if (m_aInit > 0)
@@ -390,15 +449,15 @@ bool SetNodeImpl::implLoadElements()
return m_aInit == 0;
}
-
//-----------------------------------------------------------------------------
+
void SetNodeImpl::implEnsureElementsLoaded()
{
if (!implLoadElements())
throw ConstraintViolation("Trying to access set elements beyond the loaded nestng level");
}
-
//-----------------------------------------------------------------------------
+
bool SetNodeImpl::implInitElements(InitHelper const& aInit)
{
TreeDepth nDepth = aInit;
@@ -413,8 +472,8 @@ bool SetNodeImpl::implInitElements(InitHelper const& aInit)
else
return false;
}
-
//-----------------------------------------------------------------------------
+
void SetNodeImpl::initElements(TemplateProvider const& aTemplateProvider,TreeImpl& rParentTree,NodeOffset nPos,TreeDepth nDepth)
{
OSL_ENSURE(m_pParentTree == 0 || m_pParentTree == &rParentTree, "WARNING: Set Node: Changing parent");
@@ -434,6 +493,131 @@ void SetNodeImpl::initElements(TemplateProvider const& aTemplateProvider,TreeImp
m_aTemplateProvider = aTemplateProvider;
}
}
+//-----------------------------------------------------------------------------
+
+void SetNodeImpl::implMarkAsDefault(bool bDefault)
+{
+ m_rOriginal.markAsDefault(bDefault);
+}
+//-----------------------------------------------------------------------------
+
+namespace
+{
+ //-------------------------------------------------------------------------
+ class DiffToDefault : NodeAction
+ {
+ SubtreeChange& m_rChange;
+ ISubtree& m_rDefaultTree;
+ OTreeChangeFactory& m_rChangeFactory;
+ public:
+ explicit
+ DiffToDefault(SubtreeChange& _rChange, ISubtree& _rDefaultTree)
+ : m_rChange(_rChange)
+ , m_rDefaultTree(_rDefaultTree)
+ , m_rChangeFactory( getDefaultTreeChangeFactory() )
+ {
+ }
+
+ void diff(ISubtree const& _rActualTree)
+ {
+ translate(m_rDefaultTree);
+ applyToChildren(_rActualTree);
+ }
+
+ private:
+ void translate(ISubtree& _rDefaultTree);
+ void handleDefault(std::auto_ptr<INode> _pDefaultNode);
+ void handleActual(INode const& _rNode);
+
+ virtual void handle(ValueNode const& _aValue) { handleActual(_aValue); }
+ virtual void handle(ISubtree const& _aTree) { handleActual(_aTree); }
+ };
+ //-------------------------------------------------------------------------
+
+ void DiffToDefault::translate(ISubtree& _rDefaultTree)
+ {
+ typedef CollectNames::NameList::const_iterator NameIter;
+
+ CollectNames aCollector;
+ aCollector.applyToChildren(_rDefaultTree);
+
+ CollectNames::NameList const& aNames = aCollector.list();
+
+ for(NameIter it = aNames.begin(); it != aNames.end(); ++it)
+ {
+ handleDefault(_rDefaultTree.removeChild(*it));
+ }
+
+ }
+ //-------------------------------------------------------------------------
+
+ void DiffToDefault::handleDefault(std::auto_ptr<INode> _pDefaultNode)
+ {
+ OSL_PRECOND(_pDefaultNode.get(), "Unexpected NULL default node");
+ if (!_pDefaultNode.get()) return;
+
+ OUString sName = _pDefaultNode->getName();
+
+ OSL_ENSURE(_pDefaultNode->isDefault(), "Missing default attribute on default data node");
+
+ std::auto_ptr<AddNode> pAddIt( m_rChangeFactory.createAddNodeChange(_pDefaultNode, sName,true) );
+
+ m_rChange.addChange(base_ptr(pAddIt));
+ }
+ //-------------------------------------------------------------------------
+
+ void DiffToDefault::handleActual(INode const& _rNode)
+ {
+ //needed, as the expect.. functions take a non-const pointer
+ INode* pActualNode = const_cast<INode*>(&_rNode);
+
+ OUString sName = _rNode.getName();
+
+ if (Change* pDefaultNode = m_rChange.getChange(sName) )
+ {
+ if (pDefaultNode->ISA(AddNode))
+ {
+ AddNode* pAddIt = static_cast<AddNode*>(pDefaultNode);
+ if (_rNode.isDefault())
+ {
+ m_rDefaultTree.addChild( pAddIt->releaseAddedNode() );
+
+ // no change needed - remove the change and recover the default
+ m_rChange.removeChange(sName);
+ }
+ else
+ {
+ OSL_ENSURE(!pAddIt->getReplacedNode_Unsafe(), "Duplicate node name in actual tree");
+
+ pAddIt->expectReplacedNode(pActualNode);
+ }
+ }
+ else
+ {
+ // should never happen
+ OSL_ENSURE(pDefaultNode->ISA(RemoveNode), "Unexpected node type found in translated default tree");
+ OSL_ENSURE(!pDefaultNode->ISA(RemoveNode), "Duplicate node name in actual tree");
+
+ if (_rNode.isDefault()) m_rChange.removeChange(sName);
+ }
+ }
+ else
+ {
+ OSL_ENSURE(!_rNode.isDefault(), "Node marked 'default' not found in actual default data");
+
+ std::auto_ptr<RemoveNode> pRemoveIt( m_rChangeFactory.createRemoveNodeChange(sName,true) );
+ pRemoveIt->expectRemovedNode(pActualNode);
+ m_rChange.addChange(base_ptr(pRemoveIt));
+ }
+ }
+ //-------------------------------------------------------------------------
+}
+//-----------------------------------------------------------------------------
+void SetNodeImpl::implDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree) const
+{
+ DiffToDefault(_rChangeToDefault,_rDefaultTree).diff(m_rOriginal);
+}
+//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// class ValueElementNodeImpl
@@ -472,9 +656,7 @@ UnoType ValueElementNodeImpl::getValueType() const
Attributes ValueElementNodeImpl::doGetAttributes() const
{
- Attributes aResult = fetchAttributes(m_rOriginal);
- aResult.bDefaultable = false;
- return aResult;
+ return fetchAttributes(m_rOriginal);
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/nodeimplobj.cxx b/configmgr/source/treemgr/nodeimplobj.cxx
index 5ca66ecb9601..c6392ac02978 100644
--- a/configmgr/source/treemgr/nodeimplobj.cxx
+++ b/configmgr/source/treemgr/nodeimplobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimplobj.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: jb $ $Date: 2001-07-20 11:01:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -663,6 +663,12 @@ NodeImplHolder ReadOnlyTreeSetNodeImpl::doCloneIndirect(bool)
}
//-----------------------------------------------------------------------------
+void ReadOnlyTreeSetNodeImpl::doMarkAsDefault()
+{
+ failReadOnly();
+}
+//-----------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------
// class ReadOnlyValueSetNodeImpl
//-----------------------------------------------------------------------------
@@ -726,6 +732,12 @@ NodeImplHolder ReadOnlyValueSetNodeImpl::doCloneIndirect(bool)
}
//-----------------------------------------------------------------------------
+void ReadOnlyValueSetNodeImpl::doMarkAsDefault()
+{
+ failReadOnly();
+}
+//-----------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------
// class DirectTreeSetNodeImpl
@@ -748,12 +760,14 @@ void DirectTreeSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& a
{
TreeSetNodeImpl::doInsertElement(aName,aNewEntry);
aNewEntry.tree()->makeIndirect(false);
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
void DirectTreeSetNodeImpl::doRemoveElement(Name const& aName)
{
TreeSetNodeImpl::doRemoveElement(aName);
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
@@ -788,7 +802,7 @@ void DirectTreeSetNodeImpl::doCommitChanges()
void DirectTreeSetNodeImpl::doMarkChanged()
{
- // ignore
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
@@ -807,6 +821,12 @@ NodeImplHolder DirectTreeSetNodeImpl::doCloneIndirect(bool bIndirect)
}
//-----------------------------------------------------------------------------
+void DirectTreeSetNodeImpl::doMarkAsDefault()
+{
+ implMarkAsDefault(true);
+}
+//-----------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------
// class DirectValueSetNodeImpl
//-----------------------------------------------------------------------------
@@ -828,12 +848,14 @@ void DirectValueSetNodeImpl::doInsertElement(Name const& aName, SetEntry const&
{
ValueSetNodeImpl::doInsertElement(aName,aNewElement);
aNewElement.tree()->makeIndirect(false);
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
void DirectValueSetNodeImpl::doRemoveElement(Name const& aName)
{
ValueSetNodeImpl::doRemoveElement(aName);
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
@@ -869,6 +891,7 @@ void DirectValueSetNodeImpl::doCommitChanges()
void DirectValueSetNodeImpl::doMarkChanged()
{
// Ignore
+ implMarkAsDefault(false);
}
//-----------------------------------------------------------------------------
@@ -887,6 +910,12 @@ NodeImplHolder DirectValueSetNodeImpl::doCloneIndirect(bool bIndirect)
}
//-----------------------------------------------------------------------------
+void DirectValueSetNodeImpl::doMarkAsDefault()
+{
+ implMarkAsDefault(true);
+}
+//-----------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------
// class DeferredTreeSetNodeImpl
//-----------------------------------------------------------------------------
@@ -895,6 +924,7 @@ DeferredTreeSetNodeImpl::DeferredTreeSetNodeImpl(ISubtree& rOriginal, Template*
: TreeSetNodeImpl(rOriginal,pTemplate)
, m_aChangedData()
, m_bChanged(false)
+, m_bDefault(false)
{
}
//-----------------------------------------------------------------------------
@@ -903,6 +933,7 @@ DeferredTreeSetNodeImpl::DeferredTreeSetNodeImpl(DirectTreeSetNodeImpl& rOrigina
: TreeSetNodeImpl(rOriginal)
, m_aChangedData()
, m_bChanged(false)
+, m_bDefault(false)
{
implMakeIndirect(true);
}
@@ -982,13 +1013,15 @@ SetNodeVisitor::Result DeferredTreeSetNodeImpl::doDispatchToElements(SetNodeVisi
void DeferredTreeSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
- implInsertNewElement(aName, TreeSetNodeImpl::implMakeElement(aNewEntry.tree()));
+ implInsertNewElement(aName, TreeSetNodeImpl::implMakeElement(aNewEntry));
+ m_bDefault = false;
}
//-----------------------------------------------------------------------------
void DeferredTreeSetNodeImpl::doRemoveElement(Name const& aName)
{
implRemoveOldElement(aName);
+ m_bDefault = false;
}
//-----------------------------------------------------------------------------
@@ -1153,6 +1186,7 @@ std::auto_ptr<SubtreeChange> DeferredTreeSetNodeImpl::doPreCommitChanges(Element
if (m_aChangedData.getElement(it->first) == 0)
{
OSL_ASSERT(it->second.isValid());
+ OSL_ENSURE( !m_bDefault || it->second.inDefault, "m_bDefault is inconsistent");
std::auto_ptr<SubtreeChange> pNewChange( it->second->preCommitChanges(_rRemovedElements) );
if (pNewChange.get() != 0)
@@ -1181,8 +1215,9 @@ std::auto_ptr<SubtreeChange> DeferredTreeSetNodeImpl::doPreCommitChanges(Element
aNewElement->releaseTo( aAddedTree );
OSL_ENSURE( aAddedTree.get(), "Could not take the new tree from the ElementTree");
+ OSL_ENSURE( !m_bDefault || aNewElement.inDefault, "m_bDefault is inconsistent");
- AddNode* pAddNode = new AddNode(aAddedTree, aName.toString() );
+ AddNode* pAddNode = new AddNode(aAddedTree, aName.toString(), aNewElement.inDefault );
std::auto_ptr<Change> pNewChange( pAddNode );
@@ -1195,7 +1230,9 @@ std::auto_ptr<SubtreeChange> DeferredTreeSetNodeImpl::doPreCommitChanges(Element
{
if (pOriginal)
{
- std::auto_ptr<Change> pNewChange( new RemoveNode(aName.toString()) );
+ OSL_ENSURE( !m_bDefault || aNewElement.inDefault, "m_bDefault is inconsistent");
+
+ std::auto_ptr<Change> pNewChange( new RemoveNode(aName.toString(),aNewElement.inDefault) );
pSetChange->addChange(pNewChange);
}
@@ -1204,7 +1241,7 @@ std::auto_ptr<SubtreeChange> DeferredTreeSetNodeImpl::doPreCommitChanges(Element
// collect removed or replaced element
if (pOriginal)
- _rRemovedElements.push_back( *pOriginal );
+ _rRemovedElements.push_back( pOriginal->tree );
++it;
}
@@ -1490,6 +1527,7 @@ void DeferredTreeSetNodeImpl::doFailedCommit(SubtreeChange& rChanges)
}
}
m_bChanged = false;
+ m_bDefault = false;
OSL_ENSURE(m_aChangedData.isEmpty(), "ERROR: Uncommitted changes left in set node");
}
@@ -1602,6 +1640,7 @@ void DeferredTreeSetNodeImpl::doAdjustChangedElement(NodeChangesInformation& rLo
NodeChangeImpl* DeferredTreeSetNodeImpl::doAdjustToAddedElement(Name const& aName, AddNode const& aAddNodeChange, Element const& aNewElement)
{
+ m_bDefault = false;
if (Element* pLocalElement = m_aChangedData.getElement(aName))
{
// We have another element replacing ours - what do we do ?
@@ -1640,6 +1679,7 @@ NodeChangeImpl* DeferredTreeSetNodeImpl::doAdjustToAddedElement(Name const& aNam
NodeChangeImpl* DeferredTreeSetNodeImpl::doAdjustToRemovedElement(Name const& aName, RemoveNode const& aRemoveNodeChange)
{
+ m_bDefault = false;
if (Element* pLocalElement = m_aChangedData.getElement(aName))
{
if (Element* pOriginal = getStoredElement(aName))
@@ -1667,6 +1707,90 @@ NodeChangeImpl* DeferredTreeSetNodeImpl::doAdjustToRemovedElement(Name const& aN
}
//-----------------------------------------------------------------------------
+void DeferredTreeSetNodeImpl::doDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree)
+{
+ if (!m_bDefault)
+ {
+ implDifferenceToDefaultState(_rChangeToDefault,_rDefaultTree);
+
+ NativeIterator it = m_aChangedData.beginNative();
+ NativeIterator const stop = m_aChangedData.endNative();
+
+ while(it != stop)
+ {
+ Name aName = it->first;
+ Element aElement = it->second;
+
+ Change* pChange = _rChangeToDefault.getChange( aName.toString() );
+ OSL_ENSURE(pChange == NULL || pChange->ISA(AddNode) || pChange->ISA(RemoveNode),
+ "Unexpected change type found in difference to default tree");
+
+ if (pChange == NULL)
+ {
+ std::auto_ptr<INode> aDefaultTree = _rDefaultTree.removeChild(aName.toString());
+
+ OSL_ENSURE( aDefaultTree.get(), "Error: unused Default tree not after SetNodeImpl::implDifferenceToDefaultState");
+
+ AddNode* pAddIt = new AddNode(aDefaultTree, aName.toString(), true );
+
+ std::auto_ptr<Change> pNewChange( pAddIt );
+
+ if (aElement.isValid())
+ {
+ OSL_ENSURE(!aElement.inDefault, "Default element replaced by default");
+ pAddIt->setReplacing();
+ }
+
+ _rChangeToDefault.addChange(pNewChange);
+
+ }
+ else if ( pChange->ISA(AddNode) )
+ {
+ // adjust the AddNode - remove the original expected node
+ AddNode* pAddIt = static_cast<AddNode*>(pChange);
+ pAddIt->expectReplacedNode(NULL);
+
+ if (aElement.isValid())
+ {
+ if (aElement.inDefault)
+ {
+ // change already done locally
+ _rChangeToDefault.removeChange(aName.toString());
+ }
+ else // adjust here
+ pAddIt->setReplacing();
+ }
+
+ else
+ OSL_ENSURE(!pAddIt->isReplacing(),"Could not unmark the 'replacing' state of an AddNode");
+ }
+ else if ( pChange->ISA(RemoveNode) )
+ {
+ if (aElement.isValid())
+ {
+ OSL_ENSURE(!aElement.inDefault, "Default element replaced by default");
+ // adjust the RemoveNode - remove the original expected node
+ RemoveNode* pRemoveIt = static_cast<RemoveNode*>(pChange);
+ pRemoveIt->expectRemovedNode(NULL);
+ }
+ else
+ {
+ // change already done locally
+ _rChangeToDefault.removeChange(aName.toString());
+ }
+ // TODO: mark local removal as to-default
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+
+void DeferredTreeSetNodeImpl::doMarkAsDefault()
+{
+ m_bDefault = true;
+}
+//-----------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------
// class DeferredValueSetNodeImpl
//-----------------------------------------------------------------------------
@@ -1675,6 +1799,7 @@ DeferredValueSetNodeImpl::DeferredValueSetNodeImpl(ISubtree& rOriginal, Template
: ValueSetNodeImpl(rOriginal,pTemplate)
, m_aChangedData()
, m_bChanged(false)
+, m_bDefault(false)
{
}
//-----------------------------------------------------------------------------
@@ -1683,6 +1808,7 @@ DeferredValueSetNodeImpl::DeferredValueSetNodeImpl(DirectValueSetNodeImpl& rOrig
: ValueSetNodeImpl(rOriginal)
, m_aChangedData()
, m_bChanged(false)
+, m_bDefault(false)
{
implMakeIndirect(true);
}
@@ -1762,13 +1888,15 @@ SetNodeVisitor::Result DeferredValueSetNodeImpl::doDispatchToElements(SetNodeVis
void DeferredValueSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
- implInsertNewElement(aName, ValueSetNodeImpl::implMakeElement(aNewEntry.tree()));
+ implInsertNewElement(aName, ValueSetNodeImpl::implMakeElement(aNewEntry));
+ m_bDefault = false;
}
//-----------------------------------------------------------------------------
void DeferredValueSetNodeImpl::doRemoveElement(Name const& aName)
{
implRemoveOldElement(aName);
+ m_bDefault = false;
}
//-----------------------------------------------------------------------------
@@ -1932,6 +2060,8 @@ std::auto_ptr<SubtreeChange> DeferredValueSetNodeImpl::doPreCommitChanges(Elemen
std::auto_ptr<SubtreeChange> pNewChange( it->second->preCommitChanges(_rRemovedElements) );
OSL_ENSURE(pNewChange.get() == NULL, "Unexpected change generated by value set element - ignoring that change");
+
+ OSL_ENSURE( !m_bDefault || it->second.inDefault, "m_bDefault is inconsistent");
}
}}
@@ -1953,8 +2083,9 @@ std::auto_ptr<SubtreeChange> DeferredValueSetNodeImpl::doPreCommitChanges(Elemen
aNewElement->releaseTo( aAddedTree );
OSL_ENSURE( aAddedTree.get(), "Could not take the new tree from the ElementTree");
+ OSL_ENSURE( !m_bDefault || aNewElement.inDefault, "m_bDefault is inconsistent");
- AddNode* pAddNode = new AddNode(aAddedTree, aName.toString() );
+ AddNode* pAddNode = new AddNode(aAddedTree, aName.toString(), aNewElement.inDefault );
std::auto_ptr<Change> pNewChange( pAddNode );
@@ -1967,7 +2098,9 @@ std::auto_ptr<SubtreeChange> DeferredValueSetNodeImpl::doPreCommitChanges(Elemen
{
if (pOriginal)
{
- std::auto_ptr<Change> pNewChange( new RemoveNode(aName.toString()) );
+ OSL_ENSURE( !m_bDefault || aNewElement.inDefault, "m_bDefault is inconsistent");
+
+ std::auto_ptr<Change> pNewChange( new RemoveNode(aName.toString(), aNewElement.inDefault) );
pSetChange->addChange(pNewChange);
}
@@ -1976,11 +2109,12 @@ std::auto_ptr<SubtreeChange> DeferredValueSetNodeImpl::doPreCommitChanges(Elemen
// collect removed or replaced element
if (pOriginal)
- _rRemovedElements.push_back( *pOriginal );
+ _rRemovedElements.push_back( pOriginal->tree );
++it;
}
}
+
return pSetChange;
}
//-----------------------------------------------------------------------------
@@ -2250,6 +2384,7 @@ void DeferredValueSetNodeImpl::doFailedCommit(SubtreeChange& rChanges)
}
}
m_bChanged = false;
+ m_bDefault = false;
OSL_ENSURE(m_aChangedData.isEmpty(), "ERROR: Uncommitted changes left in set node");
}
@@ -2351,6 +2486,7 @@ void DeferredValueSetNodeImpl::doAdjustChangedElement(NodeChangesInformation& rL
NodeChangeImpl* DeferredValueSetNodeImpl::doAdjustToAddedElement(Name const& aName, AddNode const& aAddNodeChange, Element const& aNewElement)
{
+ m_bDefault = false;
if (Element* pLocalElement = m_aChangedData.getElement(aName))
{
// We have another element replacing ours - what do we do ?
@@ -2389,6 +2525,7 @@ NodeChangeImpl* DeferredValueSetNodeImpl::doAdjustToAddedElement(Name const& aNa
NodeChangeImpl* DeferredValueSetNodeImpl::doAdjustToRemovedElement(Name const& aName, RemoveNode const& aRemoveNodeChange)
{
+ m_bDefault = false;
if (Element* pLocalElement = m_aChangedData.getElement(aName))
{
if (Element* pOriginal = getStoredElement(aName))
@@ -2416,7 +2553,88 @@ NodeChangeImpl* DeferredValueSetNodeImpl::doAdjustToRemovedElement(Name const& a
}
//-----------------------------------------------------------------------------
+void DeferredValueSetNodeImpl::doDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree)
+{
+ if (!m_bDefault)
+ {
+ implDifferenceToDefaultState(_rChangeToDefault,_rDefaultTree);
+
+ NativeIterator it = m_aChangedData.beginNative();
+ NativeIterator const stop = m_aChangedData.endNative();
+
+ while(it != stop)
+ {
+ Name aName = it->first;
+ Element aElement = it->second;
+
+ Change* pChange = _rChangeToDefault.getChange( aName.toString() );
+ OSL_ENSURE(pChange == NULL || pChange->ISA(AddNode) || pChange->ISA(RemoveNode),
+ "Unexpected change type found in difference to default tree");
+
+ if (pChange == NULL)
+ {
+ std::auto_ptr<INode> aDefaultTree = _rDefaultTree.removeChild(aName.toString());
+
+ OSL_ENSURE( aDefaultTree.get(), "Error: unused Default tree not after SetNodeImpl::implDifferenceToDefaultState");
+
+ AddNode* pAddIt = new AddNode(aDefaultTree, aName.toString(), true );
+ std::auto_ptr<Change> pNewChange( pAddIt );
+
+ if (aElement.isValid())
+ {
+ OSL_ENSURE(!aElement.inDefault, "Default element replaced by default");
+ pAddIt->setReplacing();
+ }
+
+ _rChangeToDefault.addChange(pNewChange);
+
+ }
+ else if ( pChange->ISA(AddNode) )
+ {
+ // adjust the AddNode - remove the original expected node
+ AddNode* pAddIt = static_cast<AddNode*>(pChange);
+ pAddIt->expectReplacedNode(NULL);
+
+ if (aElement.isValid())
+ {
+ if (aElement.inDefault)
+ {
+ // change already done locally
+ _rChangeToDefault.removeChange(aName.toString());
+ }
+ else // adjust here
+ pAddIt->setReplacing();
+ }
+
+ else
+ OSL_ENSURE(!pAddIt->isReplacing(),"Could not unmark the 'replacing' state of an AddNode");
+ }
+ else if ( pChange->ISA(RemoveNode) )
+ {
+ if (aElement.isValid())
+ {
+ OSL_ENSURE(!aElement.inDefault, "Default element replaced by default");
+ // adjust the RemoveNode - remove the original expected node
+ RemoveNode* pRemoveIt = static_cast<RemoveNode*>(pChange);
+ pRemoveIt->expectRemovedNode(NULL);
+ }
+ else
+ {
+ // change already done locally
+ _rChangeToDefault.removeChange(aName.toString());
+ }
+ // TODO: mark local removal as to-default
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+
+void DeferredValueSetNodeImpl::doMarkAsDefault()
+{
+ m_bDefault = true;
+}
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/treemgr/nodeimplobj.hxx b/configmgr/source/treemgr/nodeimplobj.hxx
index 8e456dc82857..a165a7d5941d 100644
--- a/configmgr/source/treemgr/nodeimplobj.hxx
+++ b/configmgr/source/treemgr/nodeimplobj.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: nodeimplobj.hxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: jb $ $Date: 2001-07-20 11:01:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -293,6 +293,8 @@ namespace configmgr
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
+ virtual void doMarkAsDefault();
+
virtual void doInitElements( ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
@@ -321,6 +323,8 @@ namespace configmgr
virtual void doInitElements(ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
+ virtual void doMarkAsDefault();
+
// NodeImpl implementation
virtual Attributes doGetAttributes() const;
@@ -349,6 +353,8 @@ namespace configmgr
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
+ virtual void doMarkAsDefault();
+
virtual void doInitElements( ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
@@ -378,6 +384,8 @@ namespace configmgr
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
+ virtual void doMarkAsDefault();
+
virtual void doInitElements(ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
@@ -417,6 +425,9 @@ namespace configmgr
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
+ virtual void doDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree);
+ virtual void doMarkAsDefault();
+
virtual void doInitElements(ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
@@ -438,6 +449,7 @@ namespace configmgr
ElementSet m_aChangedData;
bool m_bChanged;
+ bool m_bDefault;
};
//-----------------------------------------------------------------------------
@@ -469,6 +481,9 @@ namespace configmgr
virtual void doInsertElement(Name const& aName, SetEntry const& aNewEntry);
virtual void doRemoveElement(Name const& aName);
+ virtual void doDifferenceToDefaultState(SubtreeChange& _rChangeToDefault, ISubtree& _rDefaultTree);
+ virtual void doMarkAsDefault();
+
virtual void doInitElements(ISubtree& rTree, TreeDepth nDepth);
virtual Element doMakeAdditionalElement(AddNode const& aAddNodeChange, TreeDepth nDepth);
@@ -490,6 +505,7 @@ namespace configmgr
ElementSet m_aChangedData;
bool m_bChanged;
+ bool m_bDefault;
};
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/noderef.cxx b/configmgr/source/treemgr/noderef.cxx
index 34a0b5c561b8..5955725d97f7 100644
--- a/configmgr/source/treemgr/noderef.cxx
+++ b/configmgr/source/treemgr/noderef.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: noderef.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: jb $ $Date: 2001-08-06 15:25:20 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -324,6 +324,43 @@ namespace
return CONTINUE;
}
//-----------------------------------------------------------------------------
+ struct FindNonDefaultElement : SetNodeVisitor
+ {
+ Result visit(SetEntry const& anEntry);
+
+ static bool hasNonDefaultElement(SetNodeImpl& _rSet);
+ };
+
+ SetNodeVisitor::Result FindNonDefaultElement::visit(SetEntry const& anEntry)
+ {
+ OSL_ASSERT(anEntry.isValid());
+
+ Result aResult = DONE; // if we find a NULL element we consider this
+
+ if (TreeImpl* pTree = anEntry.tree())
+ {
+ Tree aTree( pTree );
+
+ Attributes aElementAttributes = aTree.getAttributes(aTree.getRootNode());
+
+ // a set element is considered default iff it is not replaced/added
+ bool bDefault = !aElementAttributes.bReplaced;
+
+ aResult = bDefault ? CONTINUE : DONE;
+ }
+ else
+ OSL_ENSURE(false,"Unexpected NULL SetEntry considered as non-default.");
+
+ return aResult;
+ }
+
+ bool FindNonDefaultElement::hasNonDefaultElement(SetNodeImpl& _rSet)
+ {
+ FindNonDefaultElement aCheck;
+ Result aRes = _rSet.dispatchToElements(aCheck);
+ return aRes == DONE;
+ }
+//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
@@ -1106,10 +1143,21 @@ bool Tree::isRootNode(NodeRef const& aNode) const
}
//-----------------------------------------------------------------------------
-void Tree::ensureDefaults() const
+bool Tree::hasNodeDefault(ValueRef const& aNode) const // only works for value nodes
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
- OSL_ENSURE(false,"Configuration: WARNING: Default handling not really implemented yet");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Value operation requires a valid ValueRef");
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: ValueRef does not point to valid value");
+
+ bool bHasDefault = false;
+ if (aNode.isValid())
+ {
+ ValueMemberNode aValueMember = TreeImplHelper::member_node(aNode);
+
+ bHasDefault = aValueMember.canGetDefaultValue();
+ }
+
+ return bHasDefault;
}
//-----------------------------------------------------------------------------
@@ -1119,54 +1167,94 @@ bool Tree::isNodeDefault(ValueRef const& aNode) const // only works for value no
OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Value operation requires a valid ValueRef");
OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: ValueRef does not point to valid value");
- if (!aNode.isValid()) return false;
+ if (!hasNodeDefault(aNode)) return false;
return TreeImplHelper::member_node(aNode).isDefault();
}
//-----------------------------------------------------------------------------
-bool Tree::isNodeDefault(AnyNodeRef const& aNode) const
+bool Tree::hasNodeDefault(NodeRef const& aNode) const
+{
+ OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Value operation requires a valid ValueRef");
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: ValueRef does not point to valid value");
+
+ // not a set - then it has no default
+ return aNode.isValid() && aNode.m_pImpl->isSetNode();
+}
+//-----------------------------------------------------------------------------
+
+bool Tree::isNodeDefault(NodeRef const& aNode) const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid Node");
OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: Node does not match Tree");
- // not a value - then it isn't default
- if (aNode.isNode()) return false;
+ if (!hasNodeDefault(aNode)) return false;
- return this->isNodeDefault( aNode.toValue() );
+ // not a set - then it isn't default
+ OSL_ASSERT(aNode.m_pImpl->isSetNode());
+
+ // a set is defaults, if all its elements are default
+ return !FindNonDefaultElement::hasNonDefaultElement(aNode.m_pImpl->setImpl());
}
//-----------------------------------------------------------------------------
-UnoAny Tree::getNodeDefault(ValueRef const& aNode) const // only works for value nodes
+bool Tree::hasNodeDefault(AnyNodeRef const& aNode) const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
- OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Value operation requires a valid ValueRef");
- OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: ValueRef does not point to valid value");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid Node");
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: Node does not match Tree");
- if (aNode.isValid())
- {
- ValueMemberNode aValueMember = TreeImplHelper::member_node(aNode);
+ if (aNode.isNode())
+ return this->hasNodeDefault( aNode.toNode() );
+ else
+ return this->hasNodeDefault( aNode.toValue() );
+}
+//-----------------------------------------------------------------------------
- if (aValueMember.canGetDefaultValue())
- return aValueMember.getDefaultValue();
- }
+bool Tree::isNodeDefault(AnyNodeRef const& aNode) const
+{
+ OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid Node");
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: Node does not match Tree");
- return UnoAny();
+ if (aNode.isNode())
+ return this->isNodeDefault( aNode.toNode() );
+ else
+ return this->isNodeDefault( aNode.toValue() );
}
//-----------------------------------------------------------------------------
-UnoAny Tree::getNodeDefault(AnyNodeRef const& aNode) const // only works for value nodes
+bool Tree::areValueDefaultsAvailable(NodeRef const& aNode) const
{
OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Node operation requires a valid Node");
OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: Node does not match Tree");
+ OSL_PRECOND( aNode.m_pImpl && aNode.m_pImpl->isGroupNode(),
+ "WARNING: Configuration: Group Node expected. Result is not meaningful");
+
+ return aNode.m_pImpl && aNode.m_pImpl->isGroupNode() &&
+ aNode.m_pImpl->groupImpl().areValueDefaultsAvailable();
+}
+//-----------------------------------------------------------------------------
+
+UnoAny Tree::getNodeDefaultValue(ValueRef const& aNode) const // only works for value nodes
+{
+ OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree");
+ OSL_PRECOND( aNode.isValid(), "ERROR: Configuration: Value operation requires a valid ValueRef");
+ OSL_PRECOND( isValidNode(aNode), "ERROR: Configuration: ValueRef does not point to valid value");
+
+ if (aNode.isValid())
+ {
+ ValueMemberNode aValueMember = TreeImplHelper::member_node(aNode);
- // not a value - then there isn't a default
- if (aNode.isNode()) return UnoAny();
+ if (aValueMember.canGetDefaultValue())
+ return aValueMember.getDefaultValue();
+ }
- return this->getNodeDefault( aNode.toValue() );
+ return UnoAny();
}
//-----------------------------------------------------------------------------
@@ -1768,29 +1856,24 @@ bool identifiesLocalValue(Tree const& aTree, NodeRef const& aNode, RelativePath
}
//-----------------------------------------------------------------------------
-AnyNodeRef getLocalDescendant(Tree /*const*/& aTree, NodeRef& aNode, RelativePath& rPath)
+AnyNodeRef getLocalDescendant(Tree const& aTree, NodeRef const& aNode, RelativePath const& rPath)
{
- if ( findLocalInnerDescendant(aTree,aNode,rPath) )
+ NodeRef aNestedNode( aNode );
+ RelativePath aRemainingPath(rPath);
+
+ if ( findLocalInnerDescendant(aTree,aNestedNode,aRemainingPath) )
{
- OSL_ASSERT(aTree.isValidNode(aNode));
- return AnyNodeRef(aNode);
+ OSL_ASSERT(aTree.isValidNode(aNestedNode));
+ return AnyNodeRef(aNestedNode);
}
- if ( identifiesLocalValue(aTree,aNode,rPath) )
+ if ( identifiesLocalValue(aTree,aNestedNode,aRemainingPath) )
{
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();
}
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/setnodeimpl.cxx b/configmgr/source/treemgr/setnodeimpl.cxx
index 9ae5083d9ace..705e0538b455 100644
--- a/configmgr/source/treemgr/setnodeimpl.cxx
+++ b/configmgr/source/treemgr/setnodeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setnodeimpl.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -86,6 +86,8 @@ namespace configmgr
//-------------------------------------------------------------------------
namespace
{
+ typedef AbstractSetNodeImpl::Element Element;
+
class CollectElementTrees : NodeModification
{
public:
@@ -109,7 +111,7 @@ namespace
NodeModification::applyToChildren(aSet);
}
- ElementTreeHolder create(INode& aNode)
+ Element create(INode& aNode)
{
OSL_ENSURE(collection.empty(),"warning: trying to reuse a full collection");
@@ -120,7 +122,7 @@ namespace
return collection.back();
}
- ElementTreeHolder create(ISubtree& aNode)
+ Element create(ISubtree& aNode)
{
OSL_ENSURE(collection.empty(),"warning: trying to reuse a full collection");
@@ -131,7 +133,7 @@ namespace
return collection.back();
}
- ElementTreeHolder create(ValueNode& aNode)
+ Element create(ValueNode& aNode)
{
OSL_ENSURE(collection.empty(),"warning: trying to reuse a full collection");
@@ -142,7 +144,7 @@ namespace
return collection.back();
}
- typedef vector<ElementTreeHolder> Collection;
+ typedef vector<Element> Collection;
Collection collection;
private:
void handle(ValueNode& rValue);
@@ -156,9 +158,10 @@ namespace
NodeOffset m_nPos;
TreeDepth m_nDepth;
};
+ //-------------------------------------------------------------------------
static
- Name validatedName(ElementTreeHolder const& aTree)
+ Name validatedName(Element const& aTree)
{
OSL_ENSURE(aTree.isValid(), "INTERNAL ERROR: Unexpected null tree constructed in set node");
if (!aTree.isValid()) throw Exception("INTERNAL ERROR: Unexpected null tree in set node");
@@ -168,6 +171,21 @@ namespace
return aTree->getSimpleRootName();
}
+ //-------------------------------------------------------------------------
+
+ static
+ bool isInDefault(ElementTreeImpl* pTree)
+ {
+ if (pTree == NULL) return false;
+
+ node::Attributes aAttributes = pTree->node(pTree->root())->attributes();
+
+ OSL_ENSURE(!(aAttributes.bReplaced && aAttributes.bDefaulted),
+ "Unexpected case: node is both defaulted and replaced" );
+
+ return !aAttributes.bReplaced;
+ }
+ //-------------------------------------------------------------------------
void CollectElementTrees::handle(ValueNode& rValue)
{
if (m_aTemplate.isValid())
@@ -191,6 +209,7 @@ namespace
}
add(rValue);
}
+ //-------------------------------------------------------------------------
void CollectElementTrees::handle(ISubtree& rTree)
{
if (m_aTemplate.isValid())
@@ -204,9 +223,16 @@ namespace
}
add(rTree);
}
+ //-------------------------------------------------------------------------
void CollectElementTrees::add(INode& rNode)
{
- bool bWritable = rNode.getAttributes().bWritable;
+ node::Attributes const aAttributes = rNode.getAttributes();
+
+ OSL_ENSURE(!(aAttributes.bReplaced && aAttributes.bDefaulted),
+ "Unexpected case: node is both defaulted and replaced" );
+
+ bool bWritable = aAttributes.bWritable;
+ bool bInDefault = !aAttributes.bReplaced;
NodeFactory& rNodeFactory = bWritable ? m_rFactory : NodeType::getReadAccessFactory();
@@ -217,7 +243,7 @@ namespace
else
pNewTree = new ElementTreeImpl(rNodeFactory, rNode,m_nDepth, m_aTemplate, m_aTemplateProvider);
- collection.push_back(pNewTree);
+ collection.push_back( Element(pNewTree,bInDefault));
}
}
@@ -462,13 +488,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doAdjustToRemovedElement(Name const& aName,
NodeChangeImpl* AbstractSetNodeImpl::doCreateInsert(Name const& aName, Element const& aNewElement) const
{
- // type equality check
- typedef SetInsertTreeImpl SetInsertImpl;
- typedef SetInsertValueImpl SetInsertImpl;
-
Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
- SetChangeImpl* pRet = new SetInsertImpl(aFullName, aNewElement, true);
+ SetElementChangeImpl* pRet = new SetInsertImpl(aFullName, aNewElement.tree, true);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -476,13 +498,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doCreateInsert(Name const& aName, Element c
NodeChangeImpl* AbstractSetNodeImpl::doCreateReplace(Name const& aName, Element const& aNewElement, Element const& aOldElement) const
{
- // type equality check
- typedef SetReplaceTreeImpl SetReplaceImpl;
- typedef SetReplaceValueImpl SetReplaceImpl;
-
Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
- SetChangeImpl* pRet = new SetReplaceImpl(aFullName, aNewElement, aOldElement);
+ SetElementChangeImpl* pRet = new SetReplaceImpl(aFullName, aNewElement.tree, aOldElement.tree);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -490,13 +508,9 @@ NodeChangeImpl* AbstractSetNodeImpl::doCreateReplace(Name const& aName, Element
NodeChangeImpl* AbstractSetNodeImpl::doCreateRemove(Name const& aName, Element const& aOldElement) const
{
- // type equality check
- typedef SetRemoveTreeImpl SetRemoveImpl;
- typedef SetRemoveValueImpl SetRemoveImpl;
-
Path::Component aFullName = Path::makeCompositeName(aName, this->getElementTemplate()->getName());
- SetChangeImpl* pRet = new SetRemoveImpl(aFullName, aOldElement);
+ SetElementChangeImpl* pRet = new SetRemoveImpl(aFullName, aOldElement.tree);
pRet->setTarget( getParentTree(), getContextOffset() );
return pRet;
}
@@ -621,6 +635,13 @@ void AbstractSetNodeImpl::detach(Element const& aOldElement, bool bCommit)
}
//-------------------------------------------------------------------------
+Element AbstractSetNodeImpl::entryToElement(SetEntry const& _anEntry)
+{
+ ElementTreeImpl * pTree = _anEntry.tree();
+ return Element(pTree, isInDefault(pTree));
+}
+//-------------------------------------------------------------------------
+
//-------------------------------------------------------------------------
// class TreeSetNodeImpl/ValueSetNodeImpl
@@ -628,13 +649,13 @@ void AbstractSetNodeImpl::detach(Element const& aOldElement, bool bCommit)
void TreeSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
- AbstractSetNodeImpl::implInsertElement( aName, implMakeElement(aNewEntry.tree()), true);
+ AbstractSetNodeImpl::implInsertElement( aName, implMakeElement(aNewEntry), true);
}
//-------------------------------------------------------------------------
void ValueSetNodeImpl::doInsertElement(Name const& aName, SetEntry const& aNewEntry)
{
- AbstractSetNodeImpl::implInsertElement( aName, implMakeElement(aNewEntry.tree()), true);
+ AbstractSetNodeImpl::implInsertElement( aName, implMakeElement(aNewEntry), true);
}
//-------------------------------------------------------------------------
@@ -687,14 +708,16 @@ void ValueSetNodeImpl::doAdjustChangedElement(NodeChangesInformation& rLocalChan
std::auto_ptr<ValueNode> aOldNode = ONodeConverter::createCorrespondingNode(aValueChange, getDefaultTreeNodeFactory());
aOldNode->setValue(aValueChange.getOldValue());
+ bool bWasDefault = (aValueChange.getMode() == ValueChange::wasDefault);
+
std::auto_ptr<INode> aOldNodeBase( aOldNode.release() );
- Element aOldElement = new ElementTreeImpl(aOldNodeBase, getElementTemplate(), getTemplateProvider());
+ ElementTreeHolder aOldElement = new ElementTreeImpl(aOldNodeBase, getElementTemplate(), getTemplateProvider());
OSL_ASSERT(aOldNodeBase.get() == NULL); // the tree took ownership
OSL_ASSERT(aOldElement->isFree()); // the tree is free-floating
- NodeChangeImpl* pThisChange = this->doCreateReplace(aName,*pElement,aOldElement);
+ NodeChangeImpl* pThisChange = this->doCreateReplace(aName,*pElement,Element(aOldElement,bWasDefault));
if (pThisChange)
addLocalChangeHelper( rLocalChanges, NodeChange(pThisChange) );
@@ -721,7 +744,7 @@ void TreeSetNodeImpl::initHelper( NodeFactory& rFactory, ISubtree& rTree, TreeDe
for(Iter it = aCollector.collection.begin(), stop = aCollector.collection.end();
it != stop; ++it)
{
- implInitElement(implMakeElement(*it));
+ implInitElement(implValidateElement(*it));
}
}
//-------------------------------------------------------------------------
@@ -736,12 +759,12 @@ void ValueSetNodeImpl::initHelper(NodeFactory& rFactory, ISubtree& rSet)
for(Iter it = aCollector.collection.begin(), stop = aCollector.collection.end();
it != stop; ++it)
{
- implInitElement(implMakeElement(*it));
+ implInitElement(implValidateElement(*it));
}
}
//-------------------------------------------------------------------------
-ElementTreeHolder TreeSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange, TreeDepth nDepth)
+Element TreeSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange, TreeDepth nDepth)
{
// need 'unsafe', because ownership would be gone when notifications are sent
if (INode* pNode = aAddNodeChange.getAddedNode_unsafe())
@@ -753,7 +776,7 @@ ElementTreeHolder TreeSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory,
CollectElementTrees aCollector( rFactory, getParentTree(), getContextOffset(),
nDepth, getElementTemplate(), getTemplateProvider() );
- return implMakeElement(aCollector.create(*pTreeNode));
+ return implValidateElement(aCollector.create(*pTreeNode));
}
}
else
@@ -764,7 +787,7 @@ ElementTreeHolder TreeSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory,
}
//-------------------------------------------------------------------------
-ElementTreeHolder ValueSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange)
+Element ValueSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange)
{
// need 'unsafe', because ownership would be gone when notifications are sent
if (INode* pNode = aAddNodeChange.getAddedNode_unsafe())
@@ -775,7 +798,7 @@ ElementTreeHolder ValueSetNodeImpl::makeAdditionalElement(NodeFactory& rFactory,
CollectElementTrees aCreator( rFactory, getParentTree(), getContextOffset(),
0, getElementTemplate(), getTemplateProvider() );
- return implMakeElement(aCreator.create(*pValueNode));
+ return implValidateElement(aCreator.create(*pValueNode));
}
}
else
@@ -798,7 +821,7 @@ NodeType::Enum ValueSetNodeImpl::doGetType() const
}
//-------------------------------------------------------------------------
-ElementTreeHolder TreeSetNodeImpl::implMakeElement(ElementTreeHolder const& aNewElement)
+Element TreeSetNodeImpl::implValidateElement(Element const& aNewElement)
{
TemplateHolder aTemplate = getElementTemplate();
OSL_ENSURE(aTemplate.isValid(),"INTERNAL ERROR: No template in set node");
@@ -824,7 +847,7 @@ ElementTreeHolder TreeSetNodeImpl::implMakeElement(ElementTreeHolder const& aNew
}
//-------------------------------------------------------------------------
-ElementTreeHolder ValueSetNodeImpl::implMakeElement(ElementTreeHolder const& aNewElement)
+Element ValueSetNodeImpl::implValidateElement(Element const& aNewElement)
{
TemplateHolder aTemplate = getElementTemplate();
OSL_ENSURE(aTemplate.isValid(),"INTERNAL ERROR: No template in set node");
diff --git a/configmgr/source/treemgr/setnodeimpl.hxx b/configmgr/source/treemgr/setnodeimpl.hxx
index bdd5cc666c07..53d93b35a668 100644
--- a/configmgr/source/treemgr/setnodeimpl.hxx
+++ b/configmgr/source/treemgr/setnodeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: setnodeimpl.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jb $ $Date: 2001-06-20 20:43:00 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,15 +84,37 @@ namespace configmgr
struct NodeFactory;
class ElementTreeImpl;
- typedef vos::ORef<ElementTreeImpl> ElementTreeHolder;
+
+ //-----------------------------------------------------------------------------
// basic implementations of set node contents
//-----------------------------------------------------------------------------
+ struct ElementTreeData
+ {
+ typedef vos::ORef<ElementTreeImpl> ElementTreeHolder;
+
+ // construction
+ ElementTreeData() : tree(), inDefault(false) {}
+
+ ElementTreeData(ElementTreeHolder const& _tree, bool _bDefault)
+ : tree(_tree), inDefault(_bDefault) {}
+
+ // ORef compatibility
+ sal_Bool isValid() const { return this->tree.isValid(); }
+ ElementTreeImpl* getBodyPtr() const { return this->tree.getBodyPtr(); }
+ ElementTreeHolder const& operator->() const { return this->tree; }
+
+ // data
+ ElementTreeHolder tree;
+ bool inDefault;
+ };
+ //-----------------------------------------------------------------------------
+
class ElementSet
{
public:
- typedef ElementTreeHolder Element;
+ typedef ElementTreeData Element;
typedef std::map<Name, Element> Data;
// the following must be implemented by derived classes
@@ -194,6 +216,8 @@ namespace configmgr
SetNodeVisitor::Result doDispatchToElements(SetNodeVisitor& aVisitor);
+ static Element entryToElement(SetEntry const& _anEntry);
+
void implInsertElement(Name const& aName, Element const& aNewElement, bool bCommit);
void implReplaceElement(Name const& aName, Element const& aNewElement, bool bCommit);
void implRemoveElement(Name const& aName, bool bCommit);
@@ -253,7 +277,10 @@ namespace configmgr
void initHelper(NodeFactory& rFactory, ISubtree& rTree, TreeDepth nDepth);
Element makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange, TreeDepth nDepth);
- ElementTreeHolder implMakeElement(ElementTreeHolder const& aNewEntry);
+ Element implValidateElement(Element const& aNewElement);
+
+ Element implMakeElement(SetEntry const& aNewEntry)
+ { return implValidateElement( entryToElement(aNewEntry) ); }
};
//-------------------------------------------------------------------------
@@ -276,7 +303,10 @@ namespace configmgr
void initHelper( NodeFactory& rFactory, ISubtree& rTree);
Element makeAdditionalElement(NodeFactory& rFactory, AddNode const& aAddNodeChange);
- ElementTreeHolder implMakeElement(ElementTreeHolder const& aNewEntry);
+ Element implValidateElement(Element const& aNewElement);
+
+ Element implMakeElement(SetEntry const& aNewEntry)
+ { return implValidateElement( entryToElement(aNewEntry) ); }
};
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/valuemembernode.cxx b/configmgr/source/treemgr/valuemembernode.cxx
index 9dcfada7c2e5..5a40fb0dce5d 100644
--- a/configmgr/source/treemgr/valuemembernode.cxx
+++ b/configmgr/source/treemgr/valuemembernode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: valuemembernode.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
+ * last change: $Author: jb $ $Date: 2001-09-28 12:44:40 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -236,7 +236,8 @@ bool ValueMemberNode::isDefault() const
bool ValueMemberNode::canGetDefaultValue() const
{
- if (this->getAttributes().bDefaultable)
+ // Nullable values have a default-default, namely NULL
+ if (this->getAttributes().bNullable)
return true;
return hasOriginalNodeDefault(m_pOriginal);
@@ -334,8 +335,10 @@ std::auto_ptr<ValueChange> ValueMemberNode::DeferredImpl::preCommitChange()
eMode = ValueChange::wasDefault;
// now make a ValueChange
- std::auto_ptr<ValueChange>pChange( new ValueChange( getOriginalNodeName(&m_rOriginal), this->getNewValue(),
- getOriginalNodeAttributes(&m_rOriginal), eMode,
+ std::auto_ptr<ValueChange>pChange( new ValueChange( getOriginalNodeName(&m_rOriginal),
+ getOriginalNodeAttributes(&m_rOriginal),
+ eMode,
+ this->getNewValue(),
getOriginalNodeValue(&m_rOriginal)
) );