summaryrefslogtreecommitdiff
path: root/configmgr/source/tree
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/tree')
-rw-r--r--configmgr/source/tree/builddata.cxx1134
-rw-r--r--configmgr/source/tree/changes.cxx244
-rw-r--r--configmgr/source/tree/cmtree.cxx378
-rw-r--r--configmgr/source/tree/cmtreemodel.cxx371
-rw-r--r--configmgr/source/tree/localizedtreeactions.cxx543
-rw-r--r--configmgr/source/tree/makefile.mk66
-rw-r--r--configmgr/source/tree/mergehelper.cxx456
-rw-r--r--configmgr/source/tree/node.cxx535
-rw-r--r--configmgr/source/tree/nodeconverter.cxx210
-rw-r--r--configmgr/source/tree/nodevisitor.cxx104
-rw-r--r--configmgr/source/tree/subtree.hxx110
-rw-r--r--configmgr/source/tree/treeactions.cxx64
-rw-r--r--configmgr/source/tree/treechangefactory.cxx123
-rw-r--r--configmgr/source/tree/treefragment.cxx130
-rw-r--r--configmgr/source/tree/treenodefactory.cxx110
-rw-r--r--configmgr/source/tree/treesegment.cxx88
-rw-r--r--configmgr/source/tree/updatehelper.cxx622
17 files changed, 0 insertions, 5288 deletions
diff --git a/configmgr/source/tree/builddata.cxx b/configmgr/source/tree/builddata.cxx
deleted file mode 100644
index 264ce5e759d7..000000000000
--- a/configmgr/source/tree/builddata.cxx
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "sal/types.h"
-
-#include "builddata.hxx"
-#include "nodevisitor.hxx"
-#include "node.hxx"
-#include "treefragment.hxx"
-#include "valuenode.hxx"
-#include "treenodefactory.hxx"
-#include "utility.hxx"
-
-#ifndef INCLUDED_CSTDDEF
-#include <cstddef>
-#define INCLUDED_CSTDDEF
-#endif
-#ifndef INCLUDED_ALGORITHM
-#include <algorithm>
-#define INCLUDED_ALGORITHM
-#endif
-#include <vector>
-
-namespace configmgr
-{
-//-----------------------------------------------------------------------------
- namespace data
- {
-//-----------------------------------------------------------------------------
-
- static
- inline
- sharable::Node * offsetNodeBy(sharable::Node * _aNode, sal_uInt16 _nOffset)
- {
- sharable::Node *pNode = _aNode;
- pNode += _nOffset;
- return (sharable::Node *)(pNode);
- }
-
- static
- inline
- sharable::Node * addressOfNodeAt(sharable::TreeFragment * _aTree, sal_uInt16 _nOffset)
- {
- sharable::TreeFragment *pRaw = _aTree;
- return &pRaw->nodes[_nOffset];
- }
-
-//-----------------------------------------------------------------------------
-
- class TreeNodeBuilder
- {
- sharable::TreeFragmentHeader m_header;
- std::vector< sharable::Node > m_nodes;
- sal_uInt16 m_parent;
- public:
- TreeNodeBuilder() : m_header(), m_nodes(), m_parent() {}
-
- sharable::TreeFragmentHeader & header() { return m_header; }
-
- sharable::Node & nodeAt(sal_uInt16 _pos) { checkOffset(_pos); return m_nodes[_pos]; }
- sharable::NodeInfo & nodeInfoAt(sal_uInt16 _pos) { checkOffset(_pos); return m_nodes[_pos].info; }
-
- sharable::Node & lastNode() { checkOffset(0); return m_nodes.back(); }
- sharable::NodeInfo & lastNodeInfo() { checkOffset(0); return m_nodes.back().info; }
-
- void resetTreeFragment(rtl_uString * _treeName, sal_uInt8 _state);
-
- sharable::TreeFragment * createTreeFragment();
-
- sal_uInt16 startGroup( rtl_uString * _aName, sal_uInt8 _aFlags );
- void endGroup( sal_uInt16 _nPos );
-
- void addSet( rtl_uString * _aName, sal_uInt8 _aFlags, sal_uInt8 * _aElementType );
-
- void addValue( rtl_uString * _aName, sal_uInt8 _aFlags,
- sal_uInt8 _aValueType,
- sharable::AnyData _aUserValue,
- sharable::AnyData _aDefaultName );
- public:
- class CollectSetElements;
- class LinkSetNodes;
-
- private:
- sharable::TreeFragment * allocTreeFragment();
- void linkTreeFragment(sharable::TreeFragment * _aTreeAddr);
-
- sal_uInt16 addNode(rtl_uString * _aName, sal_uInt8 _aFlags, sal_uInt8 _aType);
- void checkOffset(sal_uInt16 _pos);
- };
-//-----------------------------------------------------------------------------
-
- class TreeNodeBuilder::CollectSetElements
- {
- sharable::TreeFragment * m_head;
- public:
- explicit
- CollectSetElements() : m_head(NULL) {}
-
- void resetElementList();
- void addElement(sharable::TreeFragment * _aNewElement);
- sharable::TreeFragment * getElementListAndClear();
- };
-//-----------------------------------------------------------------------------
-
- class TreeNodeBuilder::LinkSetNodes: private SetVisitor {
- sharable::Node * m_parent;
- public:
- LinkSetNodes(): m_parent(0) {}
-
- void linkTree(sharable::TreeFragment * tree);
-
- private:
- using SetVisitor::handle;
-
- virtual bool handle(sharable::SetNode * node);
-
- virtual bool handle(sharable::TreeFragment * tree);
- };
-//-----------------------------------------------------------------------------
-
- class BasicDataTreeBuilder
- {
- public:
- explicit
- BasicDataTreeBuilder() {}
-
- sharable::TreeFragment * createTree() { return m_builder.createTreeFragment(); }
-
- protected:
- TreeNodeBuilder& builder() { return m_builder; }
- private:
- TreeNodeBuilder m_builder;
- };
-//-----------------------------------------------------------------------------
-
- class ConvertingDataTreeBuilder : private NodeAction, public BasicDataTreeBuilder
- {
- rtl::OUString m_sRootName;
- bool m_bWithDefaults;
- public:
- explicit
- ConvertingDataTreeBuilder() : BasicDataTreeBuilder() {}
-
- sharable::TreeFragment * buildTree(rtl::OUString const & _aTreeName, INode const& _aNode, bool _bWithDefault);
- sharable::TreeFragment * buildElement(INode const& _aNode, rtl::OUString const & _aTypeName, bool _bWithDefault);
- private:
- class ElementListBuilder;
-
- virtual void handle(ISubtree const & _aNode);
- virtual void handle(ValueNode const & _aNode);
-
- sal_uInt8 * makeTemplateData(rtl::OUString const & _aTemplateName, rtl::OUString const & _aTemplateModule);
-
- rtl_uString * allocName(INode const & _aNode);
- sal_uInt8 makeState(node::Attributes const & _aAttributes);
- sal_uInt8 makeFlags(node::Attributes const & _aAttributes);
- };
-//-----------------------------------------------------------------------------
-
- class ConvertingDataTreeBuilder::ElementListBuilder : private NodeAction
- {
- TreeNodeBuilder::CollectSetElements m_aCollector;
-
- rtl::OUString m_sTypeName;
- bool m_bWithDefaults;
- public:
- explicit
- ElementListBuilder()
- : m_aCollector()
- , m_sTypeName()
- , m_bWithDefaults()
- {}
-
- sharable::TreeFragment *buildElementList(ISubtree const & _aSet, bool _bWithDefaults);
- private:
- void handleNode(INode const & _aSourceNode);
-
- void handle(ValueNode const & _aSourceNode);
- void handle(ISubtree const & _aSourceNode);
- };
-//-----------------------------------------------------------------------------
-
- class CopyingDataTreeBuilder : private NodeVisitor, public BasicDataTreeBuilder
- {
- public:
- explicit
- CopyingDataTreeBuilder() : BasicDataTreeBuilder() {}
-
- sharable::TreeFragment * buildTree(sharable::TreeFragment * sourceTree);
-
- private:
- class ElementListBuilder;
-
- using NodeVisitor::handle;
- virtual bool handle(sharable::ValueNode * node);
- virtual bool handle(sharable::GroupNode * node);
- virtual bool handle(sharable::SetNode * node);
-
- sal_uInt8 * makeTemplateData(sal_uInt8 * _aSourceTemplate);
- };
-//-----------------------------------------------------------------------------
-
- class CopyingDataTreeBuilder::ElementListBuilder : private SetVisitor
- {
- TreeNodeBuilder::CollectSetElements m_aCollector;
- public:
- explicit
- ElementListBuilder() : m_aCollector() {}
-
- sharable::TreeFragment * buildElementList(sharable::SetNode * set);
-
- private:
- using SetVisitor::handle;
- virtual bool handle(sharable::TreeFragment * tree);
- };
-//-----------------------------------------------------------------------------
-
- class ConvertingNodeBuilder : private NodeVisitor
- {
- OTreeNodeFactory & m_rNodeFactory;
-
- std::auto_ptr<INode> m_pNode;
- public:
- ConvertingNodeBuilder(OTreeNodeFactory & _rNodeFactory)
- : m_rNodeFactory(_rNodeFactory)
- , m_pNode()
- {
- }
-
- std::auto_ptr<INode> buildNode(sharable::TreeFragment * tree, bool _bUseTreeName);
- std::auto_ptr<INode> buildNode(sharable::Node * tree);
-
- std::auto_ptr<ISubtree> buildNodeTree(sharable::GroupNode * groupNode) const;
- std::auto_ptr<ISubtree> buildNodeTree(sharable::SetNode * setNode) const;
- std::auto_ptr<ValueNode> buildNodeTree(sharable::ValueNode * valueNode) const
- { return convertNode(valueNode); }
-
- static node::Attributes convertAttributes(sharable::Node * node)
- { return node->getAttributes(); }
-
- private:
- std::auto_ptr<ISubtree> convertNode(sharable::GroupNode * groupNode) const;
- std::auto_ptr<ISubtree> convertNode(sharable::SetNode * setNode) const;
- std::auto_ptr<ValueNode> convertNode(sharable::ValueNode * valueNode) const;
-
- using NodeVisitor::handle;
- virtual bool handle(sharable::ValueNode * node);
- virtual bool handle(sharable::GroupNode * node);
- virtual bool handle(sharable::SetNode * node);
- };
-//-----------------------------------------------------------------------------
-
- class ConvertingSubnodeBuilder : private SetVisitor
- {
- ConvertingNodeBuilder m_aSubnodeBuilder;
- ISubtree & m_rParentNode;
- public:
- ConvertingSubnodeBuilder(OTreeNodeFactory & _rNodeFactory, ISubtree & _rParentNode)
- : m_aSubnodeBuilder(_rNodeFactory)
- , m_rParentNode(_rParentNode)
- {
- }
-
- void addElements(sharable::SetNode * set) { visitElements(set); }
- void addChildren(sharable::GroupNode * group) { visitChildren(group); }
-
- private:
- using SetVisitor::handle;
- virtual bool handle(sharable::Node * node);
- virtual bool handle(sharable::TreeFragment * tree);
- };
-//-----------------------------------------------------------------------------
-
- class DataTreeDefaultMerger : private NodeAction
- {
- public:
- explicit
- DataTreeDefaultMerger() {}
-
- void mergeDefaults(sharable::TreeFragment * _aBaseAddress, INode const& _aDefaultNode);
- private:
- void handle(ValueNode const & _aNode);
- void handle(ISubtree const & _aNode);
- };
-
-//-----------------------------------------------------------------------------
-
- class DataTreeCleanup
- {
- public:
- explicit
- DataTreeCleanup() {}
-
- sharable::TreeFragment * destroyTree(sharable::TreeFragment * _aBaseAddress);
- private:
- void destroyNode(sharable::Node * _aNodeAddress);
-
- void destroyData(sharable::TreeFragmentHeader * _pHeader);
- void destroyData(sharable::NodeInfo * _pNodeInfo);
-
- void destroyData(sharable::GroupNode * _pNode);
- void destroyData(sharable::ValueNode * _pNode);
- void destroyData(sharable::SetNode * _pNode);
- };
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * buildTree(sharable::TreeFragment * tree)
-{
- return CopyingDataTreeBuilder().buildTree(tree);
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * buildTree(rtl::OUString const & _aTreeName, INode const& _aNode, bool _bWithDefaults)
-{
- ConvertingDataTreeBuilder aBuilder;
-
- sharable::TreeFragment * aResult = aBuilder.buildTree(_aTreeName, _aNode,_bWithDefaults);
-
- return aResult;
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * buildElementTree(INode const& _aNode, rtl::OUString const & _aTypeName, bool _bWithDefaults)
-{
- ConvertingDataTreeBuilder aBuilder;
-
- sharable::TreeFragment * aResult = aBuilder.buildElement(_aNode, _aTypeName, _bWithDefaults);
-
- return aResult;
-}
-//-----------------------------------------------------------------------------
-
-void mergeDefaults(sharable::TreeFragment * _aBaseAddress, INode const& _aDefaultNode)
-{
- DataTreeDefaultMerger aMergeHelper;
-
- aMergeHelper.mergeDefaults(_aBaseAddress, _aDefaultNode);
-}
-//-----------------------------------------------------------------------------
-
-void destroyTree(sharable::TreeFragment * _aBaseAddress)
-{
- DataTreeCleanup aCleaner;
-
- aCleaner.destroyTree(_aBaseAddress);
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<INode> convertTree(sharable::TreeFragment * tree, bool _bUseTreeName)
-{
- ConvertingNodeBuilder aBuilder( configmgr::getDefaultTreeNodeFactory() );
-
- return aBuilder.buildNode(tree, _bUseTreeName);
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-inline
-void TreeNodeBuilder::CollectSetElements::resetElementList()
-{
- OSL_ENSURE(m_head == NULL, "Joining to a element list that was forgotten");
-}
-//-----------------------------------------------------------------------------
-
-inline
-sharable::TreeFragment * TreeNodeBuilder::CollectSetElements::getElementListAndClear()
-{
- sharable::TreeFragment * aResult = m_head;
- m_head = NULL;
- return aResult;
-}
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::CollectSetElements::addElement(sharable::TreeFragment * _aNewElement)
-{
- if (sharable::TreeFragment * pNewFragment = _aNewElement)
- {
- pNewFragment->header.parent = 0; // data not available here
- pNewFragment->header.next = m_head;
-
- m_head = _aNewElement;
- }
- else
- OSL_ENSURE(false, "Cannot add NULL element");
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::LinkSetNodes::linkTree(sharable::TreeFragment * tree) {
- sharable::Node * old = m_parent;
- m_parent = 0;
- sal_uInt16 n = tree->header.count;
- for (sal_uInt16 i = 0; i < n; ++i) {
- if (visitNode(tree->nodes + i)) {
- break;
- }
- }
- m_parent = old;
-}
-
-bool TreeNodeBuilder::LinkSetNodes::handle(sharable::SetNode * node)
-{
- OSL_ASSERT(m_parent == 0);
- m_parent = sharable::node(node);
- bool done = visitElements(node);
- m_parent = 0;
- return done;
-}
-
-bool TreeNodeBuilder::LinkSetNodes::handle(sharable::TreeFragment * tree)
-{
- OSL_ASSERT(m_parent != 0);
- tree->header.parent = m_parent;
- return false;
-}
-
-//-----------------------------------------------------------------------------
-
-inline void TreeNodeBuilder::checkOffset(sal_uInt16 _pos)
-{
- { (void)_pos; }
- OSL_ENSURE(_pos < m_nodes.size(), "TreeNodeBuilder: Node access past end.");
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt16 TreeNodeBuilder::addNode(rtl_uString * _aName, sal_uInt8 _aFlags, sal_uInt8 _aType)
-{
- OSL_PRECOND(_aName, "TreeNodeBuilder: Unexpected NULL name");
-
- // TODO: consistencý checks for flags
- OSL_ENSURE(m_nodes.size() == m_header.count, "TreeNodeBuilder: node count mismatch");
-
- sal_uInt16 nNewOffset = m_header.count++;
-
- m_nodes.push_back( sharable::Node() );
-
- OSL_ASSERT( &lastNode() == &nodeAt(nNewOffset) );
-
- sharable::NodeInfo & rInfo = lastNode().info;
-
- rInfo.name = _aName;
- rInfo.flags = _aFlags;
- rInfo.type = _aType;
-
- OSL_ENSURE( m_parent <= nNewOffset, "ERROR - TreeNodeBuilder: invalid parent");
- OSL_ENSURE( (nNewOffset == 0) == (nNewOffset == m_parent), "ERROR - TreeNodeBuilder: node is own parent");
-
- rInfo.parent = nNewOffset - m_parent;
-
- return nNewOffset;
-}
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::resetTreeFragment(rtl_uString * _name, sal_uInt8 _state)
-{
- m_header.next = 0;
- m_header.name = _name;
-
- m_header.parent = 0;
-
- m_header.count = 0;
- m_header.state = _state;
-
- m_nodes.clear();
- m_parent = 0;
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * TreeNodeBuilder::allocTreeFragment()
-{
- OSL_ENSURE(m_nodes.size() == m_header.count, "TreeNodeBuilder: node count mismatch");
-
- sharable::TreeFragment *pFragment = sharable::TreeFragment::allocate(m_header.count);
- pFragment->header = m_header;
- std::copy(m_nodes.begin(),m_nodes.end(),pFragment->nodes);
-
- return (sharable::TreeFragment *)( pFragment );
-}
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::linkTreeFragment(sharable::TreeFragment * _aTreeFragment)
-{
- LinkSetNodes().linkTree(_aTreeFragment);
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * TreeNodeBuilder::createTreeFragment()
-{
- sharable::TreeFragment * aResult = allocTreeFragment();
-
- if (aResult != NULL)
- {
- linkTreeFragment(aResult);
-
- m_nodes.clear(); // ownership of indirect data has gone ...
- }
- return aResult;
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt16 TreeNodeBuilder::startGroup( rtl_uString * _aName, sal_uInt8 _aFlags )
-{
- sal_uInt16 nNewIndex = addNode(_aName,_aFlags,Type::nodetype_group);
-
- lastNode().group.numDescendants = 0;
-
- m_parent = nNewIndex;
-
- return nNewIndex;
-}
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::endGroup( sal_uInt16 _nPos )
-{
- // while (_nPos < m_parent) endGroup(m_parent);
- OSL_PRECOND(_nPos == m_parent, "TreeNodeBuilder: Group being closed is not the current parent");
-
- OSL_ENSURE(nodeAt(_nPos).isGroup(), "TreeNodeBuilder: Group being closed is not a group");
-
- OSL_ENSURE(m_nodes.size() == m_header.count, "TreeNodeBuilder: node count mismatch");
-
- sharable::GroupNode & rGroup = nodeAt(_nPos).group;
-
- rGroup.numDescendants = sal_uInt16( m_nodes.size() - static_cast< ::std::size_t >(_nPos) - 1 );
- m_parent = m_parent - rGroup.info.parent;
-}
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::addSet( rtl_uString * _aName, sal_uInt8 _aFlags, sal_uInt8 * _aElementType )
-{
- addNode(_aName,_aFlags,Type::nodetype_set);
-
- lastNode().set.elementType = _aElementType;
- lastNode().set.elements = 0;
-}
-
-//-----------------------------------------------------------------------------
-
-void TreeNodeBuilder::addValue( rtl_uString * _aName, sal_uInt8 _aFlags,
- sal_uInt8 _aValueType,
- sharable::AnyData _aUserValue,
- sharable::AnyData _aDefaultValue )
-{
- OSL_PRECOND(_aValueType == (_aValueType & Type::mask_valuetype), "TreeNodeBuilder: invalid value type");
-
- addNode(_aName,_aFlags,sal_uInt8(Type::nodetype_value | _aValueType));
-
- lastNode().value.value = _aUserValue;
- lastNode().value.defaultValue = _aDefaultValue;
-}
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * CopyingDataTreeBuilder::buildTree(sharable::TreeFragment * sourceTree)
-{
- OSL_ENSURE(sourceTree != 0, "Trying to build a tree from NULL data");
-
- rtl_uString * aTreeName = acquireString( sourceTree->getName());
- this->builder().resetTreeFragment(aTreeName, sourceTree->header.state);
-
- this->visitNode(sourceTree->getRootNode());
-
- return this->createTree();
-}
-//-----------------------------------------------------------------------------
-
-bool CopyingDataTreeBuilder::handle(sharable::ValueNode * node)
-{
- rtl_uString * aNodeName = acquireString( node->info.getName());
- sal_uInt8 aFlags = node->info.flags;
-
- sal_uInt8 aType = sal_uInt8( node->info.type & Type::mask_valuetype );
-
- sharable::AnyData aNewValue, aNewDefault;
- if (aFlags & Flags::valueAvailable)
- aNewValue = sharable::allocData(aType, node->getUserValue());
- else
- aNewValue.data = 0;
-
- if (aFlags & Flags::defaultAvailable)
- aNewDefault = sharable::allocData(aType, node->getDefaultValue());
- else
- aNewDefault.data = 0;
-
- this->builder().addValue(aNodeName,aFlags,aType,aNewValue,aNewDefault);
-
- return false;
-}
-//-----------------------------------------------------------------------------
-
-bool CopyingDataTreeBuilder::handle(sharable::GroupNode * node)
-{
- rtl_uString * aNodeName = acquireString( node->info.getName());
- sal_uInt8 aFlags = node->info.flags;
-
- sal_uInt16 nGroupOffset = this->builder().startGroup(aNodeName,aFlags);
- this->visitChildren(node);
- this->builder().endGroup(nGroupOffset);
-
- return false;
-}
-//-----------------------------------------------------------------------------
-
-bool CopyingDataTreeBuilder::handle(sharable::SetNode * node)
-{
- rtl_uString * aNodeName = acquireString( node->info.getName());
- sal_uInt8 aFlags = node->info.flags;
- sal_uInt8 * aTemplate = this->makeTemplateData(node->elementType);
-
- this->builder().addSet(aNodeName,aFlags,aTemplate);
-
- OSL_ASSERT( this->builder().lastNode().isSet() );
- sharable::SetNode& _aNewSet = this->builder().lastNode().set;
-
- _aNewSet.elements = ElementListBuilder().buildElementList(node);
-
- return false;
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt8 * CopyingDataTreeBuilder::makeTemplateData(sal_uInt8 * _aSourceTemplate)
-{
- return sharable::SetNode::copyTemplateData(_aSourceTemplate);
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * CopyingDataTreeBuilder::ElementListBuilder::buildElementList(sharable::SetNode * set)
-{
- OSL_ASSERT(set != 0);
-
- m_aCollector.resetElementList();
-
- this->visitElements(set);
-
- return m_aCollector.getElementListAndClear();
-}
-//-----------------------------------------------------------------------------
-
-bool CopyingDataTreeBuilder::ElementListBuilder::handle(sharable::TreeFragment * tree)
-{
- sharable::TreeFragment * aNewElement = CopyingDataTreeBuilder().buildTree(tree);
-
- m_aCollector.addElement(aNewElement);
-
- return false;
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-rtl_uString * ConvertingDataTreeBuilder::allocName(INode const & _aNode)
-{
- rtl::OUString sNextName = _aNode.getName();
-
- if (m_sRootName.getLength())
- {
- sNextName = m_sRootName;
- m_sRootName = rtl::OUString();
- }
-
- return acquireString( sNextName);
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * ConvertingDataTreeBuilder::buildElement(INode const& _aNode, rtl::OUString const & _aTypeName, bool _bWithDefaults)
-{
- m_sRootName = _aTypeName;
- m_bWithDefaults = _bWithDefaults;
-
- rtl_uString * aTreeName = acquireString( _aNode.getName());
- this->builder().resetTreeFragment(aTreeName, makeState(_aNode.getAttributes()));
-
-
- this->applyToNode(_aNode);
-
- return this->createTree();
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * ConvertingDataTreeBuilder::buildTree(rtl::OUString const & _aTreeName, INode const& _aNode, bool _bWithDefaults)
-{
- m_sRootName = rtl::OUString();
- m_bWithDefaults = _bWithDefaults;
-
- rtl_uString * aTreeName = acquireString( _aTreeName );
- this->builder().resetTreeFragment(aTreeName, makeState(_aNode.getAttributes()));
-
-
- this->applyToNode(_aNode);
-
- return this->createTree();
-}
-//-----------------------------------------------------------------------------
-
-void ConvertingDataTreeBuilder::handle(ISubtree const & _aNode)
-{
- rtl_uString * aNodeName = allocName( _aNode );
- sal_uInt8 aFlags = makeFlags(_aNode.getAttributes());
-
- if (_aNode.isSetNode())
- {
- sal_uInt8 * aTemplate = this->makeTemplateData(_aNode.getElementTemplateName(),
- _aNode.getElementTemplateModule());
-
- this->builder().addSet(aNodeName,aFlags,aTemplate);
-
- OSL_ASSERT( this->builder().lastNode().isSet() );
- sharable::SetNode& _aNewSet = this->builder().lastNode().set;
-
- _aNewSet.elements = ElementListBuilder().buildElementList(_aNode, m_bWithDefaults);
- }
- else
- {
- sal_uInt16 nGroupOffset = this->builder().startGroup(aNodeName,aFlags);
- this->applyToChildren(_aNode);
- this->builder().endGroup(nGroupOffset);
- }
-}
-//-----------------------------------------------------------------------------
-
-void ConvertingDataTreeBuilder::handle(ValueNode const & _aNode)
-{
- rtl_uString * aNodeName = allocName( _aNode );
- sal_uInt8 aFlags = makeFlags(_aNode.getAttributes());
-
- sal_uInt8 aType = sharable::getTypeCode(_aNode.getValueType());
-
- sharable::AnyData aNewValue; aNewValue.data = 0;
- sharable::AnyData aNewDefault; aNewDefault.data = 0;
-
- OSL_ASSERT( !(aFlags & (Flags::valueAvailable | Flags::defaultAvailable)) );
-
- if (!_aNode.isDefault())
- {
- uno::Any aValue = _aNode.getValue();
- if (aValue.hasValue())
- {
- aNewValue = sharable::allocData(aType, aValue);
- aFlags |= Flags::valueAvailable;
- }
- }
-
- if (_aNode.hasUsableDefault())
- {
- uno::Any aDefault = _aNode.getDefault();
- if (aDefault.hasValue())
- {
- aNewDefault = sharable::allocData(aType, aDefault);
- aFlags |= Flags::defaultAvailable;
- }
- }
-
- this->builder().addValue(aNodeName,aFlags,aType,aNewValue,aNewDefault);
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt8 ConvertingDataTreeBuilder::makeState(node::Attributes const & _aAttributes)
-{
- sal_uInt8 state;
-
- switch (_aAttributes.state())
- {
- case node::isDefault: state = State::defaulted; m_bWithDefaults = true; break;
- case node::isMerged: state = State::merged; break;
- case node::isReplaced: state = State::replaced; m_bWithDefaults = false; break;
- case node::isAdded: state = State::added; m_bWithDefaults = false; break;
-
- default: OSL_ASSERT(false); state = 0; break;
- }
-
- if (_aAttributes.isReadonly())
- state |= State::flag_readonly;
- //Map mandatory and Removable
- if (_aAttributes.isMandatory())
- state |= State::flag_mandatory;
-
- if (_aAttributes.isRemovable())
- state |= State::flag_removable;
-
- if ( m_bWithDefaults )
- state |= State::flag_default_avail;
-
- return state;
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt8 ConvertingDataTreeBuilder::makeFlags(node::Attributes const & _aAttributes)
-{
- sal_uInt8 flags = 0;
-
- if ( _aAttributes.isReadonly())
- flags |= Flags::readonly;
-
- if ( _aAttributes.isFinalized())
- flags |= Flags::finalized;
-
- if ( _aAttributes.isNullable())
- flags |= Flags::nullable;
-
- if ( _aAttributes.isLocalized())
- flags |= Flags::localized;
-
- if (_aAttributes.isDefault())
- flags |= Flags::defaulted; // somewhat redundant with State
-
- if (!_aAttributes.isReplacedForUser())
- flags |= Flags::defaultable; // redundant with State (merged || defaulted)
-
- return flags;
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt8 * ConvertingDataTreeBuilder::makeTemplateData(rtl::OUString const & _aTemplateName, rtl::OUString const & _aTemplateModule)
-{
- return sharable::SetNode::allocTemplateData(_aTemplateName, _aTemplateModule );
-}
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * ConvertingDataTreeBuilder::ElementListBuilder::buildElementList(ISubtree const & _aSet, bool _bWithDefaults)
-{
- OSL_PRECOND(_aSet.isSetNode(), "Node must be a set");
-
- m_aCollector.resetElementList();
-
- m_sTypeName = _aSet.getElementTemplateName();
- m_bWithDefaults = _bWithDefaults;
-
- this->applyToChildren(_aSet);
-
- return m_aCollector.getElementListAndClear();
-}
-//-----------------------------------------------------------------------------
-
-void ConvertingDataTreeBuilder::ElementListBuilder::handleNode(INode const & _aSourceNode)
-{
- sharable::TreeFragment * aNewElement = ConvertingDataTreeBuilder()
- .buildElement(_aSourceNode,m_sTypeName,m_bWithDefaults);
-
- m_aCollector.addElement(aNewElement);
-}
-//-----------------------------------------------------------------------------
-
-void ConvertingDataTreeBuilder::ElementListBuilder::handle(ValueNode const & _aSourceNode)
-{
- handleNode(_aSourceNode);
-}
-//-----------------------------------------------------------------------------
-
-void ConvertingDataTreeBuilder::ElementListBuilder::handle(ISubtree const & _aSourceNode)
-{
- handleNode(_aSourceNode);
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<INode> ConvertingNodeBuilder::buildNode(sharable::TreeFragment * sourceTree, bool _bUseTreeName)
-{
- std::auto_ptr<INode> pResult = this->buildNode(sourceTree == 0 ? 0 : sourceTree->getRootNode());
- if (pResult.get() != NULL)
- {
- // use the element name !
- if (_bUseTreeName) pResult->setName( sourceTree->getName() );
-
- // do something about attributes here ?
- }
- return pResult;
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<INode> ConvertingNodeBuilder::buildNode(sharable::Node * sourceNode)
-{
- OSL_ENSURE( !m_pNode.get(), "Old node tree will be dropped");
- visitNode(sourceNode);
- return m_pNode;
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<ISubtree> ConvertingNodeBuilder::buildNodeTree(sharable::GroupNode * groupNode) const
-{
- std::auto_ptr<ISubtree> pResult = convertNode(groupNode);
-
- if (pResult.get() != NULL)
- {
- ConvertingSubnodeBuilder aCollector(m_rNodeFactory, *pResult);
- aCollector.addChildren(groupNode);
- }
-
- return pResult;
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<ISubtree> ConvertingNodeBuilder::buildNodeTree(sharable::SetNode * setNode) const
-{
- std::auto_ptr<ISubtree> pResult = convertNode(setNode);
-
- if (pResult.get() != NULL)
- {
- ConvertingSubnodeBuilder aCollector(m_rNodeFactory, *pResult);
- aCollector.addElements(setNode);
- }
-
- return pResult;
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<ISubtree> ConvertingNodeBuilder::convertNode(sharable::GroupNode * groupNode) const
-{
- return m_rNodeFactory.createGroupNode( groupNode->info.getName(),
- convertAttributes(sharable::node(groupNode)));
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<ISubtree> ConvertingNodeBuilder::convertNode(sharable::SetNode * setNode) const
-{
- return m_rNodeFactory.createSetNode(setNode->info.getName(),
- setNode->getElementTemplateName(),
- setNode->getElementTemplateModule(),
- convertAttributes(sharable::node(setNode)));
-}
-//-----------------------------------------------------------------------------
-
-std::auto_ptr<ValueNode> ConvertingNodeBuilder::convertNode(sharable::ValueNode * valueNode) const
-{
- uno::Any aUserValue = valueNode->getUserValue();
- uno::Any aDefValue = valueNode->getDefaultValue();
-
- if (aUserValue.hasValue() || aDefValue.hasValue())
- {
- return m_rNodeFactory.createValueNode(valueNode->info.getName(),
- aUserValue, aDefValue,
- convertAttributes(sharable::node(valueNode)));
- }
- else
- {
- return m_rNodeFactory.createNullValueNode(valueNode->info.getName(),
- valueNode->getValueType(),
- convertAttributes(sharable::node(valueNode)));
- }
-}
-//-----------------------------------------------------------------------------
-
-bool ConvertingNodeBuilder::handle(sharable::ValueNode * node)
-{
- m_pNode = base_ptr(buildNodeTree(node));
- return true;
-}
-//-----------------------------------------------------------------------------
-
-bool ConvertingNodeBuilder::handle(sharable::GroupNode * node)
-{
- m_pNode = base_ptr(buildNodeTree(node));
- return true;
-}
-//-----------------------------------------------------------------------------
-
-bool ConvertingNodeBuilder::handle(sharable::SetNode * node)
-{
- m_pNode = base_ptr(buildNodeTree(node));
- return true;
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-bool ConvertingSubnodeBuilder::handle(sharable::TreeFragment * tree)
-{
- OSL_ASSERT(m_rParentNode.isSetNode());
- m_rParentNode.addChild(m_aSubnodeBuilder.buildNode(tree, true));
- return false;
-}
-//-----------------------------------------------------------------------------
-
-bool ConvertingSubnodeBuilder::handle(sharable::Node * node)
-{
- OSL_ASSERT(!m_rParentNode.isSetNode());
- m_rParentNode.addChild(m_aSubnodeBuilder.buildNode(node));
- return false;
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-void DataTreeDefaultMerger::mergeDefaults(sharable::TreeFragment * /*_aBaseAddress*/, INode const& /*_aDefaultNode*/)
-{
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeDefaultMerger::handle(ISubtree const & /*_aNode*/)
-{
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeDefaultMerger::handle(ValueNode const & /*_aNode*/)
-{
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
-sharable::TreeFragment * DataTreeCleanup::destroyTree(sharable::TreeFragment * _aBaseAddress)
-{
- sharable::TreeFragment *pData = _aBaseAddress;
-
- sharable::TreeFragment *pNext = pData->header.next;
-
- sal_uInt16 const nCount = pData->header.count;
-
- destroyData( & pData->header );
-
- for (sal_uInt16 i = 0; i< nCount; ++i)
- {
- destroyNode( addressOfNodeAt(_aBaseAddress,i) );
- }
-
- sharable::TreeFragment::free_shallow( pData );
-
- return (sharable::TreeFragment *)( pNext );
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyNode(sharable::Node * _aNodeAddress)
-{
- sharable::Node * pNode = _aNodeAddress;
-
- sal_uInt8 aTypeTag = pNode->info.type;
- switch ( aTypeTag & Type::mask_nodetype )
- {
- case Type::nodetype_group:
- destroyData( &pNode->group );
- break;
- case Type::nodetype_value:
- destroyData( &pNode->value );
- break;
- case Type::nodetype_set:
- destroyData( &pNode->set );
- break;
- default:
- OSL_ENSURE(false, "Cannot destroy node: Invalid type tag in node");
- break;
- }
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyData(sharable::TreeFragmentHeader * _pHeader)
-{
- // 'component' is owned elsewhere -> leave alone
-
- rtl_uString * aName = _pHeader->name;
-
- rtl_uString_release( aName );
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyData(sharable::NodeInfo * _pNodeInfo)
-{
- rtl_uString * aName = _pNodeInfo->name;
-
- if (aName) rtl_uString_release( aName );
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyData(sharable::SetNode * _pNode)
-{
- sharable::TreeFragment * aElement( _pNode->elements );
-
- sal_uInt8 * aTemplate = _pNode->elementType;;
-
- destroyData(&_pNode->info);
-
- while (aElement != NULL)
- aElement = destroyTree(aElement);
-
- sharable::SetNode::releaseTemplateData( aTemplate );
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyData(sharable::GroupNode * _pNode)
-{
- destroyData(&_pNode->info);
- // nothing more to do
-}
-//-----------------------------------------------------------------------------
-
-void DataTreeCleanup::destroyData(sharable::ValueNode * _pNode)
-{
- sal_uInt8 aValueType = sal_uInt8( _pNode->info.type & Type::mask_valuetype );
- sal_uInt8 aFlags = _pNode->info.flags;
-
- destroyData(&_pNode->info);
-
- if (aFlags & Flags::valueAvailable)
- freeData( aValueType, _pNode->value );
-
- if (aFlags & Flags::defaultAvailable)
- freeData( aValueType, _pNode->defaultValue );
-
-}
-//-----------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-
- //-------------------------------------------------------------------------
- }
-//-----------------------------------------------------------------------------
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/changes.cxx b/configmgr/source/tree/changes.cxx
deleted file mode 100644
index 96e3375c99d6..000000000000
--- a/configmgr/source/tree/changes.cxx
+++ /dev/null
@@ -1,244 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-
-#include <stdio.h>
-
-#include "change.hxx"
-#include <osl/diagnose.h>
-
-namespace configmgr
-{
-
-//==========================================================================
-//= ValueChange
-//==========================================================================
-
-// works reliably only if old value is set and the value really changes
-uno::Type implGetValueType(uno::Any const & _aValue, uno::Any const & _aOldValue)
-{
- if (_aValue.hasValue())
- {
- OSL_ENSURE(!_aOldValue.hasValue() || _aOldValue.getValueType() == _aValue.getValueType(),
- "ERROR: Type mismatch in value change");
-
- return _aValue.getValueType();
- }
- else
- {
- OSL_ENSURE(_aOldValue.hasValue(),"WARNING: Cannot determine value type of change");
- return _aOldValue.getValueType();
- }
-}
-// -------------------------------------------------------------------------
-static inline bool isDefaultMode(ValueChange::Mode _eMode)
-{ return (_eMode == ValueChange::setToDefault) || (_eMode == ValueChange::changeDefault); }
-// -------------------------------------------------------------------------
-static inline bool isLayerChangeMode(ValueChange::Mode _eMode)
-{ return (_eMode == ValueChange::setToDefault) || (_eMode == ValueChange::wasDefault); }
-// -----------------------------------------------------------------------------
-ValueChange::ValueChange(rtl::OUString const& _rName,
- const node::Attributes& _rAttributes,
- Mode _eMode,
- uno::Any const & aNewValue, uno::Any const & aOldValue)
- : Change(_rName, isDefaultMode(_eMode))
- ,m_aValueType( implGetValueType(aNewValue,aOldValue) )
- ,m_aValue(aNewValue)
- ,m_aOldValue(aOldValue)
- ,m_aAttributes(_rAttributes)
- ,m_eMode(_eMode)
-{
- m_aAttributes.markAsDefault(Change::isToDefault());
-}
-
-// -----------------------------------------------------------------------------
-void ValueChange::setNewValue(const uno::Any& _rNewVal)
-{
- OSL_ENSURE(_rNewVal.getValueType() == m_aValueType || !_rNewVal.hasValue(),
- "ValueChange: Type mismatch in setNewValue" );
-
- m_aValue = _rNewVal;
-}
-
-// -----------------------------------------------------------------------------
-std::auto_ptr<Change> ValueChange::clone() const
-{
- return std::auto_ptr<Change>(new ValueChange(*this));
-}
-
-// -----------------------------------------------------------------------------
-bool ValueChange::isChange() const // makes sense only if old value is set
-{
- return isLayerChangeMode(m_eMode) || (m_aOldValue != m_aValue);
-}
-// -------------------------------------------------------------------------
-namespace tree_changes_internal {
- inline void doAdjust(uno::Any& aActual, uno::Any const& aTarget)
- {
- // If set - it should already match
- OSL_ASSERT(!aActual.hasValue() || aTarget == aActual);
- aActual = aTarget;
- }
-}
-
-// -------------------------------------------------------------------------
-void ValueChange::applyChangeNoRecover(ValueNode& aValue) const
-{
- switch (getMode())
- {
- case wasDefault:
- OSL_ASSERT(aValue.isDefault());
- case changeValue:
- aValue.setValue(getNewValue());
- break;
-
- case setToDefault:
- aValue.setDefault();
- break;
-
- case changeDefault:
- aValue.changeDefault(getNewValue());
- break;
-
- default:
- OSL_ENSURE(0, "Unknown mode found for ValueChange");
- break;
- }
-}
-
-//==========================================================================
-//= AddNode
-//==========================================================================
-AddNode::AddNode(rtl::Reference< data::TreeSegment > const & _aAddedTree, rtl::OUString const& _rName, bool _bToDefault)
- :Change(_rName,_bToDefault)
- ,m_aOwnNewNode(_aAddedTree)
- ,m_aOwnOldNode()
- ,m_aInsertedTree(NULL)
- ,m_bReplacing(false)
-{
-}
-
-//--------------------------------------------------------------------------
-AddNode::~AddNode()
-{
-}
-
-// -----------------------------------------------------------------------------
-AddNode::AddNode(const AddNode& _aObj)
-: Change(_aObj)
-, m_aOwnNewNode(data::TreeSegment::create(_aObj.m_aOwnNewNode))
-, m_aOwnOldNode(data::TreeSegment::create(_aObj.m_aOwnOldNode))
-, m_aInsertedTree(_aObj.m_aInsertedTree)
-, m_bReplacing(_aObj.m_bReplacing)
-{
-}
-
-// -----------------------------------------------------------------------------
-std::auto_ptr<Change> AddNode::clone() const
-{
- return std::auto_ptr<Change>(new AddNode(*this));
-}
-
-//--------------------------------------------------------------------------
-void AddNode::setInsertedAddress(sharable::TreeFragment * const & _aInsertedTree)
-{
- OSL_ENSURE( m_aInsertedTree == NULL, "AddNode already was applied - inserted a second time ?");
- m_aInsertedTree = _aInsertedTree;
-}
-//--------------------------------------------------------------------------
-
-#if 0
-void AddNode::expectReplacedNode(INode const* pOldNode)
-{
- if (pOldNode != m_aOwnOldNode.getRoot())
- {
- OSL_ENSURE(!m_aOwnOldNode.is(), "This AddNode already owns a replaced Node - throwing that away");
- m_aOwnOldNode.clear();
- }
- m_pOldNode = pOldNode;
-}
-#endif
-//--------------------------------------------------------------------------
-
-void AddNode::takeReplacedTree(rtl::Reference< data::TreeSegment > const & _aReplacedTree)
-{
- m_aOwnOldNode = _aReplacedTree;
-
- if (m_aOwnOldNode.is()) m_bReplacing = true;
-}
-
-
-//==========================================================================
-//= RemoveNode
-//==========================================================================
-RemoveNode::RemoveNode(rtl::OUString const& _rName, bool _bToDefault)
- :Change(_rName,_bToDefault)
- ,m_aOwnOldNode()
-{
-}
-
-//--------------------------------------------------------------------------
-RemoveNode::~RemoveNode()
-{
-}
-// -----------------------------------------------------------------------------
-RemoveNode::RemoveNode(const RemoveNode& _aObj)
-: Change(_aObj)
-, m_aOwnOldNode(data::TreeSegment::create(_aObj.m_aOwnOldNode))
-{
-}
-
-// -----------------------------------------------------------------------------
-std::auto_ptr<Change> RemoveNode::clone() const
-{
- return std::auto_ptr<Change>(new RemoveNode(*this));
-}
-//--------------------------------------------------------------------------
-#if 0
-void RemoveNode::expectRemovedNode(INode const* pOldNode)
-{
- if (pOldNode != m_aOwnOldNode.getRoot())
- {
- OSL_ENSURE(!m_aOwnOldNode.is(), "This RemoveNode already owns a Node - throwing that away");
- m_aOwnOldNode.clear();
- }
- m_pOldNode = pOldNode;
-}
-#endif
-//--------------------------------------------------------------------------
-
-void RemoveNode::takeRemovedTree(rtl::Reference< data::TreeSegment > const & _aRemovedTree)
-{
- m_aOwnOldNode = _aRemovedTree;
-}
-
-//--------------------------------------------------------------------------
-} // namespace configmgr
-
diff --git a/configmgr/source/tree/cmtree.cxx b/configmgr/source/tree/cmtree.cxx
deleted file mode 100644
index a7b4fa520f23..000000000000
--- a/configmgr/source/tree/cmtree.cxx
+++ /dev/null
@@ -1,378 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "subtree.hxx"
-#include "change.hxx"
-#include "treechangelist.hxx"
-
-//#include "treeactions.hxx"
-#include <rtl/string.hxx>
-#include <rtl/ustring.hxx>
-#include <osl/diagnose.h>
-
-#ifndef INCLUDED_DEQUE
-#include <deque>
-#define INCLUDED_DEQUE
-#endif
-#ifndef INCLUDED_VECTOR
-#include <vector>
-#define INCLUDED_VECTOR
-#endif
-#ifndef INCLUDED_EXCEPTION
-#include <exception>
-#define INCLUDED_EXCEPTION
-#endif
-#ifndef INCLUDED_SET
-#include <set>
-#define INCLUDED_SET
-#endif
-#include <algorithm>
-
-namespace configmgr
-{
-
-// ------------------------ ChildListSet implementations ------------------------
- ChildListSet::ChildListSet(ChildListSet const& aSet, treeop::DeepChildCopy)
- : m_aChildList(aSet.m_aChildList.size())
- {
- for (size_t i = 0; i < aSet.m_aChildList.size(); i++)
- {
- m_aChildList[i] = aSet.m_aChildList[i]->clone().release();
- }
- }
- ChildListSet::~ChildListSet()
- {
- for (size_t i = 0; i < m_aChildList.size(); i++)
- delete m_aChildList[i];
- }
-
- struct ltNode
- {
- ltNode() {}
-
- bool operator()(const configmgr::INode* n1, const configmgr::INode* n2) const
- {
- return n1->getName().compareTo(n2->getName()) < 0;
- }
- };
-
- std::vector< INode* >::iterator ChildListSet::find(INode *pNode) const
- {
- std::vector< INode* > &rList = const_cast<std::vector< INode* > &>(m_aChildList);
- std::pair<std::vector< INode* >::iterator, std::vector< INode* >::iterator> aRange;
- ltNode aCompare;
- aRange = std::equal_range(rList.begin(), rList.end(), pNode, aCompare);
- if (aRange.second - aRange.first == 0)
- return rList.end();
- else
- return aRange.first;
- }
-
- // Keep the list sorted ...
- std::pair<std::vector< INode* >::iterator, bool> ChildListSet::insert(INode *pNode)
- {
- // Inserted records are (mostly) already in order
- if (m_aChildList.size() > 0)
- {
- sal_Int32 nCmp = pNode->getName().compareTo(
- m_aChildList.back()->getName());
- if (nCmp == 0)
- {
- return std::pair<std::vector< INode* >::iterator, bool>(m_aChildList.end(), false);
- }
- else if (nCmp < 0)
- {
- std::vector< INode* >::iterator aIns;
- ltNode aCompare;
- aIns = std::lower_bound(m_aChildList.begin(), m_aChildList.end(), pNode, aCompare);
- if (aIns != m_aChildList.end() && pNode->getName().compareTo((*aIns)->getName()) == 0)
- return std::pair<std::vector< INode* >::iterator, bool>(m_aChildList.end(), false);
- return std::pair<std::vector< INode* >::iterator, bool>(m_aChildList.insert(aIns, pNode), true);
- }
- }
- // simple append - the common case.
- return std::pair<std::vector< INode* >::iterator, bool>(m_aChildList.insert(m_aChildList.end(), pNode), true);
- }
-
- INode *ChildListSet::erase(INode *pNode)
- {
- std::vector< INode* >::iterator aIter = find(pNode);
-
- if (aIter != m_aChildList.end())
- {
- INode *pCopy = *aIter;
- m_aChildList.erase(aIter);
- return pCopy;
- }
- else
- return NULL;
- }
-
-// ---------------------------- Node implementation ----------------------------
-
- INode::INode(rtl::OUString const& aName, node::Attributes _aAttr)
- :m_aName(aName)
- ,m_aAttributes(_aAttr){}
- // CopyCTor will be create automatically
-
- INode::~INode() {}
-
- ISubtree* INode::asISubtree(){return NULL;}
- ISubtree const* INode::asISubtree() const {return NULL;}
- ValueNode* INode::asValueNode() {return NULL;}
- ValueNode const* INode::asValueNode() const {return NULL;}
-
- void INode::modifyState(node::State _eNewState)
- {
- m_aAttributes.setState(_eNewState);
- }
-
- void INode::modifyAccess(node::Access _aAccessLevel)
- {
- OSL_ENSURE( node::accessWritable <= _aAccessLevel && _aAccessLevel <= node::accessReadonly,"Invalid access level for Node");
-
- m_aAttributes.setAccess(_aAccessLevel);
- }
-
- void INode::markMandatory()
- {
- m_aAttributes.markMandatory();
- }
-
- void INode::markRemovable()
- {
- m_aAttributes.markRemovable();
- }
-
- void INode::promoteAccessToDefault()
- {
- if (m_aAttributes.isFinalized())
- m_aAttributes.setAccess(node::accessReadonly);
-
- if ( m_aAttributes.isMandatory())
- m_aAttributes.setRemovability(false,false);
- }
-
-// ------------------------- SearchNode implementation -------------------------
- SearchNode::SearchNode(rtl::OUString const& aName)
- :INode(aName, node::Attributes()){}
-
- std::auto_ptr<INode> SearchNode::clone() const {return std::auto_ptr<INode>(new SearchNode(*this));}
-
- SearchNode::~SearchNode(){}
-
- //==========================================================================
- //= OPropagateLevels
- //==========================================================================
- /** fills a subtree with the correct level informations
- */
- struct OPropagateLevels : public NodeModification
- {
- public:
- OPropagateLevels(sal_Int16 _nParentLevel, sal_Int16 _nParentDefaultLevel)
- : m_nLevel ( childLevel(_nParentLevel) )
- , m_nDefaultLevel ( childLevel(_nParentDefaultLevel) )
- {
- }
- virtual void handle(ValueNode&) { /* not interested in value nodes */ }
- virtual void handle(ISubtree& _rSubtree)
- {
- _rSubtree.setLevels(m_nLevel, m_nDefaultLevel);
- }
-
- static sal_Int16 childLevel(sal_Int16 _nLevel)
- {
- OSL_ASSERT(0 > treeop::ALL_LEVELS);
- return (_nLevel > 0) ? _nLevel-1 : _nLevel;
- }
- protected:
- sal_Int16 m_nLevel;
- sal_Int16 m_nDefaultLevel;
- };
-
-
-// -------------------------- ISubtree implementation --------------------------
- ISubtree* ISubtree::asISubtree() {return this;}
- ISubtree const* ISubtree::asISubtree() const {return this;}
-
- //--------------------------------------------------------------------------
- static inline bool adjustLevel(sal_Int16& _rLevel, sal_Int16 _nNewLevel)
- {
- if (_rLevel == treeop::ALL_LEVELS) return false;
- if (_nNewLevel <= _rLevel &&
- _nNewLevel != treeop::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 ---------------------------
- std::auto_ptr<INode> Subtree::clone() const
- {
- return std::auto_ptr<INode>(new Subtree(*this, treeop::DeepChildCopy()));
- }
-
- INode* Subtree::doGetChild(rtl::OUString const& aName) const
- {
- SearchNode searchObj(aName);
-
- std::vector< INode* >::iterator aIter = m_aChildren.find(&searchObj);
- return aIter != m_aChildren.end() ? *aIter : NULL;
- }
-
- INode* Subtree::addChild(std::auto_ptr<INode> aNode) // takes ownership
- {
- rtl::OUString aName = aNode->getName();
- std::pair<std::vector< INode* >::iterator, bool> aInserted =
- m_aChildren.insert(aNode.get());
- if (aInserted.second)
- aNode.release();
- return *aInserted.first;
- }
-
- ::std::auto_ptr<INode> Subtree::removeChild(rtl::OUString const& aName)
- {
- SearchNode searchObj(aName);
- return ::std::auto_ptr<INode>(m_aChildren.erase(&searchObj));
- }
-// // -------------------------- ValueNode implementation --------------------------
-
- void Subtree::forEachChild(NodeAction& anAction) const
- {
- for(std::vector< INode* >::const_iterator it = m_aChildren.begin();
- it != m_aChildren.end();
- ++it)
- (**it).dispatch(anAction);
- }
-
- void Subtree::forEachChild(NodeModification& anAction)
- {
- std::vector< INode* >::iterator it = m_aChildren.begin();
- while( it != m_aChildren.end() )
- {
- // modification-safe iteration
- (**it++).dispatch(anAction);
- }
- }
-
-// // -------------------------- ValueNode implementation --------------------------
- bool ValueNode::setValueType(uno::Type const& _aType)
- {
- if (_aType == this->getValueType()) return true;
-
- if (!this->isNull()) return false;
-
- uno::TypeClass eTC = this->getValueType().getTypeClass();
- if (eTC != uno::TypeClass_VOID && eTC != uno::TypeClass_ANY)
- return false;
-
- m_aValuePair = AnyPair(_aType);
-
- OSL_ASSERT(_aType == this->getValueType());
-
- return true;
- }
- bool ValueNode::setValue(com::sun::star::uno::Any const& _aValue)
- {
- sal_Bool bRet = m_aValuePair.setFirst(_aValue);
- if (bRet) this->markAsDefault(false);
- return !! bRet;
- }
-
- bool ValueNode::changeDefault(com::sun::star::uno::Any const& _aValue)
- {
- return !! m_aValuePair.setSecond(_aValue);
- }
-
- void ValueNode::setDefault()
- {
- OSL_PRECOND( hasUsableDefault(), "No default value to set for value node");
- m_aValuePair.clear( selectValue() );
- this->markAsDefault();
- OSL_POSTCOND( isDefault(), "Could not set value node to default");
- }
-
- void ValueNode::promoteToDefault()
- {
- if (!isDefault())
- {
- if (m_aValuePair.hasFirst())
- {
- OSL_VERIFY( m_aValuePair.setSecond(m_aValuePair.getFirst()) );
- m_aValuePair.clear( selectValue() );
- }
- else
- {
- m_aValuePair.clear( selectDeflt() );
- OSL_ASSERT( m_aValuePair.isNull() );
- }
-
- this->markAsDefault();
-
- OSL_ENSURE( !m_aValuePair.hasFirst(), "Leaving orphaned value in after promoting to default");
- }
- else
- OSL_ENSURE( !m_aValuePair.hasFirst(), "Orphaned value in default node won't be promoted");
-
- OSL_POSTCOND( isDefault(), "Could not promote value node to default");
- }
-
- std::auto_ptr<INode> ValueNode::clone() const
- {
- return std::auto_ptr<INode>(new ValueNode(*this));
- }
-
- ValueNode* ValueNode::asValueNode() {return this;}
- ValueNode const* ValueNode::asValueNode() const {return this;}
-
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/cmtreemodel.cxx b/configmgr/source/tree/cmtreemodel.cxx
deleted file mode 100644
index 685e18c352ea..000000000000
--- a/configmgr/source/tree/cmtreemodel.cxx
+++ /dev/null
@@ -1,371 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "valuenode.hxx"
-#include "change.hxx"
-#include "configexcept.hxx"
-#include "strdecl.hxx"
-#include <osl/diagnose.h>
-
-#ifndef INCLUDED_ALGORITHM
-#define INCLUDED_ALGORITHM
-#include <algorithm>
-#endif
-
-//..........................................................................
-namespace configmgr
-{
-//==========================================================================
-
-bool isLocalizedValueSet(ISubtree const& _aSubtree)
-{
- if ( !_aSubtree.isSetNode()) return false;
- if ( !_aSubtree.isLocalized()) return false;
- if ( !_aSubtree.getElementTemplateModule().equals(TEMPLATE_MODULE_LOCALIZED_VALUE) ) return false;
- return true;
-}
-// -----------------------------------------------------------------------------
-
-bool isLocalizedValueSet(SubtreeChange const& _aSubtree)
-{
- if ( !_aSubtree.isSetNodeChange()) return false;
- if ( !_aSubtree.isLocalizedContainer()) return false;
- if ( !_aSubtree.getElementTemplateModule().equals(TEMPLATE_MODULE_LOCALIZED_VALUE) ) return false;
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool isValueSet(SubtreeChange const& _aSubtree)
-{
- if ( !_aSubtree.isSetNodeChange()) return false;
- if ( !_aSubtree.getElementTemplateModule().equals(TEMPLATE_MODULE_NATIVE_VALUE) ) return false;
- return true;
-}
-//==========================================================================
-
-//==========================================================================
-//= Change
-//==========================================================================
-void Change::swap(Change& aOther)
-{
- std::swap(m_aName, aOther.m_aName);
- std::swap(m_bIsToDefault, aOther.m_bIsToDefault);
-}
-
-//==========================================================================
-//= SubtreeChange
-//==========================================================================
-//--------------------------------------------------------------------------
-void SubtreeChange::swap(SubtreeChange& aOther)
-{
- Change::swap(aOther);
- m_aChanges.swap(aOther.m_aChanges);
- std::swap(m_sTemplateName, aOther.m_sTemplateName);
- std::swap(m_sTemplateModule, aOther.m_sTemplateModule);
- std::swap(m_aAttributes, aOther.m_aAttributes);
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::~SubtreeChange()
-{
- for(Children::iterator aIter = m_aChanges.begin();
- aIter != m_aChanges.end();
- ++aIter)
- {
- // Change* pChange = aIter->second;
- delete aIter->second;
- }
-}
-
-// -----------------------------------------------------------------------------
-SubtreeChange::SubtreeChange(const SubtreeChange& _aObj, treeop::DeepChildCopy)
- :Change(_aObj),
- m_sTemplateName(_aObj.m_sTemplateName),
- m_sTemplateModule(_aObj.m_sTemplateModule),
- m_aAttributes(_aObj.m_aAttributes)
-{
- for(Children::const_iterator aIter = _aObj.m_aChanges.begin();
- aIter != _aObj.m_aChanges.end();
- ++aIter)
- {
- OSL_ASSERT(aIter->second);
- Children::value_type aCopy(aIter->first, aIter->second->clone().release());
- m_aChanges.insert(m_aChanges.end(), aCopy);
- }
-}
-
-// -----------------------------------------------------------------------------
-std::auto_ptr<Change> SubtreeChange::clone() const
-{
- return std::auto_ptr<Change>(new SubtreeChange(*this, treeop::DeepChildCopy()));
-}
-//--------------------------------------------------------------------------
-void SubtreeChange::addChange(std::auto_ptr<Change> aChange)
-{
- rtl::OUString aNodeName(aChange->getNodeName());
- m_aChanges.find(aNodeName);
- OSL_ENSURE(m_aChanges.end() == m_aChanges.find(aNodeName),
- "SubtreeChange::addChange : overwriting an existent change !");
- delete m_aChanges[aNodeName];
- m_aChanges[aNodeName] = aChange.release();
-}
-
-//--------------------------------------------------------------------------
-::std::auto_ptr<Change> SubtreeChange::removeChange(rtl::OUString const& _rName)
-{
- Children::iterator aIter = m_aChanges.find(_rName);
-
- ::std::auto_ptr<Change> aReturn;
- if (m_aChanges.end() != aIter)
- {
- aReturn = ::std::auto_ptr<Change>(aIter->second);
- m_aChanges.erase(aIter);
- }
- return aReturn;
-}
-
-//--------------------------------------------------------------------------
-Change* SubtreeChange::getChange(rtl::OUString const& _rName)
-{
- return doGetChild(_rName);
-}
-
-//--------------------------------------------------------------------------
-Change const* SubtreeChange::getChange(rtl::OUString const& _rName) const
-{
- return doGetChild(_rName);
-}
-
-//--------------------------------------------------------------------------
-void SubtreeChange::dispatch(ChangeTreeAction& _anAction) const
-{
- _anAction.handle(*this);
-}
-
-//--------------------------------------------------------------------------
-void SubtreeChange::dispatch(ChangeTreeModification& _anAction)
-{
- _anAction.handle(*this);
-}
-
-//--------------------------------------------------------------------------
-void SubtreeChange::forEachChange(ChangeTreeAction& _anAction) const
-{
- ::std::map< ::rtl::OUString,Change* >::const_iterator aIter = m_aChanges.begin();
- while (aIter != m_aChanges.end())
- {
- (aIter++)->second->dispatch(_anAction);
- }
-}
-
-//--------------------------------------------------------------------------
-void SubtreeChange::forEachChange(ChangeTreeModification& _anAction)
-{
- ::std::map< ::rtl::OUString,Change* >::const_iterator aIter = m_aChanges.begin();
- while (aIter != m_aChanges.end())
- {
- (aIter++)->second->dispatch(_anAction);
- }
-}
-
-//--------------------------------------------------------------------------
-Change* SubtreeChange::doGetChild(rtl::OUString const& _rName) const
-{
- Children::const_iterator aIter = m_aChanges.find(_rName);
- return (aIter != m_aChanges.end()) ? aIter->second : NULL;
-}
-
-//--------------------------------------------------------------------------
-uno::Sequence< rtl::OUString > SubtreeChange::elementNames() const
-{
- uno::Sequence< rtl::OUString > aReturn(size());
- rtl::OUString* pReturn = aReturn.getArray();
-
- for ( Children::const_iterator aCollector = m_aChanges.begin();
- aCollector != m_aChanges.end();
- ++aCollector, ++pReturn
- )
- {
- *pReturn = aCollector->first;
- }
-
- return aReturn;
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::MutatingChildIterator SubtreeChange::begin_changes() throw()
-{
- return MutatingChildIterator(m_aChanges.begin());
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::MutatingChildIterator SubtreeChange::end_changes() throw()
-{
- return MutatingChildIterator(m_aChanges.end());
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator SubtreeChange::begin() const throw()
-{
- return ChildIterator(this);
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator SubtreeChange::end() const throw()
-{
- return ChildIterator(this, ChildIterator::EndPos());
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator::ChildIterator(const SubtreeChange* _pTree)
- :m_aNames(_pTree->elementNames())
- ,m_pTree(_pTree)
- ,m_nPos(0)
-{
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator::ChildIterator(const SubtreeChange* _pTree, struct EndPos)
- :m_aNames(_pTree->elementNames())
- ,m_pTree(_pTree)
- ,m_nPos(_pTree->size())
-{
-}
-
-//--------------------------------------------------------------------------
-Change const & SubtreeChange::ChildIterator::operator*() const
-{
- OSL_ENSURE(isValid(), "SubtreeChange::ChildIterator::operator* : invalid iterator !");
-
- if (!isValid())
- throw configuration::Exception("INTERNAL ERROR: Invalid SubtreeChange::ChildIterator dereferenced");
-
- return *m_pTree->getChange(m_aNames[m_nPos]);
-}
-
-//--------------------------------------------------------------------------
-Change const * SubtreeChange::ChildIterator::operator->() const
-{
- if (isValid())
- return m_pTree->getChange(m_aNames[m_nPos]);
- OSL_ENSURE(sal_False, "SubtreeChange::ChildIterator::operator-> : invalid iterator !");
- return NULL;
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator& SubtreeChange::ChildIterator::operator++()
-{
- OSL_ENSURE(m_nPos < m_aNames.getLength(), "SubtreeChange::ChildIterator : can't increment the end iterator !");
- if (m_nPos < m_aNames.getLength())
- ++m_nPos;
- return *this;
-}
-
-//--------------------------------------------------------------------------
-SubtreeChange::ChildIterator& SubtreeChange::ChildIterator::operator--()
-{
- OSL_ENSURE(m_nPos > 0, "SubtreeChange::ChildIterator : can't decrement the begin iterator !");
- if (m_nPos > 0)
- --m_nPos;
- return *this;
-}
-
-//--------------------------------------------------------------------------
-bool operator==(SubtreeChange::ChildIterator const& lhs, SubtreeChange::ChildIterator const& rhs)
-{
- return (lhs.m_pTree == rhs.m_pTree) && (lhs.m_nPos == rhs.m_nPos);
-}
-
-//==========================================================================
-//= SubtreeChangeReferrer
-//==========================================================================
-//--------------------------------------------------------------------------
-SubtreeChangeReferrer::SubtreeChangeReferrer(const SubtreeChange& _rSource)
- :SubtreeChange(_rSource, treeop::NoChildCopy())
-{
- ChildIterator aSourceChildren = _rSource.begin();
- while (aSourceChildren != _rSource.end())
- {
- const Change* pChange = &*aSourceChildren;
- OSL_ENSURE(pChange, "SubtreeChangeReferrer::SubtreeChangeReferrer : invalid change !");
- if (dynamic_cast< ValueChange const * >(pChange) != 0 ||
- dynamic_cast< RemoveNode const * >(pChange) != 0 ||
- dynamic_cast< AddNode const * >(pChange) != 0)
- SubtreeChange::addChange(::std::auto_ptr<Change>(const_cast<Change*>(pChange)));
- else if (dynamic_cast< SubtreeChange const * >(pChange) != 0 ||
- dynamic_cast< SubtreeChangeReferrer const * >(pChange) != 0)
- {
- SubtreeChange::addChange(::std::auto_ptr<Change>(new SubtreeChangeReferrer(*static_cast<const SubtreeChange*>(pChange))));
- }
- else
- OSL_ENSURE(sal_False, "SubtreeChangeReferrer::SubtreeChangeReferrer : unknown changes type !");
-
- ++aSourceChildren;
- }
-}
-
-//--------------------------------------------------------------------------
-SubtreeChangeReferrer::~SubtreeChangeReferrer()
-{
- for ( Children::iterator aChildren = m_aChanges.begin();
- aChildren != m_aChanges.end();
-
- )
- {
- const Change* pChange = aChildren->second;
- Children::iterator aCurrent = aChildren++;
-
- if (dynamic_cast< ValueChange const * >(pChange) != 0 ||
- dynamic_cast< RemoveNode const * >(pChange) != 0 ||
- dynamic_cast< AddNode const * >(pChange) != 0)
- {
- // we just hold references to the non-SubtreeChange-objects, so don't delete them
- m_aChanges.erase(aCurrent);
- }
- else if (dynamic_cast< SubtreeChange const * >(pChange) != 0 ||
- dynamic_cast< SubtreeChangeReferrer const * >(pChange) != 0)
- {
- // nothing to do
- }
- else
- OSL_ENSURE(sal_False, "SubtreeChangeReferrer::~SubtreeChangeReferrer : unknown changes type !");
- }
-
- // the base class will remove the remaining SubtreeChanges, which are SubtreeChangeReferrer's in real
-}
-
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-
diff --git a/configmgr/source/tree/localizedtreeactions.cxx b/configmgr/source/tree/localizedtreeactions.cxx
deleted file mode 100644
index 110e1d0efb98..000000000000
--- a/configmgr/source/tree/localizedtreeactions.cxx
+++ /dev/null
@@ -1,543 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "localizedtreeactions.hxx"
-#include "treeactions.hxx"
-#include "builddata.hxx"
-#include "subtree.hxx"
-#include "matchlocale.hxx"
-#include "typeconverter.hxx"
-#include "change.hxx"
-#include "treechangefactory.hxx"
-#include "treenodefactory.hxx"
-#include "strdecl.hxx"
-#include <osl/diagnose.h>
-
-
-//..........................................................................
-namespace configmgr
-{
-
-//--------------------------------------------------------------------------
-namespace
-{
-//--------------------------------------------------------------------------
- //==========================================================================
- //= OCloneForLocale
- //==========================================================================
- //= clones a subtree , in the process selecting only the best match locale
- //= from the set representation of localized values
- //==========================================================================
- class OCloneForLocale : public NodeAction
- {
- rtl::OUString m_sTargetLocale;
- std::auto_ptr<INode> m_pClone;
- public:
- OCloneForLocale(rtl::OUString const& aLocale) : m_sTargetLocale(aLocale) {}
- std::auto_ptr<INode> getResult() { return m_pClone; }
-
- private:
- void handle(ValueNode const& _aValue);
- void handle(ISubtree const& _aSubtree);
- };
-//--------------------------------------------------------------------------
- struct OCloneChildrenForLocale : NodeAction
- {
- ISubtree& m_rParent;
- localehelper::FindBestLocale& m_rLocaleMatcher;
- public:
- OCloneChildrenForLocale(ISubtree& _rParent, localehelper::FindBestLocale& _rLocaleMatcher)
- : m_rParent(_rParent)
- , m_rLocaleMatcher(_rLocaleMatcher)
- {}
-
- virtual void handle(ValueNode const& _aValue);
- virtual void handle(ISubtree const& _aSubtree);
- };
-
-//--------------------------------------------------------------------------
- struct OSelectForLocale : NodeAction
- {
- ValueNode const* m_pFound;
- localehelper::FindBestLocale& m_rLocaleMatcher;
- public:
- OSelectForLocale(localehelper::FindBestLocale& _rLocaleMatcher)
- : m_pFound(NULL)
- , m_rLocaleMatcher(_rLocaleMatcher)
- {}
-
-
- bool hasResult() const
- { return m_pFound != NULL; }
-
- ValueNode const* getResult() const
- { return m_pFound; }
-
- private:
- virtual void handle(ValueNode const& _aValue);
- virtual void handle(ISubtree const& _aSubtree);
-
- void maybeSelect(ValueNode const& _aNode);
- };
-
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
- void OSelectForLocale::handle(ValueNode const& _aValue)
- {
- maybeSelect(_aValue);
- }
-//--------------------------------------------------------------------------
- void OSelectForLocale::handle(ISubtree const& /*_aSubtree*/)
- {
- OSL_ENSURE(false, "INTERNAL ERROR: Inconsistent data: Found a Subtree in a set of localized values");
- }
-//--------------------------------------------------------------------------
- void OSelectForLocale::maybeSelect(ValueNode const& _aNode)
- {
- if (m_rLocaleMatcher.accept( localehelper::makeLocale(_aNode.getName()) ) )
- m_pFound = &_aNode;
-
- else
- OSL_ENSURE(m_pFound, "WARNING: Node Locale wasn't accepted, but no node had been found before");
- }
-
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
- std::auto_ptr< INode > implReduceLocalizedSet(ISubtree const& _aSubtree, localehelper::FindBestLocale& _rLocaleMatcher)
- {
- // -- find the best-match locale -----------------------------
- _rLocaleMatcher.reset();
-
- OSelectForLocale aSelector(_rLocaleMatcher);
-
- aSelector.applyToChildren(_aSubtree);
-
- std::auto_ptr< INode > pResult;
-
- // -- look for a non-NULL value -----------------------------
- uno::Type aValueType;
- if (aSelector.hasResult())
- {
- ValueNode const& rSelected = *aSelector.getResult();
-
- aValueType = rSelected.getValueType();
-
- if (!rSelected.isNull()) // values are present - clone it from the values
- {
- pResult.reset ( new ValueNode( _aSubtree.getName(),
- rSelected.getValue(), rSelected.getDefault(),
- _aSubtree.getAttributes()
- ) );
-
- }
- }
- else // no entry - exract the type to be used from the template name
- aValueType = parseTemplateName(_aSubtree.getElementTemplateName());
-
- // -- create NULL value, if none was found -----------------------------
- // create a NULL of the found type
- if (pResult.get() == NULL)
- {
- pResult.reset( new ValueNode( _aSubtree.getName(),
- aValueType,
- _aSubtree.getAttributes()
- ) );
- }
-
- // -- -----------------------------
- OSL_ENSURE( aValueType != uno::Type(), "VOID result type found");
-#if OSL_DEBUG_LEVEL > 0
- uno::Type aTemplateType = parseTemplateName( _aSubtree.getElementTemplateName() );
- OSL_ENSURE( ( aValueType == aTemplateType ) || ( aTemplateType.getTypeClass() == uno::TypeClass_ANY ),
- "ERROR: Found Value Type doesn't match encoded value type in pseudo template name");
-#endif
- OSL_POSTCOND( static_cast<ValueNode&>(*pResult).getValueType() == aValueType,
- "ERROR: Resulting Value Type doesn't match original value type" );
-
- return pResult;
- }
-//--------------------------------------------------------------------------
- std::auto_ptr< INode > implCloneForLocale(ISubtree const& _aSubtree, localehelper::FindBestLocale& _rLocaleMatcher)
- {
- std::auto_ptr< INode > pClone;
-
- if (isLocalizedValueSet(_aSubtree))
- {
- pClone = implReduceLocalizedSet(_aSubtree, _rLocaleMatcher);
- }
- else
- {
- // ISubtree should get a clone(NoChildCopy) member ...
- std::auto_ptr< Subtree > pCloneTree( new Subtree(_aSubtree, treeop::NoChildCopy()) );
-
- OCloneChildrenForLocale aSubCloner(*pCloneTree,_rLocaleMatcher);
-
- aSubCloner.applyToChildren(_aSubtree);
-
- pClone.reset( pCloneTree.release() );
- }
-
- return pClone;
- }
-//--------------------------------------------------------------------------
-//--- OCloneChildrenForLocale:-----------------------------------------------------------------------
-
- void OCloneChildrenForLocale::handle(ValueNode const& _aValue)
- {
- // just a single value - nothing to do
- std::auto_ptr< INode > pClone( _aValue.clone() );
-
- m_rParent.addChild(pClone);
-
- }
-//--------------------------------------------------------------------------
- void OCloneChildrenForLocale::handle(ISubtree const& _aSubtree)
- {
- std::auto_ptr< INode > pClone = implCloneForLocale(_aSubtree,m_rLocaleMatcher);
-
- m_rParent.addChild(pClone);
- }
-
- //--------------------------------------------------------------------------
- //= OCloneForLocale
-
- // rtl::OUString m_sTargetLocale;
- // std::auto_ptr<INode> m_pClone;
-
- void OCloneForLocale::handle(ValueNode const& _aValue)
- {
- // just a single value - nothing to do
- std::auto_ptr< INode > pClone( _aValue.clone() );
-
- m_pClone = pClone;
- }
- //--------------------------------------------------------------------------
- void OCloneForLocale::handle(ISubtree const& _aSubtree)
- {
- localehelper::FindBestLocale aLocaleMatcher( localehelper::makeLocale(m_sTargetLocale) );
-
- m_pClone = implCloneForLocale(_aSubtree,aLocaleMatcher);
- }
- //--------------------------------------------------------------------------
-
-//--------------------------------------------------------------------------
-} // anonymous namespace
-
-//==========================================================================
-// Helper function to invoke the previous ones properly
-
-// convert to the given locale format, assuming the original representation was expanded
-static std::auto_ptr<INode> impl_cloneExpandedForLocale(INode const* _pNode, rtl::OUString const& _sLocale)
-{
- OSL_ASSERT(_pNode != NULL);
-
- if ( localehelper::designatesAllLocales(localehelper::makeLocale(_sLocale)) ) // from expanded to expanded
- {
- return _pNode->clone();
- }
-
- else // needs reduction
- {
- OCloneForLocale aCloner(_sLocale);
- aCloner.applyToNode(*_pNode);
- return aCloner.getResult();
- }
-}
-//--------------------------------------------------------------------------
-
-// convert to the given locale format, assuming the original representation was expanded
-static rtl::Reference< data::TreeSegment > old_cloneExpandedForLocale(rtl::OUString const& _sName, INode const* _pNode, rtl::OUString const& _sLocale)
-{
- if (_pNode == NULL)
- return rtl::Reference< data::TreeSegment >();
-
- std::auto_ptr<INode> aResult;
- if (dynamic_cast< ISubtree const * >(_pNode) == 0) // simple value - nothing to reduce
- aResult = _pNode->clone();
-
- else
- aResult = impl_cloneExpandedForLocale(_pNode,_sLocale);
-
- return data::TreeSegment::create(_sName,aResult);
-}
-//--------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-rtl::Reference< data::TreeSegment > cloneExpandedForLocale(sharable::TreeFragment * tree, rtl::OUString const& _sLocale)
-{
- std::auto_ptr<INode> aOldTree = data::convertTree(tree, true);
-
- return old_cloneExpandedForLocale(tree->getName(), aOldTree.get(), _sLocale);
-}
-//--------------------------------------------------------------------------
-// convert to the given locale format, assuming the original representation was expanded
-std::auto_ptr<INode> reduceExpandedForLocale(std::auto_ptr<ISubtree> _pNode, rtl::OUString const& _sLocale)
-{
- std::auto_ptr<INode> aResult;
-
- if ( _pNode.get() == NULL || // nothing to reduce
- localehelper::designatesAllLocales(localehelper::makeLocale(_sLocale)) ) // from expanded to expanded
- {
- aResult.reset( _pNode.release() );
- }
-
- else // needs reduction
- {
- OCloneForLocale aCloner(_sLocale);
- aCloner.applyToNode(*_pNode);
- aResult = aCloner.getResult();
-
- OSL_ENSURE(aResult.get(),"Cloning a tree for a locale unexpectedly produced NOTHING");
- }
- return aResult;
-}
-//--------------------------------------------------------------------------
-namespace
-{
-//--------------------------------------------------------------------------
- class ExpandTreeForLocale : NodeModification
- {
- ISubtree & m_rParent;
- rtl::OUString const & m_aSourceLocale;
-
- ExpandTreeForLocale(ISubtree & _rParent,rtl::OUString const & _aSourceLocale)
- : m_rParent(_rParent)
- , m_aSourceLocale(_aSourceLocale)
- {}
-
- void handle(ISubtree& _rNode);
- void handle(ValueNode& _rNode);
-
- void substitute(std::auto_ptr<INode> _aExpanded);
- public:
- static void expand(ISubtree& _rTree, rtl::OUString const & _aSourceLocale)
- {
- ExpandTreeForLocale(_rTree,_aSourceLocale).applyToChildren(_rTree);
- }
-
- // returns NULL, if not a localized value
- static std::auto_ptr<ISubtree> expanded(ValueNode const& _aNode, rtl::OUString const & _aSourceLocale);
- };
-
-//--------------------------------------------------------------------------
- class ExpandChangesForLocale : ChangeTreeModification
- {
- SubtreeChange & m_rParent;
- rtl::OUString const & m_aSourceLocale;
-
- ExpandChangesForLocale(SubtreeChange & _rParent,rtl::OUString const & _aSourceLocale)
- : m_rParent(_rParent)
- , m_aSourceLocale(_aSourceLocale)
- {}
-
- void handle(SubtreeChange& _rNode);
- void handle(ValueChange& _rNode);
-
- void handle(AddNode& _rNode);
- void handle(RemoveNode& _rNode);
-
- void substitute(std::auto_ptr<Change> _aExpanded);
- public:
- static void expand(SubtreeChange& _rTree, rtl::OUString const & _aSourceLocale)
- {
- ExpandChangesForLocale(_rTree,_aSourceLocale).applyToChildren(_rTree);
- }
-
- // returns NULL, if not a localized value
- static std::auto_ptr<SubtreeChange> expanded(ValueChange const& _aNode, rtl::OUString const & _aSourceLocale);
- };
-//--------------------------------------------------------------------------
-inline
-void ExpandTreeForLocale::substitute(std::auto_ptr<INode> _aExpanded)
-{
- m_rParent.removeChild(_aExpanded->getName());
- m_rParent.addChild(_aExpanded);
-}
-
-//--------------------------------------------------------------------------
-void ExpandTreeForLocale::handle(ISubtree& _rNode)
-{
- expand(_rNode,m_aSourceLocale);
-}
-
-//--------------------------------------------------------------------------
-void ExpandTreeForLocale::handle(ValueNode& _rNode)
-{
- std::auto_ptr<ISubtree> aExpanded = expanded(_rNode,m_aSourceLocale);
-
- if (aExpanded.get())
- substitute( base_ptr(aExpanded) );
-}
-
-//--------------------------------------------------------------------------
-
-std::auto_ptr<ISubtree> ExpandTreeForLocale::expanded(ValueNode const& _aNode, rtl::OUString const & _aSourceLocale)
-{
- if (!_aNode.isLocalized()) return std::auto_ptr<ISubtree>();
-
- OTreeNodeFactory & rFactory = getDefaultTreeNodeFactory();
-
- node::Attributes aValueAttributes = _aNode.getAttributes();
-
- aValueAttributes.setLocalized(false);
- if (aValueAttributes.state() == node::isMerged)
- aValueAttributes.setState( node::isReplaced );
-
-
- std::auto_ptr<ValueNode> aValue = _aNode.isNull()
- ? rFactory.createNullValueNode(_aSourceLocale,_aNode.getValueType(),aValueAttributes)
- : rFactory.createValueNode(_aSourceLocale,_aNode.getValue(),aValueAttributes);
-
- std::auto_ptr<ISubtree> aRet = rFactory.createSetNode( _aNode.getName(),
- toTemplateName(_aNode.getValueType()),
- TEMPLATE_MODULE_LOCALIZED_VALUE,
- _aNode.getAttributes() );
-
- aRet->addChild(base_ptr(aValue));
-
- return aRet;
-}
-
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-inline
-void ExpandChangesForLocale::substitute(std::auto_ptr<Change> _aExpanded)
-{
- m_rParent.removeChange(_aExpanded->getNodeName());
- m_rParent.addChange(_aExpanded);
-}
-
-//--------------------------------------------------------------------------
-
-void ExpandChangesForLocale::handle(SubtreeChange& _rNode)
-{
- expand(_rNode,m_aSourceLocale);
-}
-
-//--------------------------------------------------------------------------
-void ExpandChangesForLocale::handle(ValueChange& _rNode)
-{
- std::auto_ptr<SubtreeChange> aExpanded = expanded(_rNode,m_aSourceLocale);
-
- if (aExpanded.get())
- substitute( base_ptr( aExpanded ) );
-}
-
-//--------------------------------------------------------------------------
-void ExpandChangesForLocale::handle(AddNode& _rNode)
-{
- rtl::Reference< data::TreeSegment > seg(_rNode.getNewTree());
- std::auto_ptr<INode> pAdded(data::convertTree(seg.is() ? seg->fragment : 0, false));
- if (pAdded.get() != NULL)
- {
- std::auto_ptr<INode> pExpanded;
- if (ISubtree * pAddedTree = pAdded->asISubtree())
- {
- ExpandTreeForLocale::expand(*pAddedTree,m_aSourceLocale);
- pExpanded = pAdded;
- }
- else if(ValueNode * pAddedValue = pAdded->asValueNode())
- {
- pExpanded = base_ptr(ExpandTreeForLocale::expanded(*pAddedValue,m_aSourceLocale));
- }
- else
- OSL_ENSURE(false, "Cannot expand unknown Node type (found in AddNode)");
-
-
- if (pExpanded.get())
- {
- rtl::Reference< data::TreeSegment > aExpanded = data::TreeSegment::create( _rNode.getNodeName(),pExpanded);
- std::auto_ptr<AddNode> aExpandedAdd( new AddNode( aExpanded, _rNode.getNodeName(), _rNode.isToDefault() ) );
-
- if (_rNode.isReplacing()) aExpandedAdd->setReplacing();
-
- substitute( base_ptr( aExpandedAdd ) );
- }
- }
- else
- OSL_ENSURE(false, "Cannot expand AddNode without content");
-}
-
-//--------------------------------------------------------------------------
-void ExpandChangesForLocale::handle(RemoveNode& )
-{
- // nothing to do
-}
-
-//--------------------------------------------------------------------------
-std::auto_ptr<SubtreeChange> ExpandChangesForLocale::expanded(ValueChange const& _aNode, rtl::OUString const & _aSourceLocale)
-{
- std::auto_ptr<SubtreeChange> aRet;
- if (_aNode.isLocalizedValue())
- {
- OTreeNodeFactory & rNodeFactory = getDefaultTreeNodeFactory();
- OTreeChangeFactory & rFactory = getDefaultTreeChangeFactory();
-
- node::Attributes aValueAttributes = _aNode.getAttributes();
-
- aValueAttributes.setLocalized(false);
- if (aValueAttributes.state() == node::isMerged)
- aValueAttributes.setState( node::isReplaced );
-
-
- rtl::OUString const sTemplateName = toTemplateName(_aNode.getValueType());
-
- std::auto_ptr<ValueNode> aValue = _aNode.getNewValue().hasValue()
- ? rNodeFactory.createValueNode(sTemplateName,_aNode.getNewValue(),aValueAttributes)
- : rNodeFactory.createNullValueNode(sTemplateName,_aNode.getValueType(),aValueAttributes);
-
- rtl::Reference< data::TreeSegment > aValueSegment = data::TreeSegment::create(_aSourceLocale, base_ptr(aValue));
-
- std::auto_ptr<AddNode> aAddValue = rFactory.createAddNodeChange(aValueSegment,_aSourceLocale,_aNode.isToDefault());
- aAddValue->setReplacing();
-
- aRet = rFactory.createSetNodeChange( _aNode.getNodeName(),
- sTemplateName,
- TEMPLATE_MODULE_LOCALIZED_VALUE,
- _aNode.getAttributes() );
-
- aRet->addChange(base_ptr(aAddValue));
- }
- return aRet;
-}
-
-//--------------------------------------------------------------------------
-} // anonymous namespace
-//--------------------------------------------------------------------------
-
-//--------------------------------------------------------------------------
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-
diff --git a/configmgr/source/tree/makefile.mk b/configmgr/source/tree/makefile.mk
deleted file mode 100644
index 1609db28878b..000000000000
--- a/configmgr/source/tree/makefile.mk
+++ /dev/null
@@ -1,66 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2000, 2010 Oracle and/or its affiliates.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org 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 version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..
-PRJINC=$(PRJ)$/source
-
-PRJNAME=configmgr
-TARGET=cm
-ENABLE_EXCEPTIONS=TRUE
-
-
-# --- Settings ---
-.IF "$(DBGUTIL_OJ)"!=""
-ENVCFLAGS+=/FR$(SLO)$/
-.ENDIF
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/makefile.pmk
-
-# --- Files ---
-
-SLOFILES=\
- $(SLO)$/builddata.obj \
- $(SLO)$/node.obj \
- $(SLO)$/treefragment.obj \
- $(SLO)$/treesegment.obj \
- $(SLO)$/nodevisitor.obj \
- $(SLO)$/changes.obj \
- $(SLO)$/treenodefactory.obj \
- $(SLO)$/treechangefactory.obj \
- $(SLO)$/localizedtreeactions.obj \
- $(SLO)$/treeactions.obj \
- $(SLO)$/cmtreemodel.obj \
- $(SLO)$/cmtree.obj \
- $(SLO)$/nodeconverter.obj \
- $(SLO)$/updatehelper.obj \
- $(SLO)$/mergehelper.obj \
-
-# --- Targets ---
-
-.INCLUDE : target.mk
-
diff --git a/configmgr/source/tree/mergehelper.cxx b/configmgr/source/tree/mergehelper.cxx
deleted file mode 100644
index 1188ac0d51f6..000000000000
--- a/configmgr/source/tree/mergehelper.cxx
+++ /dev/null
@@ -1,456 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "builddata.hxx"
-#include "nodeconverter.hxx"
-#include "treefragment.hxx"
-#include "treenodefactory.hxx"
-#include "treechangefactory.hxx"
-#include "configpath.hxx"
-#include "tracer.hxx"
-#include <osl/diagnose.h>
-
-
-//..........................................................................
-namespace configmgr
-{
-
-namespace
-{
-//==========================================================================
-//= OCleanupLayerAction
-//==========================================================================
-//= This class cleans up a layer to be merged into an existing tree
-//==========================================================================
-class OCleanupLayerAction : ChangeTreeModification
-{
- SubtreeChange& m_rResultTree; // list which containes changes merged with the existing nodes
- ISubtree const & m_rTargetTree; // reference node needed for merging
- OTreeNodeConverter m_aNodeConverter;
-public:
- static bool adjust(SubtreeChange& _rResultTree, SubtreeChange& _aLayerTree, ISubtree const& _aTargetTree)
- {
- return OCleanupLayerAction(_rResultTree,_aTargetTree).impl_cleanup(_aLayerTree);
- }
- static bool adjust(SubtreeChange& _rResultTree, SubtreeChange& _aLayerTree, ISubtree const& _aTargetTree, OTreeNodeFactory& _rNodeFactory)
- {
- return OCleanupLayerAction(_rResultTree,_aTargetTree,_rNodeFactory).impl_cleanup(_aLayerTree);
- }
-
-private:
- OCleanupLayerAction(SubtreeChange& _rResult, ISubtree const& _rTree)
- :m_rResultTree(_rResult)
- ,m_rTargetTree(_rTree)
- ,m_aNodeConverter()
- {}
-
- OCleanupLayerAction(SubtreeChange& _rResult, ISubtree const& _rTree, OTreeNodeFactory& _rNodeFactory)
- :m_rResultTree(_rResult)
- ,m_rTargetTree(_rTree)
- ,m_aNodeConverter(_rNodeFactory)
- {}
-
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
-
- bool impl_cleanup(SubtreeChange& _aUpdateTree);
-
- void add(std::auto_ptr<Change> _pChange);
- void addReplacedNode(rtl::Reference< data::TreeSegment > const & _aReplacedTree);
- void addReplacedNode(std::auto_ptr<INode> _aReplacedNode);
-};
-
-// --------------------------------- MergeLayerToTree ---------------------------------
-
-class MergeLayerToTree : ChangeTreeModification
-{
- ISubtree& m_rTree;
-
-public:
- explicit
- MergeLayerToTree(ISubtree& _rTree):m_rTree(_rTree) {}
-
- MergeLayerToTree& merge(SubtreeChange & _rLayerTree);
-private:
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
-
- static void mergeAttributes(INode& _rNode, node::Attributes const& _aChangeAttributes);
-};
-// --------------------------------- AttributeSetter ---------------------------------
-
-class AttributeSetter : NodeModification
-{
- node::State m_state;
- bool m_bPromoteFinalized;
-public:
- explicit
- AttributeSetter(node::State _state, bool _bPromoteFinalized)
- : m_state(_state)
- , m_bPromoteFinalized(_bPromoteFinalized)
- {}
-
- void setNodeAttributes(INode& _rNode);
-
- using NodeModification::applyToNode;
-private:
- void handle(ValueNode& _rValueNode);
- void handle(ISubtree& _rSubtree);
-};
-// -----------------------------------------------------------------------------
-
-} // anon namepsace
-// -----------------------------------------------------------------------------
-// this is our 'exported' function
-
-// -----------------------------------------------------------------------------
-namespace
-{
-//==========================================================================
-//= OCleanupLayerAction
-//==========================================================================
-static inline bool isFinal(node::Attributes const& _aAttributes)
-{
- return _aAttributes.isFinalized() || _aAttributes.isReadonly();
-}
-//==========================================================================
-bool OCleanupLayerAction::impl_cleanup(SubtreeChange& _aUpdateTree)
-{
- OSL_ENSURE(!_aUpdateTree.isReplacedNode(), "Layer cleanup: A replaced tree should not be merged");
-
- if (isFinal(m_rTargetTree.getAttributes()))
- {
- CFG_TRACE_WARNING("Layer cleanup : Ignoring change to write-protected tree '%s'",OUSTRING2ASCII(m_rTargetTree.getName()));
- return false;
- }
-
- // first check the changes
- this->applyToChildren(_aUpdateTree);
-
- return m_rResultTree.size() != 0;
-}
-//--------------------------------------------------------------------------
-inline void OCleanupLayerAction::add(std::auto_ptr<Change> _aChange)
-{
- m_rResultTree.addChange(_aChange);
-}
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::handle(ValueChange& _rChange)
-{
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- OSL_ENSURE(!_rChange.isToDefault(),"Found change to default in layer being merged");
-
- // replaced state -> should be a full (added/replaced) node
- //if (_rChange.isReplacedNode() && m_rTargetTree.isSetNodeChange())
- if ( _rChange.isReplacedValue() )
- {
- std::auto_ptr<ValueNode> pNode( m_aNodeConverter.createCorrespondingNode(_rChange) );
-
- this->addReplacedNode( base_ptr(pNode) );
-
- }
- else if (INode const * const pTargetNode = m_rTargetTree.getChild(sNodeName))
- {
- // this mismatch is not discarded here (should be ignored while merging though)
- OSL_ENSURE(pTargetNode->asValueNode(), "Layer cleanup : Node type mismatch: Value change applied to non-value node !");
-
- if (!isFinal(pTargetNode->getAttributes()))
- {
- std::auto_ptr<Change> pResult( new ValueChange(_rChange) );
- this->add(pResult);
- }
- else
- {
- CFG_TRACE_WARNING("Layer cleanup : Ignoring change to write-protected value '%s'",OUSTRING2ASCII(sNodeName));
- }
- }
- else
- {
- OSL_TRACE("Layer cleanup : Found orphaned node (value) '%s'",OUSTRING2ASCII(sNodeName));
- CFG_TRACE_INFO("Layer cleanup : Found orphaned node (value) '%s'",OUSTRING2ASCII(sNodeName));
- OSL_ENSURE(false, "Layer cleanup : Found orphaned Value");
- }
-}
-
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::handle(SubtreeChange& _rChange)
-{
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- OSL_ENSURE(!_rChange.isToDefault(),"Found change to default in layer being merged");
-
- // replaced state -> should be a full (added/replaced) node
- if (_rChange.isReplacedNode())
- {
- std::auto_ptr<ISubtree> pNode = m_aNodeConverter.createCorrespondingTree(_rChange);
-
- // mark as complete with defaults)
- pNode->setLevels(treeop::ALL_LEVELS,treeop::ALL_LEVELS);
-
- this->addReplacedNode( base_ptr(pNode) );
- }
- else if ( INode const * const pTargetNode = m_rTargetTree.getChild(sNodeName) )
- {
- ISubtree const * pTargetTree = pTargetNode->asISubtree();
-
- if (pTargetTree)
- {
- // generate a new change
- std::auto_ptr<SubtreeChange> pResult( new SubtreeChange(_rChange, treeop::NoChildCopy()) );
-
- // recurse
- if ( adjust(*pResult,_rChange,*pTargetTree,m_aNodeConverter.nodeFactory()) )
- this->add(base_ptr(pResult));
-
- else
- CFG_TRACE_INFO("Layer cleanup : Found void modification tree '%s'",OUSTRING2ASCII(sNodeName));
- }
- else
- {
- OSL_ENSURE(false, "Layer cleanup : Node type mismatch: Tree change applied to non-tree node !");
- CFG_TRACE_ERROR("Layer cleanup : Discarding schema violation for node '%s'",OUSTRING2ASCII(sNodeName));
- //throw Whatever();
- }
- }
- else
- {
- OSL_TRACE("Layer cleanup : Found orphaned node (subtree) '%s'",OUSTRING2ASCII(sNodeName));
- CFG_TRACE_INFO("Layer cleanup : Found orphaned node (subtree) '%s'",OUSTRING2ASCII(sNodeName));
- }
-}
-
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::handle(RemoveNode& _rChange)
-{
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- OSL_ENSURE(!_rChange.isToDefault(),"Found change to default in layer being merged");
-
- OSL_ENSURE(m_rTargetTree.isSetNode(),"Found RemoveNode for non-set-element in layer being merged");
-
- // look up the corresponding node
- INode const * const pTargetNode = m_rTargetTree.getChild(sNodeName);
-
- if (pTargetNode)
- {
- // generate the same change
- std::auto_ptr<Change> pResult( new RemoveNode(sNodeName,false) );
- this->add(pResult);
- }
- else
- {
- OSL_TRACE("Layer cleanup : Found orphaned node (removal) '%s'",OUSTRING2ASCII(sNodeName));
- CFG_TRACE_INFO("Layer cleanup : Found orphaned node (removal) '%s'",OUSTRING2ASCII(sNodeName));
- }
-}
-
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::handle(AddNode& _rChange)
-{
- OSL_ENSURE(!_rChange.isToDefault(),"Found change to default in layer being merged");
-
-// generate the same change
- this->addReplacedNode( _rChange.getNewTree() );
-}
-
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::addReplacedNode(std::auto_ptr<INode> _aReplacedNode)
-{
- OSL_ENSURE(m_rTargetTree.isSetNode(),"Found replaced node for non-set-element in layer being merged");
-
- OSL_ASSERT(_aReplacedNode.get());
-
- rtl::OUString sTypeName = m_rTargetTree.getElementTemplateName();
-
- this->addReplacedNode( data::TreeSegment::create(_aReplacedNode,sTypeName) );
-}
-
-//--------------------------------------------------------------------------
-void OCleanupLayerAction::addReplacedNode(rtl::Reference< data::TreeSegment > const & _aReplacedTree)
-{
- OSL_ENSURE(m_rTargetTree.isSetNode(),"Found replaced node for non-set-element in layer being merged");
-
- OSL_ASSERT(_aReplacedTree.is());
-
- rtl::OUString sNodeName = _aReplacedTree->fragment->getName();
-
- // add the tree to the change list
- std::auto_ptr<AddNode> pResult( new AddNode(_aReplacedTree,sNodeName, false) );
-
- // look up the corresponding existing node
- INode const * const pTargetNode = m_rTargetTree.getChild(sNodeName);
-
- if (pTargetNode) pResult->setReplacing();
-
- this->add( base_ptr(pResult) );
-}
-
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-
-void MergeLayerToTree::mergeAttributes(INode& _rNode, node::Attributes const& _aChangeAttributes)
-{
- OSL_ENSURE(!isFinal(_rNode.getAttributes()),"Layer merge: Node being merged is READONLY - cleanup broken");
- OSL_ENSURE(_aChangeAttributes.state() == node::isMerged,"Layer merge: Found unexpected state for change being merged");
-
- _rNode.modifyState(node::isMerged);
- _rNode.modifyAccess(_aChangeAttributes.getAccess());
-}
-//--------------------------------------------------------------------------
-
-MergeLayerToTree& MergeLayerToTree::merge(SubtreeChange & _rLayerTree)
-{
- OSL_ENSURE(_rLayerTree.getNodeName() == m_rTree.getName(),"Layer merge: change does not match tree");
-
- this->applyToChildren(_rLayerTree);
- mergeAttributes(m_rTree,_rLayerTree.getAttributes());
-
- return *this;
-}
-//--------------------------------------------------------------------------
-
-void MergeLayerToTree::handle(ValueChange& _rChange)
-{
- OSL_ENSURE(!_rChange.isToDefault(),"Layer merge: Found change to default - cleanup broken");
-
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- INode * const pTargetNode = m_rTree.getChild(sNodeName);
-
- OSL_ENSURE(pTargetNode,"Layer merge: Found NULL value - cleanup broken");
- OSL_ENSURE(!isFinal(pTargetNode->getAttributes()),"Layer merge: Found READONLY value - cleanup broken");
-
- if (ValueNode* pTargetValue = pTargetNode->asValueNode() )
- {
- _rChange.applyChangeNoRecover(*pTargetValue);
- mergeAttributes(*pTargetValue,_rChange.getAttributes());
- }
- else
- {
- OSL_ENSURE(false, "Layer merge : Node type mismatch: Value change applied to non-value node !");
- CFG_TRACE_ERROR("Layer merge : Discarding schema violation for value '%s'",OUSTRING2ASCII(sNodeName));
- //throw Whatever();
- }
-}
-//--------------------------------------------------------------------------
-
-void MergeLayerToTree::handle(AddNode& _rChange)
-{
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- node::State eNodeState = node::isAdded;
-
- if (_rChange.isReplacing())
- {
- OSL_VERIFY( m_rTree.removeChild(sNodeName).get() );
- eNodeState = node::isReplaced;
- }
-
- OSL_ENSURE( !m_rTree.getChild(sNodeName),"Layer merge: Found conflicting data on insert - cleanup broken");
-
- rtl::Reference< data::TreeSegment > aAddedTree = _rChange.getNewTree();
-
- OSL_ENSURE(aAddedTree.is(), "Layer merge: Found empty data on insert - cleanup broken");
-
- // clean up the attributes of the added node
- std::auto_ptr<INode> aAddedData(data::convertTree(aAddedTree->fragment, true));
-
- AttributeSetter(eNodeState,false).applyToNode(*aAddedData);
-
- m_rTree.addChild(aAddedData);
-}
-//--------------------------------------------------------------------------
-
-void MergeLayerToTree::handle(RemoveNode& _rChange)
-{
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- // should have such a node when removing
- OSL_VERIFY( m_rTree.removeChild(sNodeName).get() );
-}
-//--------------------------------------------------------------------------
-
-
-void MergeLayerToTree::handle(SubtreeChange& _rChange)
-{
- OSL_ENSURE(!_rChange.isToDefault(),"Layer merge: Found change to default - cleanup broken");
-
- rtl::OUString const sNodeName = _rChange.getNodeName();
-
- INode * const pTargetNode = m_rTree.getChild(sNodeName);
-
- OSL_ENSURE(pTargetNode,"Layer merge: Found NULL subtree - cleanup broken");
- OSL_ENSURE(!isFinal(pTargetNode->getAttributes()),"Layer merge: Found READONLY subtree - cleanup broken");
-
- ISubtree * const pTargetTree = pTargetNode->asISubtree();
- OSL_ENSURE(pTargetTree,"Layer merge: Found non-tree for SubtreeChange - cleanup broken");
-
- // recurse
- MergeLayerToTree(*pTargetTree).merge(_rChange);
-}
-//--------------------------------------------------------------------------
-
-void AttributeSetter::setNodeAttributes(INode& _rNode)
-{
- node::Attributes const aOldAttributes = _rNode.getAttributes();
-
- _rNode.modifyState(m_state);
- if (m_bPromoteFinalized && isFinal(aOldAttributes))
- _rNode.modifyAccess(node::accessReadonly);
-}
-// -----------------------------------------------------------------------------
-
-void AttributeSetter::handle(ValueNode& _rValueNode)
-{
- setNodeAttributes(_rValueNode);
-}
-// -----------------------------------------------------------------------------
-
-void AttributeSetter::handle(ISubtree& _rSubtree)
-{
- setNodeAttributes(_rSubtree);
-
- this->applyToChildren(_rSubtree);
-}
-//--------------------------------------------------------------------------
-
-} // anonymous namespace
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-
diff --git a/configmgr/source/tree/node.cxx b/configmgr/source/tree/node.cxx
deleted file mode 100644
index 2d5ac73ba051..000000000000
--- a/configmgr/source/tree/node.cxx
+++ /dev/null
@@ -1,535 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "node.hxx"
-#include "anydata.hxx"
-#include "treefragment.hxx"
-#include "attributes.hxx"
-#include "utility.hxx"
-#include <rtl/ustring.hxx>
-#include <com/sun/star/uno/Any.hxx>
-
-#ifndef INCLUDED_CSTDDEF
-#include <cstddef>
-#define INCLUDED_CSTDDEF
-#endif
-
-namespace configmgr
-{
-//-----------------------------------------------------------------------------
- namespace sharable
- {
-//-----------------------------------------------------------------------------
-
-rtl::OUString NodeInfo::getName() const
-{
- return rtl::OUString(this->name);
-}
-//-----------------------------------------------------------------------------
-
-configmgr::node::Attributes NodeInfo::getNodeInfoAttributes() const
-{
- configmgr::node::Attributes aResult;
-
- bool help = !!(flags & data::Flags::readonly);
- aResult.setAccess( help,!!(flags & data::Flags::finalized) );
-// aResult.setAccess( !!(flags & data::Flags::readonly),!!(flags & data::Flags::finalized) );
-
- aResult.setNullable(!!(flags & data::Flags::nullable));
- aResult.setLocalized(!!(flags & data::Flags::localized));
-
- configmgr::node::State state = (flags & data::Flags::defaulted) ? configmgr::node::isDefault :
- (flags & data::Flags::defaultable) ? configmgr::node::isMerged :
- configmgr::node::isReplaced;
- aResult.setState(state);
-
- return aResult;
-}
-//-----------------------------------------------------------------------------
-
-bool NodeInfo::isDefault() const
-{
- return !!(this->flags & data::Flags::defaulted);
-}
-//-----------------------------------------------------------------------------
-
-bool NodeInfo::isLocalized() const
-{
- return !!(this->flags & data::Flags::localized);
-}
-//-----------------------------------------------------------------------------
-
-void NodeInfo::markAsDefault(bool bDefault)
-{
- if (bDefault)
- {
- OSL_ENSURE(flags & data::Flags::defaultable,"Marking a non-defaultable node as default");
- this->flags |= data::Flags::defaulted;
- }
- else
- this->flags &= ~data::Flags::defaulted;
-}
-//-----------------------------------------------------------------------------
-
-bool GroupNode::hasDefaultsAvailable() const
-{
- if (this->info.isDefault())
- return true;
-
- if (node(this)->getTreeFragment()->hasDefaultsAvailable())
- return true;
-
-#if 0 // extended check for default state
- for (Node const * pChild = getFirstChild(); pChild != NULL; pChild = getNextChild(pChild))
- if (! pChild->isDefault() )
- return false;
-
- return true;
-#endif
-
- return false;
-}
-//-----------------------------------------------------------------------------
-
-Node * GroupNode::getFirstChild() const
-{
- OSL_ENSURE(numDescendants, "Groups MUST have at least one child");
- return const_cast< Node * >(node(this) + 1);
-}
-//-----------------------------------------------------------------------------
-
-static
-sal_uInt16 implGetNextChildOffset(GroupNode const * _pParent, Node const * _pChild)
-{
- OSL_PRECOND(_pChild, "getNextChild: previous child must not be NULL");
- OSL_PRECOND(_pChild->getParentNode() == node(_pParent), "getNextChild: not a child of this node");
-
-
- OSL_ENSURE( node(_pParent) < _pChild && _pChild <= node(_pParent) + _pParent->numDescendants,
- "getNextChild: child out of descendants range");
-
- // offset to child's next sibling
- sal_uInt16 next = 1;
- if ( _pChild->isGroup())
- {
- next = next + _pChild->group.numDescendants;
- }
-
- if (_pChild->info.parent + next > _pParent->numDescendants)
- {
- OSL_ENSURE(_pChild->info.parent + next == _pParent->numDescendants+1, "Next child candidate should match next sibling here");
- return 0;
- }
-
- OSL_POSTCOND( (_pChild+next)->getParentNode() == node(_pParent), "getNextChild: not a child of this node");
- return next;
-}
-//-----------------------------------------------------------------------------
-
-Node * GroupNode::getNextChild(Node * _pChild) const
-{
- if (sal_uInt16 next = implGetNextChildOffset(this, _pChild))
- return _pChild + next;
-
- else
- return NULL;
-}
-
-Node * GroupNode::getChild(rtl::OUString const & name) const {
- for (Node * child = getFirstChild(); child != 0;
- child = getNextChild(child))
- {
- if (child->isNamed(name)) {
- return child;
- }
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-// TODO: optimize this - keep a list of such structs ....
-struct SetNodeTemplateData
-{
- rtl_uString * name;
- rtl_uString * module;
-};
-//-----------------------------------------------------------------------------
-static inline
-SetNodeTemplateData * readTemplateData(sal_uInt8 * _aTemplateData)
-{
- return reinterpret_cast<SetNodeTemplateData *>( _aTemplateData );
-}
-//-----------------------------------------------------------------------------
-
-sal_uInt8 * SetNode::allocTemplateData(const rtl::OUString &rName,
- const rtl::OUString &rModule)
-{
- SetNodeTemplateData * pData = new SetNodeTemplateData();
-
- OSL_ENSURE(pData, "Creating template data: unexpected NULL data");
-
- pData->name = acquireString(rName);
- pData->module = acquireString(rModule);
-
- return reinterpret_cast<sal_uInt8 *>( pData );
-}
-
-sal_uInt8 * SetNode::copyTemplateData(sal_uInt8 * _aTemplateData)
-{
- SetNodeTemplateData const * pData = readTemplateData(_aTemplateData);
-
- OSL_ENSURE(pData, "Copying template data: unexpected NULL data");
-
- return allocTemplateData(rtl::OUString(pData->name), rtl::OUString(pData->module));
-}
-
-//-----------------------------------------------------------------------------
-
-void SetNode::releaseTemplateData(sal_uInt8 * _aTemplateData)
-{
- if (!_aTemplateData) return;
-
- SetNodeTemplateData const * pData = readTemplateData(_aTemplateData);
-
- OSL_ENSURE(pData, "Freeing template data: unexpected NULL data");
-
- rtl_uString_release(pData->name);
- rtl_uString_release(pData->module);
-
- delete pData;
-}
-
-//-----------------------------------------------------------------------------
-
-rtl::OUString SetNode::getElementTemplateName() const
-{
- SetNodeTemplateData const * pData = readTemplateData(this->elementType);
-
- OSL_ENSURE(pData, "ERROR: No template data found for set");
-
- return rtl::OUString(pData->name);
-}
-//-----------------------------------------------------------------------------
-
-rtl::OUString SetNode::getElementTemplateModule() const
-{
- SetNodeTemplateData const * pData = readTemplateData(this->elementType);
-
- OSL_ENSURE(pData, "ERROR: No template data found for set");
-
- return rtl::OUString(pData->module);
-}
-//-----------------------------------------------------------------------------
-
-static inline
-TreeFragment * implGetFragmentFromList(TreeFragment * _aListEntry)
-{
- return reinterpret_cast<TreeFragment *>(_aListEntry);
-}
-//-----------------------------------------------------------------------------
-
-TreeFragment * SetNode::getFirstElement() const
-{
- return implGetFragmentFromList(this->elements);
-}
-//-----------------------------------------------------------------------------
-
-TreeFragment * SetNode::getNextElement(TreeFragment * _pElement) const
-{
- OSL_PRECOND(_pElement, "getNextElement: previous element must not be NULL");
- OSL_PRECOND(_pElement->header.parent == (Node *)this,
- "getNextElement: not an element of this node");
-
- return implGetFragmentFromList(_pElement->header.next);
-}
-
-TreeFragment * SetNode::getElement(rtl::OUString const & name) const {
- for (TreeFragment * element = getFirstElement(); element != 0;
- element = getNextElement(element))
- {
- if (element->isNamed(name)) {
- return element;
- }
- }
- return 0;
-}
-
-void SetNode::addElement(TreeFragment * newElement) {
- OSL_ASSERT(newElement != 0);
- newElement->header.next = elements;
- newElement->header.parent = node(this);
- elements = newElement;
-}
-
-TreeFragment * SetNode::removeElement(rtl::OUString const & name) {
- for (TreeFragment ** link = &elements; *link != 0;
- link = &(*link)->header.next)
- {
- if ((*link)->isNamed(name)) {
- TreeFragment * removed = *link;
- *link = removed->header.next;
- removed->header.next = 0;
- removed->header.parent = 0;
- return removed;
- }
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-bool ValueNode::isNull() const
-{
- data::Flags::Type availmask = (info.flags & data::Flags::defaulted) ?
- data::Flags::defaultAvailable :
- data::Flags::valueAvailable;
-
- return !(info.flags & availmask);
-}
-//-----------------------------------------------------------------------------
-
-bool ValueNode::hasUsableDefault() const
-{
- return (info.flags & data::Flags::defaultable) &&
- (info.flags & (data::Flags::defaultAvailable| data::Flags::nullable));
-}
-//-----------------------------------------------------------------------------
-
-com::sun::star::uno::Type ValueNode::getValueType() const
-{
- sal_uInt8 aType = sal_uInt8( info.type & data::Type::mask_valuetype );
-
- return getUnoType(aType);
-}
-//-----------------------------------------------------------------------------
-
-com::sun::star::uno::Any ValueNode::getValue() const
-{
- if (info.flags & data::Flags::defaulted)
- return getDefaultValue();
-
- else
- return getUserValue();
-}
-//-----------------------------------------------------------------------------
-
-com::sun::star::uno::Any ValueNode::getUserValue() const
-{
- if (info.flags & data::Flags::valueAvailable)
- {
- sal_uInt8 aType = sal_uInt8( info.type & data::Type::mask_valuetype );
-
- return readData(aType,this->value);
- }
- else
- return com::sun::star::uno::Any();
-}
-//-----------------------------------------------------------------------------
-
-com::sun::star::uno::Any ValueNode::getDefaultValue() const
-{
- if (info.flags & data::Flags::defaultAvailable)
- {
- sal_uInt8 aType = sal_uInt8( info.type & data::Type::mask_valuetype );
-
- return readData(aType,this->defaultValue);
- }
- else
- return com::sun::star::uno::Any();
-}
-
-void ValueNode::setValue(com::sun::star::uno::Any const & newValue) {
- releaseValue();
- if (newValue.hasValue()) {
- sal_uInt8 type = adaptType(newValue);
- value = allocData(type, newValue);
- info.flags |= data::Flags::valueAvailable;
- }
- info.flags &= ~data::Flags::defaulted;
-}
-
-void ValueNode::setToDefault() {
- OSL_ASSERT(hasUsableDefault());
- releaseValue();
- info.flags |= data::Flags::defaulted;
-}
-
-void ValueNode::changeDefault(com::sun::star::uno::Any const & newDefault) {
- sal_uInt8 type = static_cast< sal_uInt8 >(
- info.type & data::Type::mask_valuetype);
- if (info.flags & data::Flags::defaultAvailable) {
- OSL_ASSERT(type != data::Type::value_any);
- freeData(type, defaultValue);
- defaultValue.data = 0;
- info.flags &= ~data::Flags::defaultAvailable;
- }
- if (newDefault.hasValue()) {
- type = adaptType(newDefault);
- defaultValue = allocData(type, newDefault);
- info.flags |= data::Flags::defaultAvailable;
- }
-}
-
-void ValueNode::releaseValue() {
- if ((info.flags & data::Flags::valueAvailable) != 0) {
- sal_uInt8 type = static_cast< sal_uInt8 >(
- info.type & data::Type::mask_valuetype);
- OSL_ASSERT(type != data::Type::value_any);
- freeData(type, value);
- value.data = 0;
- info.flags &= ~data::Flags::valueAvailable;
- }
-}
-
-sal_uInt8 ValueNode::adaptType(com::sun::star::uno::Any const & newValue) {
- sal_uInt8 newType = getTypeCode(newValue.getValueType());
- OSL_ASSERT(newType != data::Type::value_any);
- sal_uInt8 type = static_cast< sal_uInt8 >(
- info.type & data::Type::mask_valuetype);
- if (type == data::Type::value_any) {
- type = static_cast< sal_uInt8 >(newType & data::Type::mask_valuetype);
- info.type = (info.type & ~data::Type::mask_valuetype) | type;
- }
- OSL_ASSERT(newType == type);
- return type;
-}
-
-//-----------------------------------------------------------------------------
-
-bool Node::isNamed(rtl::OUString const & _aName) const
-{
- rtl_uString *pCmpData = _aName.pData;
- rtl_uString *pNodeData = info.name;
-
- // Creating an OUString does rather expensive interlocking here.
- if (pCmpData == pNodeData)
- return true;
- if (pCmpData->length != pNodeData->length)
- return false;
- return !rtl_ustr_compare_WithLength( pCmpData->buffer,
- pCmpData->length,
- pNodeData->buffer,
- pNodeData->length);
-}
-//-----------------------------------------------------------------------------
-
-rtl::OUString Node::getName() const
-{
- return info.getName();
-}
-//-----------------------------------------------------------------------------
-
-configmgr::node::Attributes Node::getAttributes() const
-{
- if(this->isFragmentRoot())
- {
- return this->getTreeFragment()->getAttributes();
- }
- else
- {
- return info.getNodeInfoAttributes();
- }
-}
-//-----------------------------------------------------------------------------
-
-bool Node::isDefault() const
-{
- return info.isDefault();
-}
-//-----------------------------------------------------------------------------
-
-bool Node::isFragmentRoot() const
-{
- return !info.parent;
-}
-#if OSL_DEBUG_LEVEL > 0
-//-----------------------------------------------------------------------------
-Node * Node::getParentNode()
-{
- return info.parent ? this - info.parent : NULL;
-}
-//-----------------------------------------------------------------------------
-
-Node const * Node::getParentNode() const
-{
- return info.parent ? this - info.parent : NULL;
-}
-#endif
-//-----------------------------------------------------------------------------
-static sal_uInt16 getFragmentIndex(Node const * pNode)
-{
- sal_uInt16 result = 0;
- while (sal_uInt16 step = pNode->info.parent)
- {
- result = result + step;
- pNode -= step;
- }
- return result;
-}
-//-----------------------------------------------------------------------------
-
-TreeFragment * Node::getTreeFragment()
-{
- void * pRoot = this - getFragmentIndex(this);
-
- void * pFrag = static_cast<char*>(pRoot) - offsetof(TreeFragment,nodes);
-
- return static_cast<TreeFragment *>(pFrag);
-}
-//-----------------------------------------------------------------------------
-
-TreeFragment const * Node::getTreeFragment() const
-{
- void const * pRoot = this - getFragmentIndex(this);
-
- void const * pFrag = static_cast<char const*>(pRoot) - offsetof(TreeFragment,nodes);
-
- return static_cast<TreeFragment const *>(pFrag);
-}
-
-Node * Node::getSubnode(rtl::OUString const & name) {
- if (isGroup()) {
- return group.getChild(name);
- } else if (isSet()) {
- TreeFragment * element = set.getElement(name);
- return element == 0 ? 0 : element->getRootNode();
- } else {
- OSL_ASSERT(false);
- return 0;
- }
-}
-
-//-----------------------------------------------------------------------------
- } // namespace sharable
-//-----------------------------------------------------------------------------
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/nodeconverter.cxx b/configmgr/source/tree/nodeconverter.cxx
deleted file mode 100644
index ff6373236944..000000000000
--- a/configmgr/source/tree/nodeconverter.cxx
+++ /dev/null
@@ -1,210 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "builddata.hxx"
-#include "nodeconverter.hxx"
-#include "treenodefactory.hxx"
-#include <osl/diagnose.h>
-
-
-//..........................................................................
-namespace configmgr
-{
-
-//==========================================================================
-//= OTreeNodeConverter
-//==========================================================================
-OTreeNodeConverter::OTreeNodeConverter()
-: m_rFactory( getDefaultTreeNodeFactory() )
-{
-}
-
-std::auto_ptr<ISubtree> OTreeNodeConverter::createCorrespondingNode(SubtreeChange const& _rChange)
-{
- std::auto_ptr<ISubtree> aRet;
-
- //if ( isLocalizedValueSet(aSubtree) ) { ... } else - no special case yet
- if (_rChange.isSetNodeChange())
- {
- aRet = nodeFactory().createSetNode(_rChange.getNodeName(),
- _rChange.getElementTemplateName(),
- _rChange.getElementTemplateModule(),
- _rChange.getAttributes());
- }
- else
- {
- aRet = nodeFactory().createGroupNode(_rChange.getNodeName(),
- _rChange.getAttributes());
- }
- return aRet;
-}
-
-//--------------------------------------------------------------------------
-std::auto_ptr<ValueNode> OTreeNodeConverter::createCorrespondingNode(ValueChange const& _rChange)
-{
- // DEFAULT-TODO
- OSL_ENSURE(_rChange.getValueType().getTypeClass() != uno::TypeClass_VOID, "Losing type information converting change to value");
-
- std::auto_ptr<ValueNode> aRet;
- if (_rChange.getNewValue().hasValue())
- aRet = nodeFactory().createValueNode(_rChange.getNodeName(), _rChange.getNewValue(), _rChange.getAttributes());
-
- else
- aRet = nodeFactory().createNullValueNode(_rChange.getNodeName(), _rChange.getValueType(), _rChange.getAttributes());
-
- OSL_ENSURE(aRet.get() && aRet->isValid(), "Could not create corresponding value node");
-
- return aRet;
-}
-
-//==========================================================================
-//= ONodeConverter
-//==========================================================================
-class ONodeConverter : public ChangeTreeModification
-{
- OTreeNodeConverter& m_rFactory;
- std::auto_ptr<INode> m_pNode;
-
-public:
- explicit
- ONodeConverter(OTreeNodeConverter& rFactory)
- : m_rFactory(rFactory)
- {
- }
-
- virtual void handle(ValueChange& aValueNode);
- virtual void handle(AddNode& aAddNode);
- virtual void handle(RemoveNode& aRemoveNode);
- virtual void handle(SubtreeChange& aSubtree);
-
- std::auto_ptr<INode> result() { return m_pNode; }
-
-};
-//==========================================================================
-//= OCreateSubtreeAction
-//==========================================================================
-//= creates a subtree out of a changes list
-//==========================================================================
-struct OCreateSubtreeAction : public ChangeTreeModification
-{
- ISubtree& m_rTree;
- OTreeNodeConverter& m_rNodeFactory;
-
-public:
- OCreateSubtreeAction(ISubtree& _rTree, OTreeNodeConverter& rFactory)
- :m_rTree(_rTree)
- ,m_rNodeFactory(rFactory) {}
-
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
-};
-
-
-//--------------------------------------------------------------------------
-std::auto_ptr<ISubtree> OTreeNodeConverter::createCorrespondingTree(SubtreeChange& _rChange)
-{
- std::auto_ptr<ISubtree> pBaseTree = this->createCorrespondingNode(_rChange);
-
- OCreateSubtreeAction aNextLevel(*pBaseTree,*this);
- _rChange.forEachChange(aNextLevel);
-
- return pBaseTree;
-}
-
-//--------------------------------------------------------------------------
-void ONodeConverter::handle(ValueChange& aValueNode)
-{
- m_pNode = base_ptr(m_rFactory.createCorrespondingNode(aValueNode));
-}
-
-//--------------------------------------------------------------------------
-void ONodeConverter::handle(AddNode& aAddNode)
-{
- rtl::Reference< data::TreeSegment > seg(aAddNode.getNewTree());
- m_pNode = data::convertTree(seg.is() ? seg->fragment : 0, true);
-}
-
-//--------------------------------------------------------------------------
-void ONodeConverter::handle(RemoveNode& /*aRemoveNode*/)
-{
- m_pNode.reset();
-}
-
-//--------------------------------------------------------------------------
-void ONodeConverter::handle(SubtreeChange& aSubtree)
-{
- m_pNode = base_ptr(m_rFactory.createCorrespondingNode(aSubtree));
-}
-
-//--------------------------------------------------------------------------
-void OCreateSubtreeAction::handle(ValueChange& _rChange)
-{
- // create a node by a ValueChange
- std::auto_ptr<ValueNode> pNode = m_rNodeFactory.createCorrespondingNode(_rChange);
-
- m_rTree.addChild(base_ptr(pNode));
-}
-
-//--------------------------------------------------------------------------
-void OCreateSubtreeAction::handle(SubtreeChange& _rChange)
-{
- // create a node from a SubtreeChange (recursively)
- std::auto_ptr<ISubtree> pNode = m_rNodeFactory.createCorrespondingTree(_rChange);
-
- // add it to the tree
- m_rTree.addChild(base_ptr(pNode));
-}
-
-//--------------------------------------------------------------------------
-void OCreateSubtreeAction::handle(RemoveNode& _rChange)
-{
- { (void)_rChange; }
- // we have nothing to do
- OSL_ENSURE(!m_rTree.getChild(_rChange.getNodeName()), "Removed node found in tree being built");
-}
-
-//--------------------------------------------------------------------------
-void OCreateSubtreeAction::handle(AddNode& _rChange)
-{
- // free the node and add it to the subtree
- rtl::Reference< data::TreeSegment > aNewNode = _rChange.getNewTree();
- m_rTree.addChild(data::convertTree(aNewNode.is() ? aNewNode->fragment : 0, true));
-}
-
-
-//--------------------------------------------------------------------------
-
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-
diff --git a/configmgr/source/tree/nodevisitor.cxx b/configmgr/source/tree/nodevisitor.cxx
deleted file mode 100644
index 5d20ef860fc7..000000000000
--- a/configmgr/source/tree/nodevisitor.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "precompiled_configmgr.hxx"
-#include "sal/config.h"
-
-#include "osl/diagnose.h"
-
-#include "flags.hxx"
-#include "nodevisitor.hxx"
-#include "node.hxx"
-#include "treefragment.hxx"
-
-namespace configmgr { namespace data {
-
-NodeVisitor::~NodeVisitor() {}
-
-bool NodeVisitor::visitNode(sharable::Node * node) {
- switch (node->info.type & data::Type::mask_nodetype) {
- case data::Type::nodetype_value:
- return handle(&node->value);
- case data::Type::nodetype_group:
- return handle(&node->group);
- case data::Type::nodetype_set:
- return handle(&node->set);
- default:
- OSL_ASSERT(false);
- return false;
- }
-}
-
-bool NodeVisitor::visitChildren(sharable::GroupNode * node) {
- for (sharable::Node * child = node->getFirstChild(); child != 0;
- child = node->getNextChild(child))
- {
- if (visitNode(child)) {
- return true;
- }
- }
- return false;
-}
-
-bool NodeVisitor::handle(sharable::Node *) {
- return false;
-}
-
-bool NodeVisitor::handle(sharable::ValueNode * node) {
- return handle(sharable::node(node));
-}
-
-bool NodeVisitor::handle(sharable::GroupNode * node) {
- return handle(sharable::node(node));
-}
-
-bool NodeVisitor::handle(sharable::SetNode * node) {
- return handle(sharable::node(node));
-}
-
-SetVisitor::~SetVisitor() {}
-
-bool SetVisitor::visitTree(sharable::TreeFragment * tree) {
- return handle(tree);
-}
-
-bool SetVisitor::visitElements(sharable::SetNode * node) {
- for (sharable::TreeFragment * element = node->getFirstElement();
- element != 0; element = node->getNextElement(element))
- {
- if (handle(element)) {
- return true;
- }
- }
- return false;
-}
-
-bool SetVisitor::handle(sharable::TreeFragment * tree) {
- return visitNode(tree->getRootNode());
-}
-
-} }
diff --git a/configmgr/source/tree/subtree.hxx b/configmgr/source/tree/subtree.hxx
deleted file mode 100644
index 2ce25d33881b..000000000000
--- a/configmgr/source/tree/subtree.hxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_SUBTREE_HXX
-#define CONFIGMGR_SUBTREE_HXX
-
-#include "valuenode.hxx"
-#include <rtl/ustring.hxx>
-
-#include <memory>
-#include <set>
-#include <vector>
-
-namespace configmgr
-{
- // List sorted by name for binary search
- class ChildListSet {
- std::vector< INode* > m_aChildList;
-
- ChildListSet(ChildListSet const&);
- ChildListSet& operator=(ChildListSet const& aSet);
- public:
- std::vector< INode* >::iterator begin() const { return const_cast<std::vector< INode* >*>(&m_aChildList)->begin(); }
- std::vector< INode* >::iterator end() const { return const_cast<std::vector< INode* >*>(&m_aChildList)->end(); }
- INode *erase(INode *pNode);
- std::vector< INode* >::iterator find(INode *pNode) const;
- std::pair<std::vector< INode* >::iterator, bool> insert(INode *aInsert);
-
- ChildListSet() : m_aChildList(0) {}
- ChildListSet(ChildListSet const&, treeop::DeepChildCopy);
- ~ChildListSet();
- };
-
-// Inner Node
- class Subtree : public ISubtree
- {
- ChildListSet m_aChildren;
- virtual INode* doGetChild(rtl::OUString const& name) const;
-
- public:
- Subtree(){}
- Subtree(const rtl::OUString& _rName,
- const node::Attributes& _rAttrs)
- :ISubtree(_rName, _rAttrs){};
-
- Subtree(const ISubtree& _rOther, treeop::NoChildCopy)
- : ISubtree(_rOther), m_aChildren(){};
-
- Subtree(const rtl::OUString& _rName,
- const rtl::OUString& _rTemplateName, const rtl::OUString& _rTemplateModule,
- const node::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(rtl::OUString const& name);
-
- virtual std::auto_ptr<INode> clone() const;
-
-// Iteration support
- virtual void forEachChild(NodeAction& anAction) const;
- virtual void forEachChild(NodeModification& anAction);
- };
-
-
-
- // to search in ChildListSet a value
- class SearchNode : public INode
- {
- public:
- SearchNode(rtl::OUString const& aName);
- virtual ~SearchNode();
- virtual std::auto_ptr<INode> clone() const;
-
-// double dispatch support
- virtual void dispatch(NodeAction& /*anAction*/) const { }
- virtual void dispatch(NodeModification& /*anAction*/) { }
- };
-
-// -----------------------------------------------------------------------------
-} // namespace configmgr
-
-#endif
-
diff --git a/configmgr/source/tree/treeactions.cxx b/configmgr/source/tree/treeactions.cxx
deleted file mode 100644
index 0a040ff218ac..000000000000
--- a/configmgr/source/tree/treeactions.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "treeactions.hxx"
-#include <osl/diagnose.h>
-
-
-//..........................................................................
-namespace configmgr
-{
-
-//==========================================================================
-//= OChangeActionCounter
-//==========================================================================
-
-//--------------------------------------------------------------------------
-void OChangeActionCounter::handle(ValueChange const& /*aValueNode*/){ ++nValues; }
-
-//--------------------------------------------------------------------------
-void OChangeActionCounter::handle(AddNode const& /*aAddNode*/){ ++nAdds; }
-
-//--------------------------------------------------------------------------
-void OChangeActionCounter::handle(RemoveNode const& /*aRemoveNode*/){ ++nRemoves; }
-
-//--------------------------------------------------------------------------
-void OChangeActionCounter::handle(SubtreeChange const& aSubtree)
-{
- applyToChildren(aSubtree);
-}
-
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-
diff --git a/configmgr/source/tree/treechangefactory.cxx b/configmgr/source/tree/treechangefactory.cxx
deleted file mode 100644
index 8a0840b57a90..000000000000
--- a/configmgr/source/tree/treechangefactory.cxx
+++ /dev/null
@@ -1,123 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "treechangefactory.hxx"
-#include "change.hxx"
-#include "configpath.hxx"
-
-namespace configmgr
-{
-//= dummy helpe ============================================================
-bool isGenericSetElementType(rtl::OUString const& _aElementType)
-{
- return !! _aElementType.equals( getGenericSetElementType() );
-}
-
-bool isDummySetElementModule(rtl::OUString const& _aElementModule)
-{
- return !! _aElementModule.equals( getDummySetElementModule() );
-}
-
-rtl::OUString getGenericSetElementType()
-{
- return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*"));
-}
-
-rtl::OUString getDummySetElementModule()
-{
- return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cfg:dummy-change"));
-}
-
-//= static default ============================================================
-OTreeChangeFactory& getDefaultTreeChangeFactory()
-{
- static OTreeChangeFactory aDefaultFactory;
- return aDefaultFactory;
-}
-
-//= SubtreeChanges ============================================================
-std::auto_ptr<SubtreeChange> OTreeChangeFactory::createDummyChange(
- rtl::OUString const& _aName, rtl::OUString const& _aElementTypeName)
-{
- std::auto_ptr<SubtreeChange> pResult;
-
- if (_aElementTypeName.getLength() == 0)
- {
- pResult.reset( new SubtreeChange(_aName, node::Attributes()) );
- }
- else
- {
- pResult.reset( new SubtreeChange(_aName,
- _aElementTypeName,
- getDummySetElementModule(),
- node::Attributes()) );
- }
- return pResult;
-}
-
-//-----------------------------------------------
-std::auto_ptr<SubtreeChange> OTreeChangeFactory::createSetNodeChange(
- rtl::OUString const& _aName,
- rtl::OUString const& _aTemplateName,
- rtl::OUString const& _aTemplateModule,
- node::Attributes _aAttrs,
- bool _bToDefault)
-{
- return std::auto_ptr<SubtreeChange>(new SubtreeChange(_aName,
- _aTemplateName,
- _aTemplateModule,
- _aAttrs,_bToDefault));
-}
-//-----------------------------------------------
-
-//= Set Changes ============================================================
-std::auto_ptr<AddNode> OTreeChangeFactory::createAddNodeChange(
- rtl::Reference< data::TreeSegment > const & _aNewTree,
- rtl::OUString const& _aName,
- bool _bToDefault)
-{
- return std::auto_ptr<AddNode>(new AddNode(_aNewTree,_aName,_bToDefault));
-}
-
-//-----------------------------------------------
-std::auto_ptr<RemoveNode> OTreeChangeFactory::createRemoveNodeChange(
- rtl::OUString const& _aName,
- bool _bToDefault)
-{
- return std::auto_ptr<RemoveNode>(new RemoveNode(_aName,_bToDefault));
-}
-
-//-----------------------------------------------
-
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/treefragment.cxx b/configmgr/source/tree/treefragment.cxx
deleted file mode 100644
index 352c8d078ca1..000000000000
--- a/configmgr/source/tree/treefragment.cxx
+++ /dev/null
@@ -1,130 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "treefragment.hxx"
-#include "utility.hxx"
-#include "attributes.hxx"
-#include <rtl/ustring.hxx>
-
-// memset
-#include <string.h>
-
-namespace configmgr
-{
-//-----------------------------------------------------------------------------
- namespace sharable
- {
-//-----------------------------------------------------------------------------
-rtl::OUString TreeFragment::getName() const
-{
- return rtl::OUString(this->header.name);
-}
-
-void TreeFragment::setName(rtl::OUString const & name) {
- rtl_uString * old = header.name;
- header.name = acquireString(name);
- rtl_uString_release(old);
-}
-
-//-----------------------------------------------------------------------------
-
-bool TreeFragment::isNamed(rtl::OUString const & _aName) const
-{
- // TODO: optimize comparison
- return !!(this->getName() == _aName);
-}
-//-----------------------------------------------------------------------------
-
-bool TreeFragment::hasDefaultsAvailable() const
-{
- return (this->header.state & data::State::flag_default_avail) || isDefault();
-}
-//-----------------------------------------------------------------------------
-
-
-bool TreeFragment::isDefault() const
-{
- return (this->header.state & data::State::mask_state) == data::State::defaulted;
-}
-//-----------------------------------------------------------------------------
-
-bool TreeFragment::isNew() const
-{
- return (this->header.state & data::State::mask_state) == data::State::added;
-}
-//-----------------------------------------------------------------------------
-
-configmgr::node::Attributes TreeFragment::getAttributes() const
-{
- configmgr::node::Attributes aResult;
-
- switch (this->header.state & data::State::mask_state)
- {
- case data::State::merged: aResult.setState(configmgr::node::isMerged); break;
- case data::State::defaulted: aResult.setState(configmgr::node::isDefault); break;
- case data::State::replaced: aResult.setState(configmgr::node::isReplaced); break;
- case data::State::added: aResult.setState(configmgr::node::isAdded); break;
- default: OSL_ASSERT(false); break; // not reachable
- }
-
- aResult.setRemovability(!!(this->header.state & data::State::flag_removable),
- !!(this->header.state & data::State::flag_mandatory));
-
-
- OSL_ASSERT( header.count != 0 );
- NodeInfo const & aRootNodeInfo = this->nodes[0].info;
-
- aResult.setAccess( !!(this->header.state & data::State::flag_readonly),
- !!(aRootNodeInfo.flags & data::Flags::finalized) );
-
- aResult.setLocalized ( !!(aRootNodeInfo.flags & data::Flags::localized));
-
- return aResult;
-}
-
-TreeFragment *TreeFragment::allocate(sal_uInt32 nFragments)
-{
- sal_uInt32 nSize = sizeof(TreeFragment) + sizeof(Node) * (nFragments-1);
- sal_uInt8 *pMem = new sal_uInt8 [nSize];
- memset (pMem, 0, nSize);
- return reinterpret_cast<TreeFragment *>(pMem);
-}
-
-void TreeFragment::free_shallow(TreeFragment *pFragment )
-{
- delete[] (sal_uInt8 *) pFragment;
-}
-
-//-----------------------------------------------------------------------------
- } // namespace sharable
-//-----------------------------------------------------------------------------
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/treenodefactory.cxx b/configmgr/source/tree/treenodefactory.cxx
deleted file mode 100644
index 5af6cc0d5335..000000000000
--- a/configmgr/source/tree/treenodefactory.cxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "treenodefactory.hxx"
-#include "valuenode.hxx"
-#include "subtree.hxx"
-#include "treechangefactory.hxx"
-#include "configpath.hxx"
-
-namespace configmgr
-{
-
-//= static default ============================================================
-OTreeNodeFactory& getDefaultTreeNodeFactory()
-{
- static OTreeNodeFactory aDefaultFactory;
- return aDefaultFactory;
-}
-
-//= ValueNodes ============================================================
-
-std::auto_ptr<ValueNode> OTreeNodeFactory::createValueNode(
- rtl::OUString const& aName,
- uno::Any const& aValue,
- node::Attributes _aAttrs)
-{
- OSL_ENSURE(aValue.hasValue(), "OTreeNodeFactory: Creating a value node having no type");
- return std::auto_ptr<ValueNode>( new ValueNode(aName, aValue, _aAttrs) );
-}
-
-//-----------------------------------------------
-
-std::auto_ptr<ValueNode> OTreeNodeFactory::createValueNode(
- rtl::OUString const& aName,
- uno::Any const& aValue,
- uno::Any const& aDefault,
- node::Attributes _aAttrs)
-{
- OSL_ENSURE(aValue.hasValue() || aDefault.hasValue(), "OTreeNodeFactory: Creating a value node having no type");
- return std::auto_ptr<ValueNode>( new ValueNode(aName, aValue, aDefault, _aAttrs) );
-}
-
-
-//-----------------------------------------------
-
-std::auto_ptr<ValueNode> OTreeNodeFactory::createNullValueNode(
- rtl::OUString const& aName,
- uno::Type const& aType,
- node::Attributes _aAttrs)
-{
- OSL_ENSURE(aType.getTypeClass() != uno::TypeClass_VOID, "OTreeNodeFactory: Creating a value node having VOID type");
- return std::auto_ptr<ValueNode>( new ValueNode(aName, aType, _aAttrs) );
-}
-
-
-//-----------------------------------------------
-
-std::auto_ptr<ISubtree> OTreeNodeFactory::createGroupNode(
- rtl::OUString const& aName,
- node::Attributes _aAttrs)
-{
- return std::auto_ptr<ISubtree>( new Subtree(aName, _aAttrs) );
-}
-
-
-//-----------------------------------------------
-
-std::auto_ptr<ISubtree> OTreeNodeFactory::createSetNode(
- rtl::OUString const& aName,
- rtl::OUString const& _rTemplateName,
- rtl::OUString const& _rTemplateModule,
- node::Attributes _aAttrs)
-{
- return std::auto_ptr<ISubtree>( new Subtree(aName, _rTemplateName, _rTemplateModule, _aAttrs) );
-}
-
-//-----------------------------------------------
-
-} // namespace configmgr
-
-
diff --git a/configmgr/source/tree/treesegment.cxx b/configmgr/source/tree/treesegment.cxx
deleted file mode 100644
index 99403a03e628..000000000000
--- a/configmgr/source/tree/treesegment.cxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "precompiled_configmgr.hxx"
-#include "sal/config.h"
-
-#include <memory>
-
-#include "osl/diagnose.h"
-#include "rtl/ref.hxx"
-#include "salhelper/simplereferenceobject.hxx"
-
-#include "builddata.hxx"
-#include "treesegment.hxx"
-
-namespace configmgr { namespace data {
-
-rtl::Reference< TreeSegment > TreeSegment::create(
- std::auto_ptr< INode > tree, rtl::OUString const & type)
-{
- rtl::Reference< TreeSegment > r;
- if (tree.get() != 0) {
- std::auto_ptr< sharable::TreeFragment > p(
- buildElementTree(*tree, type, false));
- r = new TreeSegment(p.get());
- p.release();
- }
- return r;
-}
-
-rtl::Reference< TreeSegment > TreeSegment::create(
- rtl::OUString const & name, std::auto_ptr< INode > tree)
-{
- rtl::Reference< TreeSegment > r;
- if (tree.get() != 0) {
- std::auto_ptr< sharable::TreeFragment > p(
- buildTree(name, *tree, false));
- r = new TreeSegment(p.get());
- p.release();
- }
- return r;
-}
-
-rtl::Reference< TreeSegment > TreeSegment::create(
- sharable::TreeFragment * tree)
-{
- rtl::Reference< TreeSegment > r;
- if (tree != 0) {
- std::auto_ptr< sharable::TreeFragment > p(data::buildTree(tree));
- r = new TreeSegment(p.get());
- p.release();
- }
- return r;
-}
-
-TreeSegment::TreeSegment(sharable::TreeFragment * tree): fragment(tree) {
- OSL_ASSERT(tree != 0);
-}
-
-TreeSegment::~TreeSegment() {
- destroyTree(fragment);
-}
-
-} }
diff --git a/configmgr/source/tree/updatehelper.cxx b/configmgr/source/tree/updatehelper.cxx
deleted file mode 100644
index f70de6be5a19..000000000000
--- a/configmgr/source/tree/updatehelper.cxx
+++ /dev/null
@@ -1,622 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org 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 version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include <stdio.h>
-
-#include "updatehelper.hxx"
-#include "change.hxx"
-#include "nodeconverter.hxx"
-#include "treeactions.hxx"
-#include "treechangefactory.hxx"
-#include "treenodefactory.hxx"
-
-// -----------------------------------------------------------------------------
-#include "node.hxx"
-#include "treefragment.hxx"
-#include "builddata.hxx"
-#include "nodevisitor.hxx"
-// -----------------------------------------------------------------------------
-#include "tracer.hxx"
-#include <osl/diagnose.h>
-
-
-//..........................................................................
-namespace configmgr
-{
-// -----------------------------------------------------------------------------
-//==========================================================================
-//= AdjustUpdate
-//==========================================================================
-//= This class tests changes on an existing tree and drops them if they
-//= are not need anymore or alters add nodes in node changes and vice versa
-//==========================================================================
-class AdjustUpdate : ChangeTreeModification
-{
- SubtreeChange& m_rChangeList; // list which containes changes merged with the existing nodes
- sharable::Node * m_refNode; // reference node needed for merging
- OTreeNodeConverter m_aNodeConverter;
-public:
- static bool adjust(SubtreeChange& _rResultTree, SubtreeChange& _aUpdateTree,
- sharable::Node * targetNode)
- {
- return AdjustUpdate(_rResultTree, targetNode).impl_adjust(_aUpdateTree);
- }
- static bool adjust(SubtreeChange& _rResultTree, SubtreeChange& _aUpdateTree,
- sharable::Node * targetNode,
- OTreeNodeFactory& _rNodeFactory)
- {
- return AdjustUpdate(_rResultTree, targetNode, _rNodeFactory).impl_adjust(_aUpdateTree);
- }
-private:
- AdjustUpdate(SubtreeChange& rList, sharable::Node * node)
- :m_rChangeList(rList)
- ,m_refNode(node)
- ,m_aNodeConverter()
- {}
-
- AdjustUpdate(SubtreeChange& rList, sharable::Node * node, OTreeNodeFactory& _rNodeFactory)
- :m_rChangeList(rList)
- ,m_refNode(node)
- ,m_aNodeConverter(_rNodeFactory)
- {}
-
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
-
- bool impl_adjust(SubtreeChange& _aUpdateTree);
-private:
- // ensuring the correct state
- bool checkNode() const;
-};
-
-// --------------------------------- ApplyUpdate ---------------------------------
-
-class ApplyUpdate : public ChangeTreeModification
-{
- sharable::Node * m_aCurrentNode;
-public:
- ApplyUpdate(sharable::Node * _aNode)
- : m_aCurrentNode(_aNode)
- {}
-
- void handle(ValueChange& aValueNode);
- void handle(AddNode& aAddNode);
- void handle(RemoveNode& aRemoveNode);
- void handle(SubtreeChange& aSubtree);
-};
-//--------------------------------------------------------------------------
-class ApplyValueChange
-{
- static
- void adjust(uno::Any& aActual, uno::Any const& aTarget);
-
-public:
- static
- void apply(ValueChange& _rValueChange, sharable::ValueNode * valueNode);
-};
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-
-// apply a already matching set of changes to the target tree
- void applyUpdateToTree(SubtreeChange& _anUpdateTree, sharable::Node * _aRootNode)
- {
- ApplyUpdate aUpdater(_aRootNode);
- _anUpdateTree.forEachChange(aUpdater);
- }
-//--------------------------------------------------------------------------
-// apply a set of changes to the target tree
- void applyUpdateWithAdjustmentToTree(SubtreeChange& _anUpdateTree, sharable::Node * _aRootNode)
- {
- // POST: pSubtree = pSubtree + aChangeList
- SubtreeChange aActualChanges(_anUpdateTree, treeop::NoChildCopy());
-
- if ( AdjustUpdate::adjust(aActualChanges,_anUpdateTree, _aRootNode) )
- {
- applyUpdateToTree(aActualChanges, _aRootNode);
- }
- _anUpdateTree.swap(aActualChanges);
-
- }
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-
-static inline
-rtl::OUString getNodeName(INode const & _aNode)
-{
- return _aNode.getName();
-}
-//--------------------------------------------------------------------------
-
-static inline
-rtl::OUString getChangeNodeName(Change const & _aChange)
-{
- return _aChange.getNodeName();
-}
-//--------------------------------------------------------------------------
-
-bool AdjustUpdate::impl_adjust(SubtreeChange& _aUpdateTree)
-{
- // first check the changes
- this->applyToChildren(_aUpdateTree);
-
- // now check whether there are real modifications
- OChangeActionCounter aChangeCounter;
- aChangeCounter.handle(m_rChangeList);
- CFG_TRACE_INFO_NI("cache manager: counted changes : additions: %i , removes: %i, value changes: %i", aChangeCounter.nAdds, aChangeCounter.nRemoves, aChangeCounter.nValues);
-
- return !! aChangeCounter.hasChanges();
-}
-// -----------------------------------------------------------------------------
-
-inline bool AdjustUpdate::checkNode() const
-{
- // Change a Value
- OSL_ENSURE(m_refNode != 0, "AdjustUpdate: no data");
-
- return m_refNode != 0;
-}
-//--------------------------------------------------------------------------
-
-void AdjustUpdate::handle(ValueChange& _rChange)
-{
- if (checkNode())
- {
- // We need to find the element in the tree
- sharable::Node * childNode = m_refNode->getSubnode(getChangeNodeName(_rChange));
-
- // We have a node so we can keep the Change and the values do not differ
- if (childNode != 0)
- {
- bool bIsValue = childNode->isValue();
- OSL_ENSURE(bIsValue, "AdjustUpdate : node must be a value node!");
-
- if (bIsValue && _rChange.isChange())
- {
- std::auto_ptr<Change> pChange( new ValueChange(_rChange) );
- m_rChangeList.addChange(pChange);
- }
- }
- else
- {
- std::auto_ptr<ValueNode> pNode = m_aNodeConverter.createCorrespondingNode(_rChange);
-
- OSL_ENSURE(m_rChangeList.isSetNodeChange(), "Adding a new value to a non-set node");
- rtl::OUString sTypeName = m_rChangeList.getElementTemplateName();
-
- rtl::Reference< data::TreeSegment > aNewTree = data::TreeSegment::create(base_ptr(pNode),sTypeName);
- // add the tree to the change list
- std::auto_ptr<Change> pChange( new AddNode( aNewTree,_rChange.getNodeName(), _rChange.isToDefault()) );
- m_rChangeList.addChange(pChange);
- }
- }
-}
-//--------------------------------------------------------------------------
-
-void AdjustUpdate::handle(SubtreeChange& _rChange)
-{
- if (checkNode())
- {
- // We need to find the element in the tree
- sharable::Node * childNode = m_refNode->getSubnode(getChangeNodeName(_rChange));
-
- // if there is a node we continue
- if (childNode != 0)
- {
- bool bIsSubtree = childNode->isGroup() || childNode->isSet();
- OSL_ENSURE(bIsSubtree, "AdjustUpdate : node must be a inner node!");
-
- if (bIsSubtree)
- {
- // generate a new change
- std::auto_ptr<SubtreeChange> pChange( new SubtreeChange(_rChange, treeop::NoChildCopy()) );
-
- // recurse
- if ( adjust(*pChange,_rChange,childNode,m_aNodeConverter.nodeFactory()) )
- m_rChangeList.addChange(base_ptr(pChange));
- }
- else
- 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 = m_aNodeConverter.createCorrespondingTree(_rChange);
- OSL_ASSERT(pNode.get() != NULL);
-
- // set the level
- pNode->setLevels(treeop::ALL_LEVELS,treeop::ALL_LEVELS);
-
- OSL_ENSURE(m_rChangeList.isSetNodeChange(), "Adding a new value to a non-set node");
- rtl::OUString sTypeName = m_rChangeList.getElementTemplateName();
-
- rtl::Reference< data::TreeSegment > aNewTree = data::TreeSegment::create(base_ptr(pNode), sTypeName);
-
- // add the tree to the change list
- std::auto_ptr<Change> pChange( new AddNode(aNewTree,_rChange.getNodeName(), _rChange.isToDefault()) );
- m_rChangeList.addChange( pChange );
- }
- }
-}
-//--------------------------------------------------------------------------
-
-void AdjustUpdate::handle(RemoveNode& _rChange)
-{
- if (checkNode())
- {
- // We need to find the element in the tree
- sharable::Node * childNode = m_refNode->getSubnode(getChangeNodeName(_rChange));
-
- // only if there is a node, we will keep the change
- if (childNode != 0)
- {
- // generate a new change
- std::auto_ptr<Change> pChange( new RemoveNode(_rChange.getNodeName(),_rChange.isToDefault()) );
- m_rChangeList.addChange(pChange);
- }
- }
-}
-//--------------------------------------------------------------------------
-
-void AdjustUpdate::handle(AddNode& _rChange)
-{
- if (checkNode())
- {
- // We need to find the element in the tree
- sharable::Node * childNode = m_refNode->getSubnode(getChangeNodeName(_rChange));
-
- rtl::Reference< data::TreeSegment > aNewNode = _rChange.getNewTree();
- std::auto_ptr<AddNode> pChange( new AddNode(aNewNode,_rChange.getNodeName(),_rChange.isToDefault()) );
- if (childNode != 0)
- {
- pChange->setReplacing();
- }
- m_rChangeList.addChange(base_ptr(pChange));
- }
-}
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-
-inline
-void ApplyValueChange::adjust(uno::Any& aActual, uno::Any const& aTarget)
-{
- // If set - it should already match
- OSL_ASSERT(!aActual.hasValue() || aTarget == aActual);
- aActual = aTarget;
-}
-
-//--------------------------------------------------------------------------
-// _rValueChange.applyTo(_aValueNode)
-void ApplyValueChange::apply(ValueChange& _rValueChange, sharable::ValueNode * valueNode)
-{
- switch (_rValueChange.getMode())
- {
- case ValueChange::wasDefault:
- OSL_ASSERT(valueNode->info.isDefault());
-
- case ValueChange::changeValue:
- adjust( _rValueChange.m_aOldValue, valueNode->getValue());
- valueNode->setValue(_rValueChange.getNewValue());
- break;
-
- case ValueChange::setToDefault:
- adjust(_rValueChange.m_aOldValue, valueNode->getValue());
- adjust(_rValueChange.m_aValue, valueNode->getDefaultValue());
- valueNode->setToDefault();
- break;
-
- case ValueChange::changeDefault:
- adjust(_rValueChange.m_aOldValue, valueNode->getDefaultValue());
- valueNode->changeDefault(_rValueChange.getNewValue());
- break;
-
- default:
- OSL_ENSURE(0, "Unknown mode found for ValueChange");
- break;
- }
-}
-//--------------------------------------------------------------------------
-
-void ApplyUpdate::handle(ValueChange& _rChange)
-{
- // Change a Value
- OSL_ENSURE(m_aCurrentNode != NULL,"Cannot apply ValueChange without node");
-
- sharable::Node * childNode = m_aCurrentNode->getSubnode(getChangeNodeName(_rChange));
- OSL_ENSURE(childNode != 0, "Cannot apply Change: No node to change");
-
- sharable::ValueNode * aValueAddr = childNode->valueData();
- OSL_ENSURE(aValueAddr != NULL,"Cannot apply ValueChange: Node is not a value");
-
- if (aValueAddr != NULL)
- ApplyValueChange::apply(_rChange,aValueAddr);
-}
-//--------------------------------------------------------------------------
-
-void ApplyUpdate::handle(SubtreeChange& _rChange)
-{
- // handle traversion
- OSL_ENSURE(m_aCurrentNode != NULL,"Cannot apply SubtreeChange without node");
-
- sharable::Node * childNode = m_aCurrentNode->getSubnode(getChangeNodeName(_rChange));
- OSL_ENSURE(childNode != 0, "Cannot apply Change: No node to change");
-
- OSL_ENSURE( childNode->isGroup() || childNode->isSet(),
- "Cannot Apply SubtreeChange: Node is not an inner node");
-
- if (childNode != 0)
- {
- childNode->info.markAsDefault( _rChange.isToDefault() );
-
- sharable::Node * aOldNode = m_aCurrentNode;
- m_aCurrentNode = childNode;
-
- _rChange.forEachChange(*this);
-
- m_aCurrentNode = aOldNode;
- }
-}
-//--------------------------------------------------------------------------
-
-void ApplyUpdate::handle(AddNode& _rChange)
-{
- OSL_ENSURE(m_aCurrentNode != NULL,"Cannot apply AddNode without node");
-
- sharable::SetNode * aSetNodeAddr = sharable::SetNode::from(m_aCurrentNode);
- OSL_ENSURE(aSetNodeAddr != NULL,"Cannot apply AddNode: Node is not a set node");
-
- // Add a new element
- if (aSetNodeAddr != NULL)
- {
- if (_rChange.isReplacing())
- {
- sharable::TreeFragment * old = aSetNodeAddr->removeElement(getChangeNodeName(_rChange));
- OSL_ASSERT(old != 0);
- _rChange.takeReplacedTree(data::TreeSegment::create(old));
- }
-
- sharable::TreeFragment * aNewAddress = data::buildTree(_rChange.getNewTree()->fragment);
- OSL_ENSURE(aNewAddress != NULL, "ApplyUpdate: AddNode: could not create new element");
-
- aSetNodeAddr->addElement(aNewAddress);
-
- _rChange.setInsertedAddress( aNewAddress );
- }
-}
-//--------------------------------------------------------------------------
-
-void ApplyUpdate::handle(RemoveNode& _rChange)
-{
- OSL_ENSURE(m_aCurrentNode != NULL,"Cannot apply RemoveNode without node");
-
- sharable::SetNode * aSetNodeAddr = sharable::SetNode::from(m_aCurrentNode);
- OSL_ENSURE(aSetNodeAddr != NULL,"Cannot apply RemoveNode: Node is not a set node");
-
- // Remove an element
- if (aSetNodeAddr != NULL)
- {
- sharable::TreeFragment * old = aSetNodeAddr->removeElement(getChangeNodeName(_rChange));
- OSL_ASSERT(old != 0);
- _rChange.takeRemovedTree(data::TreeSegment::create(old));
- }
-}
-//--------------------------------------------------------------------------
-//--------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
- struct ForwardTreeDifferenceBuilder : NodeAction
- {
- protected:
- SubtreeChange& m_rChangeList;
- sharable::Node * m_cacheNode;
-
- public:
- ForwardTreeDifferenceBuilder(SubtreeChange& rList, sharable::Node * cacheNode)
- : m_rChangeList(rList)
- , m_cacheNode(cacheNode)
- {
- }
-
- virtual void handle(ValueNode const& _aNewNode)
- {
- sharable::Node * childNode = m_cacheNode->getSubnode(getNodeName(_aNewNode));
- if (childNode != 0)
- {
- sharable::ValueNode * valueNode = childNode->valueData();
-
- OSL_ENSURE(valueNode != 0, "TreeDifferenceBuilder: node must be a value node!");
-
- // if the values differ add a new change
- if (_aNewNode.getValue() != valueNode->getValue())
- {
- bool bNewDefault = _aNewNode.isDefault();
- bool bOldDefault = valueNode->info.isDefault();
-
- ValueChange::Mode eMode;
- if (bNewDefault)
- if (bOldDefault)
- eMode = ValueChange::changeDefault;
- else
- eMode = ValueChange::setToDefault;
- else
- if (bOldDefault)
- eMode = ValueChange::wasDefault;
- else
- eMode = ValueChange::changeValue;
-
- std::auto_ptr<Change> pChange(
- new ValueChange(_aNewNode.getName(), _aNewNode.getAttributes(), eMode,
- _aNewNode.getValue(), valueNode->getValue()) );
-
- m_rChangeList.addChange(pChange);
- }
- }
- }
- virtual void handle(ISubtree const& _aNewNode)
- {
- sharable::Node * childNode = m_cacheNode->getSubnode(getNodeName(_aNewNode));
-
- if (childNode != 0)
- {
- OSL_ENSURE( childNode->isGroup() || childNode->isSet(),
- "ForwardTreeDifferenceBuilder: Node must be an inner node");
-
- // generate a new change
- std::auto_ptr<SubtreeChange> pNewChange( new SubtreeChange(_aNewNode) );
-
- // .. and recurse
- ForwardTreeDifferenceBuilder aNextLevel(*pNewChange, childNode);
- aNextLevel.applyToChildren(_aNewNode);
-
- // now count if there are any changes
- OChangeActionCounter aCounter;
- aCounter.applyToChange(*pNewChange);
-
- if (aCounter.hasChanges())
- m_rChangeList.addChange(base_ptr(pNewChange));
- }
- else if (m_cacheNode != 0 && m_cacheNode->isSet())
- {
- // Subtree not in Cache, add in TreeChangeList
- // SubtreeChange* pChange = new SubtreeChange(_rSubtree);
- OSL_ENSURE(m_rChangeList.isSetNodeChange(), "Found newly added node in non-set node");
- rtl::OUString sTypeName = m_rChangeList.getElementTemplateName();
-
- std::auto_ptr<INode> pSubtree( _aNewNode.clone() );
- rtl::Reference< data::TreeSegment > aNewTree = data::TreeSegment::create(pSubtree,sTypeName);
-
- std::auto_ptr<Change> pAdd(new AddNode(aNewTree, _aNewNode.getName(), _aNewNode.isDefault()));
-
- m_rChangeList.addChange(pAdd);
- }
- else
- OSL_ENSURE(false, "Found newly added node in group");
-
- }
- };
-// -----------------------------------------------------------------------------
-
-class BackwardTreeDifferenceBuilder: public data::SetVisitor {
-public:
- BackwardTreeDifferenceBuilder(SubtreeChange & list, ISubtree const * node):
- m_changeList(list), m_newNode(node) {}
-
- void applyToChildren(sharable::Node * cacheNode) {
- OSL_ASSERT(cacheNode != 0);
- if (cacheNode->isGroup()) {
- OSL_ASSERT(!m_changeList.isSetNodeChange());
- visitChildren(&cacheNode->group);
- } else if (cacheNode->isSet()) {
- OSL_ASSERT(m_changeList.isSetNodeChange());
- visitElements(&cacheNode->set);
- } else {
- OSL_ASSERT(false);
- }
- }
-
-private:
- using NodeVisitor::handle;
-
- virtual bool handle(sharable::Node * node) {
- OSL_ASSERT(!node->isValue());
- INode const * newChild = m_newNode->getChild(node->getName());
- ISubtree const * newTree = newChild == 0 ? 0 : newChild->asISubtree();
- if (newTree != 0) {
- // Traverse down to next change:
- Change * change = m_changeList.getChange(node->getName());
- std::auto_ptr< Change > newChange;
- SubtreeChange * groupChange = 0;
- if (change == 0) {
- groupChange = new SubtreeChange(*newTree);
- newChange.reset(groupChange);
- } else {
- groupChange = dynamic_cast< SubtreeChange * >(change);
- OSL_ASSERT(groupChange != 0);
- }
- if (groupChange != 0) {
- BackwardTreeDifferenceBuilder(*groupChange, newTree).
- applyToChildren(node);
- if (newChange.get() != 0) {
- // Now count if there are any real changes:
- OChangeActionCounter counter;
- counter.applyToChange(*newChange);
- if (counter.hasChanges()) {
- m_changeList.addChange(newChange);
- }
- }
- }
- }
- return false;
- }
-
- virtual bool handle(sharable::ValueNode *) {
- return false;
- }
-
- virtual bool handle(sharable::TreeFragment * tree) {
- INode const * newElement = m_newNode->getChild(tree->getName());
- if (newElement == 0) {
- // Remove node:
- std::auto_ptr< Change > remove(
- new RemoveNode(tree->getName(), tree->isNew()));
- m_changeList.addChange(remove);
- return false;
- } else {
- // Handle the root node:
- return SetVisitor::handle(tree);
- }
- }
-
- SubtreeChange & m_changeList;
- ISubtree const * m_newNode;
-};
-
-//--------------------------------------------------------------------------
-
-// apply a set of changes to the target tree, return true, if there are changes found
- bool createUpdateFromDifference(SubtreeChange& _rResultingUpdateTree, sharable::Node * existingData, ISubtree const & _aNewData)
- {
- OSL_ENSURE(existingData != 0, "Trying to create diffrence for empty data");
- // create the differences
- ForwardTreeDifferenceBuilder aForwardTreeDifference(_rResultingUpdateTree, existingData);
- aForwardTreeDifference.applyToChildren(_aNewData);
-
- BackwardTreeDifferenceBuilder aBackwardTreeDifference(_rResultingUpdateTree, & _aNewData);
- aBackwardTreeDifference.applyToChildren(existingData);
-
- return true;
- }
-//--------------------------------------------------------------------------
-
-//..........................................................................
-} // namespace configmgr
-//..........................................................................
-
-